• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 #include "RenderNode.h"
18 
19 #include "DamageAccumulator.h"
20 #include "Debug.h"
21 #include "Properties.h"
22 #include "TreeInfo.h"
23 #include "VectorDrawable.h"
24 #include "private/hwui/WebViewFunctor.h"
25 #ifdef __ANDROID__
26 #include "renderthread/CanvasContext.h"
27 #else
28 #include "DamageAccumulator.h"
29 #include "pipeline/skia/SkiaDisplayList.h"
30 #endif
31 #include <gui/TraceUtils.h>
32 #include "utils/MathUtils.h"
33 #include "utils/StringUtils.h"
34 
35 #include <SkPathOps.h>
36 #include <algorithm>
37 #include <atomic>
38 #include <sstream>
39 #include <string>
40 #include <ui/FatVector.h>
41 
42 namespace android {
43 namespace uirenderer {
44 
45 // Used for tree mutations that are purely destructive.
46 // Generic tree mutations should use MarkAndSweepObserver instead
47 class ImmediateRemoved : public TreeObserver {
48 public:
ImmediateRemoved(TreeInfo * info)49     explicit ImmediateRemoved(TreeInfo* info) : mTreeInfo(info) {}
50 
onMaybeRemovedFromTree(RenderNode * node)51     void onMaybeRemovedFromTree(RenderNode* node) override { node->onRemovedFromTree(mTreeInfo); }
52 
53 private:
54     TreeInfo* mTreeInfo;
55 };
56 
generateId()57 static int64_t generateId() {
58     static std::atomic<int64_t> sNextId{1};
59     return sNextId++;
60 }
61 
RenderNode()62 RenderNode::RenderNode()
63         : mUniqueId(generateId())
64         , mDirtyPropertyFields(0)
65         , mNeedsDisplayListSync(false)
66         , mDisplayList(nullptr)
67         , mStagingDisplayList(nullptr)
68         , mAnimatorManager(*this)
69         , mParentCount(0) {}
70 
~RenderNode()71 RenderNode::~RenderNode() {
72     ImmediateRemoved observer(nullptr);
73     deleteDisplayList(observer);
74     LOG_ALWAYS_FATAL_IF(hasLayer(), "layer missed detachment!");
75 }
76 
setStagingDisplayList(DisplayList && newData)77 void RenderNode::setStagingDisplayList(DisplayList&& newData) {
78     mValid = newData.isValid();
79     mNeedsDisplayListSync = true;
80     mStagingDisplayList = std::move(newData);
81 }
82 
discardStagingDisplayList()83 void RenderNode::discardStagingDisplayList() {
84     setStagingDisplayList(DisplayList());
85 }
86 
87 /**
88  * This function is a simplified version of replay(), where we simply retrieve and log the
89  * display list. This function should remain in sync with the replay() function.
90  */
output()91 void RenderNode::output() {
92     LogcatStream strout;
93     strout << "Root";
94     output(strout, 0);
95 }
96 
output(std::ostream & output,uint32_t level)97 void RenderNode::output(std::ostream& output, uint32_t level) {
98     output << "  (" << getName() << " " << this
99            << (MathUtils::isZero(properties().getAlpha()) ? ", zero alpha" : "")
100            << (properties().hasShadow() ? ", casting shadow" : "")
101            << (isRenderable() ? "" : ", empty")
102            << (properties().getProjectBackwards() ? ", projected" : "")
103            << (hasLayer() ? ", on HW Layer" : "") << ")" << std::endl;
104 
105     properties().debugOutputProperties(output, level + 1);
106 
107     mDisplayList.output(output, level);
108     output << std::string(level * 2, ' ') << "/RenderNode(" << getName() << " " << this << ")";
109     output << std::endl;
110 }
111 
getUsageSize()112 int RenderNode::getUsageSize() {
113     int size = sizeof(RenderNode);
114     size += mStagingDisplayList.getUsedSize();
115     size += mDisplayList.getUsedSize();
116     return size;
117 }
118 
getAllocatedSize()119 int RenderNode::getAllocatedSize() {
120     int size = sizeof(RenderNode);
121     size += mStagingDisplayList.getAllocatedSize();
122     size += mDisplayList.getAllocatedSize();
123     return size;
124 }
125 
126 
prepareTree(TreeInfo & info)127 void RenderNode::prepareTree(TreeInfo& info) {
128     ATRACE_CALL();
129     LOG_ALWAYS_FATAL_IF(!info.damageAccumulator, "DamageAccumulator missing");
130     MarkAndSweepRemoved observer(&info);
131 
132     const int before = info.disableForceDark;
133     prepareTreeImpl(observer, info, false);
134     LOG_ALWAYS_FATAL_IF(before != info.disableForceDark, "Mis-matched force dark");
135 }
136 
addAnimator(const sp<BaseRenderNodeAnimator> & animator)137 void RenderNode::addAnimator(const sp<BaseRenderNodeAnimator>& animator) {
138     mAnimatorManager.addAnimator(animator);
139 }
140 
removeAnimator(const sp<BaseRenderNodeAnimator> & animator)141 void RenderNode::removeAnimator(const sp<BaseRenderNodeAnimator>& animator) {
142     mAnimatorManager.removeAnimator(animator);
143 }
144 
damageSelf(TreeInfo & info)145 void RenderNode::damageSelf(TreeInfo& info) {
146     if (isRenderable()) {
147         mDamageGenerationId = info.damageGenerationId;
148         if (properties().getClipDamageToBounds()) {
149             info.damageAccumulator->dirty(0, 0, properties().getWidth(), properties().getHeight());
150         } else {
151             // Hope this is big enough?
152             // TODO: Get this from the display list ops or something
153             info.damageAccumulator->dirty(DIRTY_MIN, DIRTY_MIN, DIRTY_MAX, DIRTY_MAX);
154         }
155     }
156 }
157 
prepareLayer(TreeInfo & info,uint32_t dirtyMask)158 void RenderNode::prepareLayer(TreeInfo& info, uint32_t dirtyMask) {
159     LayerType layerType = properties().effectiveLayerType();
160     if (CC_UNLIKELY(layerType == LayerType::RenderLayer)) {
161         // Damage applied so far needs to affect our parent, but does not require
162         // the layer to be updated. So we pop/push here to clear out the current
163         // damage and get a clean state for display list or children updates to
164         // affect, which will require the layer to be updated
165         info.damageAccumulator->popTransform();
166         info.damageAccumulator->pushTransform(this);
167         if (dirtyMask & DISPLAY_LIST) {
168             damageSelf(info);
169         }
170     }
171 }
172 
pushLayerUpdate(TreeInfo & info)173 void RenderNode::pushLayerUpdate(TreeInfo& info) {
174 #ifdef __ANDROID__ // Layoutlib does not support CanvasContext and Layers
175     LayerType layerType = properties().effectiveLayerType();
176     // If we are not a layer OR we cannot be rendered (eg, view was detached)
177     // we need to destroy any Layers we may have had previously
178     if (CC_LIKELY(layerType != LayerType::RenderLayer) || CC_UNLIKELY(!isRenderable()) ||
179         CC_UNLIKELY(properties().getWidth() == 0) || CC_UNLIKELY(properties().getHeight() == 0) ||
180         CC_UNLIKELY(!properties().fitsOnLayer())) {
181         if (CC_UNLIKELY(hasLayer())) {
182             this->setLayerSurface(nullptr);
183         }
184         return;
185     }
186 
187     if (info.canvasContext.createOrUpdateLayer(this, *info.damageAccumulator, info.errorHandler)) {
188         damageSelf(info);
189     }
190 
191     if (!hasLayer()) {
192         return;
193     }
194 
195     SkRect dirty;
196     info.damageAccumulator->peekAtDirty(&dirty);
197     info.layerUpdateQueue->enqueueLayerWithDamage(this, dirty);
198     if (!dirty.isEmpty()) {
199       mStretchMask.markDirty();
200     }
201 
202     // There might be prefetched layers that need to be accounted for.
203     // That might be us, so tell CanvasContext that this layer is in the
204     // tree and should not be destroyed.
205     info.canvasContext.markLayerInUse(this);
206 #endif
207 }
208 
209 /**
210  * Traverse down the the draw tree to prepare for a frame.
211  *
212  * MODE_FULL = UI Thread-driven (thus properties must be synced), otherwise RT driven
213  *
214  * While traversing down the tree, functorsNeedLayer flag is set to true if anything that uses the
215  * stencil buffer may be needed. Views that use a functor to draw will be forced onto a layer.
216  */
prepareTreeImpl(TreeObserver & observer,TreeInfo & info,bool functorsNeedLayer)217 void RenderNode::prepareTreeImpl(TreeObserver& observer, TreeInfo& info, bool functorsNeedLayer) {
218     if (mDamageGenerationId == info.damageGenerationId) {
219         // We hit the same node a second time in the same tree. We don't know the minimal
220         // damage rect anymore, so just push the biggest we can onto our parent's transform
221         // We push directly onto parent in case we are clipped to bounds but have moved position.
222         info.damageAccumulator->dirty(DIRTY_MIN, DIRTY_MIN, DIRTY_MAX, DIRTY_MAX);
223     }
224     info.damageAccumulator->pushTransform(this);
225 
226     if (info.mode == TreeInfo::MODE_FULL) {
227         pushStagingPropertiesChanges(info);
228     }
229 
230     if (!mProperties.getAllowForceDark()) {
231         info.disableForceDark++;
232     }
233     if (!mProperties.layerProperties().getStretchEffect().isEmpty()) {
234         info.stretchEffectCount++;
235     }
236 
237     uint32_t animatorDirtyMask = 0;
238     if (CC_LIKELY(info.runAnimations)) {
239         animatorDirtyMask = mAnimatorManager.animate(info);
240     }
241 
242     bool willHaveFunctor = false;
243     if (info.mode == TreeInfo::MODE_FULL && mStagingDisplayList) {
244         willHaveFunctor = mStagingDisplayList.hasFunctor();
245     } else if (mDisplayList) {
246         willHaveFunctor = mDisplayList.hasFunctor();
247     }
248     bool childFunctorsNeedLayer =
249             mProperties.prepareForFunctorPresence(willHaveFunctor, functorsNeedLayer);
250 
251     if (CC_UNLIKELY(mPositionListener.get())) {
252         mPositionListener->onPositionUpdated(*this, info);
253     }
254 
255     prepareLayer(info, animatorDirtyMask);
256     if (info.mode == TreeInfo::MODE_FULL) {
257         pushStagingDisplayListChanges(observer, info);
258     }
259 
260     if (mDisplayList) {
261         info.out.hasFunctors |= mDisplayList.hasFunctor();
262         mHasHolePunches = mDisplayList.hasHolePunches();
263         bool isDirty = mDisplayList.prepareListAndChildren(
264                 observer, info, childFunctorsNeedLayer,
265                 [this](RenderNode* child, TreeObserver& observer, TreeInfo& info,
266                        bool functorsNeedLayer) {
267                     child->prepareTreeImpl(observer, info, functorsNeedLayer);
268                     mHasHolePunches |= child->hasHolePunches();
269                 });
270         if (isDirty) {
271             damageSelf(info);
272         }
273     } else {
274         mHasHolePunches = false;
275     }
276     pushLayerUpdate(info);
277 
278     if (!mProperties.getAllowForceDark()) {
279         info.disableForceDark--;
280     }
281     if (!mProperties.layerProperties().getStretchEffect().isEmpty()) {
282         info.stretchEffectCount--;
283     }
284     info.damageAccumulator->popTransform();
285 }
286 
syncProperties()287 void RenderNode::syncProperties() {
288     mProperties = mStagingProperties;
289 }
290 
pushStagingPropertiesChanges(TreeInfo & info)291 void RenderNode::pushStagingPropertiesChanges(TreeInfo& info) {
292     if (mPositionListenerDirty) {
293         mPositionListener = std::move(mStagingPositionListener);
294         mStagingPositionListener = nullptr;
295         mPositionListenerDirty = false;
296     }
297 
298     // Push the animators first so that setupStartValueIfNecessary() is called
299     // before properties() is trampled by stagingProperties(), as they are
300     // required by some animators.
301     if (CC_LIKELY(info.runAnimations)) {
302         mAnimatorManager.pushStaging();
303     }
304     if (mDirtyPropertyFields) {
305         mDirtyPropertyFields = 0;
306         damageSelf(info);
307         info.damageAccumulator->popTransform();
308         syncProperties();
309 
310         auto& layerProperties = mProperties.layerProperties();
311         const StretchEffect& stagingStretch = layerProperties.getStretchEffect();
312         if (stagingStretch.isEmpty()) {
313             mStretchMask.clear();
314         }
315 
316         if (layerProperties.getImageFilter() == nullptr) {
317             mSnapshotResult.snapshot = nullptr;
318             mTargetImageFilter = nullptr;
319         }
320 
321         // We could try to be clever and only re-damage if the matrix changed.
322         // However, we don't need to worry about that. The cost of over-damaging
323         // here is only going to be a single additional map rect of this node
324         // plus a rect join(). The parent's transform (and up) will only be
325         // performed once.
326         info.damageAccumulator->pushTransform(this);
327         damageSelf(info);
328     }
329 }
330 
updateSnapshotIfRequired(GrRecordingContext * context,const SkImageFilter * imageFilter,const SkIRect & clipBounds)331 std::optional<RenderNode::SnapshotResult> RenderNode::updateSnapshotIfRequired(
332     GrRecordingContext* context,
333     const SkImageFilter* imageFilter,
334     const SkIRect& clipBounds
335 ) {
336     auto* layerSurface = getLayerSurface();
337     if (layerSurface == nullptr) {
338         return std::nullopt;
339     }
340 
341     sk_sp<SkImage> snapshot = layerSurface->makeImageSnapshot();
342     const auto subset = SkIRect::MakeWH(properties().getWidth(),
343                                         properties().getHeight());
344     // If we don't have an ImageFilter just return the snapshot
345     if (imageFilter == nullptr) {
346         mSnapshotResult.snapshot = snapshot;
347         mSnapshotResult.outSubset = subset;
348         mSnapshotResult.outOffset = SkIPoint::Make(0.0f, 0.0f);
349         mImageFilterClipBounds = clipBounds;
350         mTargetImageFilter = nullptr;
351     } else if (mSnapshotResult.snapshot == nullptr ||
352         imageFilter != mTargetImageFilter.get() ||
353         mImageFilterClipBounds != clipBounds) {
354         // Otherwise create a new snapshot with the given filter and snapshot
355         mSnapshotResult.snapshot =
356                 snapshot->makeWithFilter(context,
357                                          imageFilter,
358                                          subset,
359                                          clipBounds,
360                                          &mSnapshotResult.outSubset,
361                                          &mSnapshotResult.outOffset);
362         mTargetImageFilter = sk_ref_sp(imageFilter);
363         mImageFilterClipBounds = clipBounds;
364     }
365 
366     return mSnapshotResult;
367 }
368 
syncDisplayList(TreeObserver & observer,TreeInfo * info)369 void RenderNode::syncDisplayList(TreeObserver& observer, TreeInfo* info) {
370     // Make sure we inc first so that we don't fluctuate between 0 and 1,
371     // which would thrash the layer cache
372     if (mStagingDisplayList) {
373         mStagingDisplayList.updateChildren([](RenderNode* child) { child->incParentRefCount(); });
374     }
375     deleteDisplayList(observer, info);
376     mDisplayList = std::move(mStagingDisplayList);
377     if (mDisplayList) {
378         WebViewSyncData syncData {
379             .applyForceDark = info && !info->disableForceDark
380         };
381         mDisplayList.syncContents(syncData);
382         handleForceDark(info);
383     }
384 }
385 
handleForceDark(android::uirenderer::TreeInfo * info)386 void RenderNode::handleForceDark(android::uirenderer::TreeInfo *info) {
387     if (CC_LIKELY(!info || info->disableForceDark)) {
388         return;
389     }
390     auto usage = usageHint();
391     FatVector<RenderNode*, 6> children;
392     mDisplayList.updateChildren([&children](RenderNode* node) {
393         children.push_back(node);
394     });
395     if (mDisplayList.hasText()) {
396         usage = UsageHint::Foreground;
397     }
398     if (usage == UsageHint::Unknown) {
399         if (children.size() > 1) {
400             usage = UsageHint::Background;
401         } else if (children.size() == 1 &&
402                 children.front()->usageHint() !=
403                         UsageHint::Background) {
404             usage = UsageHint::Background;
405         }
406     }
407     if (children.size() > 1) {
408         // Crude overlap check
409         SkRect drawn = SkRect::MakeEmpty();
410         for (auto iter = children.rbegin(); iter != children.rend(); ++iter) {
411             const auto& child = *iter;
412             // We use stagingProperties here because we haven't yet sync'd the children
413             SkRect bounds = SkRect::MakeXYWH(child->stagingProperties().getX(), child->stagingProperties().getY(),
414                     child->stagingProperties().getWidth(), child->stagingProperties().getHeight());
415             if (bounds.contains(drawn)) {
416                 // This contains everything drawn after it, so make it a background
417                 child->setUsageHint(UsageHint::Background);
418             }
419             drawn.join(bounds);
420         }
421     }
422     mDisplayList.applyColorTransform(
423             usage == UsageHint::Background ? ColorTransform::Dark : ColorTransform::Light);
424 }
425 
pushStagingDisplayListChanges(TreeObserver & observer,TreeInfo & info)426 void RenderNode::pushStagingDisplayListChanges(TreeObserver& observer, TreeInfo& info) {
427     if (mNeedsDisplayListSync) {
428         mNeedsDisplayListSync = false;
429         // Damage with the old display list first then the new one to catch any
430         // changes in isRenderable or, in the future, bounds
431         damageSelf(info);
432         syncDisplayList(observer, &info);
433         damageSelf(info);
434     }
435 }
436 
deleteDisplayList(TreeObserver & observer,TreeInfo * info)437 void RenderNode::deleteDisplayList(TreeObserver& observer, TreeInfo* info) {
438     if (mDisplayList) {
439         mDisplayList.updateChildren(
440                 [&observer, info](RenderNode* child) { child->decParentRefCount(observer, info); });
441         mDisplayList.clear(this);
442     }
443 }
444 
destroyHardwareResources(TreeInfo * info)445 void RenderNode::destroyHardwareResources(TreeInfo* info) {
446     if (hasLayer()) {
447         this->setLayerSurface(nullptr);
448     }
449     discardStagingDisplayList();
450 
451     ImmediateRemoved observer(info);
452     deleteDisplayList(observer, info);
453 }
454 
destroyLayers()455 void RenderNode::destroyLayers() {
456     if (hasLayer()) {
457         this->setLayerSurface(nullptr);
458     }
459 
460     if (mDisplayList) {
461         mDisplayList.updateChildren([](RenderNode* child) { child->destroyLayers(); });
462     }
463 }
464 
decParentRefCount(TreeObserver & observer,TreeInfo * info)465 void RenderNode::decParentRefCount(TreeObserver& observer, TreeInfo* info) {
466     LOG_ALWAYS_FATAL_IF(!mParentCount, "already 0!");
467     mParentCount--;
468     if (!mParentCount) {
469         observer.onMaybeRemovedFromTree(this);
470         if (CC_UNLIKELY(mPositionListener.get())) {
471             mPositionListener->onPositionLost(*this, info);
472         }
473     }
474 }
475 
onRemovedFromTree(TreeInfo * info)476 void RenderNode::onRemovedFromTree(TreeInfo* info) {
477     if (Properties::enableWebViewOverlays && mDisplayList) {
478         mDisplayList.onRemovedFromTree();
479     }
480     destroyHardwareResources(info);
481 }
482 
clearRoot()483 void RenderNode::clearRoot() {
484     ImmediateRemoved observer(nullptr);
485     decParentRefCount(observer);
486 }
487 
488 /**
489  * Apply property-based transformations to input matrix
490  *
491  * If true3dTransform is set to true, the transform applied to the input matrix will use true 4x4
492  * matrix computation instead of the Skia 3x3 matrix + camera hackery.
493  */
applyViewPropertyTransforms(mat4 & matrix,bool true3dTransform) const494 void RenderNode::applyViewPropertyTransforms(mat4& matrix, bool true3dTransform) const {
495     if (properties().getLeft() != 0 || properties().getTop() != 0) {
496         matrix.translate(properties().getLeft(), properties().getTop());
497     }
498     if (properties().getStaticMatrix()) {
499         mat4 stat(*properties().getStaticMatrix());
500         matrix.multiply(stat);
501     } else if (properties().getAnimationMatrix()) {
502         mat4 anim(*properties().getAnimationMatrix());
503         matrix.multiply(anim);
504     }
505 
506     bool applyTranslationZ = true3dTransform && !MathUtils::isZero(properties().getZ());
507     if (properties().hasTransformMatrix() || applyTranslationZ) {
508         if (properties().isTransformTranslateOnly()) {
509             matrix.translate(properties().getTranslationX(), properties().getTranslationY(),
510                              true3dTransform ? properties().getZ() : 0.0f);
511         } else {
512             if (!true3dTransform) {
513                 matrix.multiply(*properties().getTransformMatrix());
514             } else {
515                 mat4 true3dMat;
516                 true3dMat.loadTranslate(properties().getPivotX() + properties().getTranslationX(),
517                                         properties().getPivotY() + properties().getTranslationY(),
518                                         properties().getZ());
519                 true3dMat.rotate(properties().getRotationX(), 1, 0, 0);
520                 true3dMat.rotate(properties().getRotationY(), 0, 1, 0);
521                 true3dMat.rotate(properties().getRotation(), 0, 0, 1);
522                 true3dMat.scale(properties().getScaleX(), properties().getScaleY(), 1);
523                 true3dMat.translate(-properties().getPivotX(), -properties().getPivotY());
524 
525                 matrix.multiply(true3dMat);
526             }
527         }
528     }
529 
530     if (Properties::getStretchEffectBehavior() == StretchEffectBehavior::UniformScale) {
531         const StretchEffect& stretch = properties().layerProperties().getStretchEffect();
532         if (!stretch.isEmpty()) {
533             matrix.multiply(
534                     stretch.makeLinearStretch(properties().getWidth(), properties().getHeight()));
535         }
536     }
537 }
538 
getClippedOutline(const SkRect & clipRect) const539 const SkPath* RenderNode::getClippedOutline(const SkRect& clipRect) const {
540     const SkPath* outlinePath = properties().getOutline().getPath();
541     const uint32_t outlineID = outlinePath->getGenerationID();
542 
543     if (outlineID != mClippedOutlineCache.outlineID || clipRect != mClippedOutlineCache.clipRect) {
544         // update the cache keys
545         mClippedOutlineCache.outlineID = outlineID;
546         mClippedOutlineCache.clipRect = clipRect;
547 
548         // update the cache value by recomputing a new path
549         SkPath clipPath;
550         clipPath.addRect(clipRect);
551         Op(*outlinePath, clipPath, kIntersect_SkPathOp, &mClippedOutlineCache.clippedOutline);
552     }
553     return &mClippedOutlineCache.clippedOutline;
554 }
555 
556 using StringBuffer = FatVector<char, 128>;
557 
558 template <typename... T>
559 // TODO:__printflike(2, 3)
560 // Doesn't work because the warning doesn't understand string_view and doesn't like that
561 // it's not a C-style variadic function.
format(StringBuffer & buffer,const std::string_view & format,T...args)562 static void format(StringBuffer& buffer, const std::string_view& format, T... args) {
563     buffer.resize(buffer.capacity());
564     while (1) {
565         int needed = snprintf(buffer.data(), buffer.size(),
566                 format.data(), std::forward<T>(args)...);
567         if (needed < 0) {
568             buffer[0] = '\0';
569             buffer.resize(1);
570             return;
571         }
572         if (needed < buffer.size()) {
573             buffer.resize(needed + 1);
574             return;
575         }
576         // If we're doing a heap alloc anyway might as well give it some slop
577         buffer.resize(needed + 100);
578     }
579 }
580 
markDrawStart(SkCanvas & canvas)581 void RenderNode::markDrawStart(SkCanvas& canvas) {
582     StringBuffer buffer;
583     format(buffer, "RenderNode(id=%" PRId64 ", name='%s')", uniqueId(), getName());
584     canvas.drawAnnotation(SkRect::MakeWH(getWidth(), getHeight()), buffer.data(), nullptr);
585 }
586 
markDrawEnd(SkCanvas & canvas)587 void RenderNode::markDrawEnd(SkCanvas& canvas) {
588     StringBuffer buffer;
589     format(buffer, "/RenderNode(id=%" PRId64 ", name='%s')", uniqueId(), getName());
590     canvas.drawAnnotation(SkRect::MakeWH(getWidth(), getHeight()), buffer.data(), nullptr);
591 }
592 
593 } /* namespace uirenderer */
594 } /* namespace android */
595