diff options
author | Romain Guy <romainguy@google.com> | 2012-09-25 12:17:14 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2012-09-25 12:22:21 -0700 |
commit | ef09a210dd6ea481158b7028ec2424a7f5769ed2 (patch) | |
tree | ac7cac37d1dbe20679cf102f36fee076bc07b120 /libs | |
parent | 509e2ced819ebaece2abb21693cb2046b5524c5b (diff) | |
download | frameworks_base-ef09a210dd6ea481158b7028ec2424a7f5769ed2.zip frameworks_base-ef09a210dd6ea481158b7028ec2424a7f5769ed2.tar.gz frameworks_base-ef09a210dd6ea481158b7028ec2424a7f5769ed2.tar.bz2 |
Don't destroy the same texture twice
Bug #7221449
SurfaceTexture already deletes the GL texture when detachFromContext
is invoked. The newly introduced refcount would casue the Layer
object to be destroyed later and attempt to delete the GL texture
again. By the time the second cleanup occurs, the texture name
might have been reused by somebody else, resulting in erroneous
behaviors.
Change-Id: I257c589fea64b34c00f46fbfaa7732e6854a5e41
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/Layer.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index d2cd440..9b6205d 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -134,10 +134,6 @@ struct Layer { return fbo; } - inline GLuint* getTexturePointer() { - return &texture.id; - } - inline GLuint getTexture() { return texture.id; } @@ -181,15 +177,31 @@ struct Layer { ANDROID_API void setColorFilter(SkiaColorFilter* filter); inline void bindTexture() { - glBindTexture(renderTarget, texture.id); + if (texture.id) { + glBindTexture(renderTarget, texture.id); + } } inline void generateTexture() { - glGenTextures(1, &texture.id); + if (!texture.id) { + glGenTextures(1, &texture.id); + } } inline void deleteTexture() { - if (texture.id) glDeleteTextures(1, &texture.id); + if (texture.id) { + glDeleteTextures(1, &texture.id); + texture.id = 0; + } + } + + /** + * When the caller frees the texture itself, the caller + * must call this method to tell this layer that it lost + * the texture. + */ + void clearTexture() { + texture.id = 0; } inline void deleteFbo() { |