blob: 83fa84eb131e8ddda40c717e087d35657070115e [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 Craik5e00c7c2016-07-06 16:10:09 -070021#include "RecordedOp.h"
Tom Hudson2dc236b2014-10-15 15:46:42 -040022#include "TreeInfo.h"
John Reck1bcacfd2017-11-03 10:12:19 -070023#include "VectorDrawable.h"
24#include "renderstate/RenderState.h"
25#include "renderthread/CanvasContext.h"
John Reck2de950d2017-01-25 10:58:30 -080026#include "utils/FatVector.h"
Chris Craike0bb87d2014-04-22 17:55:41 -070027#include "utils/MathUtils.h"
sergeyvc3849aa2016-08-08 13:22:06 -070028#include "utils/StringUtils.h"
Chris Craik70850ea2014-11-18 10:49:23 -080029#include "utils/TraceUtils.h"
John Reck113e0822014-03-18 09:22:59 -070030
Derek Sollenberger579317d42017-08-29 16:33:49 -040031#include <SkPathOps.h>
John Reck77c40102015-10-26 15:49:47 -070032#include <algorithm>
33#include <sstream>
34#include <string>
35
John Reck113e0822014-03-18 09:22:59 -070036namespace android {
37namespace uirenderer {
38
John Reck2de950d2017-01-25 10:58:30 -080039// Used for tree mutations that are purely destructive.
40// Generic tree mutations should use MarkAndSweepObserver instead
41class ImmediateRemoved : public TreeObserver {
42public:
43 explicit ImmediateRemoved(TreeInfo* info) : mTreeInfo(info) {}
44
John Reck1bcacfd2017-11-03 10:12:19 -070045 void onMaybeRemovedFromTree(RenderNode* node) override { node->onRemovedFromTree(mTreeInfo); }
John Reck2de950d2017-01-25 10:58:30 -080046
47private:
48 TreeInfo* mTreeInfo;
49};
50
John Reck8de65a82014-04-09 15:23:38 -070051RenderNode::RenderNode()
John Reckff941dc2014-05-14 16:34:14 -070052 : mDirtyPropertyFields(0)
Chris Craik003cc3d2015-10-16 10:24:55 -070053 , mNeedsDisplayListSync(false)
54 , mDisplayList(nullptr)
55 , mStagingDisplayList(nullptr)
John Reck68bfe0a2014-06-24 15:34:58 -070056 , mAnimatorManager(*this)
John Reck1bcacfd2017-11-03 10:12:19 -070057 , mParentCount(0) {}
John Reck113e0822014-03-18 09:22:59 -070058
59RenderNode::~RenderNode() {
John Reck2de950d2017-01-25 10:58:30 -080060 ImmediateRemoved observer(nullptr);
61 deleteDisplayList(observer);
Chris Craik003cc3d2015-10-16 10:24:55 -070062 delete mStagingDisplayList;
Derek Sollenberger0df62092016-09-27 16:04:42 -040063 LOG_ALWAYS_FATAL_IF(hasLayer(), "layer missed detachment!");
John Reck113e0822014-03-18 09:22:59 -070064}
65
John Reck2de950d2017-01-25 10:58:30 -080066void RenderNode::setStagingDisplayList(DisplayList* displayList) {
67 mValid = (displayList != nullptr);
Chris Craik003cc3d2015-10-16 10:24:55 -070068 mNeedsDisplayListSync = true;
69 delete mStagingDisplayList;
70 mStagingDisplayList = displayList;
John Reck113e0822014-03-18 09:22:59 -070071}
72
73/**
74 * This function is a simplified version of replay(), where we simply retrieve and log the
75 * display list. This function should remain in sync with the replay() function.
76 */
sergeyvc3849aa2016-08-08 13:22:06 -070077void RenderNode::output() {
78 LogcatStream strout;
79 strout << "Root";
80 output(strout, 0);
81}
82
83void RenderNode::output(std::ostream& output, uint32_t level) {
84 output << " (" << getName() << " " << this
John Reck1bcacfd2017-11-03 10:12:19 -070085 << (MathUtils::isZero(properties().getAlpha()) ? ", zero alpha" : "")
86 << (properties().hasShadow() ? ", casting shadow" : "")
87 << (isRenderable() ? "" : ", empty")
88 << (properties().getProjectBackwards() ? ", projected" : "")
89 << (hasLayer() ? ", on HW Layer" : "") << ")" << std::endl;
sergeyvc3849aa2016-08-08 13:22:06 -070090
91 properties().debugOutputProperties(output, level + 1);
Chris Craik91eff222016-02-22 13:39:33 -080092
93 if (mDisplayList) {
Stan Ilievd2172372017-02-09 16:59:27 -050094 mDisplayList->output(output, level);
Chris Craik91eff222016-02-22 13:39:33 -080095 }
sergeyvc3849aa2016-08-08 13:22:06 -070096 output << std::string(level * 2, ' ') << "/RenderNode(" << getName() << " " << this << ")";
97 output << std::endl;
Chris Craik91eff222016-02-22 13:39:33 -080098}
John Reck113e0822014-03-18 09:22:59 -070099
John Reckfe5e7b72014-05-23 17:42:28 -0700100int RenderNode::getDebugSize() {
101 int size = sizeof(RenderNode);
Chris Craik003cc3d2015-10-16 10:24:55 -0700102 if (mStagingDisplayList) {
103 size += mStagingDisplayList->getUsedSize();
John Reckfe5e7b72014-05-23 17:42:28 -0700104 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700105 if (mDisplayList && mDisplayList != mStagingDisplayList) {
106 size += mDisplayList->getUsedSize();
John Reckfe5e7b72014-05-23 17:42:28 -0700107 }
108 return size;
109}
110
John Reckf4198b72014-04-09 17:00:04 -0700111void RenderNode::prepareTree(TreeInfo& info) {
112 ATRACE_CALL();
Chris Craik69e5adf2014-08-14 13:34:01 -0700113 LOG_ALWAYS_FATAL_IF(!info.damageAccumulator, "DamageAccumulator missing");
John Reck2de950d2017-01-25 10:58:30 -0800114 MarkAndSweepRemoved observer(&info);
John Reckf4198b72014-04-09 17:00:04 -0700115
John Reck1072fff2018-04-12 15:20:09 -0700116 prepareTreeImpl(observer, info, false);
John Reckf4198b72014-04-09 17:00:04 -0700117}
118
John Reck68bfe0a2014-06-24 15:34:58 -0700119void RenderNode::addAnimator(const sp<BaseRenderNodeAnimator>& animator) {
120 mAnimatorManager.addAnimator(animator);
121}
122
Doris Liu8b083202016-02-19 21:46:06 +0000123void RenderNode::removeAnimator(const sp<BaseRenderNodeAnimator>& animator) {
124 mAnimatorManager.removeAnimator(animator);
125}
126
John Recke4267ea2014-06-03 15:53:15 -0700127void RenderNode::damageSelf(TreeInfo& info) {
John Reckce9f3082014-06-17 16:18:09 -0700128 if (isRenderable()) {
John Reck293e8682014-06-17 10:34:02 -0700129 if (properties().getClipDamageToBounds()) {
John Recka447d292014-06-11 18:39:44 -0700130 info.damageAccumulator->dirty(0, 0, properties().getWidth(), properties().getHeight());
131 } else {
132 // Hope this is big enough?
133 // TODO: Get this from the display list ops or something
John Reckc1288232015-08-12 13:39:11 -0700134 info.damageAccumulator->dirty(DIRTY_MIN, DIRTY_MIN, DIRTY_MAX, DIRTY_MAX);
John Recka447d292014-06-11 18:39:44 -0700135 }
John Recke4267ea2014-06-03 15:53:15 -0700136 }
137}
138
John Recka7c2ea22014-08-08 13:21:00 -0700139void RenderNode::prepareLayer(TreeInfo& info, uint32_t dirtyMask) {
Chris Craik856f0cc2015-04-21 15:13:29 -0700140 LayerType layerType = properties().effectiveLayerType();
Chris Craik182952f2015-03-09 14:17:29 -0700141 if (CC_UNLIKELY(layerType == LayerType::RenderLayer)) {
John Recka7c2ea22014-08-08 13:21:00 -0700142 // Damage applied so far needs to affect our parent, but does not require
143 // the layer to be updated. So we pop/push here to clear out the current
144 // damage and get a clean state for display list or children updates to
145 // affect, which will require the layer to be updated
146 info.damageAccumulator->popTransform();
147 info.damageAccumulator->pushTransform(this);
148 if (dirtyMask & DISPLAY_LIST) {
149 damageSelf(info);
150 }
John Reck25fbb3f2014-06-12 13:46:45 -0700151 }
152}
153
154void RenderNode::pushLayerUpdate(TreeInfo& info) {
Chris Craik856f0cc2015-04-21 15:13:29 -0700155 LayerType layerType = properties().effectiveLayerType();
John Reck25fbb3f2014-06-12 13:46:45 -0700156 // If we are not a layer OR we cannot be rendered (eg, view was detached)
157 // we need to destroy any Layers we may have had previously
John Reck1bcacfd2017-11-03 10:12:19 -0700158 if (CC_LIKELY(layerType != LayerType::RenderLayer) || CC_UNLIKELY(!isRenderable()) ||
159 CC_UNLIKELY(properties().getWidth() == 0) || CC_UNLIKELY(properties().getHeight() == 0) ||
160 CC_UNLIKELY(!properties().fitsOnLayer())) {
Derek Sollenberger0df62092016-09-27 16:04:42 -0400161 if (CC_UNLIKELY(hasLayer())) {
Derek Sollenberger6a21ca52016-09-28 13:39:55 -0400162 renderthread::CanvasContext::destroyLayer(this);
John Reck25fbb3f2014-06-12 13:46:45 -0700163 }
164 return;
165 }
166
Stan Iliev216b1572018-03-26 14:29:50 -0400167 if (info.canvasContext.createOrUpdateLayer(this, *info.damageAccumulator, info.errorHandler)) {
Chris Craik9fded232015-11-11 16:42:34 -0800168 damageSelf(info);
Chris Craik69e5adf2014-08-14 13:34:01 -0700169 }
170
Derek Sollenberger0df62092016-09-27 16:04:42 -0400171 if (!hasLayer()) {
John Reckc25e5062014-06-18 14:21:29 -0700172 return;
173 }
174
Derek Sollenberger6a21ca52016-09-28 13:39:55 -0400175 SkRect dirty;
176 info.damageAccumulator->peekAtDirty(&dirty);
Chris Craik0b7e8242015-10-28 16:50:44 -0700177 info.layerUpdateQueue->enqueueLayerWithDamage(this, dirty);
John Reck998a6d82014-08-28 15:35:53 -0700178
Chris Craike2e53a72015-10-28 15:55:40 -0700179 // There might be prefetched layers that need to be accounted for.
180 // That might be us, so tell CanvasContext that this layer is in the
181 // tree and should not be destroyed.
182 info.canvasContext.markLayerInUse(this);
John Reck25fbb3f2014-06-12 13:46:45 -0700183}
184
Chris Craika766cb22015-06-08 16:49:43 -0700185/**
186 * Traverse down the the draw tree to prepare for a frame.
187 *
188 * MODE_FULL = UI Thread-driven (thus properties must be synced), otherwise RT driven
189 *
190 * While traversing down the tree, functorsNeedLayer flag is set to true if anything that uses the
191 * stencil buffer may be needed. Views that use a functor to draw will be forced onto a layer.
192 */
John Reck2de950d2017-01-25 10:58:30 -0800193void RenderNode::prepareTreeImpl(TreeObserver& observer, TreeInfo& info, bool functorsNeedLayer) {
John Recka447d292014-06-11 18:39:44 -0700194 info.damageAccumulator->pushTransform(this);
John Reckf47a5942014-06-30 16:20:04 -0700195
John Reckdcba6722014-07-08 13:59:49 -0700196 if (info.mode == TreeInfo::MODE_FULL) {
John Reck25fbb3f2014-06-12 13:46:45 -0700197 pushStagingPropertiesChanges(info);
John Recke45b1fd2014-04-15 09:50:16 -0700198 }
John Reck9eb9f6f2014-08-21 11:23:05 -0700199 uint32_t animatorDirtyMask = 0;
200 if (CC_LIKELY(info.runAnimations)) {
201 animatorDirtyMask = mAnimatorManager.animate(info);
202 }
Chris Craika766cb22015-06-08 16:49:43 -0700203
John Reck3f725f02015-06-16 10:29:31 -0700204 bool willHaveFunctor = false;
Chris Craik003cc3d2015-10-16 10:24:55 -0700205 if (info.mode == TreeInfo::MODE_FULL && mStagingDisplayList) {
Derek Sollenberger0df62092016-09-27 16:04:42 -0400206 willHaveFunctor = mStagingDisplayList->hasFunctor();
Chris Craik003cc3d2015-10-16 10:24:55 -0700207 } else if (mDisplayList) {
Derek Sollenberger0df62092016-09-27 16:04:42 -0400208 willHaveFunctor = mDisplayList->hasFunctor();
John Reck3f725f02015-06-16 10:29:31 -0700209 }
John Reck1bcacfd2017-11-03 10:12:19 -0700210 bool childFunctorsNeedLayer =
211 mProperties.prepareForFunctorPresence(willHaveFunctor, functorsNeedLayer);
Chris Craika766cb22015-06-08 16:49:43 -0700212
John Reckf6481082016-02-02 15:18:23 -0800213 if (CC_UNLIKELY(mPositionListener.get())) {
214 mPositionListener->onPositionUpdated(*this, info);
215 }
216
John Recka7c2ea22014-08-08 13:21:00 -0700217 prepareLayer(info, animatorDirtyMask);
John Reckdcba6722014-07-08 13:59:49 -0700218 if (info.mode == TreeInfo::MODE_FULL) {
John Reck2de950d2017-01-25 10:58:30 -0800219 pushStagingDisplayListChanges(observer, info);
John Reck25fbb3f2014-06-12 13:46:45 -0700220 }
John Reck25fbb3f2014-06-12 13:46:45 -0700221
Doris Liu07c056d2016-06-13 12:52:44 -0700222 if (mDisplayList) {
Derek Sollenberger0df62092016-09-27 16:04:42 -0400223 info.out.hasFunctors |= mDisplayList->hasFunctor();
John Reck1bcacfd2017-11-03 10:12:19 -0700224 bool isDirty = mDisplayList->prepareListAndChildren(
225 observer, info, childFunctorsNeedLayer,
226 [](RenderNode* child, TreeObserver& observer, TreeInfo& info,
227 bool functorsNeedLayer) {
228 child->prepareTreeImpl(observer, info, functorsNeedLayer);
229 });
Derek Sollenberger0df62092016-09-27 16:04:42 -0400230 if (isDirty) {
231 damageSelf(info);
Doris Liu718cd3e2016-05-17 16:50:31 -0700232 }
Doris Liu718cd3e2016-05-17 16:50:31 -0700233 }
Doris Liub51b2862016-08-01 19:56:47 -0700234 pushLayerUpdate(info);
Doris Liu718cd3e2016-05-17 16:50:31 -0700235
John Recka447d292014-06-11 18:39:44 -0700236 info.damageAccumulator->popTransform();
John Reckf4198b72014-04-09 17:00:04 -0700237}
238
Chris Craikb565df12015-10-05 13:00:52 -0700239void RenderNode::syncProperties() {
240 mProperties = mStagingProperties;
241}
242
John Reck25fbb3f2014-06-12 13:46:45 -0700243void RenderNode::pushStagingPropertiesChanges(TreeInfo& info) {
John Reckff941dc2014-05-14 16:34:14 -0700244 // Push the animators first so that setupStartValueIfNecessary() is called
245 // before properties() is trampled by stagingProperties(), as they are
246 // required by some animators.
John Reck9eb9f6f2014-08-21 11:23:05 -0700247 if (CC_LIKELY(info.runAnimations)) {
John Reck119907c2014-08-14 09:02:01 -0700248 mAnimatorManager.pushStaging();
John Reck9eb9f6f2014-08-21 11:23:05 -0700249 }
John Reckff941dc2014-05-14 16:34:14 -0700250 if (mDirtyPropertyFields) {
251 mDirtyPropertyFields = 0;
John Recke4267ea2014-06-03 15:53:15 -0700252 damageSelf(info);
John Recka447d292014-06-11 18:39:44 -0700253 info.damageAccumulator->popTransform();
Chris Craikb565df12015-10-05 13:00:52 -0700254 syncProperties();
John Recke4267ea2014-06-03 15:53:15 -0700255 // We could try to be clever and only re-damage if the matrix changed.
256 // However, we don't need to worry about that. The cost of over-damaging
257 // here is only going to be a single additional map rect of this node
258 // plus a rect join(). The parent's transform (and up) will only be
259 // performed once.
John Recka447d292014-06-11 18:39:44 -0700260 info.damageAccumulator->pushTransform(this);
John Recke4267ea2014-06-03 15:53:15 -0700261 damageSelf(info);
John Reckff941dc2014-05-14 16:34:14 -0700262 }
John Reck25fbb3f2014-06-12 13:46:45 -0700263}
264
John Reck2de950d2017-01-25 10:58:30 -0800265void RenderNode::syncDisplayList(TreeObserver& observer, TreeInfo* info) {
Chris Craikb565df12015-10-05 13:00:52 -0700266 // Make sure we inc first so that we don't fluctuate between 0 and 1,
267 // which would thrash the layer cache
Chris Craik003cc3d2015-10-16 10:24:55 -0700268 if (mStagingDisplayList) {
John Reck1bcacfd2017-11-03 10:12:19 -0700269 mStagingDisplayList->updateChildren([](RenderNode* child) { child->incParentRefCount(); });
Chris Craikb565df12015-10-05 13:00:52 -0700270 }
John Reck2de950d2017-01-25 10:58:30 -0800271 deleteDisplayList(observer, info);
Chris Craik003cc3d2015-10-16 10:24:55 -0700272 mDisplayList = mStagingDisplayList;
273 mStagingDisplayList = nullptr;
274 if (mDisplayList) {
Derek Sollenberger0df62092016-09-27 16:04:42 -0400275 mDisplayList->syncContents();
Chris Craikb565df12015-10-05 13:00:52 -0700276 }
277}
278
John Reck2de950d2017-01-25 10:58:30 -0800279void RenderNode::pushStagingDisplayListChanges(TreeObserver& observer, TreeInfo& info) {
Chris Craik003cc3d2015-10-16 10:24:55 -0700280 if (mNeedsDisplayListSync) {
281 mNeedsDisplayListSync = false;
John Reck5c9d7172014-10-22 11:32:27 -0700282 // Damage with the old display list first then the new one to catch any
283 // changes in isRenderable or, in the future, bounds
284 damageSelf(info);
John Reck2de950d2017-01-25 10:58:30 -0800285 syncDisplayList(observer, &info);
John Recke4267ea2014-06-03 15:53:15 -0700286 damageSelf(info);
John Reck8de65a82014-04-09 15:23:38 -0700287 }
John Reck8de65a82014-04-09 15:23:38 -0700288}
289
John Reck2de950d2017-01-25 10:58:30 -0800290void RenderNode::deleteDisplayList(TreeObserver& observer, TreeInfo* info) {
Chris Craik003cc3d2015-10-16 10:24:55 -0700291 if (mDisplayList) {
John Reck1bcacfd2017-11-03 10:12:19 -0700292 mDisplayList->updateChildren(
293 [&observer, info](RenderNode* child) { child->decParentRefCount(observer, info); });
Derek Sollenberger0df62092016-09-27 16:04:42 -0400294 if (!mDisplayList->reuseDisplayList(this, info ? &info->canvasContext : nullptr)) {
295 delete mDisplayList;
John Reckdcba6722014-07-08 13:59:49 -0700296 }
297 }
Chris Craik003cc3d2015-10-16 10:24:55 -0700298 mDisplayList = nullptr;
John Reckdcba6722014-07-08 13:59:49 -0700299}
300
John Reck2de950d2017-01-25 10:58:30 -0800301void RenderNode::destroyHardwareResources(TreeInfo* info) {
Derek Sollenberger0df62092016-09-27 16:04:42 -0400302 if (hasLayer()) {
Derek Sollenberger6a21ca52016-09-28 13:39:55 -0400303 renderthread::CanvasContext::destroyLayer(this);
John Reckdcba6722014-07-08 13:59:49 -0700304 }
John Reck3afd6372017-01-30 10:15:48 -0800305 setStagingDisplayList(nullptr);
306
307 ImmediateRemoved observer(info);
308 deleteDisplayList(observer, info);
John Reck2de950d2017-01-25 10:58:30 -0800309}
310
311void RenderNode::destroyLayers() {
312 if (hasLayer()) {
313 renderthread::CanvasContext::destroyLayer(this);
314 }
315 if (mDisplayList) {
John Reck1bcacfd2017-11-03 10:12:19 -0700316 mDisplayList->updateChildren([](RenderNode* child) { child->destroyLayers(); });
John Reck2de950d2017-01-25 10:58:30 -0800317 }
318}
319
320void RenderNode::decParentRefCount(TreeObserver& observer, TreeInfo* info) {
321 LOG_ALWAYS_FATAL_IF(!mParentCount, "already 0!");
322 mParentCount--;
323 if (!mParentCount) {
324 observer.onMaybeRemovedFromTree(this);
325 if (CC_UNLIKELY(mPositionListener.get())) {
326 mPositionListener->onPositionLost(*this, info);
John Reckdcba6722014-07-08 13:59:49 -0700327 }
328 }
329}
330
John Reck2de950d2017-01-25 10:58:30 -0800331void RenderNode::onRemovedFromTree(TreeInfo* info) {
332 destroyHardwareResources(info);
333}
334
335void RenderNode::clearRoot() {
336 ImmediateRemoved observer(nullptr);
337 decParentRefCount(observer);
John Reckdcba6722014-07-08 13:59:49 -0700338}
339
John Reck113e0822014-03-18 09:22:59 -0700340/**
341 * Apply property-based transformations to input matrix
342 *
343 * If true3dTransform is set to true, the transform applied to the input matrix will use true 4x4
344 * matrix computation instead of the Skia 3x3 matrix + camera hackery.
345 */
Chris Craik69e5adf2014-08-14 13:34:01 -0700346void RenderNode::applyViewPropertyTransforms(mat4& matrix, bool true3dTransform) const {
John Reckd0a0b2a2014-03-20 16:28:56 -0700347 if (properties().getLeft() != 0 || properties().getTop() != 0) {
348 matrix.translate(properties().getLeft(), properties().getTop());
John Reck113e0822014-03-18 09:22:59 -0700349 }
John Reckd0a0b2a2014-03-20 16:28:56 -0700350 if (properties().getStaticMatrix()) {
351 mat4 stat(*properties().getStaticMatrix());
John Reck113e0822014-03-18 09:22:59 -0700352 matrix.multiply(stat);
John Reckd0a0b2a2014-03-20 16:28:56 -0700353 } else if (properties().getAnimationMatrix()) {
354 mat4 anim(*properties().getAnimationMatrix());
John Reck113e0822014-03-18 09:22:59 -0700355 matrix.multiply(anim);
356 }
Chris Craike0bb87d2014-04-22 17:55:41 -0700357
Chris Craikcc39e162014-04-25 18:34:11 -0700358 bool applyTranslationZ = true3dTransform && !MathUtils::isZero(properties().getZ());
Chris Craike0bb87d2014-04-22 17:55:41 -0700359 if (properties().hasTransformMatrix() || applyTranslationZ) {
John Reckf7483e32014-04-11 08:54:47 -0700360 if (properties().isTransformTranslateOnly()) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700361 matrix.translate(properties().getTranslationX(), properties().getTranslationY(),
John Reck1bcacfd2017-11-03 10:12:19 -0700362 true3dTransform ? properties().getZ() : 0.0f);
John Reck113e0822014-03-18 09:22:59 -0700363 } else {
364 if (!true3dTransform) {
John Reckd0a0b2a2014-03-20 16:28:56 -0700365 matrix.multiply(*properties().getTransformMatrix());
John Reck113e0822014-03-18 09:22:59 -0700366 } else {
367 mat4 true3dMat;
John Reck1bcacfd2017-11-03 10:12:19 -0700368 true3dMat.loadTranslate(properties().getPivotX() + properties().getTranslationX(),
369 properties().getPivotY() + properties().getTranslationY(),
370 properties().getZ());
John Reckd0a0b2a2014-03-20 16:28:56 -0700371 true3dMat.rotate(properties().getRotationX(), 1, 0, 0);
372 true3dMat.rotate(properties().getRotationY(), 0, 1, 0);
373 true3dMat.rotate(properties().getRotation(), 0, 0, 1);
374 true3dMat.scale(properties().getScaleX(), properties().getScaleY(), 1);
375 true3dMat.translate(-properties().getPivotX(), -properties().getPivotY());
John Reck113e0822014-03-18 09:22:59 -0700376
377 matrix.multiply(true3dMat);
378 }
379 }
380 }
381}
382
Derek Sollenberger579317d42017-08-29 16:33:49 -0400383const SkPath* RenderNode::getClippedOutline(const SkRect& clipRect) const {
384 const SkPath* outlinePath = properties().getOutline().getPath();
385 const uint32_t outlineID = outlinePath->getGenerationID();
386
387 if (outlineID != mClippedOutlineCache.outlineID || clipRect != mClippedOutlineCache.clipRect) {
388 // update the cache keys
389 mClippedOutlineCache.outlineID = outlineID;
390 mClippedOutlineCache.clipRect = clipRect;
391
392 // update the cache value by recomputing a new path
393 SkPath clipPath;
394 clipPath.addRect(clipRect);
395 Op(*outlinePath, clipPath, kIntersect_SkPathOp, &mClippedOutlineCache.clippedOutline);
Derek Sollenberger579317d42017-08-29 16:33:49 -0400396 }
397 return &mClippedOutlineCache.clippedOutline;
398}
399
John Reck113e0822014-03-18 09:22:59 -0700400} /* namespace uirenderer */
401} /* namespace android */