From eb99356a0548684a501766e6a524529ab93304c8 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Tue, 5 Oct 2010 18:14:38 -0700 Subject: Optimize saveLayer() when the clip flag is set. This speeds up applications, especially Launcher. --- libs/hwui/FboCache.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'libs/hwui/FboCache.cpp') 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 + #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; } -- cgit v1.2.3-59-g8ed1b