diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/Layer.cpp | 16 | ||||
-rw-r--r-- | libs/hwui/Layer.h | 2 | ||||
-rw-r--r-- | libs/hwui/LayerRenderer.cpp | 8 | ||||
-rw-r--r-- | libs/hwui/LayerRenderer.h | 4 | ||||
-rw-r--r-- | libs/hwui/ResourceCache.cpp | 6 |
5 files changed, 25 insertions, 11 deletions
diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp index cd2e571..fb525ee 100644 --- a/libs/hwui/Layer.cpp +++ b/libs/hwui/Layer.cpp @@ -19,7 +19,6 @@ #include <utils/Log.h> #include "Layer.h" -#include "LayerRenderer.h" #include "OpenGLRenderer.h" #include "Caches.h" @@ -47,14 +46,17 @@ Layer::~Layer() { if (mesh) delete mesh; if (meshIndices) delete meshIndices; if (colorFilter) Caches::getInstance().resourceCache.decrementRefcount(colorFilter); - if (fbo) { - LayerRenderer::flushLayer(this); - Caches::getInstance().fboCache.put(fbo); - fbo = 0; - } + if (fbo) Caches::getInstance().fboCache.put(fbo); deleteTexture(); } +void Layer::freeResourcesLocked() { + if (colorFilter) { + Caches::getInstance().resourceCache.decrementRefcountLocked(colorFilter); + colorFilter = NULL; + } +} + void Layer::setPaint(SkPaint* paint) { OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode); } @@ -69,5 +71,7 @@ void Layer::setColorFilter(SkiaColorFilter* filter) { } } + + }; // namespace uirenderer }; // namespace android diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index 59c66d7..9b6205d 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -48,6 +48,8 @@ struct Layer { Layer(const uint32_t layerWidth, const uint32_t layerHeight); ~Layer(); + void freeResourcesLocked(); + /** * Sets this layer's region to a rectangle. Computes the appropriate * texture coordinates. diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp index c581041..799aea3 100644 --- a/libs/hwui/LayerRenderer.cpp +++ b/libs/hwui/LayerRenderer.cpp @@ -299,6 +299,13 @@ void LayerRenderer::destroyLayer(Layer* layer) { LAYER_RENDERER_LOGD("Recycling layer, %dx%d fbo = %d", layer->getWidth(), layer->getHeight(), layer->getFbo()); + GLuint fbo = layer->getFbo(); + if (fbo) { + flushLayer(layer); + Caches::getInstance().fboCache.put(fbo); + layer->setFbo(0); + } + if (!Caches::getInstance().layerCache.put(layer)) { LAYER_RENDERER_LOGD(" Destroyed!"); Caches::getInstance().resourceCache.decrementRefcount(layer); @@ -315,6 +322,7 @@ void LayerRenderer::destroyLayer(Layer* layer) { void LayerRenderer::destroyLayerDeferred(Layer* layer) { if (layer) { LAYER_RENDERER_LOGD("Deferring layer destruction, fbo = %d", layer->getFbo()); + Caches::getInstance().deleteLayerDeferred(layer); } } diff --git a/libs/hwui/LayerRenderer.h b/libs/hwui/LayerRenderer.h index acedbcc..392f863 100644 --- a/libs/hwui/LayerRenderer.h +++ b/libs/hwui/LayerRenderer.h @@ -60,8 +60,6 @@ public: ANDROID_API static void destroyLayerDeferred(Layer* layer); ANDROID_API static bool copyLayer(Layer* layer, SkBitmap* bitmap); - static void flushLayer(Layer* layer); - protected: virtual bool hasLayer(); virtual Region* getRegion(); @@ -71,6 +69,8 @@ protected: private: void generateMesh(); + static void flushLayer(Layer* layer); + Layer* mLayer; }; // class LayerRenderer diff --git a/libs/hwui/ResourceCache.cpp b/libs/hwui/ResourceCache.cpp index 39e64bc..18d8324 100644 --- a/libs/hwui/ResourceCache.cpp +++ b/libs/hwui/ResourceCache.cpp @@ -325,9 +325,9 @@ void ResourceCache::deleteResourceReferenceLocked(void* resource, ResourceRefere } break; case kLayer: { - // No need to check for hasInstance, layers only exist - // when we have a Caches instance - Caches::getInstance().deleteLayerDeferred((Layer*) resource); + Layer* layer = (Layer*) resource; + layer->freeResourcesLocked(); + delete layer; } break; } |