Implement full View.buildLayer
Bug: 17152292
Change-Id: Ia3cc2aadf72fe14517f50762fc634794df51ad5a
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 @@
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 @@
// 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 d9b96f6c..405ce24 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -284,6 +284,18 @@
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 @@
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);