diff options
author | John Reck <jreck@google.com> | 2014-04-09 23:01:02 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-04-09 23:01:02 +0000 |
commit | 8e1f918738abf70a4dc86dbb12b386a9deea37f8 (patch) | |
tree | 2f8b775662768ed77b50ec5740e5d7af608e56c8 /libs | |
parent | 3c86a27d3e9044d04d0f176e59a1ebbcd774a54c (diff) | |
parent | 8de65a8e05285df52a1e6f0c1d5616dd233298a7 (diff) | |
download | frameworks_base-8e1f918738abf70a4dc86dbb12b386a9deea37f8.zip frameworks_base-8e1f918738abf70a4dc86dbb12b386a9deea37f8.tar.gz frameworks_base-8e1f918738abf70a4dc86dbb12b386a9deea37f8.tar.bz2 |
Merge "Switch DisplayListData to a staging model"
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/DeferredLayerUpdater.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 1 | ||||
-rw-r--r-- | libs/hwui/RenderNode.cpp | 42 | ||||
-rw-r--r-- | libs/hwui/RenderNode.h | 8 | ||||
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.h | 1 | ||||
-rw-r--r-- | libs/hwui/renderthread/DrawFrameTask.cpp | 27 | ||||
-rw-r--r-- | libs/hwui/renderthread/DrawFrameTask.h | 14 | ||||
-rw-r--r-- | libs/hwui/renderthread/RenderProxy.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/renderthread/RenderProxy.h | 1 |
10 files changed, 39 insertions, 65 deletions
diff --git a/libs/hwui/DeferredLayerUpdater.cpp b/libs/hwui/DeferredLayerUpdater.cpp index ce711b6..358e1af 100644 --- a/libs/hwui/DeferredLayerUpdater.cpp +++ b/libs/hwui/DeferredLayerUpdater.cpp @@ -73,7 +73,7 @@ bool DeferredLayerUpdater::apply() { success = LayerRenderer::resizeLayer(mLayer, mWidth, mHeight); } mLayer->setBlend(mBlend); - mDisplayList->updateProperties(); + mDisplayList->pushStagingChanges(); mLayer->updateDeferred(mDisplayList.get(), mDirtyRect.left, mDirtyRect.top, mDirtyRect.right, mDirtyRect.bottom); mDirtyRect.setEmpty(); diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 9dbcd36..f37487f 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -1901,7 +1901,6 @@ status_t OpenGLRenderer::drawDisplayList(RenderNode* displayList, Rect& dirty, // will be performed by the display list itself if (displayList && displayList->isRenderable()) { // compute 3d ordering - displayList->updateProperties(); displayList->computeOrdering(); if (CC_UNLIKELY(mCaches.drawDeferDisabled)) { status = startFrame(); diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index 5010076..761fb84 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -49,7 +49,12 @@ void RenderNode::outputLogBuffer(int fd) { fflush(file); } -RenderNode::RenderNode() : mDestroyed(false), mNeedsPropertiesSync(false), mDisplayListData(0) { +RenderNode::RenderNode() + : mDestroyed(false) + , mNeedsPropertiesSync(false) + , mNeedsDisplayListDataSync(false) + , mDisplayListData(0) + , mStagingDisplayListData(0) { } RenderNode::~RenderNode() { @@ -57,13 +62,15 @@ RenderNode::~RenderNode() { mDestroyed = true; delete mDisplayListData; + delete mStagingDisplayListData; } -void RenderNode::setData(DisplayListData* data) { - delete mDisplayListData; - mDisplayListData = data; - if (mDisplayListData) { - Caches::getInstance().registerFunctors(mDisplayListData->functorCount); +void RenderNode::setStagingDisplayList(DisplayListData* data) { + mNeedsDisplayListDataSync = true; + delete mStagingDisplayListData; + mStagingDisplayListData = data; + if (mStagingDisplayListData) { + Caches::getInstance().registerFunctors(mStagingDisplayListData->functorCount); } } @@ -86,16 +93,29 @@ void RenderNode::output(uint32_t level) { ALOGD("%*sDone (%p, %s)", (level - 1) * 2, "", this, mName.string()); } -void RenderNode::updateProperties() { +void RenderNode::pushStagingChanges() { if (mNeedsPropertiesSync) { mNeedsPropertiesSync = false; mProperties = mStagingProperties; } + if (mNeedsDisplayListDataSync) { + mNeedsDisplayListDataSync = false; + // Do a push pass on the old tree to handle freeing DisplayListData + // that are no longer used + pushSubTreeStagingChanges(mDisplayListData); + delete mDisplayListData; + mDisplayListData = mStagingDisplayListData; + mStagingDisplayListData = 0; + } + + pushSubTreeStagingChanges(mDisplayListData); +} - if (mDisplayListData) { - for (size_t i = 0; i < mDisplayListData->children().size(); i++) { - RenderNode* childNode = mDisplayListData->children()[i]->mDisplayList; - childNode->updateProperties(); +void RenderNode::pushSubTreeStagingChanges(DisplayListData* subtree) { + if (subtree) { + for (size_t i = 0; i < subtree->children().size(); i++) { + RenderNode* childNode = subtree->children()[i]->mDisplayList; + childNode->pushStagingChanges(); } } } diff --git a/libs/hwui/RenderNode.h b/libs/hwui/RenderNode.h index fa0fb8a..e5b9d7c 100644 --- a/libs/hwui/RenderNode.h +++ b/libs/hwui/RenderNode.h @@ -89,7 +89,7 @@ public: ANDROID_API static void outputLogBuffer(int fd); - ANDROID_API void setData(DisplayListData* newData); + ANDROID_API void setStagingDisplayList(DisplayListData* newData); void computeOrdering(); @@ -141,7 +141,7 @@ public: return properties().getHeight(); } - ANDROID_API void updateProperties(); + ANDROID_API void pushStagingChanges(); // Returns true if this RenderNode or any of its children have functors bool hasFunctors(); @@ -203,6 +203,8 @@ private: const char* mText; }; + static void pushSubTreeStagingChanges(DisplayListData* subtree); + String8 mName; bool mDestroyed; // used for debugging crash, TODO: remove once invalid state crash fixed @@ -210,7 +212,9 @@ private: RenderProperties mProperties; RenderProperties mStagingProperties; + bool mNeedsDisplayListDataSync; DisplayListData* mDisplayListData; + DisplayListData* mStagingDisplayListData; /** * Draw time state - these properties are only set and used during rendering diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index af35344..014c7d0 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -385,10 +385,6 @@ void CanvasContext::setup(int width, int height) { mCanvas->setViewport(width, height); } -void CanvasContext::setDisplayListData(RenderNode* displayList, DisplayListData* newData) { - displayList->setData(newData); -} - void CanvasContext::processLayerUpdates(const Vector<DeferredLayerUpdater*>* layerUpdaters) { mGlobalContext->makeCurrent(mEglSurface); for (size_t i = 0; i < layerUpdaters->size(); i++) { diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h index 9f64944..4d830ba 100644 --- a/libs/hwui/renderthread/CanvasContext.h +++ b/libs/hwui/renderthread/CanvasContext.h @@ -65,7 +65,6 @@ public: void updateSurface(EGLNativeWindowType window); void pauseSurface(EGLNativeWindowType window); void setup(int width, int height); - void setDisplayListData(RenderNode* displayList, DisplayListData* newData); void processLayerUpdates(const Vector<DeferredLayerUpdater*>* layerUpdaters); void drawDisplayList(RenderNode* displayList, Rect* dirty); void destroyCanvas(); diff --git a/libs/hwui/renderthread/DrawFrameTask.cpp b/libs/hwui/renderthread/DrawFrameTask.cpp index 7b509a2..6e7ec9b 100644 --- a/libs/hwui/renderthread/DrawFrameTask.cpp +++ b/libs/hwui/renderthread/DrawFrameTask.cpp @@ -30,18 +30,6 @@ namespace android { namespace uirenderer { namespace renderthread { -SetDisplayListData::SetDisplayListData() : mNewData(0) {} - -SetDisplayListData::SetDisplayListData(RenderNode* node, DisplayListData* newData) - : mTargetNode(node), mNewData(newData) { -} - -SetDisplayListData::~SetDisplayListData() {} - -void SetDisplayListData::apply() const { - mTargetNode->setData(mNewData); -} - DrawFrameTask::DrawFrameTask() : mContext(0), mTaskMode(MODE_INVALID), mRenderNode(0) { } @@ -52,13 +40,6 @@ void DrawFrameTask::setContext(CanvasContext* context) { mContext = context; } -void DrawFrameTask::setDisplayListData(RenderNode* renderNode, DisplayListData* newData) { - LOG_ALWAYS_FATAL_IF(!mContext, "Lifecycle violation, there's no context to setDisplayListData with!"); - - SetDisplayListData setter(renderNode, newData); - mDisplayListDataUpdates.push(setter); -} - void DrawFrameTask::addLayer(DeferredLayerUpdater* layer) { LOG_ALWAYS_FATAL_IF(!mContext, "Lifecycle violation, there's no context to addLayer with!"); @@ -143,17 +124,11 @@ void DrawFrameTask::run() { void DrawFrameTask::syncFrameState() { ATRACE_CALL(); - for (size_t i = 0; i < mDisplayListDataUpdates.size(); i++) { - const SetDisplayListData& setter = mDisplayListDataUpdates[i]; - setter.apply(); - } - mDisplayListDataUpdates.clear(); - mContext->processLayerUpdates(&mLayers); // If we don't have an mRenderNode this is a state flush only if (mRenderNode.get()) { - mRenderNode->updateProperties(); + mRenderNode->pushStagingChanges(); } } diff --git a/libs/hwui/renderthread/DrawFrameTask.h b/libs/hwui/renderthread/DrawFrameTask.h index 4e9b244..ddf756b 100644 --- a/libs/hwui/renderthread/DrawFrameTask.h +++ b/libs/hwui/renderthread/DrawFrameTask.h @@ -37,18 +37,6 @@ namespace renderthread { class CanvasContext; class RenderThread; -class SetDisplayListData { -public: - // This ctor exists for Vector's usage - SetDisplayListData(); - SetDisplayListData(RenderNode* node, DisplayListData* newData); - ~SetDisplayListData(); - void apply() const; -private: - sp<RenderNode> mTargetNode; - DisplayListData* mNewData; -}; - /* * This is a special Super Task. It is re-used multiple times by RenderProxy, * and contains state (such as layer updaters & new DisplayListDatas) that is @@ -62,7 +50,6 @@ public: void setContext(CanvasContext* context); - void setDisplayListData(RenderNode* renderNode, DisplayListData* newData); void addLayer(DeferredLayerUpdater* layer); void removeLayer(DeferredLayerUpdater* layer); @@ -100,7 +87,6 @@ private: TaskMode mTaskMode; sp<RenderNode> mRenderNode; Rect mDirty; - Vector<SetDisplayListData> mDisplayListDataUpdates; /********************************************* * Multi frame data diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp index a7c955e..49b9aca 100644 --- a/libs/hwui/renderthread/RenderProxy.cpp +++ b/libs/hwui/renderthread/RenderProxy.cpp @@ -136,10 +136,6 @@ void RenderProxy::setup(int width, int height) { post(task); } -void RenderProxy::setDisplayListData(RenderNode* renderNode, DisplayListData* newData) { - mDrawFrameTask.setDisplayListData(renderNode, newData); -} - void RenderProxy::drawDisplayList(RenderNode* displayList, int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom) { mDrawFrameTask.setRenderNode(displayList); diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h index 489bf20..1ad3c85 100644 --- a/libs/hwui/renderthread/RenderProxy.h +++ b/libs/hwui/renderthread/RenderProxy.h @@ -63,7 +63,6 @@ public: ANDROID_API void updateSurface(const sp<ANativeWindow>& window); ANDROID_API void pauseSurface(const sp<ANativeWindow>& window); ANDROID_API void setup(int width, int height); - ANDROID_API void setDisplayListData(RenderNode* renderNode, DisplayListData* newData); ANDROID_API void drawDisplayList(RenderNode* displayList, int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom); ANDROID_API void destroyCanvas(); |