summaryrefslogtreecommitdiffstats
path: root/libs/hwui/OpenGLRenderer.cpp
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2010-10-08 15:49:53 -0700
committerRomain Guy <romainguy@google.com>2010-10-08 15:49:53 -0700
commit8550c4c7b5952b7a4e1e0ede95c9492d03099a13 (patch)
tree3f2bccdd02bcf390eac98749475aad4ead1da1e4 /libs/hwui/OpenGLRenderer.cpp
parentecd31740a00f8fb07090209cd979257c38cbcc92 (diff)
downloadframeworks_base-8550c4c7b5952b7a4e1e0ede95c9492d03099a13.zip
frameworks_base-8550c4c7b5952b7a4e1e0ede95c9492d03099a13.tar.gz
frameworks_base-8550c4c7b5952b7a4e1e0ede95c9492d03099a13.tar.bz2
Better cache for layers, reduce memory usage and increase framerate.
Change-Id: I5ff864a361db4791bd5ff6be716f7ce692ef572d
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
-rw-r--r--libs/hwui/OpenGLRenderer.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 5399668..62c590d 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -385,8 +385,7 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top,
glActiveTexture(GL_TEXTURE0);
- LayerSize size(bounds.getWidth(), bounds.getHeight());
- Layer* layer = mCaches.layerCache.get(size);
+ Layer* layer = mCaches.layerCache.get(bounds.getWidth(), bounds.getHeight());
if (!layer) {
return false;
}
@@ -394,6 +393,8 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top,
layer->mode = mode;
layer->alpha = alpha;
layer->layer.set(bounds);
+ layer->texCoords.set(0.0f, bounds.getHeight() / float(layer->height),
+ bounds.getWidth() / float(layer->width), 0.0f);
// Save the layer in the snapshot
snapshot->flags |= Snapshot::kFlagIsLayer;
@@ -420,7 +421,7 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top,
// Initialize the texture if needed
if (layer->empty) {
layer->empty = false;
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width, size.height, 0,
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, layer->width, layer->height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
}
@@ -455,12 +456,12 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top,
// TODO: Workaround for b/3054204
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bounds.left, mHeight - bounds.bottom,
- bounds.getWidth(), bounds.getHeight(), 0);
+ layer->width, layer->height, 0);
// TODO: Waiting for b/3054204 to be fixed
// if (layer->empty) {
// glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bounds.left, mHeight - bounds.bottom,
- // bounds.getWidth(), bounds.getHeight(), 0);
+ // layer->width, layer->height, 0);
// layer->empty = false;
// } else {
// glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left, mHeight - bounds.bottom,
@@ -502,8 +503,8 @@ void OpenGLRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) {
layer->alpha << 24, SkXfermode::kDstIn_Mode, true);
}
- // Layers are already drawn with a top-left origin, don't flip the texture
- resetDrawTextureTexCoords(0.0f, 1.0f, 1.0f, 0.0f);
+ const Rect& texCoords = layer->texCoords;
+ resetDrawTextureTexCoords(texCoords.left, texCoords.top, texCoords.right, texCoords.bottom);
if (fboLayer) {
drawTextureRect(rect.left, rect.top, rect.right, rect.bottom,
@@ -526,9 +527,8 @@ void OpenGLRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) {
mCaches.fboCache.put(current->fbo);
}
- LayerSize size(rect.getWidth(), rect.getHeight());
// Failing to add the layer to the cache should happen only if the layer is too large
- if (!mCaches.layerCache.put(size, layer)) {
+ if (!mCaches.layerCache.put(layer)) {
LAYER_LOGD("Deleting layer");
glDeleteTextures(1, &layer->texture);
delete layer;