diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-06-15 01:37:01 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-06-15 01:37:01 +0300 |
commit | 0f208c6842ef13d8c68b179eb0ab88a37a0926b0 (patch) | |
tree | dc60df46116896fc362ac5067fbc464982ee2cc9 /src/resources | |
parent | 8f9ffaa42e6fa11bb963fa9f1a1824d85a50b51b (diff) | |
download | mv-0f208c6842ef13d8c68b179eb0ab88a37a0926b0.tar.gz mv-0f208c6842ef13d8c68b179eb0ab88a37a0926b0.tar.bz2 mv-0f208c6842ef13d8c68b179eb0ab88a37a0926b0.tar.xz mv-0f208c6842ef13d8c68b179eb0ab88a37a0926b0.zip |
Add OpenGL extension GL_ARB_invalidate_subdata.
And use it for invalidate prepared for deletion images.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/image.cpp | 9 | ||||
-rw-r--r-- | src/resources/image.h | 2 | ||||
-rw-r--r-- | src/resources/openglimagehelper.cpp | 9 | ||||
-rw-r--r-- | src/resources/openglimagehelper.h | 2 | ||||
-rw-r--r-- | src/resources/subimage.cpp | 7 | ||||
-rw-r--r-- | src/resources/subimage.h | 4 |
6 files changed, 33 insertions, 0 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp index d9d2a8a01..d6f5cd27c 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -467,3 +467,12 @@ void Image::SDLTerminateAlphaCache() SDLCleanCache(); mUseAlphaCache = false; } + +#ifdef USE_OPENGL +void Image::decRef() +{ + if (getRefCount() <= 1) + OpenGLImageHelper::invalidate(mGLImage); + Resource::decRef(); +} +#endif diff --git a/src/resources/image.h b/src/resources/image.h index 2c67281b7..868b5690e 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -167,6 +167,8 @@ class Image notfinal : public Resource GLuint getGLImage() const A_WARN_UNUSED { return mGLImage; } + void decRef() override; + GLuint mGLImage; int mTexWidth; int mTexHeight; diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp index 2ce4bd405..2eadf35ff 100644 --- a/src/resources/openglimagehelper.cpp +++ b/src/resources/openglimagehelper.cpp @@ -348,4 +348,13 @@ void OpenGLImageHelper::postInit() glGenTextures(texturesSize, &mTextures[mFreeTextureIndex]); } +void OpenGLImageHelper::invalidate(const GLuint textureId) +{ + if (mglInvalidateTexImage) + { + logger->log("invalidate: %u", textureId); + mglInvalidateTexImage(textureId, 0); + } +} + #endif diff --git a/src/resources/openglimagehelper.h b/src/resources/openglimagehelper.h index d87052592..2a91689d9 100644 --- a/src/resources/openglimagehelper.h +++ b/src/resources/openglimagehelper.h @@ -116,6 +116,8 @@ class OpenGLImageHelper final : public ImageHelper static void setUseTextureSampler(const bool b) { mUseTextureSampler = b; } + static void invalidate(const GLuint textureId); + SDL_Surface *create32BitSurface(int width, int height) const override final; diff --git a/src/resources/subimage.cpp b/src/resources/subimage.cpp index 717858ae0..ef9827810 100644 --- a/src/resources/subimage.cpp +++ b/src/resources/subimage.cpp @@ -211,3 +211,10 @@ Image *SubImage::getSubImage(const int x, const int y, else return nullptr; } + +#ifdef USE_OPENGL +void SubImage::decRef() +{ + Resource::decRef(); +} +#endif diff --git a/src/resources/subimage.h b/src/resources/subimage.h index 27a76d277..2fe562c30 100644 --- a/src/resources/subimage.h +++ b/src/resources/subimage.h @@ -79,6 +79,10 @@ class SubImage final : public Image const int width, const int height) override final A_WARN_UNUSED; +#ifdef USE_OPENGL + void decRef() override final; +#endif + SDL_Rect mInternalBounds; private: |