From 3e8249568cc428296ac76c7ddce3f0382d40fe5b Mon Sep 17 00:00:00 2001 From: John Reck Date: Wed, 20 Aug 2014 10:08:39 -0700 Subject: Implement full View.buildLayer Bug: 17152292 Change-Id: Ia3cc2aadf72fe14517f50762fc634794df51ad5a --- libs/hwui/renderthread/CanvasContext.cpp | 23 +++++++++++++++++++++++ libs/hwui/renderthread/CanvasContext.h | 1 + libs/hwui/renderthread/RenderProxy.cpp | 12 ++++++++++++ libs/hwui/renderthread/RenderProxy.h | 1 + 4 files changed, 37 insertions(+) (limited to 'libs') diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index e673b0d..5922135 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -244,6 +244,29 @@ void CanvasContext::invokeFunctor(RenderThread& thread, Functor* functor) { thread.renderState().invokeFunctor(functor, mode, NULL); } +void CanvasContext::buildLayer(RenderNode* node) { + ATRACE_CALL(); + if (!mEglManager.hasEglContext() || !mCanvas) { + return; + } + requireGlContext(); + // buildLayer() will leave the tree in an unknown state, so we must stop drawing + stopDrawing(); + + TreeInfo info(TreeInfo::MODE_FULL, mRenderThread.renderState()); + info.frameTimeMs = mRenderThread.timeLord().frameTimeMs(); + info.damageAccumulator = &mDamageAccumulator; + info.renderer = mCanvas; + node->prepareTree(info); + SkRect ignore; + mDamageAccumulator.finish(&ignore); + // Tickle the GENERIC property on node to mark it as dirty for damaging + // purposes when the frame is actually drawn + node->setPropertyFieldsDirty(RenderNode::GENERIC); + + mCanvas->flushLayerUpdates(); +} + bool CanvasContext::copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) { requireGlContext(); layer->apply(); diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h index 2a01027..0cbed6f 100644 --- a/libs/hwui/renderthread/CanvasContext.h +++ b/libs/hwui/renderthread/CanvasContext.h @@ -65,6 +65,7 @@ public: // IFrameCallback, Chroreographer-driven frame callback entry point virtual void doFrame(); + void buildLayer(RenderNode* node); bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap); void destroyHardwareResources(); diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp index d9b96f6..405ce24 100644 --- a/libs/hwui/renderthread/RenderProxy.cpp +++ b/libs/hwui/renderthread/RenderProxy.cpp @@ -284,6 +284,18 @@ DeferredLayerUpdater* RenderProxy::createTextureLayer() { return layer; } +CREATE_BRIDGE2(buildLayer, CanvasContext* context, RenderNode* node) { + args->context->buildLayer(args->node); + return NULL; +} + +void RenderProxy::buildLayer(RenderNode* node) { + SETUP_TASK(buildLayer); + args->context = mContext; + args->node = node; + postAndWait(task); +} + CREATE_BRIDGE3(copyLayerInto, CanvasContext* context, DeferredLayerUpdater* layer, SkBitmap* bitmap) { bool success = args->context->copyLayerInto(args->layer, args->bitmap); diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h index 28d0173..eea3674 100644 --- a/libs/hwui/renderthread/RenderProxy.h +++ b/libs/hwui/renderthread/RenderProxy.h @@ -81,6 +81,7 @@ public: static void enqueueDestroyLayer(Layer* layer); ANDROID_API DeferredLayerUpdater* createDisplayListLayer(int width, int height); ANDROID_API DeferredLayerUpdater* createTextureLayer(); + ANDROID_API void buildLayer(RenderNode* node); ANDROID_API bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap); ANDROID_API void pushLayerUpdate(DeferredLayerUpdater* layer); ANDROID_API void cancelLayerUpdate(DeferredLayerUpdater* layer); -- cgit v1.1