summaryrefslogtreecommitdiff
path: root/libs/hwui/FboCache.cpp
diff options
context:
space:
mode:
author Romain Guy <romainguy@google.com> 2010-10-05 18:16:35 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2010-10-05 18:16:35 -0700
commit1e14f49d06b871d8101e33c47ba34b87c3c8089d (patch)
treec304de50878ea70f36b2228aa8fe735270bd510c /libs/hwui/FboCache.cpp
parent0f8ee7439a0c0487b023f6b150ba0f9986a6cb15 (diff)
parenteb99356a0548684a501766e6a524529ab93304c8 (diff)
Merge "Optimize saveLayer() when the clip flag is set."
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 77fbda2ad181..2ef71c245305 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;
}