blob: ea872a133ddb424ab381381c36245bef03c60923 [file] [log] [blame]
John Reck113e0822014-03-18 09:22:59 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
John Reck113e0822014-03-18 09:22:59 -070017#include "RenderNode.h"
18
John Recke4267ea2014-06-03 15:53:15 -070019#include "DamageAccumulator.h"
John Reck113e0822014-03-18 09:22:59 -070020#include "Debug.h"
Chris Craikb565df12015-10-05 13:00:52 -070021#if HWUI_NEW_OPS
22#include "RecordedOp.h"
23#endif
John Reck113e0822014-03-18 09:22:59 -070024#include "DisplayListOp.h"
John Reck25fbb3f2014-06-12 13:46:45 -070025#include "LayerRenderer.h"
26#include "OpenGLRenderer.h"
Tom Hudson2dc236b2014-10-15 15:46:42 -040027#include "TreeInfo.h"
Chris Craike0bb87d2014-04-22 17:55:41 -070028#include "utils/MathUtils.h"
Chris Craik70850ea2014-11-18 10:49:23 -080029#include "utils/TraceUtils.h"
John Reck998a6d82014-08-28 15:35:53 -070030#include "renderthread/CanvasContext.h"
John Reck113e0822014-03-18 09:22:59 -070031
John Recke248bd12015-08-05 13:53:53 -070032#include "protos/hwui.pb.h"
33#include "protos/ProtoHelpers.h"
34
John Reck77c40102015-10-26 15:49:47 -070035#include <SkCanvas.h>
36
37#include <algorithm>
38#include <sstream>
39#include <string>
40
John Reck113e0822014-03-18 09:22:59 -070041namespace android {
42namespace uirenderer {
43
John Reck443a7142014-09-04 17:40:05 -070044void RenderNode::debugDumpLayers(const char* prefix) {
45 if (mLayer) {
46 ALOGD("%sNode %p (%s) has layer %p (fbo = %u, wasBuildLayered = %s)",
47 prefix, this, getName(), mLayer, mLayer->getFbo(),
48 mLayer->wasBuildLayered ? "true" : "false");
49 }
Chris Craik003cc3d2015-10-16 10:24:55 -070050 if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -070051 for (auto&& child : mDisplayList->getChildren()) {
Chris Craik10ed6922015-10-15 10:55:15 -070052 child->renderNode->debugDumpLayers(prefix);
John Reck443a7142014-09-04 17:40:05 -070053 }
54 }
55}
56
John Reck8de65a82014-04-09 15:23:38 -070057RenderNode::RenderNode()
John Reckff941dc2014-05-14 16:34:14 -070058 : mDirtyPropertyFields(0)
Chris Craik003cc3d2015-10-16 10:24:55 -070059 , mNeedsDisplayListSync(false)
60 , mDisplayList(nullptr)
61 , mStagingDisplayList(nullptr)
John Reck68bfe0a2014-06-24 15:34:58 -070062 , mAnimatorManager(*this)
Chris Craikd41c4d82015-01-05 15:51:13 -080063 , mLayer(nullptr)
John Reckdcba6722014-07-08 13:59:49 -070064 , mParentCount(0) {
John Reck113e0822014-03-18 09:22:59 -070065}
66
67RenderNode::~RenderNode() {
Chris Craik003cc3d2015-10-16 10:24:55 -070068 deleteDisplayList();
69 delete mStagingDisplayList;
John Reck0e89e2b2014-10-31 14:49:06 -070070 if (mLayer) {
71 ALOGW("Memory Warning: Layer %p missed its detachment, held on to for far too long!", mLayer);
72 mLayer->postDecStrong();
Chris Craikd41c4d82015-01-05 15:51:13 -080073 mLayer = nullptr;
John Reck0e89e2b2014-10-31 14:49:06 -070074 }
John Reck113e0822014-03-18 09:22:59 -070075}
76
Chris Craik003cc3d2015-10-16 10:24:55 -070077void RenderNode::setStagingDisplayList(DisplayList* displayList) {
78 mNeedsDisplayListSync = true;
79 delete mStagingDisplayList;
80 mStagingDisplayList = displayList;
John Reck113e0822014-03-18 09:22:59 -070081}
82
83/**
84 * This function is a simplified version of replay(), where we simply retrieve and log the
85 * display list. This function should remain in sync with the replay() function.
86 */
87void RenderNode::output(uint32_t level) {
Chris Craikbf72eb82015-06-08 11:30:44 -070088 ALOGD("%*sStart display list (%p, %s%s%s%s%s%s)", (level - 1) * 2, "", this,
Chris Craikb5a54352014-11-21 14:54:35 -080089 getName(),
Chris Craik43a1d312015-05-27 11:28:14 -070090 (MathUtils::isZero(properties().getAlpha()) ? ", zero alpha" : ""),
Chris Craikb5a54352014-11-21 14:54:35 -080091 (properties().hasShadow() ? ", casting shadow" : ""),
92 (isRenderable() ? "" : ", empty"),
Chris Craikbf72eb82015-06-08 11:30:44 -070093 (properties().getProjectBackwards() ? ", projected" : ""),
Chris Craikd41c4d82015-01-05 15:51:13 -080094 (mLayer != nullptr ? ", on HW Layer" : ""));
John Reck113e0822014-03-18 09:22:59 -070095 ALOGD("%*s%s %d", level * 2, "", "Save",
96 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
97
John Reckd0a0b2a2014-03-20 16:28:56 -070098 properties().debugOutputProperties(level);
Chris Craik10ed6922015-10-15 10:55:15 -070099
Chris Craik003cc3d2015-10-16 10:24:55 -0700100 if (mDisplayList) {
Chris Craik10ed6922015-10-15 10:55:15 -0700101#if HWUI_NEW_OPS
102 LOG_ALWAYS_FATAL("op dumping unsupported");
103#else
Chris Craik8afd0f22014-08-21 17:41:57 -0700104 // TODO: consider printing the chunk boundaries here
Chris Craik003cc3d2015-10-16 10:24:55 -0700105 for (auto&& op : mDisplayList->getOps()) {
Chris Craik10ed6922015-10-15 10:55:15 -0700106 op->output(level, DisplayListOp::kOpLogFlag_Recurse);
John Reckdc0349b2014-08-06 15:28:07 -0700107 }
Chris Craik10ed6922015-10-15 10:55:15 -0700108#endif
John Reck113e0822014-03-18 09:22:59 -0700109 }
110
Chris Craik3f0854292014-04-15 16:18:08 -0700111 ALOGD("%*sDone (%p, %s)", (level - 1) * 2, "", this, getName());
John Reck113e0822014-03-18 09:22:59 -0700112}
113
John Recke248bd12015-08-05 13:53:53 -0700114void RenderNode::copyTo(proto::RenderNode *pnode) {
115 pnode->set_id(static_cast<uint64_t>(
116 reinterpret_cast<uintptr_t>(this)));
117 pnode->set_name(mName.string(), mName.length());
118
119 proto::RenderProperties* pprops = pnode->mutable_properties();
120 pprops->set_left(properties().getLeft());
121 pprops->set_top(properties().getTop());
122 pprops->set_right(properties().getRight());
123 pprops->set_bottom(properties().getBottom());
124 pprops->set_clip_flags(properties().getClippingFlags());
125 pprops->set_alpha(properties().getAlpha());
126 pprops->set_translation_x(properties().getTranslationX());
127 pprops->set_translation_y(properties().getTranslationY());
128 pprops->set_translation_z(properties().getTranslationZ());
129 pprops->set_elevation(properties().getElevation());
130 pprops->set_rotation(properties().getRotation());
131 pprops->set_rotation_x(properties().getRotationX());
132 pprops->set_rotation_y(properties().getRotationY());
133 pprops->set_scale_x(properties().getScaleX());
134 pprops->set_scale_y(properties().getScaleY());
135 pprops->set_pivot_x(properties().getPivotX());
136 pprops->set_pivot_y(properties().getPivotY());
137 pprops->set_has_overlapping_rendering(properties().getHasOverlappingRendering());
138 pprops->set_pivot_explicitly_set(properties().isPivotExplicitlySet());
139 pprops->set_project_backwards(properties().getProjectBackwards());
140 pprops->set_projection_receiver(properties().isProjectionReceiver());
141 set(pprops->mutable_clip_bounds(), properties().getClipBounds());
142
143 const Outline& outline = properties().getOutline();
144 if (outline.getType() != Outline::Type::None) {
145 proto::Outline* poutline = pprops->mutable_outline();
146 poutline->clear_path();
147 if (outline.getType() == Outline::Type::Empty) {
148 poutline->set_type(proto::Outline_Type_Empty);
149 } else if (outline.getType() == Outline::Type::ConvexPath) {
150 poutline->set_type(proto::Outline_Type_ConvexPath);
151 if (const SkPath* path = outline.getPath()) {
152 set(poutline->mutable_path(), *path);
153 }
154 } else if (outline.getType() == Outline::Type::RoundRect) {
155 poutline->set_type(proto::Outline_Type_RoundRect);
156 } else {
157 ALOGW("Uknown outline type! %d", static_cast<int>(outline.getType()));
158 poutline->set_type(proto::Outline_Type_None);
159 }
160 poutline->set_should_clip(outline.getShouldClip());
161 poutline->set_alpha(outline.getAlpha());
162 poutline->set_radius(outline.getRadius());
163 set(poutline->mutable_bounds(), outline.getBounds());
164 } else {
165 pprops->clear_outline();
166 }
167
168 const RevealClip& revealClip = properties().getRevealClip();
169 if (revealClip.willClip()) {
170 proto::RevealClip* prevealClip = pprops->mutable_reveal_clip();
171 prevealClip->set_x(revealClip.getX());
172 prevealClip->set_y(revealClip.getY());
173 prevealClip->set_radius(revealClip.getRadius());
174 } else {
175 pprops->clear_reveal_clip();
176 }
177
178 pnode->clear_children();
Chris Craik003cc3d2015-10-16 10:24:55 -0700179 if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700180 for (auto&& child : mDisplayList->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700181 child->renderNode->copyTo(pnode->add_children());
John Recke248bd12015-08-05 13:53:53 -0700182 }
183 }
184}
185
John Reckfe5e7b72014-05-23 17:42:28 -0700186int RenderNode::getDebugSize() {
187 int size = sizeof(RenderNode);
Chris Craik003cc3d2015-10-16 10:24:55 -0700188 if (mStagingDisplayList) {
189 size += mStagingDisplayList->getUsedSize();
John Reckfe5e7b72014-05-23 17:42:28 -0700190 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700191 if (mDisplayList && mDisplayList != mStagingDisplayList) {
192 size += mDisplayList->getUsedSize();
John Reckfe5e7b72014-05-23 17:42:28 -0700193 }
194 return size;
195}
196
John Reckf4198b72014-04-09 17:00:04 -0700197void RenderNode::prepareTree(TreeInfo& info) {
198 ATRACE_CALL();
Chris Craik69e5adf2014-08-14 13:34:01 -0700199 LOG_ALWAYS_FATAL_IF(!info.damageAccumulator, "DamageAccumulator missing");
John Reckf4198b72014-04-09 17:00:04 -0700200
Chris Craika766cb22015-06-08 16:49:43 -0700201 // Functors don't correctly handle stencil usage of overdraw debugging - shove 'em in a layer.
202 bool functorsNeedLayer = Properties::debugOverdraw;
203
204 prepareTreeImpl(info, functorsNeedLayer);
John Reckf4198b72014-04-09 17:00:04 -0700205}
206
John Reck68bfe0a2014-06-24 15:34:58 -0700207void RenderNode::addAnimator(const sp<BaseRenderNodeAnimator>& animator) {
208 mAnimatorManager.addAnimator(animator);
209}
210
John Recke4267ea2014-06-03 15:53:15 -0700211void RenderNode::damageSelf(TreeInfo& info) {
John Reckce9f3082014-06-17 16:18:09 -0700212 if (isRenderable()) {
John Reck293e8682014-06-17 10:34:02 -0700213 if (properties().getClipDamageToBounds()) {
John Recka447d292014-06-11 18:39:44 -0700214 info.damageAccumulator->dirty(0, 0, properties().getWidth(), properties().getHeight());
215 } else {
216 // Hope this is big enough?
217 // TODO: Get this from the display list ops or something
John Reckc1288232015-08-12 13:39:11 -0700218 info.damageAccumulator->dirty(DIRTY_MIN, DIRTY_MIN, DIRTY_MAX, DIRTY_MAX);
John Recka447d292014-06-11 18:39:44 -0700219 }
John Recke4267ea2014-06-03 15:53:15 -0700220 }
221}
222
John Recka7c2ea22014-08-08 13:21:00 -0700223void RenderNode::prepareLayer(TreeInfo& info, uint32_t dirtyMask) {
Chris Craik856f0cc2015-04-21 15:13:29 -0700224 LayerType layerType = properties().effectiveLayerType();
Chris Craik182952f2015-03-09 14:17:29 -0700225 if (CC_UNLIKELY(layerType == LayerType::RenderLayer)) {
John Recka7c2ea22014-08-08 13:21:00 -0700226 // Damage applied so far needs to affect our parent, but does not require
227 // the layer to be updated. So we pop/push here to clear out the current
228 // damage and get a clean state for display list or children updates to
229 // affect, which will require the layer to be updated
230 info.damageAccumulator->popTransform();
231 info.damageAccumulator->pushTransform(this);
232 if (dirtyMask & DISPLAY_LIST) {
233 damageSelf(info);
234 }
John Reck25fbb3f2014-06-12 13:46:45 -0700235 }
236}
237
238void RenderNode::pushLayerUpdate(TreeInfo& info) {
Chris Craik856f0cc2015-04-21 15:13:29 -0700239 LayerType layerType = properties().effectiveLayerType();
John Reck25fbb3f2014-06-12 13:46:45 -0700240 // If we are not a layer OR we cannot be rendered (eg, view was detached)
241 // we need to destroy any Layers we may have had previously
Chris Craik182952f2015-03-09 14:17:29 -0700242 if (CC_LIKELY(layerType != LayerType::RenderLayer) || CC_UNLIKELY(!isRenderable())) {
John Reck25fbb3f2014-06-12 13:46:45 -0700243 if (CC_UNLIKELY(mLayer)) {
244 LayerRenderer::destroyLayer(mLayer);
Chris Craikd41c4d82015-01-05 15:51:13 -0800245 mLayer = nullptr;
John Reck25fbb3f2014-06-12 13:46:45 -0700246 }
247 return;
248 }
249
Chris Craik69e5adf2014-08-14 13:34:01 -0700250 bool transformUpdateNeeded = false;
John Reck25fbb3f2014-06-12 13:46:45 -0700251 if (!mLayer) {
John Reck3b202512014-06-23 13:13:08 -0700252 mLayer = LayerRenderer::createRenderLayer(info.renderState, getWidth(), getHeight());
John Reck25fbb3f2014-06-12 13:46:45 -0700253 applyLayerPropertiesToLayer(info);
254 damageSelf(info);
Chris Craik69e5adf2014-08-14 13:34:01 -0700255 transformUpdateNeeded = true;
John Reck25fbb3f2014-06-12 13:46:45 -0700256 } else if (mLayer->layer.getWidth() != getWidth() || mLayer->layer.getHeight() != getHeight()) {
John Reckc25e5062014-06-18 14:21:29 -0700257 if (!LayerRenderer::resizeLayer(mLayer, getWidth(), getHeight())) {
258 LayerRenderer::destroyLayer(mLayer);
Chris Craikd41c4d82015-01-05 15:51:13 -0800259 mLayer = nullptr;
John Reckc25e5062014-06-18 14:21:29 -0700260 }
John Reck25fbb3f2014-06-12 13:46:45 -0700261 damageSelf(info);
Chris Craik69e5adf2014-08-14 13:34:01 -0700262 transformUpdateNeeded = true;
263 }
264
John Reck25fbb3f2014-06-12 13:46:45 -0700265 SkRect dirty;
266 info.damageAccumulator->peekAtDirty(&dirty);
John Reck25fbb3f2014-06-12 13:46:45 -0700267
John Reckc25e5062014-06-18 14:21:29 -0700268 if (!mLayer) {
John Reck0e89e2b2014-10-31 14:49:06 -0700269 Caches::getInstance().dumpMemoryUsage();
John Reckc25e5062014-06-18 14:21:29 -0700270 if (info.errorHandler) {
John Reck77c40102015-10-26 15:49:47 -0700271 std::ostringstream err;
272 err << "Unable to create layer for " << getName();
273 const int maxTextureSize = Caches::getInstance().maxTextureSize;
274 if (getWidth() > maxTextureSize || getHeight() > maxTextureSize) {
275 err << ", size " << getWidth() << "x" << getHeight()
276 << " exceeds max size " << maxTextureSize;
277 } else {
278 err << ", see logcat for more info";
279 }
280 info.errorHandler->onError(err.str());
John Reckc25e5062014-06-18 14:21:29 -0700281 }
282 return;
283 }
284
Chris Craikc71bfca2014-08-21 10:18:58 -0700285 if (transformUpdateNeeded) {
286 // update the transform in window of the layer to reset its origin wrt light source position
287 Matrix4 windowTransform;
288 info.damageAccumulator->computeCurrentTransform(&windowTransform);
289 mLayer->setWindowTransform(windowTransform);
290 }
John Reckc79eabc2014-08-05 11:03:42 -0700291
292 if (dirty.intersect(0, 0, getWidth(), getHeight())) {
Mike Reed71487eb2014-11-19 16:13:20 -0500293 dirty.roundOut(&dirty);
John Reck25fbb3f2014-06-12 13:46:45 -0700294 mLayer->updateDeferred(this, dirty.fLeft, dirty.fTop, dirty.fRight, dirty.fBottom);
295 }
296 // This is not inside the above if because we may have called
297 // updateDeferred on a previous prepare pass that didn't have a renderer
298 if (info.renderer && mLayer->deferredUpdateScheduled) {
299 info.renderer->pushLayerUpdate(mLayer);
300 }
John Reck998a6d82014-08-28 15:35:53 -0700301
John Reck00e79c92015-07-21 10:23:59 -0700302 if (info.canvasContext) {
303 // There might be prefetched layers that need to be accounted for.
304 // That might be us, so tell CanvasContext that this layer is in the
305 // tree and should not be destroyed.
John Reck998a6d82014-08-28 15:35:53 -0700306 info.canvasContext->markLayerInUse(this);
307 }
John Reck25fbb3f2014-06-12 13:46:45 -0700308}
309
Chris Craika766cb22015-06-08 16:49:43 -0700310/**
311 * Traverse down the the draw tree to prepare for a frame.
312 *
313 * MODE_FULL = UI Thread-driven (thus properties must be synced), otherwise RT driven
314 *
315 * While traversing down the tree, functorsNeedLayer flag is set to true if anything that uses the
316 * stencil buffer may be needed. Views that use a functor to draw will be forced onto a layer.
317 */
318void RenderNode::prepareTreeImpl(TreeInfo& info, bool functorsNeedLayer) {
John Recka447d292014-06-11 18:39:44 -0700319 info.damageAccumulator->pushTransform(this);
John Reckf47a5942014-06-30 16:20:04 -0700320
John Reckdcba6722014-07-08 13:59:49 -0700321 if (info.mode == TreeInfo::MODE_FULL) {
John Reck25fbb3f2014-06-12 13:46:45 -0700322 pushStagingPropertiesChanges(info);
John Recke45b1fd2014-04-15 09:50:16 -0700323 }
John Reck9eb9f6f2014-08-21 11:23:05 -0700324 uint32_t animatorDirtyMask = 0;
325 if (CC_LIKELY(info.runAnimations)) {
326 animatorDirtyMask = mAnimatorManager.animate(info);
327 }
Chris Craika766cb22015-06-08 16:49:43 -0700328
John Reck3f725f02015-06-16 10:29:31 -0700329 bool willHaveFunctor = false;
Chris Craik003cc3d2015-10-16 10:24:55 -0700330 if (info.mode == TreeInfo::MODE_FULL && mStagingDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700331 willHaveFunctor = !mStagingDisplayList->getFunctors().empty();
Chris Craik003cc3d2015-10-16 10:24:55 -0700332 } else if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700333 willHaveFunctor = !mDisplayList->getFunctors().empty();
John Reck3f725f02015-06-16 10:29:31 -0700334 }
Chris Craika766cb22015-06-08 16:49:43 -0700335 bool childFunctorsNeedLayer = mProperties.prepareForFunctorPresence(
336 willHaveFunctor, functorsNeedLayer);
337
John Recka7c2ea22014-08-08 13:21:00 -0700338 prepareLayer(info, animatorDirtyMask);
John Reckdcba6722014-07-08 13:59:49 -0700339 if (info.mode == TreeInfo::MODE_FULL) {
John Reck25fbb3f2014-06-12 13:46:45 -0700340 pushStagingDisplayListChanges(info);
341 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700342 prepareSubTree(info, childFunctorsNeedLayer, mDisplayList);
John Reck25fbb3f2014-06-12 13:46:45 -0700343 pushLayerUpdate(info);
344
John Recka447d292014-06-11 18:39:44 -0700345 info.damageAccumulator->popTransform();
John Reckf4198b72014-04-09 17:00:04 -0700346}
347
Chris Craikb565df12015-10-05 13:00:52 -0700348void RenderNode::syncProperties() {
349 mProperties = mStagingProperties;
350}
351
John Reck25fbb3f2014-06-12 13:46:45 -0700352void RenderNode::pushStagingPropertiesChanges(TreeInfo& info) {
John Reckff941dc2014-05-14 16:34:14 -0700353 // Push the animators first so that setupStartValueIfNecessary() is called
354 // before properties() is trampled by stagingProperties(), as they are
355 // required by some animators.
John Reck9eb9f6f2014-08-21 11:23:05 -0700356 if (CC_LIKELY(info.runAnimations)) {
John Reck119907c2014-08-14 09:02:01 -0700357 mAnimatorManager.pushStaging();
John Reck9eb9f6f2014-08-21 11:23:05 -0700358 }
John Reckff941dc2014-05-14 16:34:14 -0700359 if (mDirtyPropertyFields) {
360 mDirtyPropertyFields = 0;
John Recke4267ea2014-06-03 15:53:15 -0700361 damageSelf(info);
John Recka447d292014-06-11 18:39:44 -0700362 info.damageAccumulator->popTransform();
Chris Craikb565df12015-10-05 13:00:52 -0700363 syncProperties();
John Reck25fbb3f2014-06-12 13:46:45 -0700364 applyLayerPropertiesToLayer(info);
John Recke4267ea2014-06-03 15:53:15 -0700365 // We could try to be clever and only re-damage if the matrix changed.
366 // However, we don't need to worry about that. The cost of over-damaging
367 // here is only going to be a single additional map rect of this node
368 // plus a rect join(). The parent's transform (and up) will only be
369 // performed once.
John Recka447d292014-06-11 18:39:44 -0700370 info.damageAccumulator->pushTransform(this);
John Recke4267ea2014-06-03 15:53:15 -0700371 damageSelf(info);
John Reckff941dc2014-05-14 16:34:14 -0700372 }
John Reck25fbb3f2014-06-12 13:46:45 -0700373}
374
Andreas Gampe64bb4132014-11-22 00:35:09 +0000375void RenderNode::applyLayerPropertiesToLayer(TreeInfo& info) {
John Reck25fbb3f2014-06-12 13:46:45 -0700376 if (CC_LIKELY(!mLayer)) return;
377
378 const LayerProperties& props = properties().layerProperties();
379 mLayer->setAlpha(props.alpha(), props.xferMode());
380 mLayer->setColorFilter(props.colorFilter());
381 mLayer->setBlend(props.needsBlending());
382}
383
Chris Craikb565df12015-10-05 13:00:52 -0700384void RenderNode::syncDisplayList() {
385 // Make sure we inc first so that we don't fluctuate between 0 and 1,
386 // which would thrash the layer cache
Chris Craik003cc3d2015-10-16 10:24:55 -0700387 if (mStagingDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700388 for (auto&& child : mStagingDisplayList->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700389 child->renderNode->incParentRefCount();
390 }
391 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700392 deleteDisplayList();
393 mDisplayList = mStagingDisplayList;
394 mStagingDisplayList = nullptr;
395 if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700396 for (size_t i = 0; i < mDisplayList->getFunctors().size(); i++) {
397 (*mDisplayList->getFunctors()[i])(DrawGlInfo::kModeSync, nullptr);
Chris Craikb565df12015-10-05 13:00:52 -0700398 }
399 }
400}
401
John Reck25fbb3f2014-06-12 13:46:45 -0700402void RenderNode::pushStagingDisplayListChanges(TreeInfo& info) {
Chris Craik003cc3d2015-10-16 10:24:55 -0700403 if (mNeedsDisplayListSync) {
404 mNeedsDisplayListSync = false;
John Reck5c9d7172014-10-22 11:32:27 -0700405 // Damage with the old display list first then the new one to catch any
406 // changes in isRenderable or, in the future, bounds
407 damageSelf(info);
Chris Craikb565df12015-10-05 13:00:52 -0700408 syncDisplayList();
John Recke4267ea2014-06-03 15:53:15 -0700409 damageSelf(info);
John Reck8de65a82014-04-09 15:23:38 -0700410 }
John Reck8de65a82014-04-09 15:23:38 -0700411}
412
Chris Craik003cc3d2015-10-16 10:24:55 -0700413void RenderNode::deleteDisplayList() {
414 if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700415 for (auto&& child : mDisplayList->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700416 child->renderNode->decParentRefCount();
John Reckdcba6722014-07-08 13:59:49 -0700417 }
418 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700419 delete mDisplayList;
420 mDisplayList = nullptr;
John Reckdcba6722014-07-08 13:59:49 -0700421}
422
Chris Craik003cc3d2015-10-16 10:24:55 -0700423void RenderNode::prepareSubTree(TreeInfo& info, bool functorsNeedLayer, DisplayList* subtree) {
John Reck8de65a82014-04-09 15:23:38 -0700424 if (subtree) {
John Reck860d1552014-04-11 19:15:05 -0700425 TextureCache& cache = Caches::getInstance().textureCache;
Chris Craikb36af872015-10-16 14:23:12 -0700426 info.out.hasFunctors |= subtree->getFunctors().size();
427 for (auto&& bitmapResource : subtree->getBitmapResources()) {
428 info.prepareTextures = cache.prefetchAndMarkInUse(info.canvasContext, bitmapResource);
John Reckf4198b72014-04-09 17:00:04 -0700429 }
Chris Craikb36af872015-10-16 14:23:12 -0700430 for (auto&& op : subtree->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700431 RenderNode* childNode = op->renderNode;
432#if HWUI_NEW_OPS
433 info.damageAccumulator->pushTransform(&op->localMatrix);
434 bool childFunctorsNeedLayer = functorsNeedLayer; // TODO! || op->mRecordedWithPotentialStencilClip;
435#else
John Recka447d292014-06-11 18:39:44 -0700436 info.damageAccumulator->pushTransform(&op->mTransformFromParent);
Chris Craika766cb22015-06-08 16:49:43 -0700437 bool childFunctorsNeedLayer = functorsNeedLayer
438 // Recorded with non-rect clip, or canvas-rotated by parent
439 || op->mRecordedWithPotentialStencilClip;
Chris Craikb565df12015-10-05 13:00:52 -0700440#endif
Chris Craika766cb22015-06-08 16:49:43 -0700441 childNode->prepareTreeImpl(info, childFunctorsNeedLayer);
John Recka447d292014-06-11 18:39:44 -0700442 info.damageAccumulator->popTransform();
John Reck5bf11bb2014-03-25 10:22:09 -0700443 }
John Reck113e0822014-03-18 09:22:59 -0700444 }
445}
446
John Reckdcba6722014-07-08 13:59:49 -0700447void RenderNode::destroyHardwareResources() {
448 if (mLayer) {
449 LayerRenderer::destroyLayer(mLayer);
Chris Craikd41c4d82015-01-05 15:51:13 -0800450 mLayer = nullptr;
John Reckdcba6722014-07-08 13:59:49 -0700451 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700452 if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700453 for (auto&& child : mDisplayList->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700454 child->renderNode->destroyHardwareResources();
John Reckdcba6722014-07-08 13:59:49 -0700455 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700456 if (mNeedsDisplayListSync) {
John Reckdcba6722014-07-08 13:59:49 -0700457 // Next prepare tree we are going to push a new display list, so we can
458 // drop our current one now
Chris Craik003cc3d2015-10-16 10:24:55 -0700459 deleteDisplayList();
John Reckdcba6722014-07-08 13:59:49 -0700460 }
461 }
462}
463
464void RenderNode::decParentRefCount() {
465 LOG_ALWAYS_FATAL_IF(!mParentCount, "already 0!");
466 mParentCount--;
467 if (!mParentCount) {
468 // If a child of ours is being attached to our parent then this will incorrectly
469 // destroy its hardware resources. However, this situation is highly unlikely
470 // and the failure is "just" that the layer is re-created, so this should
471 // be safe enough
472 destroyHardwareResources();
473 }
474}
475
Chris Craikb565df12015-10-05 13:00:52 -0700476bool RenderNode::applyViewProperties(CanvasState& canvasState) const {
477 const Outline& outline = properties().getOutline();
478 if (properties().getAlpha() <= 0
479 || (outline.getShouldClip() && outline.isEmpty())
480 || properties().getScaleX() == 0
481 || properties().getScaleY() == 0) {
482 return false; // rejected
483 }
484
485 if (properties().getLeft() != 0 || properties().getTop() != 0) {
486 canvasState.translate(properties().getLeft(), properties().getTop());
487 }
488 if (properties().getStaticMatrix()) {
489 canvasState.concatMatrix(*properties().getStaticMatrix());
490 } else if (properties().getAnimationMatrix()) {
491 canvasState.concatMatrix(*properties().getAnimationMatrix());
492 }
493 if (properties().hasTransformMatrix()) {
494 if (properties().isTransformTranslateOnly()) {
495 canvasState.translate(properties().getTranslationX(), properties().getTranslationY());
496 } else {
497 canvasState.concatMatrix(*properties().getTransformMatrix());
498 }
499 }
500 return !canvasState.quickRejectConservative(
501 0, 0, properties().getWidth(), properties().getHeight());
502}
503
John Reck113e0822014-03-18 09:22:59 -0700504/*
505 * For property operations, we pass a savecount of 0, since the operations aren't part of the
506 * displaylist, and thus don't have to compensate for the record-time/playback-time discrepancy in
John Reckd0a0b2a2014-03-20 16:28:56 -0700507 * base saveCount (i.e., how RestoreToCount uses saveCount + properties().getCount())
John Reck113e0822014-03-18 09:22:59 -0700508 */
509#define PROPERTY_SAVECOUNT 0
510
511template <class T>
Chris Craikb265e2c2014-03-27 15:50:09 -0700512void RenderNode::setViewProperties(OpenGLRenderer& renderer, T& handler) {
John Reck113e0822014-03-18 09:22:59 -0700513#if DEBUG_DISPLAY_LIST
Chris Craikb265e2c2014-03-27 15:50:09 -0700514 properties().debugOutputProperties(handler.level() + 1);
John Reck113e0822014-03-18 09:22:59 -0700515#endif
John Reckd0a0b2a2014-03-20 16:28:56 -0700516 if (properties().getLeft() != 0 || properties().getTop() != 0) {
517 renderer.translate(properties().getLeft(), properties().getTop());
John Reck113e0822014-03-18 09:22:59 -0700518 }
John Reckd0a0b2a2014-03-20 16:28:56 -0700519 if (properties().getStaticMatrix()) {
Derek Sollenberger13908822013-12-10 12:28:58 -0500520 renderer.concatMatrix(*properties().getStaticMatrix());
John Reckd0a0b2a2014-03-20 16:28:56 -0700521 } else if (properties().getAnimationMatrix()) {
Derek Sollenberger13908822013-12-10 12:28:58 -0500522 renderer.concatMatrix(*properties().getAnimationMatrix());
John Reck113e0822014-03-18 09:22:59 -0700523 }
John Reckf7483e32014-04-11 08:54:47 -0700524 if (properties().hasTransformMatrix()) {
525 if (properties().isTransformTranslateOnly()) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700526 renderer.translate(properties().getTranslationX(), properties().getTranslationY());
John Reck113e0822014-03-18 09:22:59 -0700527 } else {
John Reckd0a0b2a2014-03-20 16:28:56 -0700528 renderer.concatMatrix(*properties().getTransformMatrix());
John Reck113e0822014-03-18 09:22:59 -0700529 }
530 }
Chris Craik856f0cc2015-04-21 15:13:29 -0700531 const bool isLayer = properties().effectiveLayerType() != LayerType::None;
Chris Craika753f4c2014-07-24 12:39:17 -0700532 int clipFlags = properties().getClippingFlags();
John Reckd0a0b2a2014-03-20 16:28:56 -0700533 if (properties().getAlpha() < 1) {
John Reck25fbb3f2014-06-12 13:46:45 -0700534 if (isLayer) {
Chris Craika753f4c2014-07-24 12:39:17 -0700535 clipFlags &= ~CLIP_TO_BOUNDS; // bounds clipping done by layer
John Reck113e0822014-03-18 09:22:59 -0700536 }
Chris Craik4e9d9b22015-06-12 11:07:23 -0700537 if (CC_LIKELY(isLayer || !properties().getHasOverlappingRendering())) {
538 // simply scale rendering content's alpha
539 renderer.scaleAlpha(properties().getAlpha());
540 } else {
541 // savelayer needed to create an offscreen buffer
542 Rect layerBounds(0, 0, getWidth(), getHeight());
543 if (clipFlags) {
544 properties().getClippingRectForFlags(clipFlags, &layerBounds);
545 clipFlags = 0; // all clipping done by savelayer
546 }
547 SaveLayerOp* op = new (handler.allocator()) SaveLayerOp(
548 layerBounds.left, layerBounds.top,
549 layerBounds.right, layerBounds.bottom,
550 (int) (properties().getAlpha() * 255),
551 SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kClipToLayer_SaveFlag);
552 handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds());
553 }
Chris Craik1a0808e2015-05-13 16:33:04 -0700554
555 if (CC_UNLIKELY(ATRACE_ENABLED() && properties().promotedToLayer())) {
Chris Craik4e9d9b22015-06-12 11:07:23 -0700556 // pretend alpha always causes savelayer to warn about
557 // performance problem affecting old versions
Chris Craik1a0808e2015-05-13 16:33:04 -0700558 ATRACE_FORMAT("%s alpha caused saveLayer %dx%d", getName(),
559 static_cast<int>(getWidth()),
560 static_cast<int>(getHeight()));
561 }
John Reck113e0822014-03-18 09:22:59 -0700562 }
Chris Craika753f4c2014-07-24 12:39:17 -0700563 if (clipFlags) {
564 Rect clipRect;
565 properties().getClippingRectForFlags(clipFlags, &clipRect);
Chris Craik8c271ca2014-03-25 10:33:01 -0700566 ClipRectOp* op = new (handler.allocator()) ClipRectOp(
Chris Craika753f4c2014-07-24 12:39:17 -0700567 clipRect.left, clipRect.top, clipRect.right, clipRect.bottom,
568 SkRegion::kIntersect_Op);
John Reckd0a0b2a2014-03-20 16:28:56 -0700569 handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -0700570 }
Chris Craik8c271ca2014-03-25 10:33:01 -0700571
Chris Craike83cbd42014-09-03 17:52:24 -0700572 // TODO: support nesting round rect clips
Chris Craikaf4d04c2014-07-29 12:50:14 -0700573 if (mProperties.getRevealClip().willClip()) {
574 Rect bounds;
575 mProperties.getRevealClip().getBounds(&bounds);
576 renderer.setClippingRoundRect(handler.allocator(), bounds, mProperties.getRevealClip().getRadius());
577 } else if (mProperties.getOutline().willClip()) {
578 renderer.setClippingOutline(handler.allocator(), &(mProperties.getOutline()));
John Reck113e0822014-03-18 09:22:59 -0700579 }
580}
581
582/**
583 * Apply property-based transformations to input matrix
584 *
585 * If true3dTransform is set to true, the transform applied to the input matrix will use true 4x4
586 * matrix computation instead of the Skia 3x3 matrix + camera hackery.
587 */
Chris Craik69e5adf2014-08-14 13:34:01 -0700588void RenderNode::applyViewPropertyTransforms(mat4& matrix, bool true3dTransform) const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700589 if (properties().getLeft() != 0 || properties().getTop() != 0) {
590 matrix.translate(properties().getLeft(), properties().getTop());
John Reck113e0822014-03-18 09:22:59 -0700591 }
John Reckd0a0b2a2014-03-20 16:28:56 -0700592 if (properties().getStaticMatrix()) {
593 mat4 stat(*properties().getStaticMatrix());
John Reck113e0822014-03-18 09:22:59 -0700594 matrix.multiply(stat);
John Reckd0a0b2a2014-03-20 16:28:56 -0700595 } else if (properties().getAnimationMatrix()) {
596 mat4 anim(*properties().getAnimationMatrix());
John Reck113e0822014-03-18 09:22:59 -0700597 matrix.multiply(anim);
598 }
Chris Craike0bb87d2014-04-22 17:55:41 -0700599
Chris Craikcc39e162014-04-25 18:34:11 -0700600 bool applyTranslationZ = true3dTransform && !MathUtils::isZero(properties().getZ());
Chris Craike0bb87d2014-04-22 17:55:41 -0700601 if (properties().hasTransformMatrix() || applyTranslationZ) {
John Reckf7483e32014-04-11 08:54:47 -0700602 if (properties().isTransformTranslateOnly()) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700603 matrix.translate(properties().getTranslationX(), properties().getTranslationY(),
Chris Craikcc39e162014-04-25 18:34:11 -0700604 true3dTransform ? properties().getZ() : 0.0f);
John Reck113e0822014-03-18 09:22:59 -0700605 } else {
606 if (!true3dTransform) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700607 matrix.multiply(*properties().getTransformMatrix());
John Reck113e0822014-03-18 09:22:59 -0700608 } else {
609 mat4 true3dMat;
610 true3dMat.loadTranslate(
John Reckd0a0b2a2014-03-20 16:28:56 -0700611 properties().getPivotX() + properties().getTranslationX(),
612 properties().getPivotY() + properties().getTranslationY(),
Chris Craikcc39e162014-04-25 18:34:11 -0700613 properties().getZ());
John Reckd0a0b2a2014-03-20 16:28:56 -0700614 true3dMat.rotate(properties().getRotationX(), 1, 0, 0);
615 true3dMat.rotate(properties().getRotationY(), 0, 1, 0);
616 true3dMat.rotate(properties().getRotation(), 0, 0, 1);
617 true3dMat.scale(properties().getScaleX(), properties().getScaleY(), 1);
618 true3dMat.translate(-properties().getPivotX(), -properties().getPivotY());
John Reck113e0822014-03-18 09:22:59 -0700619
620 matrix.multiply(true3dMat);
621 }
622 }
623 }
624}
625
626/**
627 * Organizes the DisplayList hierarchy to prepare for background projection reordering.
628 *
629 * This should be called before a call to defer() or drawDisplayList()
630 *
631 * Each DisplayList that serves as a 3d root builds its list of composited children,
632 * which are flagged to not draw in the standard draw loop.
633 */
634void RenderNode::computeOrdering() {
Chris Craikb565df12015-10-05 13:00:52 -0700635#if !HWUI_NEW_OPS
John Reck113e0822014-03-18 09:22:59 -0700636 ATRACE_CALL();
637 mProjectedNodes.clear();
638
639 // TODO: create temporary DDLOp and call computeOrderingImpl on top DisplayList so that
640 // transform properties are applied correctly to top level children
Chris Craik003cc3d2015-10-16 10:24:55 -0700641 if (mDisplayList == nullptr) return;
Chris Craikb36af872015-10-16 14:23:12 -0700642 for (unsigned int i = 0; i < mDisplayList->getChildren().size(); i++) {
643 DrawRenderNodeOp* childOp = mDisplayList->getChildren()[i];
Chris Craikb565df12015-10-05 13:00:52 -0700644 childOp->renderNode->computeOrderingImpl(childOp, &mProjectedNodes, &mat4::identity());
John Reck113e0822014-03-18 09:22:59 -0700645 }
Chris Craikb565df12015-10-05 13:00:52 -0700646#endif
John Reck113e0822014-03-18 09:22:59 -0700647}
648
649void RenderNode::computeOrderingImpl(
Chris Craika7090e02014-06-20 16:01:00 -0700650 DrawRenderNodeOp* opState,
John Reck272a6852015-07-29 16:48:58 -0700651 std::vector<DrawRenderNodeOp*>* compositedChildrenOfProjectionSurface,
John Reck113e0822014-03-18 09:22:59 -0700652 const mat4* transformFromProjectionSurface) {
Chris Craikb565df12015-10-05 13:00:52 -0700653#if !HWUI_NEW_OPS
John Reck113e0822014-03-18 09:22:59 -0700654 mProjectedNodes.clear();
Chris Craik003cc3d2015-10-16 10:24:55 -0700655 if (mDisplayList == nullptr || mDisplayList->isEmpty()) return;
John Reck113e0822014-03-18 09:22:59 -0700656
657 // TODO: should avoid this calculation in most cases
658 // TODO: just calculate single matrix, down to all leaf composited elements
659 Matrix4 localTransformFromProjectionSurface(*transformFromProjectionSurface);
660 localTransformFromProjectionSurface.multiply(opState->mTransformFromParent);
661
John Reckd0a0b2a2014-03-20 16:28:56 -0700662 if (properties().getProjectBackwards()) {
John Reck113e0822014-03-18 09:22:59 -0700663 // composited projectee, flag for out of order draw, save matrix, and store in proj surface
664 opState->mSkipInOrderDraw = true;
Chris Craik7c85c542015-08-19 15:10:24 -0700665 opState->mTransformFromCompositingAncestor = localTransformFromProjectionSurface;
John Reck272a6852015-07-29 16:48:58 -0700666 compositedChildrenOfProjectionSurface->push_back(opState);
John Reck113e0822014-03-18 09:22:59 -0700667 } else {
668 // standard in order draw
669 opState->mSkipInOrderDraw = false;
670 }
671
Chris Craikb36af872015-10-16 14:23:12 -0700672 if (mDisplayList->getChildren().size() > 0) {
Chris Craik003cc3d2015-10-16 10:24:55 -0700673 const bool isProjectionReceiver = mDisplayList->projectionReceiveIndex >= 0;
John Reck113e0822014-03-18 09:22:59 -0700674 bool haveAppliedPropertiesToProjection = false;
Chris Craikb36af872015-10-16 14:23:12 -0700675 for (unsigned int i = 0; i < mDisplayList->getChildren().size(); i++) {
676 DrawRenderNodeOp* childOp = mDisplayList->getChildren()[i];
Chris Craikb565df12015-10-05 13:00:52 -0700677 RenderNode* child = childOp->renderNode;
John Reck113e0822014-03-18 09:22:59 -0700678
John Reck272a6852015-07-29 16:48:58 -0700679 std::vector<DrawRenderNodeOp*>* projectionChildren = nullptr;
Chris Craikd41c4d82015-01-05 15:51:13 -0800680 const mat4* projectionTransform = nullptr;
John Reckd0a0b2a2014-03-20 16:28:56 -0700681 if (isProjectionReceiver && !child->properties().getProjectBackwards()) {
Chris Craikbf72eb82015-06-08 11:30:44 -0700682 // if receiving projections, collect projecting descendant
John Reck113e0822014-03-18 09:22:59 -0700683
Chris Craikbf72eb82015-06-08 11:30:44 -0700684 // Note that if a direct descendant is projecting backwards, we pass its
685 // grandparent projection collection, since it shouldn't project onto its
John Reck113e0822014-03-18 09:22:59 -0700686 // parent, where it will already be drawing.
687 projectionChildren = &mProjectedNodes;
688 projectionTransform = &mat4::identity();
689 } else {
690 if (!haveAppliedPropertiesToProjection) {
691 applyViewPropertyTransforms(localTransformFromProjectionSurface);
692 haveAppliedPropertiesToProjection = true;
693 }
694 projectionChildren = compositedChildrenOfProjectionSurface;
695 projectionTransform = &localTransformFromProjectionSurface;
696 }
Derek Sollenbergerf2932592015-08-13 14:59:33 -0400697 child->computeOrderingImpl(childOp, projectionChildren, projectionTransform);
John Reck113e0822014-03-18 09:22:59 -0700698 }
699 }
Chris Craikb565df12015-10-05 13:00:52 -0700700#endif
John Reck113e0822014-03-18 09:22:59 -0700701}
702
703class DeferOperationHandler {
704public:
705 DeferOperationHandler(DeferStateStruct& deferStruct, int level)
706 : mDeferStruct(deferStruct), mLevel(level) {}
707 inline void operator()(DisplayListOp* operation, int saveCount, bool clipToBounds) {
708 operation->defer(mDeferStruct, saveCount, mLevel, clipToBounds);
709 }
710 inline LinearAllocator& allocator() { return *(mDeferStruct.mAllocator); }
Andreas Gampe64bb4132014-11-22 00:35:09 +0000711 inline void startMark(const char* name) {} // do nothing
Chris Craikb265e2c2014-03-27 15:50:09 -0700712 inline void endMark() {}
713 inline int level() { return mLevel; }
714 inline int replayFlags() { return mDeferStruct.mReplayFlags; }
Chris Craik74669862014-08-07 17:27:30 -0700715 inline SkPath* allocPathForFrame() { return mDeferStruct.allocPathForFrame(); }
John Reck113e0822014-03-18 09:22:59 -0700716
717private:
718 DeferStateStruct& mDeferStruct;
719 const int mLevel;
720};
721
Chris Craik80d49022014-06-20 15:03:43 -0700722void RenderNode::defer(DeferStateStruct& deferStruct, const int level) {
John Reck113e0822014-03-18 09:22:59 -0700723 DeferOperationHandler handler(deferStruct, level);
Chris Craikb265e2c2014-03-27 15:50:09 -0700724 issueOperations<DeferOperationHandler>(deferStruct.mRenderer, handler);
John Reck113e0822014-03-18 09:22:59 -0700725}
726
727class ReplayOperationHandler {
728public:
729 ReplayOperationHandler(ReplayStateStruct& replayStruct, int level)
730 : mReplayStruct(replayStruct), mLevel(level) {}
731 inline void operator()(DisplayListOp* operation, int saveCount, bool clipToBounds) {
732#if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS
Chris Craik3f0854292014-04-15 16:18:08 -0700733 mReplayStruct.mRenderer.eventMark(operation->name());
John Reck113e0822014-03-18 09:22:59 -0700734#endif
735 operation->replay(mReplayStruct, saveCount, mLevel, clipToBounds);
736 }
737 inline LinearAllocator& allocator() { return *(mReplayStruct.mAllocator); }
Chris Craikb265e2c2014-03-27 15:50:09 -0700738 inline void startMark(const char* name) {
739 mReplayStruct.mRenderer.startMark(name);
740 }
741 inline void endMark() {
742 mReplayStruct.mRenderer.endMark();
Chris Craikb265e2c2014-03-27 15:50:09 -0700743 }
744 inline int level() { return mLevel; }
745 inline int replayFlags() { return mReplayStruct.mReplayFlags; }
Chris Craik74669862014-08-07 17:27:30 -0700746 inline SkPath* allocPathForFrame() { return mReplayStruct.allocPathForFrame(); }
John Reck113e0822014-03-18 09:22:59 -0700747
748private:
749 ReplayStateStruct& mReplayStruct;
750 const int mLevel;
751};
752
Chris Craik80d49022014-06-20 15:03:43 -0700753void RenderNode::replay(ReplayStateStruct& replayStruct, const int level) {
John Reck113e0822014-03-18 09:22:59 -0700754 ReplayOperationHandler handler(replayStruct, level);
Chris Craikb265e2c2014-03-27 15:50:09 -0700755 issueOperations<ReplayOperationHandler>(replayStruct.mRenderer, handler);
John Reck113e0822014-03-18 09:22:59 -0700756}
757
Chris Craik003cc3d2015-10-16 10:24:55 -0700758void RenderNode::buildZSortedChildList(const DisplayList::Chunk& chunk,
John Reck272a6852015-07-29 16:48:58 -0700759 std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes) {
Chris Craikb565df12015-10-05 13:00:52 -0700760#if !HWUI_NEW_OPS
Chris Craik8afd0f22014-08-21 17:41:57 -0700761 if (chunk.beginChildIndex == chunk.endChildIndex) return;
John Reck113e0822014-03-18 09:22:59 -0700762
Chris Craik8afd0f22014-08-21 17:41:57 -0700763 for (unsigned int i = chunk.beginChildIndex; i < chunk.endChildIndex; i++) {
Chris Craikb36af872015-10-16 14:23:12 -0700764 DrawRenderNodeOp* childOp = mDisplayList->getChildren()[i];
Chris Craikb565df12015-10-05 13:00:52 -0700765 RenderNode* child = childOp->renderNode;
Chris Craikcc39e162014-04-25 18:34:11 -0700766 float childZ = child->properties().getZ();
John Reck113e0822014-03-18 09:22:59 -0700767
Chris Craik8afd0f22014-08-21 17:41:57 -0700768 if (!MathUtils::isZero(childZ) && chunk.reorderChildren) {
John Reck272a6852015-07-29 16:48:58 -0700769 zTranslatedNodes.push_back(ZDrawRenderNodeOpPair(childZ, childOp));
John Reck113e0822014-03-18 09:22:59 -0700770 childOp->mSkipInOrderDraw = true;
John Reckd0a0b2a2014-03-20 16:28:56 -0700771 } else if (!child->properties().getProjectBackwards()) {
John Reck113e0822014-03-18 09:22:59 -0700772 // regular, in order drawing DisplayList
773 childOp->mSkipInOrderDraw = false;
774 }
775 }
776
Chris Craik8afd0f22014-08-21 17:41:57 -0700777 // Z sort any 3d children (stable-ness makes z compare fall back to standard drawing order)
John Reck113e0822014-03-18 09:22:59 -0700778 std::stable_sort(zTranslatedNodes.begin(), zTranslatedNodes.end());
Chris Craikb565df12015-10-05 13:00:52 -0700779#endif
John Reck113e0822014-03-18 09:22:59 -0700780}
781
Chris Craikb265e2c2014-03-27 15:50:09 -0700782template <class T>
783void RenderNode::issueDrawShadowOperation(const Matrix4& transformFromParent, T& handler) {
Chris Craik77b5cad2014-07-30 18:23:07 -0700784 if (properties().getAlpha() <= 0.0f
785 || properties().getOutline().getAlpha() <= 0.0f
Teng-Hui Zhu8d0ec382015-10-01 16:49:16 -0700786 || !properties().getOutline().getPath()
787 || properties().getScaleX() == 0
788 || properties().getScaleY() == 0) {
Chris Craik77b5cad2014-07-30 18:23:07 -0700789 // no shadow to draw
790 return;
791 }
Chris Craikb265e2c2014-03-27 15:50:09 -0700792
793 mat4 shadowMatrixXY(transformFromParent);
794 applyViewPropertyTransforms(shadowMatrixXY);
795
796 // Z matrix needs actual 3d transformation, so mapped z values will be correct
797 mat4 shadowMatrixZ(transformFromParent);
798 applyViewPropertyTransforms(shadowMatrixZ, true);
799
Chris Craik74669862014-08-07 17:27:30 -0700800 const SkPath* casterOutlinePath = properties().getOutline().getPath();
Chris Craikaf4d04c2014-07-29 12:50:14 -0700801 const SkPath* revealClipPath = properties().getRevealClip().getPath();
Chris Craik61317322014-05-21 13:03:52 -0700802 if (revealClipPath && revealClipPath->isEmpty()) return;
803
Chris Craik77b5cad2014-07-30 18:23:07 -0700804 float casterAlpha = properties().getAlpha() * properties().getOutline().getAlpha();
Chris Craik74669862014-08-07 17:27:30 -0700805
Chris Craik74669862014-08-07 17:27:30 -0700806
Chris Craikfaa79ff2014-12-01 13:44:21 -0800807 // holds temporary SkPath to store the result of intersections
Chris Craikd41c4d82015-01-05 15:51:13 -0800808 SkPath* frameAllocatedPath = nullptr;
Chris Craikfaa79ff2014-12-01 13:44:21 -0800809 const SkPath* outlinePath = casterOutlinePath;
810
811 // intersect the outline with the reveal clip, if present
812 if (revealClipPath) {
813 frameAllocatedPath = handler.allocPathForFrame();
814
Tom Hudson02a26302015-06-24 11:32:42 -0400815 Op(*outlinePath, *revealClipPath, kIntersect_SkPathOp, frameAllocatedPath);
Chris Craikfaa79ff2014-12-01 13:44:21 -0800816 outlinePath = frameAllocatedPath;
817 }
818
819 // intersect the outline with the clipBounds, if present
820 if (properties().getClippingFlags() & CLIP_TO_CLIP_BOUNDS) {
821 if (!frameAllocatedPath) {
822 frameAllocatedPath = handler.allocPathForFrame();
823 }
824
825 Rect clipBounds;
826 properties().getClippingRectForFlags(CLIP_TO_CLIP_BOUNDS, &clipBounds);
827 SkPath clipBoundsPath;
828 clipBoundsPath.addRect(clipBounds.left, clipBounds.top,
829 clipBounds.right, clipBounds.bottom);
830
Tom Hudson02a26302015-06-24 11:32:42 -0400831 Op(*outlinePath, clipBoundsPath, kIntersect_SkPathOp, frameAllocatedPath);
Chris Craik74669862014-08-07 17:27:30 -0700832 outlinePath = frameAllocatedPath;
833 }
834
Chris Craikb265e2c2014-03-27 15:50:09 -0700835 DisplayListOp* shadowOp = new (handler.allocator()) DrawShadowOp(
Chris Craik74669862014-08-07 17:27:30 -0700836 shadowMatrixXY, shadowMatrixZ, casterAlpha, outlinePath);
Chris Craikb265e2c2014-03-27 15:50:09 -0700837 handler(shadowOp, PROPERTY_SAVECOUNT, properties().getClipToBounds());
838}
839
John Reck113e0822014-03-18 09:22:59 -0700840#define SHADOW_DELTA 0.1f
841
842template <class T>
Chris Craikc3e75f92014-08-27 15:34:52 -0700843void RenderNode::issueOperationsOf3dChildren(ChildrenSelectMode mode,
John Reck272a6852015-07-29 16:48:58 -0700844 const Matrix4& initialTransform, const std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes,
Chris Craikc3e75f92014-08-27 15:34:52 -0700845 OpenGLRenderer& renderer, T& handler) {
John Reck113e0822014-03-18 09:22:59 -0700846 const int size = zTranslatedNodes.size();
847 if (size == 0
Chris Craikb9ce116d2015-08-20 15:14:06 -0700848 || (mode == ChildrenSelectMode::NegativeZChildren && zTranslatedNodes[0].key > 0.0f)
849 || (mode == ChildrenSelectMode::PositiveZChildren && zTranslatedNodes[size - 1].key < 0.0f)) {
John Reck113e0822014-03-18 09:22:59 -0700850 // no 3d children to draw
851 return;
852 }
853
Chris Craikc3e75f92014-08-27 15:34:52 -0700854 // Apply the base transform of the parent of the 3d children. This isolates
855 // 3d children of the current chunk from transformations made in previous chunks.
856 int rootRestoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag);
Chris Craik6daa13c2015-08-19 13:32:12 -0700857 renderer.setGlobalMatrix(initialTransform);
Chris Craikc3e75f92014-08-27 15:34:52 -0700858
John Reck113e0822014-03-18 09:22:59 -0700859 /**
860 * Draw shadows and (potential) casters mostly in order, but allow the shadows of casters
861 * with very similar Z heights to draw together.
862 *
863 * This way, if Views A & B have the same Z height and are both casting shadows, the shadows are
864 * underneath both, and neither's shadow is drawn on top of the other.
865 */
866 const size_t nonNegativeIndex = findNonNegativeIndex(zTranslatedNodes);
867 size_t drawIndex, shadowIndex, endIndex;
Chris Craikb9ce116d2015-08-20 15:14:06 -0700868 if (mode == ChildrenSelectMode::NegativeZChildren) {
John Reck113e0822014-03-18 09:22:59 -0700869 drawIndex = 0;
870 endIndex = nonNegativeIndex;
871 shadowIndex = endIndex; // draw no shadows
872 } else {
873 drawIndex = nonNegativeIndex;
874 endIndex = size;
875 shadowIndex = drawIndex; // potentially draw shadow for each pos Z child
876 }
Chris Craik3f0854292014-04-15 16:18:08 -0700877
878 DISPLAY_LIST_LOGD("%*s%d %s 3d children:", (handler.level() + 1) * 2, "",
879 endIndex - drawIndex, mode == kNegativeZChildren ? "negative" : "positive");
880
John Reck113e0822014-03-18 09:22:59 -0700881 float lastCasterZ = 0.0f;
882 while (shadowIndex < endIndex || drawIndex < endIndex) {
883 if (shadowIndex < endIndex) {
Chris Craika7090e02014-06-20 16:01:00 -0700884 DrawRenderNodeOp* casterOp = zTranslatedNodes[shadowIndex].value;
Chris Craikb565df12015-10-05 13:00:52 -0700885 RenderNode* caster = casterOp->renderNode;
John Reck113e0822014-03-18 09:22:59 -0700886 const float casterZ = zTranslatedNodes[shadowIndex].key;
887 // attempt to render the shadow if the caster about to be drawn is its caster,
888 // OR if its caster's Z value is similar to the previous potential caster
889 if (shadowIndex == drawIndex || casterZ - lastCasterZ < SHADOW_DELTA) {
Chris Craikb265e2c2014-03-27 15:50:09 -0700890 caster->issueDrawShadowOperation(casterOp->mTransformFromParent, handler);
John Reck113e0822014-03-18 09:22:59 -0700891
892 lastCasterZ = casterZ; // must do this even if current caster not casting a shadow
893 shadowIndex++;
894 continue;
895 }
896 }
897
898 // only the actual child DL draw needs to be in save/restore,
899 // since it modifies the renderer's matrix
900 int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag);
901
Chris Craika7090e02014-06-20 16:01:00 -0700902 DrawRenderNodeOp* childOp = zTranslatedNodes[drawIndex].value;
John Reck113e0822014-03-18 09:22:59 -0700903
904 renderer.concatMatrix(childOp->mTransformFromParent);
905 childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone
John Reckd0a0b2a2014-03-20 16:28:56 -0700906 handler(childOp, renderer.getSaveCount() - 1, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -0700907 childOp->mSkipInOrderDraw = true;
908
909 renderer.restoreToCount(restoreTo);
910 drawIndex++;
911 }
Chris Craikc3e75f92014-08-27 15:34:52 -0700912 renderer.restoreToCount(rootRestoreTo);
John Reck113e0822014-03-18 09:22:59 -0700913}
914
915template <class T>
Chris Craikb265e2c2014-03-27 15:50:09 -0700916void RenderNode::issueOperationsOfProjectedChildren(OpenGLRenderer& renderer, T& handler) {
Chris Craik3f0854292014-04-15 16:18:08 -0700917 DISPLAY_LIST_LOGD("%*s%d projected children:", (handler.level() + 1) * 2, "", mProjectedNodes.size());
918 const SkPath* projectionReceiverOutline = properties().getOutline().getPath();
Chris Craik3f0854292014-04-15 16:18:08 -0700919 int restoreTo = renderer.getSaveCount();
920
Chris Craikb3cca872014-08-08 18:42:51 -0700921 LinearAllocator& alloc = handler.allocator();
922 handler(new (alloc) SaveOp(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag),
923 PROPERTY_SAVECOUNT, properties().getClipToBounds());
924
925 // Transform renderer to match background we're projecting onto
926 // (by offsetting canvas by translationX/Y of background rendernode, since only those are set)
927 const DisplayListOp* op =
Chris Craik10ed6922015-10-15 10:55:15 -0700928#if HWUI_NEW_OPS
929 nullptr;
930 LOG_ALWAYS_FATAL("unsupported");
931#else
Chris Craik003cc3d2015-10-16 10:24:55 -0700932 (mDisplayList->getOps()[mDisplayList->projectionReceiveIndex]);
Chris Craik10ed6922015-10-15 10:55:15 -0700933#endif
Chris Craikb3cca872014-08-08 18:42:51 -0700934 const DrawRenderNodeOp* backgroundOp = reinterpret_cast<const DrawRenderNodeOp*>(op);
Chris Craikb565df12015-10-05 13:00:52 -0700935 const RenderProperties& backgroundProps = backgroundOp->renderNode->properties();
Chris Craikb3cca872014-08-08 18:42:51 -0700936 renderer.translate(backgroundProps.getTranslationX(), backgroundProps.getTranslationY());
937
Chris Craik6fe991e52015-10-20 09:39:42 -0700938 // If the projection receiver has an outline, we mask projected content to it
Chris Craikfca52b752015-04-28 11:45:59 -0700939 // (which we know, apriori, are all tessellated paths)
940 renderer.setProjectionPathMask(alloc, projectionReceiverOutline);
Chris Craik3f0854292014-04-15 16:18:08 -0700941
942 // draw projected nodes
John Reck113e0822014-03-18 09:22:59 -0700943 for (size_t i = 0; i < mProjectedNodes.size(); i++) {
Chris Craika7090e02014-06-20 16:01:00 -0700944 DrawRenderNodeOp* childOp = mProjectedNodes[i];
John Reck113e0822014-03-18 09:22:59 -0700945
946 // matrix save, concat, and restore can be done safely without allocating operations
947 int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag);
948 renderer.concatMatrix(childOp->mTransformFromCompositingAncestor);
949 childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone
John Reckd0a0b2a2014-03-20 16:28:56 -0700950 handler(childOp, renderer.getSaveCount() - 1, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -0700951 childOp->mSkipInOrderDraw = true;
952 renderer.restoreToCount(restoreTo);
953 }
Chris Craik3f0854292014-04-15 16:18:08 -0700954
Chris Craikfca52b752015-04-28 11:45:59 -0700955 handler(new (alloc) RestoreToCountOp(restoreTo),
956 PROPERTY_SAVECOUNT, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -0700957}
958
959/**
960 * This function serves both defer and replay modes, and will organize the displayList's component
961 * operations for a single frame:
962 *
963 * Every 'simple' state operation that affects just the matrix and alpha (or other factors of
964 * DeferredDisplayState) may be issued directly to the renderer, but complex operations (with custom
965 * defer logic) and operations in displayListOps are issued through the 'handler' which handles the
966 * defer vs replay logic, per operation
967 */
968template <class T>
Chris Craikb265e2c2014-03-27 15:50:09 -0700969void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) {
Chris Craik003cc3d2015-10-16 10:24:55 -0700970 if (mDisplayList->isEmpty()) {
Chris Craikbf72eb82015-06-08 11:30:44 -0700971 DISPLAY_LIST_LOGD("%*sEmpty display list (%p, %s)", handler.level() * 2, "",
972 this, getName());
Chris Craik06451282014-07-21 10:25:54 -0700973 return;
974 }
975
Chris Craik51d6a3d2014-12-22 17:16:56 -0800976 const bool drawLayer = (mLayer && (&renderer != mLayer->renderer.get()));
John Reck25fbb3f2014-06-12 13:46:45 -0700977 // If we are updating the contents of mLayer, we don't want to apply any of
978 // the RenderNode's properties to this issueOperations pass. Those will all
979 // be applied when the layer is drawn, aka when this is true.
980 const bool useViewProperties = (!mLayer || drawLayer);
Chris Craik06451282014-07-21 10:25:54 -0700981 if (useViewProperties) {
982 const Outline& outline = properties().getOutline();
Teng-Hui Zhu8d0ec382015-10-01 16:49:16 -0700983 if (properties().getAlpha() <= 0
984 || (outline.getShouldClip() && outline.isEmpty())
985 || properties().getScaleX() == 0
986 || properties().getScaleY() == 0) {
Chris Craikbf72eb82015-06-08 11:30:44 -0700987 DISPLAY_LIST_LOGD("%*sRejected display list (%p, %s)", handler.level() * 2, "",
988 this, getName());
Chris Craik06451282014-07-21 10:25:54 -0700989 return;
990 }
John Reck113e0822014-03-18 09:22:59 -0700991 }
992
Chris Craik3f0854292014-04-15 16:18:08 -0700993 handler.startMark(getName());
Chris Craikb265e2c2014-03-27 15:50:09 -0700994
John Reck113e0822014-03-18 09:22:59 -0700995#if DEBUG_DISPLAY_LIST
Chris Craik3f0854292014-04-15 16:18:08 -0700996 const Rect& clipRect = renderer.getLocalClipBounds();
997 DISPLAY_LIST_LOGD("%*sStart display list (%p, %s), localClipBounds: %.0f, %.0f, %.0f, %.0f",
Chris Craik03188872015-02-02 18:39:33 -0800998 handler.level() * 2, "", this, getName(),
Chris Craik3f0854292014-04-15 16:18:08 -0700999 clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
John Reck113e0822014-03-18 09:22:59 -07001000#endif
1001
1002 LinearAllocator& alloc = handler.allocator();
1003 int restoreTo = renderer.getSaveCount();
1004 handler(new (alloc) SaveOp(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag),
John Reckd0a0b2a2014-03-20 16:28:56 -07001005 PROPERTY_SAVECOUNT, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -07001006
Chris Craikbf72eb82015-06-08 11:30:44 -07001007 DISPLAY_LIST_LOGD("%*sSave %d %d", (handler.level() + 1) * 2, "",
John Reck113e0822014-03-18 09:22:59 -07001008 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag, restoreTo);
1009
John Reck25fbb3f2014-06-12 13:46:45 -07001010 if (useViewProperties) {
1011 setViewProperties<T>(renderer, handler);
1012 }
John Reck113e0822014-03-18 09:22:59 -07001013
Chris Craik10ed6922015-10-15 10:55:15 -07001014#if HWUI_NEW_OPS
1015 LOG_ALWAYS_FATAL("legacy op traversal not supported");
1016#else
Chris Craik8c271ca2014-03-25 10:33:01 -07001017 bool quickRejected = properties().getClipToBounds()
1018 && renderer.quickRejectConservative(0, 0, properties().getWidth(), properties().getHeight());
John Reck113e0822014-03-18 09:22:59 -07001019 if (!quickRejected) {
Chris Craikc3e75f92014-08-27 15:34:52 -07001020 Matrix4 initialTransform(*(renderer.currentTransform()));
Tom Hudsonac7b6d32015-06-30 11:26:13 -04001021 renderer.setBaseTransform(initialTransform);
Chris Craikc3e75f92014-08-27 15:34:52 -07001022
John Reck25fbb3f2014-06-12 13:46:45 -07001023 if (drawLayer) {
Chris Craik3aadd602015-08-20 12:41:40 -07001024 handler(new (alloc) DrawLayerOp(mLayer),
John Reck25fbb3f2014-06-12 13:46:45 -07001025 renderer.getSaveCount() - 1, properties().getClipToBounds());
1026 } else {
Chris Craikc166b6c2014-09-05 19:55:30 -07001027 const int saveCountOffset = renderer.getSaveCount() - 1;
Chris Craik003cc3d2015-10-16 10:24:55 -07001028 const int projectionReceiveIndex = mDisplayList->projectionReceiveIndex;
1029 for (size_t chunkIndex = 0; chunkIndex < mDisplayList->getChunks().size(); chunkIndex++) {
1030 const DisplayList::Chunk& chunk = mDisplayList->getChunks()[chunkIndex];
John Reck113e0822014-03-18 09:22:59 -07001031
John Reck272a6852015-07-29 16:48:58 -07001032 std::vector<ZDrawRenderNodeOpPair> zTranslatedNodes;
Chris Craik8afd0f22014-08-21 17:41:57 -07001033 buildZSortedChildList(chunk, zTranslatedNodes);
1034
Chris Craikb9ce116d2015-08-20 15:14:06 -07001035 issueOperationsOf3dChildren(ChildrenSelectMode::NegativeZChildren,
Chris Craikc3e75f92014-08-27 15:34:52 -07001036 initialTransform, zTranslatedNodes, renderer, handler);
1037
Andreas Gampeedaecc12014-11-10 20:54:07 -08001038 for (size_t opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) {
Chris Craik003cc3d2015-10-16 10:24:55 -07001039 DisplayListOp *op = mDisplayList->getOps()[opIndex];
Chris Craik80d49022014-06-20 15:03:43 -07001040#if DEBUG_DISPLAY_LIST
Chris Craik03188872015-02-02 18:39:33 -08001041 op->output(handler.level() + 1);
Chris Craik80d49022014-06-20 15:03:43 -07001042#endif
Chris Craik8afd0f22014-08-21 17:41:57 -07001043 handler(op, saveCountOffset, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -07001044
John Reck272a6852015-07-29 16:48:58 -07001045 if (CC_UNLIKELY(!mProjectedNodes.empty() && projectionReceiveIndex >= 0 &&
Andreas Gampeedaecc12014-11-10 20:54:07 -08001046 opIndex == static_cast<size_t>(projectionReceiveIndex))) {
Chris Craik8afd0f22014-08-21 17:41:57 -07001047 issueOperationsOfProjectedChildren(renderer, handler);
1048 }
John Reck25fbb3f2014-06-12 13:46:45 -07001049 }
John Reck113e0822014-03-18 09:22:59 -07001050
Chris Craikb9ce116d2015-08-20 15:14:06 -07001051 issueOperationsOf3dChildren(ChildrenSelectMode::PositiveZChildren,
Chris Craikc3e75f92014-08-27 15:34:52 -07001052 initialTransform, zTranslatedNodes, renderer, handler);
Chris Craik8afd0f22014-08-21 17:41:57 -07001053 }
John Reck25fbb3f2014-06-12 13:46:45 -07001054 }
John Reck113e0822014-03-18 09:22:59 -07001055 }
Chris Craik10ed6922015-10-15 10:55:15 -07001056#endif
John Reck113e0822014-03-18 09:22:59 -07001057
Chris Craikbf72eb82015-06-08 11:30:44 -07001058 DISPLAY_LIST_LOGD("%*sRestoreToCount %d", (handler.level() + 1) * 2, "", restoreTo);
John Reck113e0822014-03-18 09:22:59 -07001059 handler(new (alloc) RestoreToCountOp(restoreTo),
John Reckd0a0b2a2014-03-20 16:28:56 -07001060 PROPERTY_SAVECOUNT, properties().getClipToBounds());
Chris Craikb265e2c2014-03-27 15:50:09 -07001061
Chris Craikbf72eb82015-06-08 11:30:44 -07001062 DISPLAY_LIST_LOGD("%*sDone (%p, %s)", handler.level() * 2, "", this, getName());
Chris Craikb265e2c2014-03-27 15:50:09 -07001063 handler.endMark();
John Reck113e0822014-03-18 09:22:59 -07001064}
1065
1066} /* namespace uirenderer */
1067} /* namespace android */