summaryrefslogtreecommitdiff
path: root/libs/hwui/LayerCache.cpp
diff options
context:
space:
mode:
author Romain Guy <romainguy@google.com> 2011-02-02 21:07:17 -0800
committer Android Git Automerger <android-git-automerger@android.com> 2011-02-02 21:07:17 -0800
commit109da7dfd4c0766274b17467880ee673c731735c (patch)
tree746838158c3aec5f10b8d6f05ee78919e784a1f9 /libs/hwui/LayerCache.cpp
parenta29acdfb8a3c9812718ead057f77ef5dbd508682 (diff)
parent5bfd1afffe361958682bcb899b763ce35ec00c3a (diff)
am 5bfd1aff: Merge "Allocate layers from the layers pool. Bug #3413433" into honeycomb
* commit '5bfd1afffe361958682bcb899b763ce35ec00c3a': Allocate layers from the layers pool. Bug #3413433
Diffstat (limited to 'libs/hwui/LayerCache.cpp')
-rw-r--r--libs/hwui/LayerCache.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp
index 7667af5fe018..a9710ad6adbf 100644
--- a/libs/hwui/LayerCache.cpp
+++ b/libs/hwui/LayerCache.cpp
@@ -128,6 +128,31 @@ Layer* LayerCache::get(const uint32_t width, const uint32_t height) {
return layer;
}
+bool LayerCache::resize(Layer* layer, const uint32_t width, const uint32_t height) {
+ // TODO: We should be smarter and see if we have a texture of the appropriate
+ // size already in the cache, and reuse it instead of creating a new one
+
+ LayerEntry entry(width, height);
+ if (entry.mWidth <= layer->width && entry.mHeight <= layer->height) {
+ return true;
+ }
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, layer->texture);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, entry.mWidth, entry.mHeight, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+ if (glGetError() != GL_NO_ERROR) {
+ return false;
+ }
+
+ layer->width = entry.mWidth;
+ layer->height = entry.mHeight;
+
+ return true;
+}
+
bool LayerCache::put(Layer* layer) {
const uint32_t size = layer->width * layer->height * 4;
// Don't even try to cache a layer that's bigger than the cache