summaryrefslogtreecommitdiffstats
path: root/libs/hwui/renderthread/RenderProxy.cpp
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2014-05-29 18:56:11 -0700
committerJohn Reck <jreck@google.com>2014-05-30 12:19:33 -0700
commitd72e0a339b54af0c4e731513bbad120dff694723 (patch)
treeca8ac198de9a0cfeeae1e9e8039e35523e7810c3 /libs/hwui/renderthread/RenderProxy.cpp
parentaee470c0232afdac4256d13020fa0cf04f30395c (diff)
downloadframeworks_base-d72e0a339b54af0c4e731513bbad120dff694723.zip
frameworks_base-d72e0a339b54af0c4e731513bbad120dff694723.tar.gz
frameworks_base-d72e0a339b54af0c4e731513bbad120dff694723.tar.bz2
Re-jigger layers
Bug: 15185239 Bug: 15238382 Make DeferredLayerUpdater ref counted so that HardwareLayer:finalizer() works non-crashily on leaked layers Give DeferredLayerUpdater the ability to have a layer destroyer set so that leaked layers can still be recycled on the RenderThread Order layer updates based off of pushLayerUpdate() calls to fix issue with nested layers Change-Id: I4449cee607f7e5126e02fed7464cf48038e3dfdf
Diffstat (limited to 'libs/hwui/renderthread/RenderProxy.cpp')
-rw-r--r--libs/hwui/renderthread/RenderProxy.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index 77c0aa7..0901963 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -229,10 +229,21 @@ void RenderProxy::runWithGlContext(RenderTask* gltask) {
postAndWait(task);
}
+CREATE_BRIDGE1(destroyLayer, Layer* layer) {
+ LayerRenderer::destroyLayer(args->layer);
+ return NULL;
+}
+
+static void enqueueDestroyLayer(Layer* layer) {
+ SETUP_TASK(destroyLayer);
+ args->layer = layer;
+ RenderThread::getInstance().queue(task);
+}
+
CREATE_BRIDGE3(createDisplayListLayer, CanvasContext* context, int width, int height) {
Layer* layer = args->context->createRenderLayer(args->width, args->height);
if (!layer) return 0;
- return new DeferredLayerUpdater(layer);
+ return new DeferredLayerUpdater(layer, enqueueDestroyLayer);
}
DeferredLayerUpdater* RenderProxy::createDisplayListLayer(int width, int height) {
@@ -242,14 +253,13 @@ DeferredLayerUpdater* RenderProxy::createDisplayListLayer(int width, int height)
args->context = mContext;
void* retval = postAndWait(task);
DeferredLayerUpdater* layer = reinterpret_cast<DeferredLayerUpdater*>(retval);
- mDrawFrameTask.addLayer(layer);
return layer;
}
CREATE_BRIDGE1(createTextureLayer, CanvasContext* context) {
Layer* layer = args->context->createTextureLayer();
if (!layer) return 0;
- return new DeferredLayerUpdater(layer);
+ return new DeferredLayerUpdater(layer, enqueueDestroyLayer);
}
DeferredLayerUpdater* RenderProxy::createTextureLayer() {
@@ -257,15 +267,9 @@ DeferredLayerUpdater* RenderProxy::createTextureLayer() {
args->context = mContext;
void* retval = postAndWait(task);
DeferredLayerUpdater* layer = reinterpret_cast<DeferredLayerUpdater*>(retval);
- mDrawFrameTask.addLayer(layer);
return layer;
}
-CREATE_BRIDGE1(destroyLayer, Layer* layer) {
- LayerRenderer::destroyLayer(args->layer);
- return NULL;
-}
-
CREATE_BRIDGE3(copyLayerInto, CanvasContext* context, DeferredLayerUpdater* layer,
SkBitmap* bitmap) {
bool success = args->context->copyLayerInto(args->layer, args->bitmap);
@@ -280,11 +284,12 @@ bool RenderProxy::copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) {
return (bool) postAndWait(task);
}
-void RenderProxy::destroyLayer(DeferredLayerUpdater* layer) {
- mDrawFrameTask.removeLayer(layer);
- SETUP_TASK(destroyLayer);
- args->layer = layer->detachBackingLayer();
- post(task);
+void RenderProxy::pushLayerUpdate(DeferredLayerUpdater* layer) {
+ mDrawFrameTask.pushLayerUpdate(layer);
+}
+
+void RenderProxy::cancelLayerUpdate(DeferredLayerUpdater* layer) {
+ mDrawFrameTask.removeLayerUpdate(layer);
}
CREATE_BRIDGE2(flushCaches, CanvasContext* context, Caches::FlushMode flushMode) {