summaryrefslogtreecommitdiffstats
path: root/libs/hwui/FboCache.cpp
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2010-10-05 18:14:38 -0700
committerRomain Guy <romainguy@google.com>2010-10-05 18:14:38 -0700
commiteb99356a0548684a501766e6a524529ab93304c8 (patch)
tree7beb40beea2f12944057cd025ca8b212d3a01855 /libs/hwui/FboCache.cpp
parent7adaf3d1aa18c7e521f7154e545fe52d329763c3 (diff)
downloadframeworks_base-eb99356a0548684a501766e6a524529ab93304c8.zip
frameworks_base-eb99356a0548684a501766e6a524529ab93304c8.tar.gz
frameworks_base-eb99356a0548684a501766e6a524529ab93304c8.tar.bz2
Optimize saveLayer() when the clip flag is set.
This speeds up applications, especially Launcher.
Diffstat (limited to 'libs/hwui/FboCache.cpp')
-rw-r--r--libs/hwui/FboCache.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/libs/hwui/FboCache.cpp b/libs/hwui/FboCache.cpp
index 77fbda2..2ef71c2 100644
--- a/libs/hwui/FboCache.cpp
+++ b/libs/hwui/FboCache.cpp
@@ -16,6 +16,8 @@
#define LOG_TAG "OpenGLRenderer"
+#include <stdlib.h>
+
#include "FboCache.h"
#include "Properties.h"
@@ -57,14 +59,31 @@ uint32_t FboCache::getMaxSize() {
///////////////////////////////////////////////////////////////////////////////
void FboCache::clear() {
-
+ for (size_t i = 0; i < mCache.size(); i++) {
+ const GLuint fbo = mCache.itemAt(i);
+ glDeleteFramebuffers(1, &fbo);
+ }
+ mCache.clear();
}
GLuint FboCache::get() {
- return 0;
+ GLuint fbo;
+ if (mCache.size() > 0) {
+ fbo = mCache.itemAt(mCache.size() - 1);
+ mCache.removeAt(mCache.size() - 1);
+ } else {
+ glGenFramebuffers(1, &fbo);
+ }
+ return fbo;
}
bool FboCache::put(GLuint fbo) {
+ if (mCache.size() < mMaxSize) {
+ mCache.add(fbo);
+ return true;
+ }
+
+ glDeleteFramebuffers(1, &fbo);
return false;
}