summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorDave Burke <daveburke@google.com>2012-09-25 20:31:08 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-25 20:31:08 -0700
commitcefbd1438c9054e3a34b4ab93b4b26b427604cb1 (patch)
treee7fe0697770cd30b9df9f95720be891e4ce6e43c /libs
parente8e2b672563fed2820e392de48226acf894cf06b (diff)
parent56257aff8a55c847be72be9924c392033fd8151d (diff)
downloadframeworks_base-cefbd1438c9054e3a34b4ab93b4b26b427604cb1.zip
frameworks_base-cefbd1438c9054e3a34b4ab93b4b26b427604cb1.tar.gz
frameworks_base-cefbd1438c9054e3a34b4ab93b4b26b427604cb1.tar.bz2
Merge "Revert "Deleting objects on the wrong thread is a silly idea Bug #7195815"" into jb-mr1-dev
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/Layer.cpp16
-rw-r--r--libs/hwui/Layer.h2
-rw-r--r--libs/hwui/LayerRenderer.cpp8
-rw-r--r--libs/hwui/LayerRenderer.h4
-rw-r--r--libs/hwui/ResourceCache.cpp6
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;
}