diff options
author | Romain Guy <romainguy@android.com> | 2010-09-22 22:48:20 -0700 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2010-09-22 22:51:12 -0700 |
commit | 38c85b907a478af96d71b9a5df5a2066b8475311 (patch) | |
tree | 03c8ffe517ff14b71fb24e29ca43c3eb482ba442 /libs | |
parent | 806de5b1c5f98d67b00f7ba6087faca3b9632845 (diff) | |
download | frameworks_base-38c85b907a478af96d71b9a5df5a2066b8475311.zip frameworks_base-38c85b907a478af96d71b9a5df5a2066b8475311.tar.gz frameworks_base-38c85b907a478af96d71b9a5df5a2066b8475311.tar.bz2 |
Correctly initialize/refresh layers.
Change-Id: Id8cdcf587b13098460f7d4aa1bd17708784d89bb
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/Layer.h | 4 | ||||
-rw-r--r-- | libs/hwui/LayerCache.cpp | 8 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 11 |
3 files changed, 16 insertions, 7 deletions
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index c527038..60523db 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -82,6 +82,10 @@ struct Layer { * Indicates whether this layer should be blended. */ bool blend; + /** + * Indicates that this layer has never been used before. + */ + bool empty; }; // struct Layer }; // namespace uirenderer diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp index 39c3111..2770868 100644 --- a/libs/hwui/LayerCache.cpp +++ b/libs/hwui/LayerCache.cpp @@ -109,18 +109,16 @@ Layer* LayerCache::get(LayerSize& size) { layer = new Layer; layer->blend = true; + layer->empty = true; glGenTextures(1, &layer->texture); glBindTexture(GL_TEXTURE_2D, layer->texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width, size.height, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); } return layer; diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index e62a693..e032085 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -381,8 +381,15 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top, // Copy the framebuffer into the layer glBindTexture(GL_TEXTURE_2D, layer->texture); - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bounds.left, mHeight - bounds.bottom, - bounds.getWidth(), bounds.getHeight(), 0); + + if (layer->empty) { + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bounds.left, mHeight - bounds.bottom, + bounds.getWidth(), bounds.getHeight(), 0); + layer->empty = false; + } else { + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left, mHeight - bounds.bottom, + bounds.getWidth(), bounds.getHeight()); + } if (flags & SkCanvas::kClipToLayer_SaveFlag) { if (mSnapshot->clipTransformed(bounds)) setScissorFromClip(); |