summaryrefslogtreecommitdiffstats
path: root/libs/hwui
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui')
-rw-r--r--libs/hwui/Caches.cpp4
-rw-r--r--libs/hwui/Caches.h3
-rw-r--r--libs/hwui/DisplayListRenderer.h2
-rw-r--r--libs/hwui/Layer.h4
-rw-r--r--libs/hwui/LayerCache.cpp15
-rw-r--r--libs/hwui/LayerCache.h5
-rw-r--r--libs/hwui/LayerRenderer.cpp10
-rw-r--r--libs/hwui/TextureCache.cpp2
8 files changed, 34 insertions, 11 deletions
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index 7114b6a..c5858e9 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -173,13 +173,15 @@ void Caches::flush(FlushMode mode) {
gradientCache.clear();
// fall through
case kFlushMode_Moderate:
- layerCache.clear();
pathCache.clear();
roundRectShapeCache.clear();
circleShapeCache.clear();
ovalShapeCache.clear();
rectShapeCache.clear();
arcShapeCache.clear();
+ // fall through
+ case kFlushMode_Layers:
+ layerCache.clear();
break;
}
}
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index 76dff4b..cdcbf21 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -101,7 +101,8 @@ class Caches: public Singleton<Caches> {
public:
enum FlushMode {
- kFlushMode_Moderate = 0,
+ kFlushMode_Layers = 0,
+ kFlushMode_Moderate,
kFlushMode_Full
};
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index 8157631..a3d346d 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -37,7 +37,7 @@ namespace uirenderer {
// Defines
///////////////////////////////////////////////////////////////////////////////
-#define MIN_WRITER_SIZE 16384
+#define MIN_WRITER_SIZE 4096
// Debug
#if DEBUG_DISPLAY_LIST
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h
index 0c536b0..dd75497 100644
--- a/libs/hwui/Layer.h
+++ b/libs/hwui/Layer.h
@@ -191,6 +191,10 @@ struct Layer {
if (texture.id) glDeleteTextures(1, &texture.id);
}
+ inline void deleteFbo() {
+ if (fbo) glDeleteFramebuffers(1, &fbo);
+ }
+
inline void allocateTexture(GLenum format, GLenum storage) {
glTexImage2D(renderTarget, 0, format, getWidth(), getHeight(), 0, format, storage, NULL);
}
diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp
index 36083af..89c35da 100644
--- a/libs/hwui/LayerCache.cpp
+++ b/libs/hwui/LayerCache.cpp
@@ -69,6 +69,7 @@ void LayerCache::setMaxSize(uint32_t maxSize) {
void LayerCache::deleteLayer(Layer* layer) {
if (layer) {
mSize -= layer->getWidth() * layer->getHeight() * 4;
+ layer->deleteFbo();
layer->deleteTexture();
delete layer;
}
@@ -111,17 +112,21 @@ Layer* LayerCache::get(const uint32_t width, const uint32_t height) {
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
#if DEBUG_LAYERS
- size_t size = mCache.size();
- for (size_t i = 0; i < size; i++) {
- const LayerEntry& entry = mCache.itemAt(i);
- LAYER_LOGD(" Layer size %dx%d", entry.mWidth, entry.mHeight);
- }
+ dump();
#endif
}
return layer;
}
+void LayerCache::dump() {
+ size_t size = mCache.size();
+ for (size_t i = 0; i < size; i++) {
+ const LayerEntry& entry = mCache.itemAt(i);
+ LAYER_LOGD(" Layer size %dx%d", entry.mWidth, entry.mHeight);
+ }
+}
+
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
diff --git a/libs/hwui/LayerCache.h b/libs/hwui/LayerCache.h
index 81b8bf3..a0eae59 100644
--- a/libs/hwui/LayerCache.h
+++ b/libs/hwui/LayerCache.h
@@ -101,6 +101,11 @@ public:
*/
uint32_t getSize();
+ /**
+ * Prints out the content of the cache.
+ */
+ void dump();
+
private:
void deleteLayer(Layer* layer);
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp
index 1fa343b..81816f6 100644
--- a/libs/hwui/LayerRenderer.cpp
+++ b/libs/hwui/LayerRenderer.cpp
@@ -167,7 +167,7 @@ void LayerRenderer::generateMesh() {
///////////////////////////////////////////////////////////////////////////////
Layer* LayerRenderer::createLayer(uint32_t width, uint32_t height, bool isOpaque) {
- LAYER_RENDERER_LOGD("Creating new layer %dx%d", width, height);
+ LAYER_RENDERER_LOGD("Requesting new render layer %dx%d", width, height);
GLuint fbo = Caches::getInstance().fboCache.get();
if (!fbo) {
@@ -288,16 +288,22 @@ void LayerRenderer::updateTextureLayer(Layer* layer, uint32_t width, uint32_t he
void LayerRenderer::destroyLayer(Layer* layer) {
if (layer) {
- LAYER_RENDERER_LOGD("Destroying layer, fbo = %d", layer->getFbo());
+ LAYER_RENDERER_LOGD("Recycling layer, %dx%d fbo = %d",
+ layer->getWidth(), layer->getHeight(), layer->getFbo());
if (layer->getFbo()) {
Caches::getInstance().fboCache.put(layer->getFbo());
}
if (!Caches::getInstance().layerCache.put(layer)) {
+ LAYER_RENDERER_LOGD(" Destroyed!");
layer->deleteTexture();
delete layer;
} else {
+ LAYER_RENDERER_LOGD(" Cached!");
+#if DEBUG_LAYERS
+ Caches::getInstance().layerCache.dump();
+#endif
layer->region.clear();
}
}
diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp
index f926fdd..fbdbf92 100644
--- a/libs/hwui/TextureCache.cpp
+++ b/libs/hwui/TextureCache.cpp
@@ -165,7 +165,7 @@ void TextureCache::clearGarbage() {
void TextureCache::clear() {
mCache.clear();
- TEXTURE_LOGD("TextureCache:clear(), miSize = %d", mSize);
+ TEXTURE_LOGD("TextureCache:clear(), mSize = %d", mSize);
}
void TextureCache::generateTexture(SkBitmap* bitmap, Texture* texture, bool regenerate) {