From 8ca3eecc2b7fe507d3482745efc4cd2567ad15a1 Mon Sep 17 00:00:00 2001 From: John Reck Date: Thu, 10 Apr 2014 10:28:45 -0700 Subject: [PATCH] Remove sync flush Bug: 13952590 It was attempting to flush state changes after the canvas was destroyed, which caused layer updates to crash. Due to the removal of SetDisplayListData, the sync mode isn't able to do anything ever, so remove it. Change-Id: I1e18ce288d81fd47cc6e612afda9476f75ecef2e --- libs/hwui/DeferredLayerUpdater.cpp | 1 + libs/hwui/renderthread/CanvasContext.cpp | 1 + libs/hwui/renderthread/DrawFrameTask.cpp | 29 +++++------------------- libs/hwui/renderthread/DrawFrameTask.h | 10 +------- libs/hwui/renderthread/RenderProxy.cpp | 7 ------ 5 files changed, 9 insertions(+), 39 deletions(-) diff --git a/libs/hwui/DeferredLayerUpdater.cpp b/libs/hwui/DeferredLayerUpdater.cpp index c64c16989c582..8b239551a1af5 100644 --- a/libs/hwui/DeferredLayerUpdater.cpp +++ b/libs/hwui/DeferredLayerUpdater.cpp @@ -41,6 +41,7 @@ DeferredLayerUpdater::DeferredLayerUpdater(Layer* layer, OpenGLRenderer* rendere DeferredLayerUpdater::~DeferredLayerUpdater() { SkSafeUnref(mColorFilter); + setTransform(0); if (mLayer) { mCaches.resourceCache.decrementRefcount(mLayer); } diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index c5122e27a253d..a39abc337c88a 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -387,6 +387,7 @@ void CanvasContext::setup(int width, int height) { void CanvasContext::processLayerUpdates(const Vector* layerUpdaters, bool* hasFunctors) { + LOG_ALWAYS_FATAL_IF(!mCanvas, "Cannot process layer updates without a canvas!"); mGlobalContext->makeCurrent(mEglSurface); for (size_t i = 0; i < layerUpdaters->size(); i++) { DeferredLayerUpdater* update = layerUpdaters->itemAt(i); diff --git a/libs/hwui/renderthread/DrawFrameTask.cpp b/libs/hwui/renderthread/DrawFrameTask.cpp index 372d0d0084d6d..cf6c8db9889ac 100644 --- a/libs/hwui/renderthread/DrawFrameTask.cpp +++ b/libs/hwui/renderthread/DrawFrameTask.cpp @@ -30,7 +30,7 @@ namespace android { namespace uirenderer { namespace renderthread { -DrawFrameTask::DrawFrameTask() : mContext(0), mTaskMode(MODE_INVALID), mRenderNode(0) { +DrawFrameTask::DrawFrameTask() : mContext(0), mRenderNode(0) { } DrawFrameTask::~DrawFrameTask() { @@ -69,23 +69,14 @@ void DrawFrameTask::drawFrame(RenderThread* renderThread) { LOG_ALWAYS_FATAL_IF(!mRenderNode.get(), "Cannot drawFrame with no render node!"); LOG_ALWAYS_FATAL_IF(!mContext, "Cannot drawFrame with no CanvasContext!"); - postAndWait(renderThread, MODE_FULL); + postAndWait(renderThread); // Reset the single-frame data mDirty.setEmpty(); mRenderNode = 0; } -void DrawFrameTask::flushStateChanges(RenderThread* renderThread) { - LOG_ALWAYS_FATAL_IF(!mContext, "Cannot drawFrame with no CanvasContext!"); - - postAndWait(renderThread, MODE_STATE_ONLY); -} - -void DrawFrameTask::postAndWait(RenderThread* renderThread, TaskMode mode) { - LOG_ALWAYS_FATAL_IF(mode == MODE_INVALID, "That's not a real mode, silly!"); - - mTaskMode = mode; +void DrawFrameTask::postAndWait(RenderThread* renderThread) { AutoMutex _lock(mLock); renderThread->queue(this); mSignal.wait(mLock); @@ -97,11 +88,6 @@ void DrawFrameTask::run() { // canUnblockUiThread is temporary until WebView has a solution for syncing frame state bool canUnblockUiThread = syncFrameState(); - if (mTaskMode == MODE_STATE_ONLY) { - unblockUiThread(); - return; - } - // Grab a copy of everything we need Rect dirtyCopy(mDirty); sp renderNode = mRenderNode; @@ -125,12 +111,9 @@ bool DrawFrameTask::syncFrameState() { bool hasFunctors = false; mContext->processLayerUpdates(&mLayers, &hasFunctors); - // If we don't have an mRenderNode this is a state flush only - if (mRenderNode.get()) { - TreeInfo info = {0}; - mRenderNode->prepareTree(info); - hasFunctors |= info.hasFunctors; - } + TreeInfo info = {0}; + mRenderNode->prepareTree(info); + hasFunctors |= info.hasFunctors; return !hasFunctors; } diff --git a/libs/hwui/renderthread/DrawFrameTask.h b/libs/hwui/renderthread/DrawFrameTask.h index a5124088d7907..055d4cf3f29dd 100644 --- a/libs/hwui/renderthread/DrawFrameTask.h +++ b/libs/hwui/renderthread/DrawFrameTask.h @@ -56,18 +56,11 @@ public: void setRenderNode(RenderNode* renderNode); void setDirty(int left, int top, int right, int bottom); void drawFrame(RenderThread* renderThread); - void flushStateChanges(RenderThread* renderThread); virtual void run(); private: - enum TaskMode { - MODE_INVALID, - MODE_FULL, - MODE_STATE_ONLY, - }; - - void postAndWait(RenderThread* renderThread, TaskMode mode); + void postAndWait(RenderThread* renderThread); bool syncFrameState(); void unblockUiThread(); static void drawRenderNode(CanvasContext* context, RenderNode* renderNode, Rect* dirty); @@ -80,7 +73,6 @@ private: /********************************************* * Single frame data *********************************************/ - TaskMode mTaskMode; sp mRenderNode; Rect mDirty; diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp index 49b9acab1c17e..5ab43b509c249 100644 --- a/libs/hwui/renderthread/RenderProxy.cpp +++ b/libs/hwui/renderthread/RenderProxy.cpp @@ -75,9 +75,6 @@ CREATE_BRIDGE1(destroyContext, CanvasContext* context) { void RenderProxy::destroyContext() { if (mContext) { - // Flush any pending changes to ensure all garbage is destroyed - mDrawFrameTask.flushStateChanges(&mRenderThread); - SETUP_TASK(destroyContext); args->context = mContext; mContext = 0; @@ -149,10 +146,6 @@ CREATE_BRIDGE1(destroyCanvas, CanvasContext* context) { } void RenderProxy::destroyCanvas() { - // If the canvas is being destroyed we won't be drawing again anytime soon - // So flush any pending state changes to allow for resource cleanup. - mDrawFrameTask.flushStateChanges(&mRenderThread); - SETUP_TASK(destroyCanvas); args->context = mContext; post(task);