diff options
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(); |