blob: df85cc61ff9bd503b2e1217710d9d52a5d658e92 [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 Recke45b1fd2014-04-15 09:50:16 -070019#include <algorithm>
John Reckc25e5062014-06-18 14:21:29 -070020#include <string>
John Recke45b1fd2014-04-15 09:50:16 -070021
John Reck113e0822014-03-18 09:22:59 -070022#include <SkCanvas.h>
23#include <algorithm>
24
John Reck113e0822014-03-18 09:22:59 -070025
John Recke4267ea2014-06-03 15:53:15 -070026#include "DamageAccumulator.h"
John Reck113e0822014-03-18 09:22:59 -070027#include "Debug.h"
Chris Craikb565df12015-10-05 13:00:52 -070028#if HWUI_NEW_OPS
29#include "RecordedOp.h"
30#endif
John Reck113e0822014-03-18 09:22:59 -070031#include "DisplayListOp.h"
John Reck25fbb3f2014-06-12 13:46:45 -070032#include "LayerRenderer.h"
33#include "OpenGLRenderer.h"
Tom Hudson2dc236b2014-10-15 15:46:42 -040034#include "TreeInfo.h"
Chris Craike0bb87d2014-04-22 17:55:41 -070035#include "utils/MathUtils.h"
Chris Craik70850ea2014-11-18 10:49:23 -080036#include "utils/TraceUtils.h"
John Reck998a6d82014-08-28 15:35:53 -070037#include "renderthread/CanvasContext.h"
John Reck113e0822014-03-18 09:22:59 -070038
John Recke248bd12015-08-05 13:53:53 -070039#include "protos/hwui.pb.h"
40#include "protos/ProtoHelpers.h"
41
John Reck113e0822014-03-18 09:22:59 -070042namespace android {
43namespace uirenderer {
44
John Reck443a7142014-09-04 17:40:05 -070045void RenderNode::debugDumpLayers(const char* prefix) {
46 if (mLayer) {
47 ALOGD("%sNode %p (%s) has layer %p (fbo = %u, wasBuildLayered = %s)",
48 prefix, this, getName(), mLayer, mLayer->getFbo(),
49 mLayer->wasBuildLayered ? "true" : "false");
50 }
Chris Craik003cc3d2015-10-16 10:24:55 -070051 if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -070052 for (auto&& child : mDisplayList->getChildren()) {
Chris Craik10ed6922015-10-15 10:55:15 -070053 child->renderNode->debugDumpLayers(prefix);
John Reck443a7142014-09-04 17:40:05 -070054 }
55 }
56}
57
John Reck8de65a82014-04-09 15:23:38 -070058RenderNode::RenderNode()
John Reckff941dc2014-05-14 16:34:14 -070059 : mDirtyPropertyFields(0)
Chris Craik003cc3d2015-10-16 10:24:55 -070060 , mNeedsDisplayListSync(false)
61 , mDisplayList(nullptr)
62 , mStagingDisplayList(nullptr)
John Reck68bfe0a2014-06-24 15:34:58 -070063 , mAnimatorManager(*this)
Chris Craikd41c4d82015-01-05 15:51:13 -080064 , mLayer(nullptr)
John Reckdcba6722014-07-08 13:59:49 -070065 , mParentCount(0) {
John Reck113e0822014-03-18 09:22:59 -070066}
67
68RenderNode::~RenderNode() {
Chris Craik003cc3d2015-10-16 10:24:55 -070069 deleteDisplayList();
70 delete mStagingDisplayList;
John Reck0e89e2b2014-10-31 14:49:06 -070071 if (mLayer) {
72 ALOGW("Memory Warning: Layer %p missed its detachment, held on to for far too long!", mLayer);
73 mLayer->postDecStrong();
Chris Craikd41c4d82015-01-05 15:51:13 -080074 mLayer = nullptr;
John Reck0e89e2b2014-10-31 14:49:06 -070075 }
John Reck113e0822014-03-18 09:22:59 -070076}
77
Chris Craik003cc3d2015-10-16 10:24:55 -070078void RenderNode::setStagingDisplayList(DisplayList* displayList) {
79 mNeedsDisplayListSync = true;
80 delete mStagingDisplayList;
81 mStagingDisplayList = displayList;
John Reck9dea0d52015-10-27 10:04:38 -070082 // If mParentCount == 0 we are the sole reference to this RenderNode,
83 // so immediately free the old display list
84 if (!mParentCount && !mStagingDisplayList) {
85 deleteDisplayList();
86 }
John Reck113e0822014-03-18 09:22:59 -070087}
88
89/**
90 * This function is a simplified version of replay(), where we simply retrieve and log the
91 * display list. This function should remain in sync with the replay() function.
92 */
93void RenderNode::output(uint32_t level) {
Chris Craikbf72eb82015-06-08 11:30:44 -070094 ALOGD("%*sStart display list (%p, %s%s%s%s%s%s)", (level - 1) * 2, "", this,
Chris Craikb5a54352014-11-21 14:54:35 -080095 getName(),
Chris Craik43a1d312015-05-27 11:28:14 -070096 (MathUtils::isZero(properties().getAlpha()) ? ", zero alpha" : ""),
Chris Craikb5a54352014-11-21 14:54:35 -080097 (properties().hasShadow() ? ", casting shadow" : ""),
98 (isRenderable() ? "" : ", empty"),
Chris Craikbf72eb82015-06-08 11:30:44 -070099 (properties().getProjectBackwards() ? ", projected" : ""),
Chris Craikd41c4d82015-01-05 15:51:13 -0800100 (mLayer != nullptr ? ", on HW Layer" : ""));
John Reck113e0822014-03-18 09:22:59 -0700101 ALOGD("%*s%s %d", level * 2, "", "Save",
102 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
103
John Reckd0a0b2a2014-03-20 16:28:56 -0700104 properties().debugOutputProperties(level);
Chris Craik10ed6922015-10-15 10:55:15 -0700105
Chris Craik003cc3d2015-10-16 10:24:55 -0700106 if (mDisplayList) {
Chris Craik10ed6922015-10-15 10:55:15 -0700107#if HWUI_NEW_OPS
108 LOG_ALWAYS_FATAL("op dumping unsupported");
109#else
Chris Craik8afd0f22014-08-21 17:41:57 -0700110 // TODO: consider printing the chunk boundaries here
Chris Craik003cc3d2015-10-16 10:24:55 -0700111 for (auto&& op : mDisplayList->getOps()) {
Chris Craik10ed6922015-10-15 10:55:15 -0700112 op->output(level, DisplayListOp::kOpLogFlag_Recurse);
John Reckdc0349b2014-08-06 15:28:07 -0700113 }
Chris Craik10ed6922015-10-15 10:55:15 -0700114#endif
John Reck113e0822014-03-18 09:22:59 -0700115 }
116
Chris Craik3f0854292014-04-15 16:18:08 -0700117 ALOGD("%*sDone (%p, %s)", (level - 1) * 2, "", this, getName());
John Reck113e0822014-03-18 09:22:59 -0700118}
119
John Recke248bd12015-08-05 13:53:53 -0700120void RenderNode::copyTo(proto::RenderNode *pnode) {
121 pnode->set_id(static_cast<uint64_t>(
122 reinterpret_cast<uintptr_t>(this)));
123 pnode->set_name(mName.string(), mName.length());
124
125 proto::RenderProperties* pprops = pnode->mutable_properties();
126 pprops->set_left(properties().getLeft());
127 pprops->set_top(properties().getTop());
128 pprops->set_right(properties().getRight());
129 pprops->set_bottom(properties().getBottom());
130 pprops->set_clip_flags(properties().getClippingFlags());
131 pprops->set_alpha(properties().getAlpha());
132 pprops->set_translation_x(properties().getTranslationX());
133 pprops->set_translation_y(properties().getTranslationY());
134 pprops->set_translation_z(properties().getTranslationZ());
135 pprops->set_elevation(properties().getElevation());
136 pprops->set_rotation(properties().getRotation());
137 pprops->set_rotation_x(properties().getRotationX());
138 pprops->set_rotation_y(properties().getRotationY());
139 pprops->set_scale_x(properties().getScaleX());
140 pprops->set_scale_y(properties().getScaleY());
141 pprops->set_pivot_x(properties().getPivotX());
142 pprops->set_pivot_y(properties().getPivotY());
143 pprops->set_has_overlapping_rendering(properties().getHasOverlappingRendering());
144 pprops->set_pivot_explicitly_set(properties().isPivotExplicitlySet());
145 pprops->set_project_backwards(properties().getProjectBackwards());
146 pprops->set_projection_receiver(properties().isProjectionReceiver());
147 set(pprops->mutable_clip_bounds(), properties().getClipBounds());
148
149 const Outline& outline = properties().getOutline();
150 if (outline.getType() != Outline::Type::None) {
151 proto::Outline* poutline = pprops->mutable_outline();
152 poutline->clear_path();
153 if (outline.getType() == Outline::Type::Empty) {
154 poutline->set_type(proto::Outline_Type_Empty);
155 } else if (outline.getType() == Outline::Type::ConvexPath) {
156 poutline->set_type(proto::Outline_Type_ConvexPath);
157 if (const SkPath* path = outline.getPath()) {
158 set(poutline->mutable_path(), *path);
159 }
160 } else if (outline.getType() == Outline::Type::RoundRect) {
161 poutline->set_type(proto::Outline_Type_RoundRect);
162 } else {
163 ALOGW("Uknown outline type! %d", static_cast<int>(outline.getType()));
164 poutline->set_type(proto::Outline_Type_None);
165 }
166 poutline->set_should_clip(outline.getShouldClip());
167 poutline->set_alpha(outline.getAlpha());
168 poutline->set_radius(outline.getRadius());
169 set(poutline->mutable_bounds(), outline.getBounds());
170 } else {
171 pprops->clear_outline();
172 }
173
174 const RevealClip& revealClip = properties().getRevealClip();
175 if (revealClip.willClip()) {
176 proto::RevealClip* prevealClip = pprops->mutable_reveal_clip();
177 prevealClip->set_x(revealClip.getX());
178 prevealClip->set_y(revealClip.getY());
179 prevealClip->set_radius(revealClip.getRadius());
180 } else {
181 pprops->clear_reveal_clip();
182 }
183
184 pnode->clear_children();
Chris Craik003cc3d2015-10-16 10:24:55 -0700185 if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700186 for (auto&& child : mDisplayList->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700187 child->renderNode->copyTo(pnode->add_children());
John Recke248bd12015-08-05 13:53:53 -0700188 }
189 }
190}
191
John Reckfe5e7b72014-05-23 17:42:28 -0700192int RenderNode::getDebugSize() {
193 int size = sizeof(RenderNode);
Chris Craik003cc3d2015-10-16 10:24:55 -0700194 if (mStagingDisplayList) {
195 size += mStagingDisplayList->getUsedSize();
John Reckfe5e7b72014-05-23 17:42:28 -0700196 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700197 if (mDisplayList && mDisplayList != mStagingDisplayList) {
198 size += mDisplayList->getUsedSize();
John Reckfe5e7b72014-05-23 17:42:28 -0700199 }
200 return size;
201}
202
John Reckf4198b72014-04-09 17:00:04 -0700203void RenderNode::prepareTree(TreeInfo& info) {
204 ATRACE_CALL();
Chris Craik69e5adf2014-08-14 13:34:01 -0700205 LOG_ALWAYS_FATAL_IF(!info.damageAccumulator, "DamageAccumulator missing");
John Reckf4198b72014-04-09 17:00:04 -0700206
Chris Craika766cb22015-06-08 16:49:43 -0700207 // Functors don't correctly handle stencil usage of overdraw debugging - shove 'em in a layer.
208 bool functorsNeedLayer = Properties::debugOverdraw;
209
210 prepareTreeImpl(info, functorsNeedLayer);
John Reckf4198b72014-04-09 17:00:04 -0700211}
212
John Reck68bfe0a2014-06-24 15:34:58 -0700213void RenderNode::addAnimator(const sp<BaseRenderNodeAnimator>& animator) {
214 mAnimatorManager.addAnimator(animator);
215}
216
John Recke4267ea2014-06-03 15:53:15 -0700217void RenderNode::damageSelf(TreeInfo& info) {
John Reckce9f3082014-06-17 16:18:09 -0700218 if (isRenderable()) {
John Reck293e8682014-06-17 10:34:02 -0700219 if (properties().getClipDamageToBounds()) {
John Recka447d292014-06-11 18:39:44 -0700220 info.damageAccumulator->dirty(0, 0, properties().getWidth(), properties().getHeight());
221 } else {
222 // Hope this is big enough?
223 // TODO: Get this from the display list ops or something
John Reckc1288232015-08-12 13:39:11 -0700224 info.damageAccumulator->dirty(DIRTY_MIN, DIRTY_MIN, DIRTY_MAX, DIRTY_MAX);
John Recka447d292014-06-11 18:39:44 -0700225 }
John Recke4267ea2014-06-03 15:53:15 -0700226 }
227}
228
John Recka7c2ea22014-08-08 13:21:00 -0700229void RenderNode::prepareLayer(TreeInfo& info, uint32_t dirtyMask) {
Chris Craik856f0cc2015-04-21 15:13:29 -0700230 LayerType layerType = properties().effectiveLayerType();
Chris Craik182952f2015-03-09 14:17:29 -0700231 if (CC_UNLIKELY(layerType == LayerType::RenderLayer)) {
John Recka7c2ea22014-08-08 13:21:00 -0700232 // Damage applied so far needs to affect our parent, but does not require
233 // the layer to be updated. So we pop/push here to clear out the current
234 // damage and get a clean state for display list or children updates to
235 // affect, which will require the layer to be updated
236 info.damageAccumulator->popTransform();
237 info.damageAccumulator->pushTransform(this);
238 if (dirtyMask & DISPLAY_LIST) {
239 damageSelf(info);
240 }
John Reck25fbb3f2014-06-12 13:46:45 -0700241 }
242}
243
244void RenderNode::pushLayerUpdate(TreeInfo& info) {
Chris Craik856f0cc2015-04-21 15:13:29 -0700245 LayerType layerType = properties().effectiveLayerType();
John Reck25fbb3f2014-06-12 13:46:45 -0700246 // If we are not a layer OR we cannot be rendered (eg, view was detached)
247 // we need to destroy any Layers we may have had previously
Chris Craik182952f2015-03-09 14:17:29 -0700248 if (CC_LIKELY(layerType != LayerType::RenderLayer) || CC_UNLIKELY(!isRenderable())) {
John Reck25fbb3f2014-06-12 13:46:45 -0700249 if (CC_UNLIKELY(mLayer)) {
250 LayerRenderer::destroyLayer(mLayer);
Chris Craikd41c4d82015-01-05 15:51:13 -0800251 mLayer = nullptr;
John Reck25fbb3f2014-06-12 13:46:45 -0700252 }
253 return;
254 }
255
Chris Craik69e5adf2014-08-14 13:34:01 -0700256 bool transformUpdateNeeded = false;
John Reck25fbb3f2014-06-12 13:46:45 -0700257 if (!mLayer) {
John Reck3b202512014-06-23 13:13:08 -0700258 mLayer = LayerRenderer::createRenderLayer(info.renderState, getWidth(), getHeight());
John Reck25fbb3f2014-06-12 13:46:45 -0700259 applyLayerPropertiesToLayer(info);
260 damageSelf(info);
Chris Craik69e5adf2014-08-14 13:34:01 -0700261 transformUpdateNeeded = true;
John Reck25fbb3f2014-06-12 13:46:45 -0700262 } else if (mLayer->layer.getWidth() != getWidth() || mLayer->layer.getHeight() != getHeight()) {
John Reckc25e5062014-06-18 14:21:29 -0700263 if (!LayerRenderer::resizeLayer(mLayer, getWidth(), getHeight())) {
264 LayerRenderer::destroyLayer(mLayer);
Chris Craikd41c4d82015-01-05 15:51:13 -0800265 mLayer = nullptr;
John Reckc25e5062014-06-18 14:21:29 -0700266 }
John Reck25fbb3f2014-06-12 13:46:45 -0700267 damageSelf(info);
Chris Craik69e5adf2014-08-14 13:34:01 -0700268 transformUpdateNeeded = true;
269 }
270
John Reck25fbb3f2014-06-12 13:46:45 -0700271 SkRect dirty;
272 info.damageAccumulator->peekAtDirty(&dirty);
John Reck25fbb3f2014-06-12 13:46:45 -0700273
John Reckc25e5062014-06-18 14:21:29 -0700274 if (!mLayer) {
John Reck0e89e2b2014-10-31 14:49:06 -0700275 Caches::getInstance().dumpMemoryUsage();
John Reckc25e5062014-06-18 14:21:29 -0700276 if (info.errorHandler) {
277 std::string msg = "Unable to create layer for ";
278 msg += getName();
279 info.errorHandler->onError(msg);
280 }
281 return;
282 }
283
Chris Craikc71bfca2014-08-21 10:18:58 -0700284 if (transformUpdateNeeded) {
285 // update the transform in window of the layer to reset its origin wrt light source position
286 Matrix4 windowTransform;
287 info.damageAccumulator->computeCurrentTransform(&windowTransform);
288 mLayer->setWindowTransform(windowTransform);
289 }
John Reckc79eabc2014-08-05 11:03:42 -0700290
291 if (dirty.intersect(0, 0, getWidth(), getHeight())) {
Mike Reed71487eb2014-11-19 16:13:20 -0500292 dirty.roundOut(&dirty);
John Reck25fbb3f2014-06-12 13:46:45 -0700293 mLayer->updateDeferred(this, dirty.fLeft, dirty.fTop, dirty.fRight, dirty.fBottom);
294 }
295 // This is not inside the above if because we may have called
296 // updateDeferred on a previous prepare pass that didn't have a renderer
297 if (info.renderer && mLayer->deferredUpdateScheduled) {
298 info.renderer->pushLayerUpdate(mLayer);
299 }
John Reck998a6d82014-08-28 15:35:53 -0700300
John Reck00e79c92015-07-21 10:23:59 -0700301 if (info.canvasContext) {
302 // There might be prefetched layers that need to be accounted for.
303 // That might be us, so tell CanvasContext that this layer is in the
304 // tree and should not be destroyed.
John Reck998a6d82014-08-28 15:35:53 -0700305 info.canvasContext->markLayerInUse(this);
306 }
John Reck25fbb3f2014-06-12 13:46:45 -0700307}
308
Chris Craika766cb22015-06-08 16:49:43 -0700309/**
310 * Traverse down the the draw tree to prepare for a frame.
311 *
312 * MODE_FULL = UI Thread-driven (thus properties must be synced), otherwise RT driven
313 *
314 * While traversing down the tree, functorsNeedLayer flag is set to true if anything that uses the
315 * stencil buffer may be needed. Views that use a functor to draw will be forced onto a layer.
316 */
317void RenderNode::prepareTreeImpl(TreeInfo& info, bool functorsNeedLayer) {
John Recka447d292014-06-11 18:39:44 -0700318 info.damageAccumulator->pushTransform(this);
John Reckf47a5942014-06-30 16:20:04 -0700319
John Reckdcba6722014-07-08 13:59:49 -0700320 if (info.mode == TreeInfo::MODE_FULL) {
John Reck25fbb3f2014-06-12 13:46:45 -0700321 pushStagingPropertiesChanges(info);
John Recke45b1fd2014-04-15 09:50:16 -0700322 }
John Reck9eb9f6f2014-08-21 11:23:05 -0700323 uint32_t animatorDirtyMask = 0;
324 if (CC_LIKELY(info.runAnimations)) {
325 animatorDirtyMask = mAnimatorManager.animate(info);
326 }
Chris Craika766cb22015-06-08 16:49:43 -0700327
John Reck3f725f02015-06-16 10:29:31 -0700328 bool willHaveFunctor = false;
Chris Craik003cc3d2015-10-16 10:24:55 -0700329 if (info.mode == TreeInfo::MODE_FULL && mStagingDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700330 willHaveFunctor = !mStagingDisplayList->getFunctors().empty();
Chris Craik003cc3d2015-10-16 10:24:55 -0700331 } else if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700332 willHaveFunctor = !mDisplayList->getFunctors().empty();
John Reck3f725f02015-06-16 10:29:31 -0700333 }
Chris Craika766cb22015-06-08 16:49:43 -0700334 bool childFunctorsNeedLayer = mProperties.prepareForFunctorPresence(
335 willHaveFunctor, functorsNeedLayer);
336
John Recka7c2ea22014-08-08 13:21:00 -0700337 prepareLayer(info, animatorDirtyMask);
John Reckdcba6722014-07-08 13:59:49 -0700338 if (info.mode == TreeInfo::MODE_FULL) {
John Reck25fbb3f2014-06-12 13:46:45 -0700339 pushStagingDisplayListChanges(info);
340 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700341 prepareSubTree(info, childFunctorsNeedLayer, mDisplayList);
John Reck25fbb3f2014-06-12 13:46:45 -0700342 pushLayerUpdate(info);
343
John Recka447d292014-06-11 18:39:44 -0700344 info.damageAccumulator->popTransform();
John Reckf4198b72014-04-09 17:00:04 -0700345}
346
Chris Craikb565df12015-10-05 13:00:52 -0700347void RenderNode::syncProperties() {
348 mProperties = mStagingProperties;
349}
350
John Reck25fbb3f2014-06-12 13:46:45 -0700351void RenderNode::pushStagingPropertiesChanges(TreeInfo& info) {
John Reckff941dc2014-05-14 16:34:14 -0700352 // Push the animators first so that setupStartValueIfNecessary() is called
353 // before properties() is trampled by stagingProperties(), as they are
354 // required by some animators.
John Reck9eb9f6f2014-08-21 11:23:05 -0700355 if (CC_LIKELY(info.runAnimations)) {
John Reck119907c2014-08-14 09:02:01 -0700356 mAnimatorManager.pushStaging();
John Reck9eb9f6f2014-08-21 11:23:05 -0700357 }
John Reckff941dc2014-05-14 16:34:14 -0700358 if (mDirtyPropertyFields) {
359 mDirtyPropertyFields = 0;
John Recke4267ea2014-06-03 15:53:15 -0700360 damageSelf(info);
John Recka447d292014-06-11 18:39:44 -0700361 info.damageAccumulator->popTransform();
Chris Craikb565df12015-10-05 13:00:52 -0700362 syncProperties();
John Reck25fbb3f2014-06-12 13:46:45 -0700363 applyLayerPropertiesToLayer(info);
John Recke4267ea2014-06-03 15:53:15 -0700364 // We could try to be clever and only re-damage if the matrix changed.
365 // However, we don't need to worry about that. The cost of over-damaging
366 // here is only going to be a single additional map rect of this node
367 // plus a rect join(). The parent's transform (and up) will only be
368 // performed once.
John Recka447d292014-06-11 18:39:44 -0700369 info.damageAccumulator->pushTransform(this);
John Recke4267ea2014-06-03 15:53:15 -0700370 damageSelf(info);
John Reckff941dc2014-05-14 16:34:14 -0700371 }
John Reck25fbb3f2014-06-12 13:46:45 -0700372}
373
Andreas Gampe64bb4132014-11-22 00:35:09 +0000374void RenderNode::applyLayerPropertiesToLayer(TreeInfo& info) {
John Reck25fbb3f2014-06-12 13:46:45 -0700375 if (CC_LIKELY(!mLayer)) return;
376
377 const LayerProperties& props = properties().layerProperties();
378 mLayer->setAlpha(props.alpha(), props.xferMode());
379 mLayer->setColorFilter(props.colorFilter());
380 mLayer->setBlend(props.needsBlending());
381}
382
Chris Craikb565df12015-10-05 13:00:52 -0700383void RenderNode::syncDisplayList() {
384 // Make sure we inc first so that we don't fluctuate between 0 and 1,
385 // which would thrash the layer cache
Chris Craik003cc3d2015-10-16 10:24:55 -0700386 if (mStagingDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700387 for (auto&& child : mStagingDisplayList->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700388 child->renderNode->incParentRefCount();
389 }
390 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700391 deleteDisplayList();
392 mDisplayList = mStagingDisplayList;
393 mStagingDisplayList = nullptr;
394 if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700395 for (size_t i = 0; i < mDisplayList->getFunctors().size(); i++) {
396 (*mDisplayList->getFunctors()[i])(DrawGlInfo::kModeSync, nullptr);
Chris Craikb565df12015-10-05 13:00:52 -0700397 }
398 }
399}
400
John Reck25fbb3f2014-06-12 13:46:45 -0700401void RenderNode::pushStagingDisplayListChanges(TreeInfo& info) {
Chris Craik003cc3d2015-10-16 10:24:55 -0700402 if (mNeedsDisplayListSync) {
403 mNeedsDisplayListSync = false;
John Reck5c9d7172014-10-22 11:32:27 -0700404 // Damage with the old display list first then the new one to catch any
405 // changes in isRenderable or, in the future, bounds
406 damageSelf(info);
Chris Craikb565df12015-10-05 13:00:52 -0700407 syncDisplayList();
John Recke4267ea2014-06-03 15:53:15 -0700408 damageSelf(info);
John Reck8de65a82014-04-09 15:23:38 -0700409 }
John Reck8de65a82014-04-09 15:23:38 -0700410}
411
Chris Craik003cc3d2015-10-16 10:24:55 -0700412void RenderNode::deleteDisplayList() {
413 if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700414 for (auto&& child : mDisplayList->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700415 child->renderNode->decParentRefCount();
John Reckdcba6722014-07-08 13:59:49 -0700416 }
417 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700418 delete mDisplayList;
419 mDisplayList = nullptr;
John Reckdcba6722014-07-08 13:59:49 -0700420}
421
Chris Craik003cc3d2015-10-16 10:24:55 -0700422void RenderNode::prepareSubTree(TreeInfo& info, bool functorsNeedLayer, DisplayList* subtree) {
John Reck8de65a82014-04-09 15:23:38 -0700423 if (subtree) {
John Reck860d1552014-04-11 19:15:05 -0700424 TextureCache& cache = Caches::getInstance().textureCache;
Chris Craikb36af872015-10-16 14:23:12 -0700425 info.out.hasFunctors |= subtree->getFunctors().size();
426 for (auto&& bitmapResource : subtree->getBitmapResources()) {
427 info.prepareTextures = cache.prefetchAndMarkInUse(info.canvasContext, bitmapResource);
John Reckf4198b72014-04-09 17:00:04 -0700428 }
Chris Craikb36af872015-10-16 14:23:12 -0700429 for (auto&& op : subtree->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700430 RenderNode* childNode = op->renderNode;
431#if HWUI_NEW_OPS
432 info.damageAccumulator->pushTransform(&op->localMatrix);
433 bool childFunctorsNeedLayer = functorsNeedLayer; // TODO! || op->mRecordedWithPotentialStencilClip;
434#else
John Recka447d292014-06-11 18:39:44 -0700435 info.damageAccumulator->pushTransform(&op->mTransformFromParent);
Chris Craika766cb22015-06-08 16:49:43 -0700436 bool childFunctorsNeedLayer = functorsNeedLayer
437 // Recorded with non-rect clip, or canvas-rotated by parent
438 || op->mRecordedWithPotentialStencilClip;
Chris Craikb565df12015-10-05 13:00:52 -0700439#endif
Chris Craika766cb22015-06-08 16:49:43 -0700440 childNode->prepareTreeImpl(info, childFunctorsNeedLayer);
John Recka447d292014-06-11 18:39:44 -0700441 info.damageAccumulator->popTransform();
John Reck5bf11bb2014-03-25 10:22:09 -0700442 }
John Reck113e0822014-03-18 09:22:59 -0700443 }
444}
445
John Reckdcba6722014-07-08 13:59:49 -0700446void RenderNode::destroyHardwareResources() {
447 if (mLayer) {
448 LayerRenderer::destroyLayer(mLayer);
Chris Craikd41c4d82015-01-05 15:51:13 -0800449 mLayer = nullptr;
John Reckdcba6722014-07-08 13:59:49 -0700450 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700451 if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700452 for (auto&& child : mDisplayList->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700453 child->renderNode->destroyHardwareResources();
John Reckdcba6722014-07-08 13:59:49 -0700454 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700455 if (mNeedsDisplayListSync) {
John Reckdcba6722014-07-08 13:59:49 -0700456 // Next prepare tree we are going to push a new display list, so we can
457 // drop our current one now
Chris Craik003cc3d2015-10-16 10:24:55 -0700458 deleteDisplayList();
John Reckdcba6722014-07-08 13:59:49 -0700459 }
460 }
461}
462
463void RenderNode::decParentRefCount() {
464 LOG_ALWAYS_FATAL_IF(!mParentCount, "already 0!");
465 mParentCount--;
466 if (!mParentCount) {
467 // If a child of ours is being attached to our parent then this will incorrectly
468 // destroy its hardware resources. However, this situation is highly unlikely
469 // and the failure is "just" that the layer is re-created, so this should
470 // be safe enough
471 destroyHardwareResources();
472 }
473}
474
Chris Craikb565df12015-10-05 13:00:52 -0700475bool RenderNode::applyViewProperties(CanvasState& canvasState) const {
476 const Outline& outline = properties().getOutline();
477 if (properties().getAlpha() <= 0
478 || (outline.getShouldClip() && outline.isEmpty())
479 || properties().getScaleX() == 0
480 || properties().getScaleY() == 0) {
481 return false; // rejected
482 }
483
484 if (properties().getLeft() != 0 || properties().getTop() != 0) {
485 canvasState.translate(properties().getLeft(), properties().getTop());
486 }
487 if (properties().getStaticMatrix()) {
488 canvasState.concatMatrix(*properties().getStaticMatrix());
489 } else if (properties().getAnimationMatrix()) {
490 canvasState.concatMatrix(*properties().getAnimationMatrix());
491 }
492 if (properties().hasTransformMatrix()) {
493 if (properties().isTransformTranslateOnly()) {
494 canvasState.translate(properties().getTranslationX(), properties().getTranslationY());
495 } else {
496 canvasState.concatMatrix(*properties().getTransformMatrix());
497 }
498 }
499 return !canvasState.quickRejectConservative(
500 0, 0, properties().getWidth(), properties().getHeight());
501}
502
John Reck113e0822014-03-18 09:22:59 -0700503/*
504 * For property operations, we pass a savecount of 0, since the operations aren't part of the
505 * displaylist, and thus don't have to compensate for the record-time/playback-time discrepancy in
John Reckd0a0b2a2014-03-20 16:28:56 -0700506 * base saveCount (i.e., how RestoreToCount uses saveCount + properties().getCount())
John Reck113e0822014-03-18 09:22:59 -0700507 */
508#define PROPERTY_SAVECOUNT 0
509
510template <class T>
Chris Craikb265e2c2014-03-27 15:50:09 -0700511void RenderNode::setViewProperties(OpenGLRenderer& renderer, T& handler) {
John Reck113e0822014-03-18 09:22:59 -0700512#if DEBUG_DISPLAY_LIST
Chris Craikb265e2c2014-03-27 15:50:09 -0700513 properties().debugOutputProperties(handler.level() + 1);
John Reck113e0822014-03-18 09:22:59 -0700514#endif
John Reckd0a0b2a2014-03-20 16:28:56 -0700515 if (properties().getLeft() != 0 || properties().getTop() != 0) {
516 renderer.translate(properties().getLeft(), properties().getTop());
John Reck113e0822014-03-18 09:22:59 -0700517 }
John Reckd0a0b2a2014-03-20 16:28:56 -0700518 if (properties().getStaticMatrix()) {
Derek Sollenberger13908822013-12-10 12:28:58 -0500519 renderer.concatMatrix(*properties().getStaticMatrix());
John Reckd0a0b2a2014-03-20 16:28:56 -0700520 } else if (properties().getAnimationMatrix()) {
Derek Sollenberger13908822013-12-10 12:28:58 -0500521 renderer.concatMatrix(*properties().getAnimationMatrix());
John Reck113e0822014-03-18 09:22:59 -0700522 }
John Reckf7483e32014-04-11 08:54:47 -0700523 if (properties().hasTransformMatrix()) {
524 if (properties().isTransformTranslateOnly()) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700525 renderer.translate(properties().getTranslationX(), properties().getTranslationY());
John Reck113e0822014-03-18 09:22:59 -0700526 } else {
John Reckd0a0b2a2014-03-20 16:28:56 -0700527 renderer.concatMatrix(*properties().getTransformMatrix());
John Reck113e0822014-03-18 09:22:59 -0700528 }
529 }
Chris Craik856f0cc2015-04-21 15:13:29 -0700530 const bool isLayer = properties().effectiveLayerType() != LayerType::None;
Chris Craika753f4c2014-07-24 12:39:17 -0700531 int clipFlags = properties().getClippingFlags();
John Reckd0a0b2a2014-03-20 16:28:56 -0700532 if (properties().getAlpha() < 1) {
John Reck25fbb3f2014-06-12 13:46:45 -0700533 if (isLayer) {
Chris Craika753f4c2014-07-24 12:39:17 -0700534 clipFlags &= ~CLIP_TO_BOUNDS; // bounds clipping done by layer
John Reck113e0822014-03-18 09:22:59 -0700535 }
Chris Craik4e9d9b22015-06-12 11:07:23 -0700536 if (CC_LIKELY(isLayer || !properties().getHasOverlappingRendering())) {
537 // simply scale rendering content's alpha
538 renderer.scaleAlpha(properties().getAlpha());
539 } else {
540 // savelayer needed to create an offscreen buffer
541 Rect layerBounds(0, 0, getWidth(), getHeight());
542 if (clipFlags) {
543 properties().getClippingRectForFlags(clipFlags, &layerBounds);
544 clipFlags = 0; // all clipping done by savelayer
545 }
546 SaveLayerOp* op = new (handler.allocator()) SaveLayerOp(
547 layerBounds.left, layerBounds.top,
548 layerBounds.right, layerBounds.bottom,
549 (int) (properties().getAlpha() * 255),
550 SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kClipToLayer_SaveFlag);
551 handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds());
552 }
Chris Craik1a0808e2015-05-13 16:33:04 -0700553
554 if (CC_UNLIKELY(ATRACE_ENABLED() && properties().promotedToLayer())) {
Chris Craik4e9d9b22015-06-12 11:07:23 -0700555 // pretend alpha always causes savelayer to warn about
556 // performance problem affecting old versions
Chris Craik1a0808e2015-05-13 16:33:04 -0700557 ATRACE_FORMAT("%s alpha caused saveLayer %dx%d", getName(),
558 static_cast<int>(getWidth()),
559 static_cast<int>(getHeight()));
560 }
John Reck113e0822014-03-18 09:22:59 -0700561 }
Chris Craika753f4c2014-07-24 12:39:17 -0700562 if (clipFlags) {
563 Rect clipRect;
564 properties().getClippingRectForFlags(clipFlags, &clipRect);
Chris Craik8c271ca2014-03-25 10:33:01 -0700565 ClipRectOp* op = new (handler.allocator()) ClipRectOp(
Chris Craika753f4c2014-07-24 12:39:17 -0700566 clipRect.left, clipRect.top, clipRect.right, clipRect.bottom,
567 SkRegion::kIntersect_Op);
John Reckd0a0b2a2014-03-20 16:28:56 -0700568 handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -0700569 }
Chris Craik8c271ca2014-03-25 10:33:01 -0700570
Chris Craike83cbd42014-09-03 17:52:24 -0700571 // TODO: support nesting round rect clips
Chris Craikaf4d04c2014-07-29 12:50:14 -0700572 if (mProperties.getRevealClip().willClip()) {
573 Rect bounds;
574 mProperties.getRevealClip().getBounds(&bounds);
575 renderer.setClippingRoundRect(handler.allocator(), bounds, mProperties.getRevealClip().getRadius());
576 } else if (mProperties.getOutline().willClip()) {
577 renderer.setClippingOutline(handler.allocator(), &(mProperties.getOutline()));
John Reck113e0822014-03-18 09:22:59 -0700578 }
579}
580
581/**
582 * Apply property-based transformations to input matrix
583 *
584 * If true3dTransform is set to true, the transform applied to the input matrix will use true 4x4
585 * matrix computation instead of the Skia 3x3 matrix + camera hackery.
586 */
Chris Craik69e5adf2014-08-14 13:34:01 -0700587void RenderNode::applyViewPropertyTransforms(mat4& matrix, bool true3dTransform) const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700588 if (properties().getLeft() != 0 || properties().getTop() != 0) {
589 matrix.translate(properties().getLeft(), properties().getTop());
John Reck113e0822014-03-18 09:22:59 -0700590 }
John Reckd0a0b2a2014-03-20 16:28:56 -0700591 if (properties().getStaticMatrix()) {
592 mat4 stat(*properties().getStaticMatrix());
John Reck113e0822014-03-18 09:22:59 -0700593 matrix.multiply(stat);
John Reckd0a0b2a2014-03-20 16:28:56 -0700594 } else if (properties().getAnimationMatrix()) {
595 mat4 anim(*properties().getAnimationMatrix());
John Reck113e0822014-03-18 09:22:59 -0700596 matrix.multiply(anim);
597 }
Chris Craike0bb87d2014-04-22 17:55:41 -0700598
Chris Craikcc39e162014-04-25 18:34:11 -0700599 bool applyTranslationZ = true3dTransform && !MathUtils::isZero(properties().getZ());
Chris Craike0bb87d2014-04-22 17:55:41 -0700600 if (properties().hasTransformMatrix() || applyTranslationZ) {
John Reckf7483e32014-04-11 08:54:47 -0700601 if (properties().isTransformTranslateOnly()) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700602 matrix.translate(properties().getTranslationX(), properties().getTranslationY(),
Chris Craikcc39e162014-04-25 18:34:11 -0700603 true3dTransform ? properties().getZ() : 0.0f);
John Reck113e0822014-03-18 09:22:59 -0700604 } else {
605 if (!true3dTransform) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700606 matrix.multiply(*properties().getTransformMatrix());
John Reck113e0822014-03-18 09:22:59 -0700607 } else {
608 mat4 true3dMat;
609 true3dMat.loadTranslate(
John Reckd0a0b2a2014-03-20 16:28:56 -0700610 properties().getPivotX() + properties().getTranslationX(),
611 properties().getPivotY() + properties().getTranslationY(),
Chris Craikcc39e162014-04-25 18:34:11 -0700612 properties().getZ());
John Reckd0a0b2a2014-03-20 16:28:56 -0700613 true3dMat.rotate(properties().getRotationX(), 1, 0, 0);
614 true3dMat.rotate(properties().getRotationY(), 0, 1, 0);
615 true3dMat.rotate(properties().getRotation(), 0, 0, 1);
616 true3dMat.scale(properties().getScaleX(), properties().getScaleY(), 1);
617 true3dMat.translate(-properties().getPivotX(), -properties().getPivotY());
John Reck113e0822014-03-18 09:22:59 -0700618
619 matrix.multiply(true3dMat);
620 }
621 }
622 }
623}
624
625/**
626 * Organizes the DisplayList hierarchy to prepare for background projection reordering.
627 *
628 * This should be called before a call to defer() or drawDisplayList()
629 *
630 * Each DisplayList that serves as a 3d root builds its list of composited children,
631 * which are flagged to not draw in the standard draw loop.
632 */
633void RenderNode::computeOrdering() {
Chris Craikb565df12015-10-05 13:00:52 -0700634#if !HWUI_NEW_OPS
John Reck113e0822014-03-18 09:22:59 -0700635 ATRACE_CALL();
636 mProjectedNodes.clear();
637
638 // TODO: create temporary DDLOp and call computeOrderingImpl on top DisplayList so that
639 // transform properties are applied correctly to top level children
Chris Craik003cc3d2015-10-16 10:24:55 -0700640 if (mDisplayList == nullptr) return;
Chris Craikb36af872015-10-16 14:23:12 -0700641 for (unsigned int i = 0; i < mDisplayList->getChildren().size(); i++) {
642 DrawRenderNodeOp* childOp = mDisplayList->getChildren()[i];
Chris Craikb565df12015-10-05 13:00:52 -0700643 childOp->renderNode->computeOrderingImpl(childOp, &mProjectedNodes, &mat4::identity());
John Reck113e0822014-03-18 09:22:59 -0700644 }
Chris Craikb565df12015-10-05 13:00:52 -0700645#endif
John Reck113e0822014-03-18 09:22:59 -0700646}
647
648void RenderNode::computeOrderingImpl(
Chris Craika7090e02014-06-20 16:01:00 -0700649 DrawRenderNodeOp* opState,
John Reck272a6852015-07-29 16:48:58 -0700650 std::vector<DrawRenderNodeOp*>* compositedChildrenOfProjectionSurface,
John Reck113e0822014-03-18 09:22:59 -0700651 const mat4* transformFromProjectionSurface) {
Chris Craikb565df12015-10-05 13:00:52 -0700652#if !HWUI_NEW_OPS
John Reck113e0822014-03-18 09:22:59 -0700653 mProjectedNodes.clear();
Chris Craik003cc3d2015-10-16 10:24:55 -0700654 if (mDisplayList == nullptr || mDisplayList->isEmpty()) return;
John Reck113e0822014-03-18 09:22:59 -0700655
656 // TODO: should avoid this calculation in most cases
657 // TODO: just calculate single matrix, down to all leaf composited elements
658 Matrix4 localTransformFromProjectionSurface(*transformFromProjectionSurface);
659 localTransformFromProjectionSurface.multiply(opState->mTransformFromParent);
660
John Reckd0a0b2a2014-03-20 16:28:56 -0700661 if (properties().getProjectBackwards()) {
John Reck113e0822014-03-18 09:22:59 -0700662 // composited projectee, flag for out of order draw, save matrix, and store in proj surface
663 opState->mSkipInOrderDraw = true;
Chris Craik7c85c542015-08-19 15:10:24 -0700664 opState->mTransformFromCompositingAncestor = localTransformFromProjectionSurface;
John Reck272a6852015-07-29 16:48:58 -0700665 compositedChildrenOfProjectionSurface->push_back(opState);
John Reck113e0822014-03-18 09:22:59 -0700666 } else {
667 // standard in order draw
668 opState->mSkipInOrderDraw = false;
669 }
670
Chris Craikb36af872015-10-16 14:23:12 -0700671 if (mDisplayList->getChildren().size() > 0) {
Chris Craik003cc3d2015-10-16 10:24:55 -0700672 const bool isProjectionReceiver = mDisplayList->projectionReceiveIndex >= 0;
John Reck113e0822014-03-18 09:22:59 -0700673 bool haveAppliedPropertiesToProjection = false;
Chris Craikb36af872015-10-16 14:23:12 -0700674 for (unsigned int i = 0; i < mDisplayList->getChildren().size(); i++) {
675 DrawRenderNodeOp* childOp = mDisplayList->getChildren()[i];
Chris Craikb565df12015-10-05 13:00:52 -0700676 RenderNode* child = childOp->renderNode;
John Reck113e0822014-03-18 09:22:59 -0700677
John Reck272a6852015-07-29 16:48:58 -0700678 std::vector<DrawRenderNodeOp*>* projectionChildren = nullptr;
Chris Craikd41c4d82015-01-05 15:51:13 -0800679 const mat4* projectionTransform = nullptr;
John Reckd0a0b2a2014-03-20 16:28:56 -0700680 if (isProjectionReceiver && !child->properties().getProjectBackwards()) {
Chris Craikbf72eb82015-06-08 11:30:44 -0700681 // if receiving projections, collect projecting descendant
John Reck113e0822014-03-18 09:22:59 -0700682
Chris Craikbf72eb82015-06-08 11:30:44 -0700683 // Note that if a direct descendant is projecting backwards, we pass its
684 // grandparent projection collection, since it shouldn't project onto its
John Reck113e0822014-03-18 09:22:59 -0700685 // parent, where it will already be drawing.
686 projectionChildren = &mProjectedNodes;
687 projectionTransform = &mat4::identity();
688 } else {
689 if (!haveAppliedPropertiesToProjection) {
690 applyViewPropertyTransforms(localTransformFromProjectionSurface);
691 haveAppliedPropertiesToProjection = true;
692 }
693 projectionChildren = compositedChildrenOfProjectionSurface;
694 projectionTransform = &localTransformFromProjectionSurface;
695 }
Derek Sollenbergerf2932592015-08-13 14:59:33 -0400696 child->computeOrderingImpl(childOp, projectionChildren, projectionTransform);
John Reck113e0822014-03-18 09:22:59 -0700697 }
698 }
Chris Craikb565df12015-10-05 13:00:52 -0700699#endif
John Reck113e0822014-03-18 09:22:59 -0700700}
701
702class DeferOperationHandler {
703public:
704 DeferOperationHandler(DeferStateStruct& deferStruct, int level)
705 : mDeferStruct(deferStruct), mLevel(level) {}
706 inline void operator()(DisplayListOp* operation, int saveCount, bool clipToBounds) {
707 operation->defer(mDeferStruct, saveCount, mLevel, clipToBounds);
708 }
709 inline LinearAllocator& allocator() { return *(mDeferStruct.mAllocator); }
Andreas Gampe64bb4132014-11-22 00:35:09 +0000710 inline void startMark(const char* name) {} // do nothing
Chris Craikb265e2c2014-03-27 15:50:09 -0700711 inline void endMark() {}
712 inline int level() { return mLevel; }
713 inline int replayFlags() { return mDeferStruct.mReplayFlags; }
Chris Craik74669862014-08-07 17:27:30 -0700714 inline SkPath* allocPathForFrame() { return mDeferStruct.allocPathForFrame(); }
John Reck113e0822014-03-18 09:22:59 -0700715
716private:
717 DeferStateStruct& mDeferStruct;
718 const int mLevel;
719};
720
Chris Craik80d49022014-06-20 15:03:43 -0700721void RenderNode::defer(DeferStateStruct& deferStruct, const int level) {
John Reck113e0822014-03-18 09:22:59 -0700722 DeferOperationHandler handler(deferStruct, level);
Chris Craikb265e2c2014-03-27 15:50:09 -0700723 issueOperations<DeferOperationHandler>(deferStruct.mRenderer, handler);
John Reck113e0822014-03-18 09:22:59 -0700724}
725
726class ReplayOperationHandler {
727public:
728 ReplayOperationHandler(ReplayStateStruct& replayStruct, int level)
729 : mReplayStruct(replayStruct), mLevel(level) {}
730 inline void operator()(DisplayListOp* operation, int saveCount, bool clipToBounds) {
731#if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS
Chris Craik3f0854292014-04-15 16:18:08 -0700732 mReplayStruct.mRenderer.eventMark(operation->name());
John Reck113e0822014-03-18 09:22:59 -0700733#endif
734 operation->replay(mReplayStruct, saveCount, mLevel, clipToBounds);
735 }
736 inline LinearAllocator& allocator() { return *(mReplayStruct.mAllocator); }
Chris Craikb265e2c2014-03-27 15:50:09 -0700737 inline void startMark(const char* name) {
738 mReplayStruct.mRenderer.startMark(name);
739 }
740 inline void endMark() {
741 mReplayStruct.mRenderer.endMark();
Chris Craikb265e2c2014-03-27 15:50:09 -0700742 }
743 inline int level() { return mLevel; }
744 inline int replayFlags() { return mReplayStruct.mReplayFlags; }
Chris Craik74669862014-08-07 17:27:30 -0700745 inline SkPath* allocPathForFrame() { return mReplayStruct.allocPathForFrame(); }
John Reck113e0822014-03-18 09:22:59 -0700746
747private:
748 ReplayStateStruct& mReplayStruct;
749 const int mLevel;
750};
751
Chris Craik80d49022014-06-20 15:03:43 -0700752void RenderNode::replay(ReplayStateStruct& replayStruct, const int level) {
John Reck113e0822014-03-18 09:22:59 -0700753 ReplayOperationHandler handler(replayStruct, level);
Chris Craikb265e2c2014-03-27 15:50:09 -0700754 issueOperations<ReplayOperationHandler>(replayStruct.mRenderer, handler);
John Reck113e0822014-03-18 09:22:59 -0700755}
756
Chris Craik003cc3d2015-10-16 10:24:55 -0700757void RenderNode::buildZSortedChildList(const DisplayList::Chunk& chunk,
John Reck272a6852015-07-29 16:48:58 -0700758 std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes) {
Chris Craikb565df12015-10-05 13:00:52 -0700759#if !HWUI_NEW_OPS
Chris Craik8afd0f22014-08-21 17:41:57 -0700760 if (chunk.beginChildIndex == chunk.endChildIndex) return;
John Reck113e0822014-03-18 09:22:59 -0700761
Chris Craik8afd0f22014-08-21 17:41:57 -0700762 for (unsigned int i = chunk.beginChildIndex; i < chunk.endChildIndex; i++) {
Chris Craikb36af872015-10-16 14:23:12 -0700763 DrawRenderNodeOp* childOp = mDisplayList->getChildren()[i];
Chris Craikb565df12015-10-05 13:00:52 -0700764 RenderNode* child = childOp->renderNode;
Chris Craikcc39e162014-04-25 18:34:11 -0700765 float childZ = child->properties().getZ();
John Reck113e0822014-03-18 09:22:59 -0700766
Chris Craik8afd0f22014-08-21 17:41:57 -0700767 if (!MathUtils::isZero(childZ) && chunk.reorderChildren) {
John Reck272a6852015-07-29 16:48:58 -0700768 zTranslatedNodes.push_back(ZDrawRenderNodeOpPair(childZ, childOp));
John Reck113e0822014-03-18 09:22:59 -0700769 childOp->mSkipInOrderDraw = true;
John Reckd0a0b2a2014-03-20 16:28:56 -0700770 } else if (!child->properties().getProjectBackwards()) {
John Reck113e0822014-03-18 09:22:59 -0700771 // regular, in order drawing DisplayList
772 childOp->mSkipInOrderDraw = false;
773 }
774 }
775
Chris Craik8afd0f22014-08-21 17:41:57 -0700776 // Z sort any 3d children (stable-ness makes z compare fall back to standard drawing order)
John Reck113e0822014-03-18 09:22:59 -0700777 std::stable_sort(zTranslatedNodes.begin(), zTranslatedNodes.end());
Chris Craikb565df12015-10-05 13:00:52 -0700778#endif
John Reck113e0822014-03-18 09:22:59 -0700779}
780
Chris Craikb265e2c2014-03-27 15:50:09 -0700781template <class T>
782void RenderNode::issueDrawShadowOperation(const Matrix4& transformFromParent, T& handler) {
Chris Craik77b5cad2014-07-30 18:23:07 -0700783 if (properties().getAlpha() <= 0.0f
784 || properties().getOutline().getAlpha() <= 0.0f
Teng-Hui Zhu8d0ec382015-10-01 16:49:16 -0700785 || !properties().getOutline().getPath()
786 || properties().getScaleX() == 0
787 || properties().getScaleY() == 0) {
Chris Craik77b5cad2014-07-30 18:23:07 -0700788 // no shadow to draw
789 return;
790 }
Chris Craikb265e2c2014-03-27 15:50:09 -0700791
792 mat4 shadowMatrixXY(transformFromParent);
793 applyViewPropertyTransforms(shadowMatrixXY);
794
795 // Z matrix needs actual 3d transformation, so mapped z values will be correct
796 mat4 shadowMatrixZ(transformFromParent);
797 applyViewPropertyTransforms(shadowMatrixZ, true);
798
Chris Craik74669862014-08-07 17:27:30 -0700799 const SkPath* casterOutlinePath = properties().getOutline().getPath();
Chris Craikaf4d04c2014-07-29 12:50:14 -0700800 const SkPath* revealClipPath = properties().getRevealClip().getPath();
Chris Craik61317322014-05-21 13:03:52 -0700801 if (revealClipPath && revealClipPath->isEmpty()) return;
802
Chris Craik77b5cad2014-07-30 18:23:07 -0700803 float casterAlpha = properties().getAlpha() * properties().getOutline().getAlpha();
Chris Craik74669862014-08-07 17:27:30 -0700804
Chris Craik74669862014-08-07 17:27:30 -0700805
Chris Craikfaa79ff2014-12-01 13:44:21 -0800806 // holds temporary SkPath to store the result of intersections
Chris Craikd41c4d82015-01-05 15:51:13 -0800807 SkPath* frameAllocatedPath = nullptr;
Chris Craikfaa79ff2014-12-01 13:44:21 -0800808 const SkPath* outlinePath = casterOutlinePath;
809
810 // intersect the outline with the reveal clip, if present
811 if (revealClipPath) {
812 frameAllocatedPath = handler.allocPathForFrame();
813
Tom Hudson02a26302015-06-24 11:32:42 -0400814 Op(*outlinePath, *revealClipPath, kIntersect_SkPathOp, frameAllocatedPath);
Chris Craikfaa79ff2014-12-01 13:44:21 -0800815 outlinePath = frameAllocatedPath;
816 }
817
818 // intersect the outline with the clipBounds, if present
819 if (properties().getClippingFlags() & CLIP_TO_CLIP_BOUNDS) {
820 if (!frameAllocatedPath) {
821 frameAllocatedPath = handler.allocPathForFrame();
822 }
823
824 Rect clipBounds;
825 properties().getClippingRectForFlags(CLIP_TO_CLIP_BOUNDS, &clipBounds);
826 SkPath clipBoundsPath;
827 clipBoundsPath.addRect(clipBounds.left, clipBounds.top,
828 clipBounds.right, clipBounds.bottom);
829
Tom Hudson02a26302015-06-24 11:32:42 -0400830 Op(*outlinePath, clipBoundsPath, kIntersect_SkPathOp, frameAllocatedPath);
Chris Craik74669862014-08-07 17:27:30 -0700831 outlinePath = frameAllocatedPath;
832 }
833
Chris Craikb265e2c2014-03-27 15:50:09 -0700834 DisplayListOp* shadowOp = new (handler.allocator()) DrawShadowOp(
Chris Craik74669862014-08-07 17:27:30 -0700835 shadowMatrixXY, shadowMatrixZ, casterAlpha, outlinePath);
Chris Craikb265e2c2014-03-27 15:50:09 -0700836 handler(shadowOp, PROPERTY_SAVECOUNT, properties().getClipToBounds());
837}
838
John Reck113e0822014-03-18 09:22:59 -0700839#define SHADOW_DELTA 0.1f
840
841template <class T>
Chris Craikc3e75f92014-08-27 15:34:52 -0700842void RenderNode::issueOperationsOf3dChildren(ChildrenSelectMode mode,
John Reck272a6852015-07-29 16:48:58 -0700843 const Matrix4& initialTransform, const std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes,
Chris Craikc3e75f92014-08-27 15:34:52 -0700844 OpenGLRenderer& renderer, T& handler) {
John Reck113e0822014-03-18 09:22:59 -0700845 const int size = zTranslatedNodes.size();
846 if (size == 0
Chris Craikb9ce116d2015-08-20 15:14:06 -0700847 || (mode == ChildrenSelectMode::NegativeZChildren && zTranslatedNodes[0].key > 0.0f)
848 || (mode == ChildrenSelectMode::PositiveZChildren && zTranslatedNodes[size - 1].key < 0.0f)) {
John Reck113e0822014-03-18 09:22:59 -0700849 // no 3d children to draw
850 return;
851 }
852
Chris Craikc3e75f92014-08-27 15:34:52 -0700853 // Apply the base transform of the parent of the 3d children. This isolates
854 // 3d children of the current chunk from transformations made in previous chunks.
855 int rootRestoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag);
Chris Craik6daa13c2015-08-19 13:32:12 -0700856 renderer.setGlobalMatrix(initialTransform);
Chris Craikc3e75f92014-08-27 15:34:52 -0700857
John Reck113e0822014-03-18 09:22:59 -0700858 /**
859 * Draw shadows and (potential) casters mostly in order, but allow the shadows of casters
860 * with very similar Z heights to draw together.
861 *
862 * This way, if Views A & B have the same Z height and are both casting shadows, the shadows are
863 * underneath both, and neither's shadow is drawn on top of the other.
864 */
865 const size_t nonNegativeIndex = findNonNegativeIndex(zTranslatedNodes);
866 size_t drawIndex, shadowIndex, endIndex;
Chris Craikb9ce116d2015-08-20 15:14:06 -0700867 if (mode == ChildrenSelectMode::NegativeZChildren) {
John Reck113e0822014-03-18 09:22:59 -0700868 drawIndex = 0;
869 endIndex = nonNegativeIndex;
870 shadowIndex = endIndex; // draw no shadows
871 } else {
872 drawIndex = nonNegativeIndex;
873 endIndex = size;
874 shadowIndex = drawIndex; // potentially draw shadow for each pos Z child
875 }
Chris Craik3f0854292014-04-15 16:18:08 -0700876
877 DISPLAY_LIST_LOGD("%*s%d %s 3d children:", (handler.level() + 1) * 2, "",
878 endIndex - drawIndex, mode == kNegativeZChildren ? "negative" : "positive");
879
John Reck113e0822014-03-18 09:22:59 -0700880 float lastCasterZ = 0.0f;
881 while (shadowIndex < endIndex || drawIndex < endIndex) {
882 if (shadowIndex < endIndex) {
Chris Craika7090e02014-06-20 16:01:00 -0700883 DrawRenderNodeOp* casterOp = zTranslatedNodes[shadowIndex].value;
Chris Craikb565df12015-10-05 13:00:52 -0700884 RenderNode* caster = casterOp->renderNode;
John Reck113e0822014-03-18 09:22:59 -0700885 const float casterZ = zTranslatedNodes[shadowIndex].key;
886 // attempt to render the shadow if the caster about to be drawn is its caster,
887 // OR if its caster's Z value is similar to the previous potential caster
888 if (shadowIndex == drawIndex || casterZ - lastCasterZ < SHADOW_DELTA) {
Chris Craikb265e2c2014-03-27 15:50:09 -0700889 caster->issueDrawShadowOperation(casterOp->mTransformFromParent, handler);
John Reck113e0822014-03-18 09:22:59 -0700890
891 lastCasterZ = casterZ; // must do this even if current caster not casting a shadow
892 shadowIndex++;
893 continue;
894 }
895 }
896
897 // only the actual child DL draw needs to be in save/restore,
898 // since it modifies the renderer's matrix
899 int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag);
900
Chris Craika7090e02014-06-20 16:01:00 -0700901 DrawRenderNodeOp* childOp = zTranslatedNodes[drawIndex].value;
John Reck113e0822014-03-18 09:22:59 -0700902
903 renderer.concatMatrix(childOp->mTransformFromParent);
904 childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone
John Reckd0a0b2a2014-03-20 16:28:56 -0700905 handler(childOp, renderer.getSaveCount() - 1, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -0700906 childOp->mSkipInOrderDraw = true;
907
908 renderer.restoreToCount(restoreTo);
909 drawIndex++;
910 }
Chris Craikc3e75f92014-08-27 15:34:52 -0700911 renderer.restoreToCount(rootRestoreTo);
John Reck113e0822014-03-18 09:22:59 -0700912}
913
914template <class T>
Chris Craikb265e2c2014-03-27 15:50:09 -0700915void RenderNode::issueOperationsOfProjectedChildren(OpenGLRenderer& renderer, T& handler) {
Chris Craik3f0854292014-04-15 16:18:08 -0700916 DISPLAY_LIST_LOGD("%*s%d projected children:", (handler.level() + 1) * 2, "", mProjectedNodes.size());
917 const SkPath* projectionReceiverOutline = properties().getOutline().getPath();
Chris Craik3f0854292014-04-15 16:18:08 -0700918 int restoreTo = renderer.getSaveCount();
919
Chris Craikb3cca872014-08-08 18:42:51 -0700920 LinearAllocator& alloc = handler.allocator();
921 handler(new (alloc) SaveOp(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag),
922 PROPERTY_SAVECOUNT, properties().getClipToBounds());
923
924 // Transform renderer to match background we're projecting onto
925 // (by offsetting canvas by translationX/Y of background rendernode, since only those are set)
926 const DisplayListOp* op =
Chris Craik10ed6922015-10-15 10:55:15 -0700927#if HWUI_NEW_OPS
928 nullptr;
929 LOG_ALWAYS_FATAL("unsupported");
930#else
Chris Craik003cc3d2015-10-16 10:24:55 -0700931 (mDisplayList->getOps()[mDisplayList->projectionReceiveIndex]);
Chris Craik10ed6922015-10-15 10:55:15 -0700932#endif
Chris Craikb3cca872014-08-08 18:42:51 -0700933 const DrawRenderNodeOp* backgroundOp = reinterpret_cast<const DrawRenderNodeOp*>(op);
Chris Craikb565df12015-10-05 13:00:52 -0700934 const RenderProperties& backgroundProps = backgroundOp->renderNode->properties();
Chris Craikb3cca872014-08-08 18:42:51 -0700935 renderer.translate(backgroundProps.getTranslationX(), backgroundProps.getTranslationY());
936
Chris Craik6fe991e52015-10-20 09:39:42 -0700937 // If the projection receiver has an outline, we mask projected content to it
Chris Craikfca52b752015-04-28 11:45:59 -0700938 // (which we know, apriori, are all tessellated paths)
939 renderer.setProjectionPathMask(alloc, projectionReceiverOutline);
Chris Craik3f0854292014-04-15 16:18:08 -0700940
941 // draw projected nodes
John Reck113e0822014-03-18 09:22:59 -0700942 for (size_t i = 0; i < mProjectedNodes.size(); i++) {
Chris Craika7090e02014-06-20 16:01:00 -0700943 DrawRenderNodeOp* childOp = mProjectedNodes[i];
John Reck113e0822014-03-18 09:22:59 -0700944
945 // matrix save, concat, and restore can be done safely without allocating operations
946 int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag);
947 renderer.concatMatrix(childOp->mTransformFromCompositingAncestor);
948 childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone
John Reckd0a0b2a2014-03-20 16:28:56 -0700949 handler(childOp, renderer.getSaveCount() - 1, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -0700950 childOp->mSkipInOrderDraw = true;
951 renderer.restoreToCount(restoreTo);
952 }
Chris Craik3f0854292014-04-15 16:18:08 -0700953
Chris Craikfca52b752015-04-28 11:45:59 -0700954 handler(new (alloc) RestoreToCountOp(restoreTo),
955 PROPERTY_SAVECOUNT, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -0700956}
957
958/**
959 * This function serves both defer and replay modes, and will organize the displayList's component
960 * operations for a single frame:
961 *
962 * Every 'simple' state operation that affects just the matrix and alpha (or other factors of
963 * DeferredDisplayState) may be issued directly to the renderer, but complex operations (with custom
964 * defer logic) and operations in displayListOps are issued through the 'handler' which handles the
965 * defer vs replay logic, per operation
966 */
967template <class T>
Chris Craikb265e2c2014-03-27 15:50:09 -0700968void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) {
Chris Craik003cc3d2015-10-16 10:24:55 -0700969 if (mDisplayList->isEmpty()) {
Chris Craikbf72eb82015-06-08 11:30:44 -0700970 DISPLAY_LIST_LOGD("%*sEmpty display list (%p, %s)", handler.level() * 2, "",
971 this, getName());
Chris Craik06451282014-07-21 10:25:54 -0700972 return;
973 }
974
Chris Craik51d6a3d2014-12-22 17:16:56 -0800975 const bool drawLayer = (mLayer && (&renderer != mLayer->renderer.get()));
John Reck25fbb3f2014-06-12 13:46:45 -0700976 // If we are updating the contents of mLayer, we don't want to apply any of
977 // the RenderNode's properties to this issueOperations pass. Those will all
978 // be applied when the layer is drawn, aka when this is true.
979 const bool useViewProperties = (!mLayer || drawLayer);
Chris Craik06451282014-07-21 10:25:54 -0700980 if (useViewProperties) {
981 const Outline& outline = properties().getOutline();
Teng-Hui Zhu8d0ec382015-10-01 16:49:16 -0700982 if (properties().getAlpha() <= 0
983 || (outline.getShouldClip() && outline.isEmpty())
984 || properties().getScaleX() == 0
985 || properties().getScaleY() == 0) {
Chris Craikbf72eb82015-06-08 11:30:44 -0700986 DISPLAY_LIST_LOGD("%*sRejected display list (%p, %s)", handler.level() * 2, "",
987 this, getName());
Chris Craik06451282014-07-21 10:25:54 -0700988 return;
989 }
John Reck113e0822014-03-18 09:22:59 -0700990 }
991
Chris Craik3f0854292014-04-15 16:18:08 -0700992 handler.startMark(getName());
Chris Craikb265e2c2014-03-27 15:50:09 -0700993
John Reck113e0822014-03-18 09:22:59 -0700994#if DEBUG_DISPLAY_LIST
Chris Craik3f0854292014-04-15 16:18:08 -0700995 const Rect& clipRect = renderer.getLocalClipBounds();
996 DISPLAY_LIST_LOGD("%*sStart display list (%p, %s), localClipBounds: %.0f, %.0f, %.0f, %.0f",
Chris Craik03188872015-02-02 18:39:33 -0800997 handler.level() * 2, "", this, getName(),
Chris Craik3f0854292014-04-15 16:18:08 -0700998 clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
John Reck113e0822014-03-18 09:22:59 -0700999#endif
1000
1001 LinearAllocator& alloc = handler.allocator();
1002 int restoreTo = renderer.getSaveCount();
1003 handler(new (alloc) SaveOp(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag),
John Reckd0a0b2a2014-03-20 16:28:56 -07001004 PROPERTY_SAVECOUNT, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -07001005
Chris Craikbf72eb82015-06-08 11:30:44 -07001006 DISPLAY_LIST_LOGD("%*sSave %d %d", (handler.level() + 1) * 2, "",
John Reck113e0822014-03-18 09:22:59 -07001007 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag, restoreTo);
1008
John Reck25fbb3f2014-06-12 13:46:45 -07001009 if (useViewProperties) {
1010 setViewProperties<T>(renderer, handler);
1011 }
John Reck113e0822014-03-18 09:22:59 -07001012
Chris Craik10ed6922015-10-15 10:55:15 -07001013#if HWUI_NEW_OPS
1014 LOG_ALWAYS_FATAL("legacy op traversal not supported");
1015#else
Chris Craik8c271ca2014-03-25 10:33:01 -07001016 bool quickRejected = properties().getClipToBounds()
1017 && renderer.quickRejectConservative(0, 0, properties().getWidth(), properties().getHeight());
John Reck113e0822014-03-18 09:22:59 -07001018 if (!quickRejected) {
Chris Craikc3e75f92014-08-27 15:34:52 -07001019 Matrix4 initialTransform(*(renderer.currentTransform()));
Tom Hudsonac7b6d32015-06-30 11:26:13 -04001020 renderer.setBaseTransform(initialTransform);
Chris Craikc3e75f92014-08-27 15:34:52 -07001021
John Reck25fbb3f2014-06-12 13:46:45 -07001022 if (drawLayer) {
Chris Craik3aadd602015-08-20 12:41:40 -07001023 handler(new (alloc) DrawLayerOp(mLayer),
John Reck25fbb3f2014-06-12 13:46:45 -07001024 renderer.getSaveCount() - 1, properties().getClipToBounds());
1025 } else {
Chris Craikc166b6c2014-09-05 19:55:30 -07001026 const int saveCountOffset = renderer.getSaveCount() - 1;
Chris Craik003cc3d2015-10-16 10:24:55 -07001027 const int projectionReceiveIndex = mDisplayList->projectionReceiveIndex;
1028 for (size_t chunkIndex = 0; chunkIndex < mDisplayList->getChunks().size(); chunkIndex++) {
1029 const DisplayList::Chunk& chunk = mDisplayList->getChunks()[chunkIndex];
John Reck113e0822014-03-18 09:22:59 -07001030
John Reck272a6852015-07-29 16:48:58 -07001031 std::vector<ZDrawRenderNodeOpPair> zTranslatedNodes;
Chris Craik8afd0f22014-08-21 17:41:57 -07001032 buildZSortedChildList(chunk, zTranslatedNodes);
1033
Chris Craikb9ce116d2015-08-20 15:14:06 -07001034 issueOperationsOf3dChildren(ChildrenSelectMode::NegativeZChildren,
Chris Craikc3e75f92014-08-27 15:34:52 -07001035 initialTransform, zTranslatedNodes, renderer, handler);
1036
Andreas Gampeedaecc12014-11-10 20:54:07 -08001037 for (size_t opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) {
Chris Craik003cc3d2015-10-16 10:24:55 -07001038 DisplayListOp *op = mDisplayList->getOps()[opIndex];
Chris Craik80d49022014-06-20 15:03:43 -07001039#if DEBUG_DISPLAY_LIST
Chris Craik03188872015-02-02 18:39:33 -08001040 op->output(handler.level() + 1);
Chris Craik80d49022014-06-20 15:03:43 -07001041#endif
Chris Craik8afd0f22014-08-21 17:41:57 -07001042 handler(op, saveCountOffset, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -07001043
John Reck272a6852015-07-29 16:48:58 -07001044 if (CC_UNLIKELY(!mProjectedNodes.empty() && projectionReceiveIndex >= 0 &&
Andreas Gampeedaecc12014-11-10 20:54:07 -08001045 opIndex == static_cast<size_t>(projectionReceiveIndex))) {
Chris Craik8afd0f22014-08-21 17:41:57 -07001046 issueOperationsOfProjectedChildren(renderer, handler);
1047 }
John Reck25fbb3f2014-06-12 13:46:45 -07001048 }
John Reck113e0822014-03-18 09:22:59 -07001049
Chris Craikb9ce116d2015-08-20 15:14:06 -07001050 issueOperationsOf3dChildren(ChildrenSelectMode::PositiveZChildren,
Chris Craikc3e75f92014-08-27 15:34:52 -07001051 initialTransform, zTranslatedNodes, renderer, handler);
Chris Craik8afd0f22014-08-21 17:41:57 -07001052 }
John Reck25fbb3f2014-06-12 13:46:45 -07001053 }
John Reck113e0822014-03-18 09:22:59 -07001054 }
Chris Craik10ed6922015-10-15 10:55:15 -07001055#endif
John Reck113e0822014-03-18 09:22:59 -07001056
Chris Craikbf72eb82015-06-08 11:30:44 -07001057 DISPLAY_LIST_LOGD("%*sRestoreToCount %d", (handler.level() + 1) * 2, "", restoreTo);
John Reck113e0822014-03-18 09:22:59 -07001058 handler(new (alloc) RestoreToCountOp(restoreTo),
John Reckd0a0b2a2014-03-20 16:28:56 -07001059 PROPERTY_SAVECOUNT, properties().getClipToBounds());
Chris Craikb265e2c2014-03-27 15:50:09 -07001060
Chris Craikbf72eb82015-06-08 11:30:44 -07001061 DISPLAY_LIST_LOGD("%*sDone (%p, %s)", handler.level() * 2, "", this, getName());
Chris Craikb265e2c2014-03-27 15:50:09 -07001062 handler.endMark();
John Reck113e0822014-03-18 09:22:59 -07001063}
1064
1065} /* namespace uirenderer */
1066} /* namespace android */