blob: 39cb8e9229b10caeb70ced701606dc30a3998fed [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 Reck9dea0d52015-10-27 10:04:38 -070081 // If mParentCount == 0 we are the sole reference to this RenderNode,
82 // so immediately free the old display list
83 if (!mParentCount && !mStagingDisplayList) {
84 deleteDisplayList();
85 }
John Reck113e0822014-03-18 09:22:59 -070086}
87
88/**
89 * This function is a simplified version of replay(), where we simply retrieve and log the
90 * display list. This function should remain in sync with the replay() function.
91 */
92void RenderNode::output(uint32_t level) {
Chris Craikbf72eb82015-06-08 11:30:44 -070093 ALOGD("%*sStart display list (%p, %s%s%s%s%s%s)", (level - 1) * 2, "", this,
Chris Craikb5a54352014-11-21 14:54:35 -080094 getName(),
Chris Craik43a1d312015-05-27 11:28:14 -070095 (MathUtils::isZero(properties().getAlpha()) ? ", zero alpha" : ""),
Chris Craikb5a54352014-11-21 14:54:35 -080096 (properties().hasShadow() ? ", casting shadow" : ""),
97 (isRenderable() ? "" : ", empty"),
Chris Craikbf72eb82015-06-08 11:30:44 -070098 (properties().getProjectBackwards() ? ", projected" : ""),
Chris Craikd41c4d82015-01-05 15:51:13 -080099 (mLayer != nullptr ? ", on HW Layer" : ""));
John Reck113e0822014-03-18 09:22:59 -0700100 ALOGD("%*s%s %d", level * 2, "", "Save",
101 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
102
John Reckd0a0b2a2014-03-20 16:28:56 -0700103 properties().debugOutputProperties(level);
Chris Craik10ed6922015-10-15 10:55:15 -0700104
Chris Craik003cc3d2015-10-16 10:24:55 -0700105 if (mDisplayList) {
Chris Craik10ed6922015-10-15 10:55:15 -0700106#if HWUI_NEW_OPS
107 LOG_ALWAYS_FATAL("op dumping unsupported");
108#else
Chris Craik8afd0f22014-08-21 17:41:57 -0700109 // TODO: consider printing the chunk boundaries here
Chris Craik003cc3d2015-10-16 10:24:55 -0700110 for (auto&& op : mDisplayList->getOps()) {
Chris Craik10ed6922015-10-15 10:55:15 -0700111 op->output(level, DisplayListOp::kOpLogFlag_Recurse);
John Reckdc0349b2014-08-06 15:28:07 -0700112 }
Chris Craik10ed6922015-10-15 10:55:15 -0700113#endif
John Reck113e0822014-03-18 09:22:59 -0700114 }
115
Chris Craik3f0854292014-04-15 16:18:08 -0700116 ALOGD("%*sDone (%p, %s)", (level - 1) * 2, "", this, getName());
John Reck113e0822014-03-18 09:22:59 -0700117}
118
John Recke248bd12015-08-05 13:53:53 -0700119void RenderNode::copyTo(proto::RenderNode *pnode) {
120 pnode->set_id(static_cast<uint64_t>(
121 reinterpret_cast<uintptr_t>(this)));
122 pnode->set_name(mName.string(), mName.length());
123
124 proto::RenderProperties* pprops = pnode->mutable_properties();
125 pprops->set_left(properties().getLeft());
126 pprops->set_top(properties().getTop());
127 pprops->set_right(properties().getRight());
128 pprops->set_bottom(properties().getBottom());
129 pprops->set_clip_flags(properties().getClippingFlags());
130 pprops->set_alpha(properties().getAlpha());
131 pprops->set_translation_x(properties().getTranslationX());
132 pprops->set_translation_y(properties().getTranslationY());
133 pprops->set_translation_z(properties().getTranslationZ());
134 pprops->set_elevation(properties().getElevation());
135 pprops->set_rotation(properties().getRotation());
136 pprops->set_rotation_x(properties().getRotationX());
137 pprops->set_rotation_y(properties().getRotationY());
138 pprops->set_scale_x(properties().getScaleX());
139 pprops->set_scale_y(properties().getScaleY());
140 pprops->set_pivot_x(properties().getPivotX());
141 pprops->set_pivot_y(properties().getPivotY());
142 pprops->set_has_overlapping_rendering(properties().getHasOverlappingRendering());
143 pprops->set_pivot_explicitly_set(properties().isPivotExplicitlySet());
144 pprops->set_project_backwards(properties().getProjectBackwards());
145 pprops->set_projection_receiver(properties().isProjectionReceiver());
146 set(pprops->mutable_clip_bounds(), properties().getClipBounds());
147
148 const Outline& outline = properties().getOutline();
149 if (outline.getType() != Outline::Type::None) {
150 proto::Outline* poutline = pprops->mutable_outline();
151 poutline->clear_path();
152 if (outline.getType() == Outline::Type::Empty) {
153 poutline->set_type(proto::Outline_Type_Empty);
154 } else if (outline.getType() == Outline::Type::ConvexPath) {
155 poutline->set_type(proto::Outline_Type_ConvexPath);
156 if (const SkPath* path = outline.getPath()) {
157 set(poutline->mutable_path(), *path);
158 }
159 } else if (outline.getType() == Outline::Type::RoundRect) {
160 poutline->set_type(proto::Outline_Type_RoundRect);
161 } else {
162 ALOGW("Uknown outline type! %d", static_cast<int>(outline.getType()));
163 poutline->set_type(proto::Outline_Type_None);
164 }
165 poutline->set_should_clip(outline.getShouldClip());
166 poutline->set_alpha(outline.getAlpha());
167 poutline->set_radius(outline.getRadius());
168 set(poutline->mutable_bounds(), outline.getBounds());
169 } else {
170 pprops->clear_outline();
171 }
172
173 const RevealClip& revealClip = properties().getRevealClip();
174 if (revealClip.willClip()) {
175 proto::RevealClip* prevealClip = pprops->mutable_reveal_clip();
176 prevealClip->set_x(revealClip.getX());
177 prevealClip->set_y(revealClip.getY());
178 prevealClip->set_radius(revealClip.getRadius());
179 } else {
180 pprops->clear_reveal_clip();
181 }
182
183 pnode->clear_children();
Chris Craik003cc3d2015-10-16 10:24:55 -0700184 if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700185 for (auto&& child : mDisplayList->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700186 child->renderNode->copyTo(pnode->add_children());
John Recke248bd12015-08-05 13:53:53 -0700187 }
188 }
189}
190
John Reckfe5e7b72014-05-23 17:42:28 -0700191int RenderNode::getDebugSize() {
192 int size = sizeof(RenderNode);
Chris Craik003cc3d2015-10-16 10:24:55 -0700193 if (mStagingDisplayList) {
194 size += mStagingDisplayList->getUsedSize();
John Reckfe5e7b72014-05-23 17:42:28 -0700195 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700196 if (mDisplayList && mDisplayList != mStagingDisplayList) {
197 size += mDisplayList->getUsedSize();
John Reckfe5e7b72014-05-23 17:42:28 -0700198 }
199 return size;
200}
201
John Reckf4198b72014-04-09 17:00:04 -0700202void RenderNode::prepareTree(TreeInfo& info) {
203 ATRACE_CALL();
Chris Craik69e5adf2014-08-14 13:34:01 -0700204 LOG_ALWAYS_FATAL_IF(!info.damageAccumulator, "DamageAccumulator missing");
John Reckf4198b72014-04-09 17:00:04 -0700205
Chris Craika766cb22015-06-08 16:49:43 -0700206 // Functors don't correctly handle stencil usage of overdraw debugging - shove 'em in a layer.
207 bool functorsNeedLayer = Properties::debugOverdraw;
208
209 prepareTreeImpl(info, functorsNeedLayer);
John Reckf4198b72014-04-09 17:00:04 -0700210}
211
John Reck68bfe0a2014-06-24 15:34:58 -0700212void RenderNode::addAnimator(const sp<BaseRenderNodeAnimator>& animator) {
213 mAnimatorManager.addAnimator(animator);
214}
215
John Recke4267ea2014-06-03 15:53:15 -0700216void RenderNode::damageSelf(TreeInfo& info) {
John Reckce9f3082014-06-17 16:18:09 -0700217 if (isRenderable()) {
John Reck293e8682014-06-17 10:34:02 -0700218 if (properties().getClipDamageToBounds()) {
John Recka447d292014-06-11 18:39:44 -0700219 info.damageAccumulator->dirty(0, 0, properties().getWidth(), properties().getHeight());
220 } else {
221 // Hope this is big enough?
222 // TODO: Get this from the display list ops or something
John Reckc1288232015-08-12 13:39:11 -0700223 info.damageAccumulator->dirty(DIRTY_MIN, DIRTY_MIN, DIRTY_MAX, DIRTY_MAX);
John Recka447d292014-06-11 18:39:44 -0700224 }
John Recke4267ea2014-06-03 15:53:15 -0700225 }
226}
227
John Recka7c2ea22014-08-08 13:21:00 -0700228void RenderNode::prepareLayer(TreeInfo& info, uint32_t dirtyMask) {
Chris Craik856f0cc2015-04-21 15:13:29 -0700229 LayerType layerType = properties().effectiveLayerType();
Chris Craik182952f2015-03-09 14:17:29 -0700230 if (CC_UNLIKELY(layerType == LayerType::RenderLayer)) {
John Recka7c2ea22014-08-08 13:21:00 -0700231 // Damage applied so far needs to affect our parent, but does not require
232 // the layer to be updated. So we pop/push here to clear out the current
233 // damage and get a clean state for display list or children updates to
234 // affect, which will require the layer to be updated
235 info.damageAccumulator->popTransform();
236 info.damageAccumulator->pushTransform(this);
237 if (dirtyMask & DISPLAY_LIST) {
238 damageSelf(info);
239 }
John Reck25fbb3f2014-06-12 13:46:45 -0700240 }
241}
242
243void RenderNode::pushLayerUpdate(TreeInfo& info) {
Chris Craik856f0cc2015-04-21 15:13:29 -0700244 LayerType layerType = properties().effectiveLayerType();
John Reck25fbb3f2014-06-12 13:46:45 -0700245 // If we are not a layer OR we cannot be rendered (eg, view was detached)
246 // we need to destroy any Layers we may have had previously
Chris Craik182952f2015-03-09 14:17:29 -0700247 if (CC_LIKELY(layerType != LayerType::RenderLayer) || CC_UNLIKELY(!isRenderable())) {
John Reck25fbb3f2014-06-12 13:46:45 -0700248 if (CC_UNLIKELY(mLayer)) {
249 LayerRenderer::destroyLayer(mLayer);
Chris Craikd41c4d82015-01-05 15:51:13 -0800250 mLayer = nullptr;
John Reck25fbb3f2014-06-12 13:46:45 -0700251 }
252 return;
253 }
254
Chris Craik69e5adf2014-08-14 13:34:01 -0700255 bool transformUpdateNeeded = false;
John Reck25fbb3f2014-06-12 13:46:45 -0700256 if (!mLayer) {
Chris Craike2e53a72015-10-28 15:55:40 -0700257 mLayer = LayerRenderer::createRenderLayer(
258 info.canvasContext.getRenderState(), 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) {
John Reck77c40102015-10-26 15:49:47 -0700277 std::ostringstream err;
278 err << "Unable to create layer for " << getName();
279 const int maxTextureSize = Caches::getInstance().maxTextureSize;
280 if (getWidth() > maxTextureSize || getHeight() > maxTextureSize) {
281 err << ", size " << getWidth() << "x" << getHeight()
282 << " exceeds max size " << maxTextureSize;
283 } else {
284 err << ", see logcat for more info";
285 }
286 info.errorHandler->onError(err.str());
John Reckc25e5062014-06-18 14:21:29 -0700287 }
288 return;
289 }
290
Chris Craikc71bfca2014-08-21 10:18:58 -0700291 if (transformUpdateNeeded) {
292 // update the transform in window of the layer to reset its origin wrt light source position
293 Matrix4 windowTransform;
294 info.damageAccumulator->computeCurrentTransform(&windowTransform);
295 mLayer->setWindowTransform(windowTransform);
296 }
John Reckc79eabc2014-08-05 11:03:42 -0700297
298 if (dirty.intersect(0, 0, getWidth(), getHeight())) {
Mike Reed71487eb2014-11-19 16:13:20 -0500299 dirty.roundOut(&dirty);
John Reck25fbb3f2014-06-12 13:46:45 -0700300 mLayer->updateDeferred(this, dirty.fLeft, dirty.fTop, dirty.fRight, dirty.fBottom);
301 }
302 // This is not inside the above if because we may have called
303 // updateDeferred on a previous prepare pass that didn't have a renderer
304 if (info.renderer && mLayer->deferredUpdateScheduled) {
305 info.renderer->pushLayerUpdate(mLayer);
306 }
John Reck998a6d82014-08-28 15:35:53 -0700307
Chris Craike2e53a72015-10-28 15:55:40 -0700308 // There might be prefetched layers that need to be accounted for.
309 // That might be us, so tell CanvasContext that this layer is in the
310 // tree and should not be destroyed.
311 info.canvasContext.markLayerInUse(this);
John Reck25fbb3f2014-06-12 13:46:45 -0700312}
313
Chris Craika766cb22015-06-08 16:49:43 -0700314/**
315 * Traverse down the the draw tree to prepare for a frame.
316 *
317 * MODE_FULL = UI Thread-driven (thus properties must be synced), otherwise RT driven
318 *
319 * While traversing down the tree, functorsNeedLayer flag is set to true if anything that uses the
320 * stencil buffer may be needed. Views that use a functor to draw will be forced onto a layer.
321 */
322void RenderNode::prepareTreeImpl(TreeInfo& info, bool functorsNeedLayer) {
John Recka447d292014-06-11 18:39:44 -0700323 info.damageAccumulator->pushTransform(this);
John Reckf47a5942014-06-30 16:20:04 -0700324
John Reckdcba6722014-07-08 13:59:49 -0700325 if (info.mode == TreeInfo::MODE_FULL) {
John Reck25fbb3f2014-06-12 13:46:45 -0700326 pushStagingPropertiesChanges(info);
John Recke45b1fd2014-04-15 09:50:16 -0700327 }
John Reck9eb9f6f2014-08-21 11:23:05 -0700328 uint32_t animatorDirtyMask = 0;
329 if (CC_LIKELY(info.runAnimations)) {
330 animatorDirtyMask = mAnimatorManager.animate(info);
331 }
Chris Craika766cb22015-06-08 16:49:43 -0700332
John Reck3f725f02015-06-16 10:29:31 -0700333 bool willHaveFunctor = false;
Chris Craik003cc3d2015-10-16 10:24:55 -0700334 if (info.mode == TreeInfo::MODE_FULL && mStagingDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700335 willHaveFunctor = !mStagingDisplayList->getFunctors().empty();
Chris Craik003cc3d2015-10-16 10:24:55 -0700336 } else if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700337 willHaveFunctor = !mDisplayList->getFunctors().empty();
John Reck3f725f02015-06-16 10:29:31 -0700338 }
Chris Craika766cb22015-06-08 16:49:43 -0700339 bool childFunctorsNeedLayer = mProperties.prepareForFunctorPresence(
340 willHaveFunctor, functorsNeedLayer);
341
John Recka7c2ea22014-08-08 13:21:00 -0700342 prepareLayer(info, animatorDirtyMask);
John Reckdcba6722014-07-08 13:59:49 -0700343 if (info.mode == TreeInfo::MODE_FULL) {
John Reck25fbb3f2014-06-12 13:46:45 -0700344 pushStagingDisplayListChanges(info);
345 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700346 prepareSubTree(info, childFunctorsNeedLayer, mDisplayList);
John Reck25fbb3f2014-06-12 13:46:45 -0700347 pushLayerUpdate(info);
348
John Recka447d292014-06-11 18:39:44 -0700349 info.damageAccumulator->popTransform();
John Reckf4198b72014-04-09 17:00:04 -0700350}
351
Chris Craikb565df12015-10-05 13:00:52 -0700352void RenderNode::syncProperties() {
353 mProperties = mStagingProperties;
354}
355
John Reck25fbb3f2014-06-12 13:46:45 -0700356void RenderNode::pushStagingPropertiesChanges(TreeInfo& info) {
John Reckff941dc2014-05-14 16:34:14 -0700357 // Push the animators first so that setupStartValueIfNecessary() is called
358 // before properties() is trampled by stagingProperties(), as they are
359 // required by some animators.
John Reck9eb9f6f2014-08-21 11:23:05 -0700360 if (CC_LIKELY(info.runAnimations)) {
John Reck119907c2014-08-14 09:02:01 -0700361 mAnimatorManager.pushStaging();
John Reck9eb9f6f2014-08-21 11:23:05 -0700362 }
John Reckff941dc2014-05-14 16:34:14 -0700363 if (mDirtyPropertyFields) {
364 mDirtyPropertyFields = 0;
John Recke4267ea2014-06-03 15:53:15 -0700365 damageSelf(info);
John Recka447d292014-06-11 18:39:44 -0700366 info.damageAccumulator->popTransform();
Chris Craikb565df12015-10-05 13:00:52 -0700367 syncProperties();
John Reck25fbb3f2014-06-12 13:46:45 -0700368 applyLayerPropertiesToLayer(info);
John Recke4267ea2014-06-03 15:53:15 -0700369 // We could try to be clever and only re-damage if the matrix changed.
370 // However, we don't need to worry about that. The cost of over-damaging
371 // here is only going to be a single additional map rect of this node
372 // plus a rect join(). The parent's transform (and up) will only be
373 // performed once.
John Recka447d292014-06-11 18:39:44 -0700374 info.damageAccumulator->pushTransform(this);
John Recke4267ea2014-06-03 15:53:15 -0700375 damageSelf(info);
John Reckff941dc2014-05-14 16:34:14 -0700376 }
John Reck25fbb3f2014-06-12 13:46:45 -0700377}
378
Andreas Gampe64bb4132014-11-22 00:35:09 +0000379void RenderNode::applyLayerPropertiesToLayer(TreeInfo& info) {
John Reck25fbb3f2014-06-12 13:46:45 -0700380 if (CC_LIKELY(!mLayer)) return;
381
382 const LayerProperties& props = properties().layerProperties();
383 mLayer->setAlpha(props.alpha(), props.xferMode());
384 mLayer->setColorFilter(props.colorFilter());
385 mLayer->setBlend(props.needsBlending());
386}
387
Chris Craikb565df12015-10-05 13:00:52 -0700388void RenderNode::syncDisplayList() {
389 // Make sure we inc first so that we don't fluctuate between 0 and 1,
390 // which would thrash the layer cache
Chris Craik003cc3d2015-10-16 10:24:55 -0700391 if (mStagingDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700392 for (auto&& child : mStagingDisplayList->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700393 child->renderNode->incParentRefCount();
394 }
395 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700396 deleteDisplayList();
397 mDisplayList = mStagingDisplayList;
398 mStagingDisplayList = nullptr;
399 if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700400 for (size_t i = 0; i < mDisplayList->getFunctors().size(); i++) {
401 (*mDisplayList->getFunctors()[i])(DrawGlInfo::kModeSync, nullptr);
Chris Craikb565df12015-10-05 13:00:52 -0700402 }
403 }
404}
405
John Reck25fbb3f2014-06-12 13:46:45 -0700406void RenderNode::pushStagingDisplayListChanges(TreeInfo& info) {
Chris Craik003cc3d2015-10-16 10:24:55 -0700407 if (mNeedsDisplayListSync) {
408 mNeedsDisplayListSync = false;
John Reck5c9d7172014-10-22 11:32:27 -0700409 // Damage with the old display list first then the new one to catch any
410 // changes in isRenderable or, in the future, bounds
411 damageSelf(info);
Chris Craikb565df12015-10-05 13:00:52 -0700412 syncDisplayList();
John Recke4267ea2014-06-03 15:53:15 -0700413 damageSelf(info);
John Reck8de65a82014-04-09 15:23:38 -0700414 }
John Reck8de65a82014-04-09 15:23:38 -0700415}
416
Chris Craik003cc3d2015-10-16 10:24:55 -0700417void RenderNode::deleteDisplayList() {
418 if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700419 for (auto&& child : mDisplayList->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700420 child->renderNode->decParentRefCount();
John Reckdcba6722014-07-08 13:59:49 -0700421 }
422 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700423 delete mDisplayList;
424 mDisplayList = nullptr;
John Reckdcba6722014-07-08 13:59:49 -0700425}
426
Chris Craik003cc3d2015-10-16 10:24:55 -0700427void RenderNode::prepareSubTree(TreeInfo& info, bool functorsNeedLayer, DisplayList* subtree) {
John Reck8de65a82014-04-09 15:23:38 -0700428 if (subtree) {
John Reck860d1552014-04-11 19:15:05 -0700429 TextureCache& cache = Caches::getInstance().textureCache;
Chris Craikb36af872015-10-16 14:23:12 -0700430 info.out.hasFunctors |= subtree->getFunctors().size();
431 for (auto&& bitmapResource : subtree->getBitmapResources()) {
Chris Craike2e53a72015-10-28 15:55:40 -0700432 void* ownerToken = &info.canvasContext;
433 info.prepareTextures = cache.prefetchAndMarkInUse(ownerToken, bitmapResource);
John Reckf4198b72014-04-09 17:00:04 -0700434 }
Chris Craikb36af872015-10-16 14:23:12 -0700435 for (auto&& op : subtree->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700436 RenderNode* childNode = op->renderNode;
437#if HWUI_NEW_OPS
438 info.damageAccumulator->pushTransform(&op->localMatrix);
439 bool childFunctorsNeedLayer = functorsNeedLayer; // TODO! || op->mRecordedWithPotentialStencilClip;
440#else
John Recka447d292014-06-11 18:39:44 -0700441 info.damageAccumulator->pushTransform(&op->mTransformFromParent);
Chris Craika766cb22015-06-08 16:49:43 -0700442 bool childFunctorsNeedLayer = functorsNeedLayer
443 // Recorded with non-rect clip, or canvas-rotated by parent
444 || op->mRecordedWithPotentialStencilClip;
Chris Craikb565df12015-10-05 13:00:52 -0700445#endif
Chris Craika766cb22015-06-08 16:49:43 -0700446 childNode->prepareTreeImpl(info, childFunctorsNeedLayer);
John Recka447d292014-06-11 18:39:44 -0700447 info.damageAccumulator->popTransform();
John Reck5bf11bb2014-03-25 10:22:09 -0700448 }
John Reck113e0822014-03-18 09:22:59 -0700449 }
450}
451
John Reckdcba6722014-07-08 13:59:49 -0700452void RenderNode::destroyHardwareResources() {
453 if (mLayer) {
454 LayerRenderer::destroyLayer(mLayer);
Chris Craikd41c4d82015-01-05 15:51:13 -0800455 mLayer = nullptr;
John Reckdcba6722014-07-08 13:59:49 -0700456 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700457 if (mDisplayList) {
Chris Craikb36af872015-10-16 14:23:12 -0700458 for (auto&& child : mDisplayList->getChildren()) {
Chris Craikb565df12015-10-05 13:00:52 -0700459 child->renderNode->destroyHardwareResources();
John Reckdcba6722014-07-08 13:59:49 -0700460 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700461 if (mNeedsDisplayListSync) {
John Reckdcba6722014-07-08 13:59:49 -0700462 // Next prepare tree we are going to push a new display list, so we can
463 // drop our current one now
Chris Craik003cc3d2015-10-16 10:24:55 -0700464 deleteDisplayList();
John Reckdcba6722014-07-08 13:59:49 -0700465 }
466 }
467}
468
469void RenderNode::decParentRefCount() {
470 LOG_ALWAYS_FATAL_IF(!mParentCount, "already 0!");
471 mParentCount--;
472 if (!mParentCount) {
473 // If a child of ours is being attached to our parent then this will incorrectly
474 // destroy its hardware resources. However, this situation is highly unlikely
475 // and the failure is "just" that the layer is re-created, so this should
476 // be safe enough
477 destroyHardwareResources();
478 }
479}
480
Chris Craikb565df12015-10-05 13:00:52 -0700481bool RenderNode::applyViewProperties(CanvasState& canvasState) const {
482 const Outline& outline = properties().getOutline();
483 if (properties().getAlpha() <= 0
484 || (outline.getShouldClip() && outline.isEmpty())
485 || properties().getScaleX() == 0
486 || properties().getScaleY() == 0) {
487 return false; // rejected
488 }
489
490 if (properties().getLeft() != 0 || properties().getTop() != 0) {
491 canvasState.translate(properties().getLeft(), properties().getTop());
492 }
493 if (properties().getStaticMatrix()) {
494 canvasState.concatMatrix(*properties().getStaticMatrix());
495 } else if (properties().getAnimationMatrix()) {
496 canvasState.concatMatrix(*properties().getAnimationMatrix());
497 }
498 if (properties().hasTransformMatrix()) {
499 if (properties().isTransformTranslateOnly()) {
500 canvasState.translate(properties().getTranslationX(), properties().getTranslationY());
501 } else {
502 canvasState.concatMatrix(*properties().getTransformMatrix());
503 }
504 }
505 return !canvasState.quickRejectConservative(
506 0, 0, properties().getWidth(), properties().getHeight());
507}
508
John Reck113e0822014-03-18 09:22:59 -0700509/*
510 * For property operations, we pass a savecount of 0, since the operations aren't part of the
511 * displaylist, and thus don't have to compensate for the record-time/playback-time discrepancy in
John Reckd0a0b2a2014-03-20 16:28:56 -0700512 * base saveCount (i.e., how RestoreToCount uses saveCount + properties().getCount())
John Reck113e0822014-03-18 09:22:59 -0700513 */
514#define PROPERTY_SAVECOUNT 0
515
516template <class T>
Chris Craikb265e2c2014-03-27 15:50:09 -0700517void RenderNode::setViewProperties(OpenGLRenderer& renderer, T& handler) {
John Reck113e0822014-03-18 09:22:59 -0700518#if DEBUG_DISPLAY_LIST
Chris Craikb265e2c2014-03-27 15:50:09 -0700519 properties().debugOutputProperties(handler.level() + 1);
John Reck113e0822014-03-18 09:22:59 -0700520#endif
John Reckd0a0b2a2014-03-20 16:28:56 -0700521 if (properties().getLeft() != 0 || properties().getTop() != 0) {
522 renderer.translate(properties().getLeft(), properties().getTop());
John Reck113e0822014-03-18 09:22:59 -0700523 }
John Reckd0a0b2a2014-03-20 16:28:56 -0700524 if (properties().getStaticMatrix()) {
Derek Sollenberger13908822013-12-10 12:28:58 -0500525 renderer.concatMatrix(*properties().getStaticMatrix());
John Reckd0a0b2a2014-03-20 16:28:56 -0700526 } else if (properties().getAnimationMatrix()) {
Derek Sollenberger13908822013-12-10 12:28:58 -0500527 renderer.concatMatrix(*properties().getAnimationMatrix());
John Reck113e0822014-03-18 09:22:59 -0700528 }
John Reckf7483e32014-04-11 08:54:47 -0700529 if (properties().hasTransformMatrix()) {
530 if (properties().isTransformTranslateOnly()) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700531 renderer.translate(properties().getTranslationX(), properties().getTranslationY());
John Reck113e0822014-03-18 09:22:59 -0700532 } else {
John Reckd0a0b2a2014-03-20 16:28:56 -0700533 renderer.concatMatrix(*properties().getTransformMatrix());
John Reck113e0822014-03-18 09:22:59 -0700534 }
535 }
Chris Craik856f0cc2015-04-21 15:13:29 -0700536 const bool isLayer = properties().effectiveLayerType() != LayerType::None;
Chris Craika753f4c2014-07-24 12:39:17 -0700537 int clipFlags = properties().getClippingFlags();
John Reckd0a0b2a2014-03-20 16:28:56 -0700538 if (properties().getAlpha() < 1) {
John Reck25fbb3f2014-06-12 13:46:45 -0700539 if (isLayer) {
Chris Craika753f4c2014-07-24 12:39:17 -0700540 clipFlags &= ~CLIP_TO_BOUNDS; // bounds clipping done by layer
John Reck113e0822014-03-18 09:22:59 -0700541 }
Chris Craik4e9d9b22015-06-12 11:07:23 -0700542 if (CC_LIKELY(isLayer || !properties().getHasOverlappingRendering())) {
543 // simply scale rendering content's alpha
544 renderer.scaleAlpha(properties().getAlpha());
545 } else {
546 // savelayer needed to create an offscreen buffer
547 Rect layerBounds(0, 0, getWidth(), getHeight());
548 if (clipFlags) {
549 properties().getClippingRectForFlags(clipFlags, &layerBounds);
550 clipFlags = 0; // all clipping done by savelayer
551 }
552 SaveLayerOp* op = new (handler.allocator()) SaveLayerOp(
553 layerBounds.left, layerBounds.top,
554 layerBounds.right, layerBounds.bottom,
555 (int) (properties().getAlpha() * 255),
556 SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kClipToLayer_SaveFlag);
557 handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds());
558 }
Chris Craik1a0808e2015-05-13 16:33:04 -0700559
560 if (CC_UNLIKELY(ATRACE_ENABLED() && properties().promotedToLayer())) {
Chris Craik4e9d9b22015-06-12 11:07:23 -0700561 // pretend alpha always causes savelayer to warn about
562 // performance problem affecting old versions
Chris Craik1a0808e2015-05-13 16:33:04 -0700563 ATRACE_FORMAT("%s alpha caused saveLayer %dx%d", getName(),
564 static_cast<int>(getWidth()),
565 static_cast<int>(getHeight()));
566 }
John Reck113e0822014-03-18 09:22:59 -0700567 }
Chris Craika753f4c2014-07-24 12:39:17 -0700568 if (clipFlags) {
569 Rect clipRect;
570 properties().getClippingRectForFlags(clipFlags, &clipRect);
Chris Craik8c271ca2014-03-25 10:33:01 -0700571 ClipRectOp* op = new (handler.allocator()) ClipRectOp(
Chris Craika753f4c2014-07-24 12:39:17 -0700572 clipRect.left, clipRect.top, clipRect.right, clipRect.bottom,
573 SkRegion::kIntersect_Op);
John Reckd0a0b2a2014-03-20 16:28:56 -0700574 handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -0700575 }
Chris Craik8c271ca2014-03-25 10:33:01 -0700576
Chris Craike83cbd42014-09-03 17:52:24 -0700577 // TODO: support nesting round rect clips
Chris Craikaf4d04c2014-07-29 12:50:14 -0700578 if (mProperties.getRevealClip().willClip()) {
579 Rect bounds;
580 mProperties.getRevealClip().getBounds(&bounds);
581 renderer.setClippingRoundRect(handler.allocator(), bounds, mProperties.getRevealClip().getRadius());
582 } else if (mProperties.getOutline().willClip()) {
583 renderer.setClippingOutline(handler.allocator(), &(mProperties.getOutline()));
John Reck113e0822014-03-18 09:22:59 -0700584 }
585}
586
587/**
588 * Apply property-based transformations to input matrix
589 *
590 * If true3dTransform is set to true, the transform applied to the input matrix will use true 4x4
591 * matrix computation instead of the Skia 3x3 matrix + camera hackery.
592 */
Chris Craik69e5adf2014-08-14 13:34:01 -0700593void RenderNode::applyViewPropertyTransforms(mat4& matrix, bool true3dTransform) const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700594 if (properties().getLeft() != 0 || properties().getTop() != 0) {
595 matrix.translate(properties().getLeft(), properties().getTop());
John Reck113e0822014-03-18 09:22:59 -0700596 }
John Reckd0a0b2a2014-03-20 16:28:56 -0700597 if (properties().getStaticMatrix()) {
598 mat4 stat(*properties().getStaticMatrix());
John Reck113e0822014-03-18 09:22:59 -0700599 matrix.multiply(stat);
John Reckd0a0b2a2014-03-20 16:28:56 -0700600 } else if (properties().getAnimationMatrix()) {
601 mat4 anim(*properties().getAnimationMatrix());
John Reck113e0822014-03-18 09:22:59 -0700602 matrix.multiply(anim);
603 }
Chris Craike0bb87d2014-04-22 17:55:41 -0700604
Chris Craikcc39e162014-04-25 18:34:11 -0700605 bool applyTranslationZ = true3dTransform && !MathUtils::isZero(properties().getZ());
Chris Craike0bb87d2014-04-22 17:55:41 -0700606 if (properties().hasTransformMatrix() || applyTranslationZ) {
John Reckf7483e32014-04-11 08:54:47 -0700607 if (properties().isTransformTranslateOnly()) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700608 matrix.translate(properties().getTranslationX(), properties().getTranslationY(),
Chris Craikcc39e162014-04-25 18:34:11 -0700609 true3dTransform ? properties().getZ() : 0.0f);
John Reck113e0822014-03-18 09:22:59 -0700610 } else {
611 if (!true3dTransform) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700612 matrix.multiply(*properties().getTransformMatrix());
John Reck113e0822014-03-18 09:22:59 -0700613 } else {
614 mat4 true3dMat;
615 true3dMat.loadTranslate(
John Reckd0a0b2a2014-03-20 16:28:56 -0700616 properties().getPivotX() + properties().getTranslationX(),
617 properties().getPivotY() + properties().getTranslationY(),
Chris Craikcc39e162014-04-25 18:34:11 -0700618 properties().getZ());
John Reckd0a0b2a2014-03-20 16:28:56 -0700619 true3dMat.rotate(properties().getRotationX(), 1, 0, 0);
620 true3dMat.rotate(properties().getRotationY(), 0, 1, 0);
621 true3dMat.rotate(properties().getRotation(), 0, 0, 1);
622 true3dMat.scale(properties().getScaleX(), properties().getScaleY(), 1);
623 true3dMat.translate(-properties().getPivotX(), -properties().getPivotY());
John Reck113e0822014-03-18 09:22:59 -0700624
625 matrix.multiply(true3dMat);
626 }
627 }
628 }
629}
630
631/**
632 * Organizes the DisplayList hierarchy to prepare for background projection reordering.
633 *
634 * This should be called before a call to defer() or drawDisplayList()
635 *
636 * Each DisplayList that serves as a 3d root builds its list of composited children,
637 * which are flagged to not draw in the standard draw loop.
638 */
639void RenderNode::computeOrdering() {
Chris Craikb565df12015-10-05 13:00:52 -0700640#if !HWUI_NEW_OPS
John Reck113e0822014-03-18 09:22:59 -0700641 ATRACE_CALL();
642 mProjectedNodes.clear();
643
644 // TODO: create temporary DDLOp and call computeOrderingImpl on top DisplayList so that
645 // transform properties are applied correctly to top level children
Chris Craik003cc3d2015-10-16 10:24:55 -0700646 if (mDisplayList == nullptr) return;
Chris Craikb36af872015-10-16 14:23:12 -0700647 for (unsigned int i = 0; i < mDisplayList->getChildren().size(); i++) {
648 DrawRenderNodeOp* childOp = mDisplayList->getChildren()[i];
Chris Craikb565df12015-10-05 13:00:52 -0700649 childOp->renderNode->computeOrderingImpl(childOp, &mProjectedNodes, &mat4::identity());
John Reck113e0822014-03-18 09:22:59 -0700650 }
Chris Craikb565df12015-10-05 13:00:52 -0700651#endif
John Reck113e0822014-03-18 09:22:59 -0700652}
653
654void RenderNode::computeOrderingImpl(
Chris Craika7090e02014-06-20 16:01:00 -0700655 DrawRenderNodeOp* opState,
John Reck272a6852015-07-29 16:48:58 -0700656 std::vector<DrawRenderNodeOp*>* compositedChildrenOfProjectionSurface,
John Reck113e0822014-03-18 09:22:59 -0700657 const mat4* transformFromProjectionSurface) {
Chris Craikb565df12015-10-05 13:00:52 -0700658#if !HWUI_NEW_OPS
John Reck113e0822014-03-18 09:22:59 -0700659 mProjectedNodes.clear();
Chris Craik003cc3d2015-10-16 10:24:55 -0700660 if (mDisplayList == nullptr || mDisplayList->isEmpty()) return;
John Reck113e0822014-03-18 09:22:59 -0700661
662 // TODO: should avoid this calculation in most cases
663 // TODO: just calculate single matrix, down to all leaf composited elements
664 Matrix4 localTransformFromProjectionSurface(*transformFromProjectionSurface);
665 localTransformFromProjectionSurface.multiply(opState->mTransformFromParent);
666
John Reckd0a0b2a2014-03-20 16:28:56 -0700667 if (properties().getProjectBackwards()) {
John Reck113e0822014-03-18 09:22:59 -0700668 // composited projectee, flag for out of order draw, save matrix, and store in proj surface
669 opState->mSkipInOrderDraw = true;
Chris Craik7c85c542015-08-19 15:10:24 -0700670 opState->mTransformFromCompositingAncestor = localTransformFromProjectionSurface;
John Reck272a6852015-07-29 16:48:58 -0700671 compositedChildrenOfProjectionSurface->push_back(opState);
John Reck113e0822014-03-18 09:22:59 -0700672 } else {
673 // standard in order draw
674 opState->mSkipInOrderDraw = false;
675 }
676
Chris Craikb36af872015-10-16 14:23:12 -0700677 if (mDisplayList->getChildren().size() > 0) {
Chris Craik003cc3d2015-10-16 10:24:55 -0700678 const bool isProjectionReceiver = mDisplayList->projectionReceiveIndex >= 0;
John Reck113e0822014-03-18 09:22:59 -0700679 bool haveAppliedPropertiesToProjection = false;
Chris Craikb36af872015-10-16 14:23:12 -0700680 for (unsigned int i = 0; i < mDisplayList->getChildren().size(); i++) {
681 DrawRenderNodeOp* childOp = mDisplayList->getChildren()[i];
Chris Craikb565df12015-10-05 13:00:52 -0700682 RenderNode* child = childOp->renderNode;
John Reck113e0822014-03-18 09:22:59 -0700683
John Reck272a6852015-07-29 16:48:58 -0700684 std::vector<DrawRenderNodeOp*>* projectionChildren = nullptr;
Chris Craikd41c4d82015-01-05 15:51:13 -0800685 const mat4* projectionTransform = nullptr;
John Reckd0a0b2a2014-03-20 16:28:56 -0700686 if (isProjectionReceiver && !child->properties().getProjectBackwards()) {
Chris Craikbf72eb82015-06-08 11:30:44 -0700687 // if receiving projections, collect projecting descendant
John Reck113e0822014-03-18 09:22:59 -0700688
Chris Craikbf72eb82015-06-08 11:30:44 -0700689 // Note that if a direct descendant is projecting backwards, we pass its
690 // grandparent projection collection, since it shouldn't project onto its
John Reck113e0822014-03-18 09:22:59 -0700691 // parent, where it will already be drawing.
692 projectionChildren = &mProjectedNodes;
693 projectionTransform = &mat4::identity();
694 } else {
695 if (!haveAppliedPropertiesToProjection) {
696 applyViewPropertyTransforms(localTransformFromProjectionSurface);
697 haveAppliedPropertiesToProjection = true;
698 }
699 projectionChildren = compositedChildrenOfProjectionSurface;
700 projectionTransform = &localTransformFromProjectionSurface;
701 }
Derek Sollenbergerf2932592015-08-13 14:59:33 -0400702 child->computeOrderingImpl(childOp, projectionChildren, projectionTransform);
John Reck113e0822014-03-18 09:22:59 -0700703 }
704 }
Chris Craikb565df12015-10-05 13:00:52 -0700705#endif
John Reck113e0822014-03-18 09:22:59 -0700706}
707
708class DeferOperationHandler {
709public:
710 DeferOperationHandler(DeferStateStruct& deferStruct, int level)
711 : mDeferStruct(deferStruct), mLevel(level) {}
712 inline void operator()(DisplayListOp* operation, int saveCount, bool clipToBounds) {
713 operation->defer(mDeferStruct, saveCount, mLevel, clipToBounds);
714 }
715 inline LinearAllocator& allocator() { return *(mDeferStruct.mAllocator); }
Andreas Gampe64bb4132014-11-22 00:35:09 +0000716 inline void startMark(const char* name) {} // do nothing
Chris Craikb265e2c2014-03-27 15:50:09 -0700717 inline void endMark() {}
718 inline int level() { return mLevel; }
719 inline int replayFlags() { return mDeferStruct.mReplayFlags; }
Chris Craik74669862014-08-07 17:27:30 -0700720 inline SkPath* allocPathForFrame() { return mDeferStruct.allocPathForFrame(); }
John Reck113e0822014-03-18 09:22:59 -0700721
722private:
723 DeferStateStruct& mDeferStruct;
724 const int mLevel;
725};
726
Chris Craik80d49022014-06-20 15:03:43 -0700727void RenderNode::defer(DeferStateStruct& deferStruct, const int level) {
John Reck113e0822014-03-18 09:22:59 -0700728 DeferOperationHandler handler(deferStruct, level);
Chris Craikb265e2c2014-03-27 15:50:09 -0700729 issueOperations<DeferOperationHandler>(deferStruct.mRenderer, handler);
John Reck113e0822014-03-18 09:22:59 -0700730}
731
732class ReplayOperationHandler {
733public:
734 ReplayOperationHandler(ReplayStateStruct& replayStruct, int level)
735 : mReplayStruct(replayStruct), mLevel(level) {}
736 inline void operator()(DisplayListOp* operation, int saveCount, bool clipToBounds) {
737#if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS
Chris Craik3f0854292014-04-15 16:18:08 -0700738 mReplayStruct.mRenderer.eventMark(operation->name());
John Reck113e0822014-03-18 09:22:59 -0700739#endif
740 operation->replay(mReplayStruct, saveCount, mLevel, clipToBounds);
741 }
742 inline LinearAllocator& allocator() { return *(mReplayStruct.mAllocator); }
Chris Craikb265e2c2014-03-27 15:50:09 -0700743 inline void startMark(const char* name) {
744 mReplayStruct.mRenderer.startMark(name);
745 }
746 inline void endMark() {
747 mReplayStruct.mRenderer.endMark();
Chris Craikb265e2c2014-03-27 15:50:09 -0700748 }
749 inline int level() { return mLevel; }
750 inline int replayFlags() { return mReplayStruct.mReplayFlags; }
Chris Craik74669862014-08-07 17:27:30 -0700751 inline SkPath* allocPathForFrame() { return mReplayStruct.allocPathForFrame(); }
John Reck113e0822014-03-18 09:22:59 -0700752
753private:
754 ReplayStateStruct& mReplayStruct;
755 const int mLevel;
756};
757
Chris Craik80d49022014-06-20 15:03:43 -0700758void RenderNode::replay(ReplayStateStruct& replayStruct, const int level) {
John Reck113e0822014-03-18 09:22:59 -0700759 ReplayOperationHandler handler(replayStruct, level);
Chris Craikb265e2c2014-03-27 15:50:09 -0700760 issueOperations<ReplayOperationHandler>(replayStruct.mRenderer, handler);
John Reck113e0822014-03-18 09:22:59 -0700761}
762
Chris Craik003cc3d2015-10-16 10:24:55 -0700763void RenderNode::buildZSortedChildList(const DisplayList::Chunk& chunk,
John Reck272a6852015-07-29 16:48:58 -0700764 std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes) {
Chris Craikb565df12015-10-05 13:00:52 -0700765#if !HWUI_NEW_OPS
Chris Craik8afd0f22014-08-21 17:41:57 -0700766 if (chunk.beginChildIndex == chunk.endChildIndex) return;
John Reck113e0822014-03-18 09:22:59 -0700767
Chris Craik8afd0f22014-08-21 17:41:57 -0700768 for (unsigned int i = chunk.beginChildIndex; i < chunk.endChildIndex; i++) {
Chris Craikb36af872015-10-16 14:23:12 -0700769 DrawRenderNodeOp* childOp = mDisplayList->getChildren()[i];
Chris Craikb565df12015-10-05 13:00:52 -0700770 RenderNode* child = childOp->renderNode;
Chris Craikcc39e162014-04-25 18:34:11 -0700771 float childZ = child->properties().getZ();
John Reck113e0822014-03-18 09:22:59 -0700772
Chris Craik8afd0f22014-08-21 17:41:57 -0700773 if (!MathUtils::isZero(childZ) && chunk.reorderChildren) {
John Reck272a6852015-07-29 16:48:58 -0700774 zTranslatedNodes.push_back(ZDrawRenderNodeOpPair(childZ, childOp));
John Reck113e0822014-03-18 09:22:59 -0700775 childOp->mSkipInOrderDraw = true;
John Reckd0a0b2a2014-03-20 16:28:56 -0700776 } else if (!child->properties().getProjectBackwards()) {
John Reck113e0822014-03-18 09:22:59 -0700777 // regular, in order drawing DisplayList
778 childOp->mSkipInOrderDraw = false;
779 }
780 }
781
Chris Craik8afd0f22014-08-21 17:41:57 -0700782 // Z sort any 3d children (stable-ness makes z compare fall back to standard drawing order)
John Reck113e0822014-03-18 09:22:59 -0700783 std::stable_sort(zTranslatedNodes.begin(), zTranslatedNodes.end());
Chris Craikb565df12015-10-05 13:00:52 -0700784#endif
John Reck113e0822014-03-18 09:22:59 -0700785}
786
Chris Craikb265e2c2014-03-27 15:50:09 -0700787template <class T>
788void RenderNode::issueDrawShadowOperation(const Matrix4& transformFromParent, T& handler) {
Chris Craik77b5cad2014-07-30 18:23:07 -0700789 if (properties().getAlpha() <= 0.0f
790 || properties().getOutline().getAlpha() <= 0.0f
Teng-Hui Zhu8d0ec382015-10-01 16:49:16 -0700791 || !properties().getOutline().getPath()
792 || properties().getScaleX() == 0
793 || properties().getScaleY() == 0) {
Chris Craik77b5cad2014-07-30 18:23:07 -0700794 // no shadow to draw
795 return;
796 }
Chris Craikb265e2c2014-03-27 15:50:09 -0700797
798 mat4 shadowMatrixXY(transformFromParent);
799 applyViewPropertyTransforms(shadowMatrixXY);
800
801 // Z matrix needs actual 3d transformation, so mapped z values will be correct
802 mat4 shadowMatrixZ(transformFromParent);
803 applyViewPropertyTransforms(shadowMatrixZ, true);
804
Chris Craik74669862014-08-07 17:27:30 -0700805 const SkPath* casterOutlinePath = properties().getOutline().getPath();
Chris Craikaf4d04c2014-07-29 12:50:14 -0700806 const SkPath* revealClipPath = properties().getRevealClip().getPath();
Chris Craik61317322014-05-21 13:03:52 -0700807 if (revealClipPath && revealClipPath->isEmpty()) return;
808
Chris Craik77b5cad2014-07-30 18:23:07 -0700809 float casterAlpha = properties().getAlpha() * properties().getOutline().getAlpha();
Chris Craik74669862014-08-07 17:27:30 -0700810
Chris Craik74669862014-08-07 17:27:30 -0700811
Chris Craikfaa79ff2014-12-01 13:44:21 -0800812 // holds temporary SkPath to store the result of intersections
Chris Craikd41c4d82015-01-05 15:51:13 -0800813 SkPath* frameAllocatedPath = nullptr;
Chris Craikfaa79ff2014-12-01 13:44:21 -0800814 const SkPath* outlinePath = casterOutlinePath;
815
816 // intersect the outline with the reveal clip, if present
817 if (revealClipPath) {
818 frameAllocatedPath = handler.allocPathForFrame();
819
Tom Hudson02a26302015-06-24 11:32:42 -0400820 Op(*outlinePath, *revealClipPath, kIntersect_SkPathOp, frameAllocatedPath);
Chris Craikfaa79ff2014-12-01 13:44:21 -0800821 outlinePath = frameAllocatedPath;
822 }
823
824 // intersect the outline with the clipBounds, if present
825 if (properties().getClippingFlags() & CLIP_TO_CLIP_BOUNDS) {
826 if (!frameAllocatedPath) {
827 frameAllocatedPath = handler.allocPathForFrame();
828 }
829
830 Rect clipBounds;
831 properties().getClippingRectForFlags(CLIP_TO_CLIP_BOUNDS, &clipBounds);
832 SkPath clipBoundsPath;
833 clipBoundsPath.addRect(clipBounds.left, clipBounds.top,
834 clipBounds.right, clipBounds.bottom);
835
Tom Hudson02a26302015-06-24 11:32:42 -0400836 Op(*outlinePath, clipBoundsPath, kIntersect_SkPathOp, frameAllocatedPath);
Chris Craik74669862014-08-07 17:27:30 -0700837 outlinePath = frameAllocatedPath;
838 }
839
Chris Craikb265e2c2014-03-27 15:50:09 -0700840 DisplayListOp* shadowOp = new (handler.allocator()) DrawShadowOp(
Chris Craik74669862014-08-07 17:27:30 -0700841 shadowMatrixXY, shadowMatrixZ, casterAlpha, outlinePath);
Chris Craikb265e2c2014-03-27 15:50:09 -0700842 handler(shadowOp, PROPERTY_SAVECOUNT, properties().getClipToBounds());
843}
844
John Reck113e0822014-03-18 09:22:59 -0700845#define SHADOW_DELTA 0.1f
846
847template <class T>
Chris Craikc3e75f92014-08-27 15:34:52 -0700848void RenderNode::issueOperationsOf3dChildren(ChildrenSelectMode mode,
John Reck272a6852015-07-29 16:48:58 -0700849 const Matrix4& initialTransform, const std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes,
Chris Craikc3e75f92014-08-27 15:34:52 -0700850 OpenGLRenderer& renderer, T& handler) {
John Reck113e0822014-03-18 09:22:59 -0700851 const int size = zTranslatedNodes.size();
852 if (size == 0
Chris Craikb9ce116d2015-08-20 15:14:06 -0700853 || (mode == ChildrenSelectMode::NegativeZChildren && zTranslatedNodes[0].key > 0.0f)
854 || (mode == ChildrenSelectMode::PositiveZChildren && zTranslatedNodes[size - 1].key < 0.0f)) {
John Reck113e0822014-03-18 09:22:59 -0700855 // no 3d children to draw
856 return;
857 }
858
Chris Craikc3e75f92014-08-27 15:34:52 -0700859 // Apply the base transform of the parent of the 3d children. This isolates
860 // 3d children of the current chunk from transformations made in previous chunks.
861 int rootRestoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag);
Chris Craik6daa13c2015-08-19 13:32:12 -0700862 renderer.setGlobalMatrix(initialTransform);
Chris Craikc3e75f92014-08-27 15:34:52 -0700863
John Reck113e0822014-03-18 09:22:59 -0700864 /**
865 * Draw shadows and (potential) casters mostly in order, but allow the shadows of casters
866 * with very similar Z heights to draw together.
867 *
868 * This way, if Views A & B have the same Z height and are both casting shadows, the shadows are
869 * underneath both, and neither's shadow is drawn on top of the other.
870 */
871 const size_t nonNegativeIndex = findNonNegativeIndex(zTranslatedNodes);
872 size_t drawIndex, shadowIndex, endIndex;
Chris Craikb9ce116d2015-08-20 15:14:06 -0700873 if (mode == ChildrenSelectMode::NegativeZChildren) {
John Reck113e0822014-03-18 09:22:59 -0700874 drawIndex = 0;
875 endIndex = nonNegativeIndex;
876 shadowIndex = endIndex; // draw no shadows
877 } else {
878 drawIndex = nonNegativeIndex;
879 endIndex = size;
880 shadowIndex = drawIndex; // potentially draw shadow for each pos Z child
881 }
Chris Craik3f0854292014-04-15 16:18:08 -0700882
883 DISPLAY_LIST_LOGD("%*s%d %s 3d children:", (handler.level() + 1) * 2, "",
884 endIndex - drawIndex, mode == kNegativeZChildren ? "negative" : "positive");
885
John Reck113e0822014-03-18 09:22:59 -0700886 float lastCasterZ = 0.0f;
887 while (shadowIndex < endIndex || drawIndex < endIndex) {
888 if (shadowIndex < endIndex) {
Chris Craika7090e02014-06-20 16:01:00 -0700889 DrawRenderNodeOp* casterOp = zTranslatedNodes[shadowIndex].value;
Chris Craikb565df12015-10-05 13:00:52 -0700890 RenderNode* caster = casterOp->renderNode;
John Reck113e0822014-03-18 09:22:59 -0700891 const float casterZ = zTranslatedNodes[shadowIndex].key;
892 // attempt to render the shadow if the caster about to be drawn is its caster,
893 // OR if its caster's Z value is similar to the previous potential caster
894 if (shadowIndex == drawIndex || casterZ - lastCasterZ < SHADOW_DELTA) {
Chris Craikb265e2c2014-03-27 15:50:09 -0700895 caster->issueDrawShadowOperation(casterOp->mTransformFromParent, handler);
John Reck113e0822014-03-18 09:22:59 -0700896
897 lastCasterZ = casterZ; // must do this even if current caster not casting a shadow
898 shadowIndex++;
899 continue;
900 }
901 }
902
903 // only the actual child DL draw needs to be in save/restore,
904 // since it modifies the renderer's matrix
905 int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag);
906
Chris Craika7090e02014-06-20 16:01:00 -0700907 DrawRenderNodeOp* childOp = zTranslatedNodes[drawIndex].value;
John Reck113e0822014-03-18 09:22:59 -0700908
909 renderer.concatMatrix(childOp->mTransformFromParent);
910 childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone
John Reckd0a0b2a2014-03-20 16:28:56 -0700911 handler(childOp, renderer.getSaveCount() - 1, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -0700912 childOp->mSkipInOrderDraw = true;
913
914 renderer.restoreToCount(restoreTo);
915 drawIndex++;
916 }
Chris Craikc3e75f92014-08-27 15:34:52 -0700917 renderer.restoreToCount(rootRestoreTo);
John Reck113e0822014-03-18 09:22:59 -0700918}
919
920template <class T>
Chris Craikb265e2c2014-03-27 15:50:09 -0700921void RenderNode::issueOperationsOfProjectedChildren(OpenGLRenderer& renderer, T& handler) {
Chris Craik3f0854292014-04-15 16:18:08 -0700922 DISPLAY_LIST_LOGD("%*s%d projected children:", (handler.level() + 1) * 2, "", mProjectedNodes.size());
923 const SkPath* projectionReceiverOutline = properties().getOutline().getPath();
Chris Craik3f0854292014-04-15 16:18:08 -0700924 int restoreTo = renderer.getSaveCount();
925
Chris Craikb3cca872014-08-08 18:42:51 -0700926 LinearAllocator& alloc = handler.allocator();
927 handler(new (alloc) SaveOp(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag),
928 PROPERTY_SAVECOUNT, properties().getClipToBounds());
929
930 // Transform renderer to match background we're projecting onto
931 // (by offsetting canvas by translationX/Y of background rendernode, since only those are set)
932 const DisplayListOp* op =
Chris Craik10ed6922015-10-15 10:55:15 -0700933#if HWUI_NEW_OPS
934 nullptr;
935 LOG_ALWAYS_FATAL("unsupported");
936#else
Chris Craik003cc3d2015-10-16 10:24:55 -0700937 (mDisplayList->getOps()[mDisplayList->projectionReceiveIndex]);
Chris Craik10ed6922015-10-15 10:55:15 -0700938#endif
Chris Craikb3cca872014-08-08 18:42:51 -0700939 const DrawRenderNodeOp* backgroundOp = reinterpret_cast<const DrawRenderNodeOp*>(op);
Chris Craikb565df12015-10-05 13:00:52 -0700940 const RenderProperties& backgroundProps = backgroundOp->renderNode->properties();
Chris Craikb3cca872014-08-08 18:42:51 -0700941 renderer.translate(backgroundProps.getTranslationX(), backgroundProps.getTranslationY());
942
Chris Craik6fe991e52015-10-20 09:39:42 -0700943 // If the projection receiver has an outline, we mask projected content to it
Chris Craikfca52b752015-04-28 11:45:59 -0700944 // (which we know, apriori, are all tessellated paths)
945 renderer.setProjectionPathMask(alloc, projectionReceiverOutline);
Chris Craik3f0854292014-04-15 16:18:08 -0700946
947 // draw projected nodes
John Reck113e0822014-03-18 09:22:59 -0700948 for (size_t i = 0; i < mProjectedNodes.size(); i++) {
Chris Craika7090e02014-06-20 16:01:00 -0700949 DrawRenderNodeOp* childOp = mProjectedNodes[i];
John Reck113e0822014-03-18 09:22:59 -0700950
951 // matrix save, concat, and restore can be done safely without allocating operations
952 int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag);
953 renderer.concatMatrix(childOp->mTransformFromCompositingAncestor);
954 childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone
John Reckd0a0b2a2014-03-20 16:28:56 -0700955 handler(childOp, renderer.getSaveCount() - 1, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -0700956 childOp->mSkipInOrderDraw = true;
957 renderer.restoreToCount(restoreTo);
958 }
Chris Craik3f0854292014-04-15 16:18:08 -0700959
Chris Craikfca52b752015-04-28 11:45:59 -0700960 handler(new (alloc) RestoreToCountOp(restoreTo),
961 PROPERTY_SAVECOUNT, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -0700962}
963
964/**
965 * This function serves both defer and replay modes, and will organize the displayList's component
966 * operations for a single frame:
967 *
968 * Every 'simple' state operation that affects just the matrix and alpha (or other factors of
969 * DeferredDisplayState) may be issued directly to the renderer, but complex operations (with custom
970 * defer logic) and operations in displayListOps are issued through the 'handler' which handles the
971 * defer vs replay logic, per operation
972 */
973template <class T>
Chris Craikb265e2c2014-03-27 15:50:09 -0700974void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) {
Chris Craik003cc3d2015-10-16 10:24:55 -0700975 if (mDisplayList->isEmpty()) {
Chris Craikbf72eb82015-06-08 11:30:44 -0700976 DISPLAY_LIST_LOGD("%*sEmpty display list (%p, %s)", handler.level() * 2, "",
977 this, getName());
Chris Craik06451282014-07-21 10:25:54 -0700978 return;
979 }
980
Chris Craik51d6a3d2014-12-22 17:16:56 -0800981 const bool drawLayer = (mLayer && (&renderer != mLayer->renderer.get()));
John Reck25fbb3f2014-06-12 13:46:45 -0700982 // If we are updating the contents of mLayer, we don't want to apply any of
983 // the RenderNode's properties to this issueOperations pass. Those will all
984 // be applied when the layer is drawn, aka when this is true.
985 const bool useViewProperties = (!mLayer || drawLayer);
Chris Craik06451282014-07-21 10:25:54 -0700986 if (useViewProperties) {
987 const Outline& outline = properties().getOutline();
Teng-Hui Zhu8d0ec382015-10-01 16:49:16 -0700988 if (properties().getAlpha() <= 0
989 || (outline.getShouldClip() && outline.isEmpty())
990 || properties().getScaleX() == 0
991 || properties().getScaleY() == 0) {
Chris Craikbf72eb82015-06-08 11:30:44 -0700992 DISPLAY_LIST_LOGD("%*sRejected display list (%p, %s)", handler.level() * 2, "",
993 this, getName());
Chris Craik06451282014-07-21 10:25:54 -0700994 return;
995 }
John Reck113e0822014-03-18 09:22:59 -0700996 }
997
Chris Craik3f0854292014-04-15 16:18:08 -0700998 handler.startMark(getName());
Chris Craikb265e2c2014-03-27 15:50:09 -0700999
John Reck113e0822014-03-18 09:22:59 -07001000#if DEBUG_DISPLAY_LIST
Chris Craik3f0854292014-04-15 16:18:08 -07001001 const Rect& clipRect = renderer.getLocalClipBounds();
1002 DISPLAY_LIST_LOGD("%*sStart display list (%p, %s), localClipBounds: %.0f, %.0f, %.0f, %.0f",
Chris Craik03188872015-02-02 18:39:33 -08001003 handler.level() * 2, "", this, getName(),
Chris Craik3f0854292014-04-15 16:18:08 -07001004 clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
John Reck113e0822014-03-18 09:22:59 -07001005#endif
1006
1007 LinearAllocator& alloc = handler.allocator();
1008 int restoreTo = renderer.getSaveCount();
1009 handler(new (alloc) SaveOp(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag),
John Reckd0a0b2a2014-03-20 16:28:56 -07001010 PROPERTY_SAVECOUNT, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -07001011
Chris Craikbf72eb82015-06-08 11:30:44 -07001012 DISPLAY_LIST_LOGD("%*sSave %d %d", (handler.level() + 1) * 2, "",
John Reck113e0822014-03-18 09:22:59 -07001013 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag, restoreTo);
1014
John Reck25fbb3f2014-06-12 13:46:45 -07001015 if (useViewProperties) {
1016 setViewProperties<T>(renderer, handler);
1017 }
John Reck113e0822014-03-18 09:22:59 -07001018
Chris Craik10ed6922015-10-15 10:55:15 -07001019#if HWUI_NEW_OPS
1020 LOG_ALWAYS_FATAL("legacy op traversal not supported");
1021#else
Chris Craik8c271ca2014-03-25 10:33:01 -07001022 bool quickRejected = properties().getClipToBounds()
1023 && renderer.quickRejectConservative(0, 0, properties().getWidth(), properties().getHeight());
John Reck113e0822014-03-18 09:22:59 -07001024 if (!quickRejected) {
Chris Craikc3e75f92014-08-27 15:34:52 -07001025 Matrix4 initialTransform(*(renderer.currentTransform()));
Tom Hudsonac7b6d32015-06-30 11:26:13 -04001026 renderer.setBaseTransform(initialTransform);
Chris Craikc3e75f92014-08-27 15:34:52 -07001027
John Reck25fbb3f2014-06-12 13:46:45 -07001028 if (drawLayer) {
Chris Craik3aadd602015-08-20 12:41:40 -07001029 handler(new (alloc) DrawLayerOp(mLayer),
John Reck25fbb3f2014-06-12 13:46:45 -07001030 renderer.getSaveCount() - 1, properties().getClipToBounds());
1031 } else {
Chris Craikc166b6c2014-09-05 19:55:30 -07001032 const int saveCountOffset = renderer.getSaveCount() - 1;
Chris Craik003cc3d2015-10-16 10:24:55 -07001033 const int projectionReceiveIndex = mDisplayList->projectionReceiveIndex;
1034 for (size_t chunkIndex = 0; chunkIndex < mDisplayList->getChunks().size(); chunkIndex++) {
1035 const DisplayList::Chunk& chunk = mDisplayList->getChunks()[chunkIndex];
John Reck113e0822014-03-18 09:22:59 -07001036
John Reck272a6852015-07-29 16:48:58 -07001037 std::vector<ZDrawRenderNodeOpPair> zTranslatedNodes;
Chris Craik8afd0f22014-08-21 17:41:57 -07001038 buildZSortedChildList(chunk, zTranslatedNodes);
1039
Chris Craikb9ce116d2015-08-20 15:14:06 -07001040 issueOperationsOf3dChildren(ChildrenSelectMode::NegativeZChildren,
Chris Craikc3e75f92014-08-27 15:34:52 -07001041 initialTransform, zTranslatedNodes, renderer, handler);
1042
Andreas Gampeedaecc12014-11-10 20:54:07 -08001043 for (size_t opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) {
Chris Craik003cc3d2015-10-16 10:24:55 -07001044 DisplayListOp *op = mDisplayList->getOps()[opIndex];
Chris Craik80d49022014-06-20 15:03:43 -07001045#if DEBUG_DISPLAY_LIST
Chris Craik03188872015-02-02 18:39:33 -08001046 op->output(handler.level() + 1);
Chris Craik80d49022014-06-20 15:03:43 -07001047#endif
Chris Craik8afd0f22014-08-21 17:41:57 -07001048 handler(op, saveCountOffset, properties().getClipToBounds());
John Reck113e0822014-03-18 09:22:59 -07001049
John Reck272a6852015-07-29 16:48:58 -07001050 if (CC_UNLIKELY(!mProjectedNodes.empty() && projectionReceiveIndex >= 0 &&
Andreas Gampeedaecc12014-11-10 20:54:07 -08001051 opIndex == static_cast<size_t>(projectionReceiveIndex))) {
Chris Craik8afd0f22014-08-21 17:41:57 -07001052 issueOperationsOfProjectedChildren(renderer, handler);
1053 }
John Reck25fbb3f2014-06-12 13:46:45 -07001054 }
John Reck113e0822014-03-18 09:22:59 -07001055
Chris Craikb9ce116d2015-08-20 15:14:06 -07001056 issueOperationsOf3dChildren(ChildrenSelectMode::PositiveZChildren,
Chris Craikc3e75f92014-08-27 15:34:52 -07001057 initialTransform, zTranslatedNodes, renderer, handler);
Chris Craik8afd0f22014-08-21 17:41:57 -07001058 }
John Reck25fbb3f2014-06-12 13:46:45 -07001059 }
John Reck113e0822014-03-18 09:22:59 -07001060 }
Chris Craik10ed6922015-10-15 10:55:15 -07001061#endif
John Reck113e0822014-03-18 09:22:59 -07001062
Chris Craikbf72eb82015-06-08 11:30:44 -07001063 DISPLAY_LIST_LOGD("%*sRestoreToCount %d", (handler.level() + 1) * 2, "", restoreTo);
John Reck113e0822014-03-18 09:22:59 -07001064 handler(new (alloc) RestoreToCountOp(restoreTo),
John Reckd0a0b2a2014-03-20 16:28:56 -07001065 PROPERTY_SAVECOUNT, properties().getClipToBounds());
Chris Craikb265e2c2014-03-27 15:50:09 -07001066
Chris Craikbf72eb82015-06-08 11:30:44 -07001067 DISPLAY_LIST_LOGD("%*sDone (%p, %s)", handler.level() * 2, "", this, getName());
Chris Craikb265e2c2014-03-27 15:50:09 -07001068 handler.endMark();
John Reck113e0822014-03-18 09:22:59 -07001069}
1070
1071} /* namespace uirenderer */
1072} /* namespace android */