diff options
author | bsalomon <bsalomon@google.com> | 2015-11-11 12:40:42 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-11 12:40:42 -0800 |
commit | 67d7620285cdfa60158add6615db03bd48e6d8b0 (patch) | |
tree | cc658c120433b59378beff7ad1d1ec495878153e /src | |
parent | a13e202563979fd5076936606dcc1d660da8c632 (diff) |
Fix leaks in unit tests of GrGLTextureInfos
TBR=egdaniel@google.com
Review URL: https://codereview.chromium.org/1433353005
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrGpu.h | 14 | ||||
-rw-r--r-- | src/gpu/GrTest.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 6 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 4 |
4 files changed, 18 insertions, 10 deletions
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index a2d1fafb87..c5fa61bd99 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -363,12 +363,18 @@ public: Stats* stats() { return &fStats; } - // creation and deletion of raw texture for testing - // only to be used in GPU-specific tests + /** Creates a texture directly in the backend API without wrapping it in a GrTexture. This is + only to be used for testing (particularly for testing the methods that import an externally + created texture into Skia. Must be matched with a call to deleteTestingOnlyTexture(). */ virtual GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h, GrPixelConfig config) const = 0; - virtual bool isTestingOnlyBackendTexture(GrBackendObject id) const = 0; - virtual void deleteTestingOnlyBackendTexture(GrBackendObject id) const = 0; + /** Check a handle represents an actual texture in the backend API that has not been freed. */ + virtual bool isTestingOnlyBackendTexture(GrBackendObject) const = 0; + /** If ownership of the backend texture has been transferred pass true for abandonTexture. This + will do any necessary cleanup of the handle without freeing the texture in the backend + API. */ + virtual void deleteTestingOnlyBackendTexture(GrBackendObject, + bool abandonTexture = false) const = 0; // width and height may be larger than rt (if underlying API allows it). // Returns nullptr if compatible sb could not be created, otherwise the caller owns the ref on diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp index 2889e9709e..975636d28b 100644 --- a/src/gpu/GrTest.cpp +++ b/src/gpu/GrTest.cpp @@ -281,8 +281,8 @@ private: GrPixelConfig config) const override { return 0; } - bool isTestingOnlyBackendTexture(GrBackendObject id) const override { return false; } - void deleteTestingOnlyBackendTexture(GrBackendObject id) const override {} + bool isTestingOnlyBackendTexture(GrBackendObject ) const override { return false; } + void deleteTestingOnlyBackendTexture(GrBackendObject, bool abandonTexture) const override {} typedef GrGpu INHERITED; }; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 5ae116cef8..72262abed3 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -3291,7 +3291,7 @@ bool GrGLGpu::isTestingOnlyBackendTexture(GrBackendObject id) const { return (GR_GL_TRUE == result); } -void GrGLGpu::deleteTestingOnlyBackendTexture(GrBackendObject id) const { +void GrGLGpu::deleteTestingOnlyBackendTexture(GrBackendObject id, bool abandonTexture) const { #ifdef SK_IGNORE_GL_TEXTURE_TARGET GrGLuint texID = (GrGLuint)id; #else @@ -3299,7 +3299,9 @@ void GrGLGpu::deleteTestingOnlyBackendTexture(GrBackendObject id) const { GrGLuint texID = info->fID; #endif - GL_CALL(DeleteTextures(1, &texID)); + if (!abandonTexture) { + GL_CALL(DeleteTextures(1, &texID)); + } #ifndef SK_IGNORE_GL_TEXTURE_TARGET delete info; diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 0a18e17b11..e1db4309a9 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -125,8 +125,8 @@ public: GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h, GrPixelConfig config) const override; - bool isTestingOnlyBackendTexture(GrBackendObject id) const override; - void deleteTestingOnlyBackendTexture(GrBackendObject id) const override; + bool isTestingOnlyBackendTexture(GrBackendObject) const override; + void deleteTestingOnlyBackendTexture(GrBackendObject, bool abandonTexture) const override; private: GrGLGpu(GrGLContext* ctx, GrContext* context); |