RenderNode.cpp revision 286ffe4b28d2c004ce98f7ddb3a5f34441ab0d80
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#define ATRACE_TAG ATRACE_TAG_VIEW
18
19#include "RenderNode.h"
20
21#include <SkCanvas.h>
22#include <algorithm>
23
24#include <utils/Trace.h>
25
26#include "Debug.h"
27#include "DisplayListOp.h"
28#include "DisplayListLogBuffer.h"
29
30namespace android {
31namespace uirenderer {
32
33void RenderNode::outputLogBuffer(int fd) {
34    DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
35    if (logBuffer.isEmpty()) {
36        return;
37    }
38
39    FILE *file = fdopen(fd, "a");
40
41    fprintf(file, "\nRecent DisplayList operations\n");
42    logBuffer.outputCommands(file);
43
44    String8 cachesLog;
45    Caches::getInstance().dumpMemoryUsage(cachesLog);
46    fprintf(file, "\nCaches:\n%s", cachesLog.string());
47    fprintf(file, "\n");
48
49    fflush(file);
50}
51
52RenderNode::RenderNode()
53        : mNeedsPropertiesSync(false)
54        , mNeedsDisplayListDataSync(false)
55        , mDisplayListData(0)
56        , mStagingDisplayListData(0) {
57}
58
59RenderNode::~RenderNode() {
60    delete mDisplayListData;
61    delete mStagingDisplayListData;
62}
63
64void RenderNode::setStagingDisplayList(DisplayListData* data) {
65    mNeedsDisplayListDataSync = true;
66    delete mStagingDisplayListData;
67    mStagingDisplayListData = data;
68    if (mStagingDisplayListData) {
69        Caches::getInstance().registerFunctors(mStagingDisplayListData->functorCount);
70    }
71}
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 */
77void RenderNode::output(uint32_t level) {
78    ALOGD("%*sStart display list (%p, %s, render=%d)", (level - 1) * 2, "", this,
79            mName.string(), isRenderable());
80    ALOGD("%*s%s %d", level * 2, "", "Save",
81            SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
82
83    properties().debugOutputProperties(level);
84    int flags = DisplayListOp::kOpLogFlag_Recurse;
85    for (unsigned int i = 0; i < mDisplayListData->displayListOps.size(); i++) {
86        mDisplayListData->displayListOps[i]->output(level, flags);
87    }
88
89    ALOGD("%*sDone (%p, %s)", (level - 1) * 2, "", this, mName.string());
90}
91
92void RenderNode::prepareTree(TreeInfo& info) {
93    ATRACE_CALL();
94
95    prepareTreeImpl(info);
96}
97
98void RenderNode::prepareTreeImpl(TreeInfo& info) {
99    pushStagingChanges(info);
100    prepareSubTree(info, mDisplayListData);
101}
102
103void RenderNode::pushStagingChanges(TreeInfo& info) {
104    if (mNeedsPropertiesSync) {
105        mNeedsPropertiesSync = false;
106        mProperties = mStagingProperties;
107    }
108    if (mNeedsDisplayListDataSync) {
109        mNeedsDisplayListDataSync = false;
110        // Do a push pass on the old tree to handle freeing DisplayListData
111        // that are no longer used
112        TreeInfo oldTreeInfo = {0};
113        prepareSubTree(oldTreeInfo, mDisplayListData);
114        // TODO: The damage for the old tree should be accounted for
115        delete mDisplayListData;
116        mDisplayListData = mStagingDisplayListData;
117        mStagingDisplayListData = 0;
118    }
119}
120
121void RenderNode::prepareSubTree(TreeInfo& info, DisplayListData* subtree) {
122    if (subtree) {
123        if (!info.hasFunctors) {
124            info.hasFunctors = subtree->functorCount;
125        }
126        for (size_t i = 0; i < subtree->children().size(); i++) {
127            RenderNode* childNode = subtree->children()[i]->mDisplayList;
128            childNode->prepareTreeImpl(info);
129        }
130    }
131}
132
133/*
134 * For property operations, we pass a savecount of 0, since the operations aren't part of the
135 * displaylist, and thus don't have to compensate for the record-time/playback-time discrepancy in
136 * base saveCount (i.e., how RestoreToCount uses saveCount + properties().getCount())
137 */
138#define PROPERTY_SAVECOUNT 0
139
140template <class T>
141void RenderNode::setViewProperties(OpenGLRenderer& renderer, T& handler) {
142#if DEBUG_DISPLAY_LIST
143    properties().debugOutputProperties(handler.level() + 1);
144#endif
145    if (properties().getLeft() != 0 || properties().getTop() != 0) {
146        renderer.translate(properties().getLeft(), properties().getTop());
147    }
148    if (properties().getStaticMatrix()) {
149        renderer.concatMatrix(properties().getStaticMatrix());
150    } else if (properties().getAnimationMatrix()) {
151        renderer.concatMatrix(properties().getAnimationMatrix());
152    }
153    if (properties().hasTransformMatrix()) {
154        if (properties().isTransformTranslateOnly()) {
155            renderer.translate(properties().getTranslationX(), properties().getTranslationY());
156        } else {
157            renderer.concatMatrix(*properties().getTransformMatrix());
158        }
159    }
160    bool clipToBoundsNeeded = properties().getCaching() ? false : properties().getClipToBounds();
161    if (properties().getAlpha() < 1) {
162        if (properties().getCaching()) {
163            renderer.setOverrideLayerAlpha(properties().getAlpha());
164        } else if (!properties().getHasOverlappingRendering()) {
165            renderer.scaleAlpha(properties().getAlpha());
166        } else {
167            // TODO: should be able to store the size of a DL at record time and not
168            // have to pass it into this call. In fact, this information might be in the
169            // location/size info that we store with the new native transform data.
170            int saveFlags = SkCanvas::kHasAlphaLayer_SaveFlag;
171            if (clipToBoundsNeeded) {
172                saveFlags |= SkCanvas::kClipToLayer_SaveFlag;
173                clipToBoundsNeeded = false; // clipping done by saveLayer
174            }
175
176            SaveLayerOp* op = new (handler.allocator()) SaveLayerOp(
177                    0, 0, properties().getWidth(), properties().getHeight(),
178                    properties().getAlpha() * 255, saveFlags);
179            handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds());
180        }
181    }
182    if (clipToBoundsNeeded) {
183        ClipRectOp* op = new (handler.allocator()) ClipRectOp(
184                0, 0, properties().getWidth(), properties().getHeight(), SkRegion::kIntersect_Op);
185        handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds());
186    }
187
188    if (CC_UNLIKELY(properties().hasClippingPath())) {
189        // TODO: optimize for round rect/circle clipping
190        const SkPath* path = properties().getClippingPath();
191        ClipPathOp* op = new (handler.allocator()) ClipPathOp(path, SkRegion::kIntersect_Op);
192        handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds());
193    }
194}
195
196/**
197 * Apply property-based transformations to input matrix
198 *
199 * If true3dTransform is set to true, the transform applied to the input matrix will use true 4x4
200 * matrix computation instead of the Skia 3x3 matrix + camera hackery.
201 */
202void RenderNode::applyViewPropertyTransforms(mat4& matrix, bool true3dTransform) {
203    if (properties().getLeft() != 0 || properties().getTop() != 0) {
204        matrix.translate(properties().getLeft(), properties().getTop());
205    }
206    if (properties().getStaticMatrix()) {
207        mat4 stat(*properties().getStaticMatrix());
208        matrix.multiply(stat);
209    } else if (properties().getAnimationMatrix()) {
210        mat4 anim(*properties().getAnimationMatrix());
211        matrix.multiply(anim);
212    }
213    if (properties().hasTransformMatrix()) {
214        if (properties().isTransformTranslateOnly()) {
215            matrix.translate(properties().getTranslationX(), properties().getTranslationY(),
216                    true3dTransform ? properties().getTranslationZ() : 0.0f);
217        } else {
218            if (!true3dTransform) {
219                matrix.multiply(*properties().getTransformMatrix());
220            } else {
221                mat4 true3dMat;
222                true3dMat.loadTranslate(
223                        properties().getPivotX() + properties().getTranslationX(),
224                        properties().getPivotY() + properties().getTranslationY(),
225                        properties().getTranslationZ());
226                true3dMat.rotate(properties().getRotationX(), 1, 0, 0);
227                true3dMat.rotate(properties().getRotationY(), 0, 1, 0);
228                true3dMat.rotate(properties().getRotation(), 0, 0, 1);
229                true3dMat.scale(properties().getScaleX(), properties().getScaleY(), 1);
230                true3dMat.translate(-properties().getPivotX(), -properties().getPivotY());
231
232                matrix.multiply(true3dMat);
233            }
234        }
235    }
236}
237
238/**
239 * Organizes the DisplayList hierarchy to prepare for background projection reordering.
240 *
241 * This should be called before a call to defer() or drawDisplayList()
242 *
243 * Each DisplayList that serves as a 3d root builds its list of composited children,
244 * which are flagged to not draw in the standard draw loop.
245 */
246void RenderNode::computeOrdering() {
247    ATRACE_CALL();
248    mProjectedNodes.clear();
249
250    // TODO: create temporary DDLOp and call computeOrderingImpl on top DisplayList so that
251    // transform properties are applied correctly to top level children
252    if (mDisplayListData == NULL) return;
253    for (unsigned int i = 0; i < mDisplayListData->children().size(); i++) {
254        DrawDisplayListOp* childOp = mDisplayListData->children()[i];
255        childOp->mDisplayList->computeOrderingImpl(childOp,
256                &mProjectedNodes, &mat4::identity());
257    }
258}
259
260void RenderNode::computeOrderingImpl(
261        DrawDisplayListOp* opState,
262        Vector<DrawDisplayListOp*>* compositedChildrenOfProjectionSurface,
263        const mat4* transformFromProjectionSurface) {
264    mProjectedNodes.clear();
265    if (mDisplayListData == NULL || mDisplayListData->isEmpty()) return;
266
267    // TODO: should avoid this calculation in most cases
268    // TODO: just calculate single matrix, down to all leaf composited elements
269    Matrix4 localTransformFromProjectionSurface(*transformFromProjectionSurface);
270    localTransformFromProjectionSurface.multiply(opState->mTransformFromParent);
271
272    if (properties().getProjectBackwards()) {
273        // composited projectee, flag for out of order draw, save matrix, and store in proj surface
274        opState->mSkipInOrderDraw = true;
275        opState->mTransformFromCompositingAncestor.load(localTransformFromProjectionSurface);
276        compositedChildrenOfProjectionSurface->add(opState);
277    } else {
278        // standard in order draw
279        opState->mSkipInOrderDraw = false;
280    }
281
282    if (mDisplayListData->children().size() > 0) {
283        const bool isProjectionReceiver = mDisplayListData->projectionReceiveIndex >= 0;
284        bool haveAppliedPropertiesToProjection = false;
285        for (unsigned int i = 0; i < mDisplayListData->children().size(); i++) {
286            DrawDisplayListOp* childOp = mDisplayListData->children()[i];
287            RenderNode* child = childOp->mDisplayList;
288
289            Vector<DrawDisplayListOp*>* projectionChildren = NULL;
290            const mat4* projectionTransform = NULL;
291            if (isProjectionReceiver && !child->properties().getProjectBackwards()) {
292                // if receiving projections, collect projecting descendent
293
294                // Note that if a direct descendent is projecting backwards, we pass it's
295                // grandparent projection collection, since it shouldn't project onto it's
296                // parent, where it will already be drawing.
297                projectionChildren = &mProjectedNodes;
298                projectionTransform = &mat4::identity();
299            } else {
300                if (!haveAppliedPropertiesToProjection) {
301                    applyViewPropertyTransforms(localTransformFromProjectionSurface);
302                    haveAppliedPropertiesToProjection = true;
303                }
304                projectionChildren = compositedChildrenOfProjectionSurface;
305                projectionTransform = &localTransformFromProjectionSurface;
306            }
307            child->computeOrderingImpl(childOp, projectionChildren, projectionTransform);
308        }
309    }
310}
311
312class DeferOperationHandler {
313public:
314    DeferOperationHandler(DeferStateStruct& deferStruct, int level)
315        : mDeferStruct(deferStruct), mLevel(level) {}
316    inline void operator()(DisplayListOp* operation, int saveCount, bool clipToBounds) {
317        operation->defer(mDeferStruct, saveCount, mLevel, clipToBounds);
318    }
319    inline LinearAllocator& allocator() { return *(mDeferStruct.mAllocator); }
320    inline void startMark(const char* name) {} // do nothing
321    inline void endMark() {}
322    inline int level() { return mLevel; }
323    inline int replayFlags() { return mDeferStruct.mReplayFlags; }
324
325private:
326    DeferStateStruct& mDeferStruct;
327    const int mLevel;
328};
329
330void RenderNode::deferNodeTree(DeferStateStruct& deferStruct) {
331    DeferOperationHandler handler(deferStruct, 0);
332    if (properties().getTranslationZ() > 0.0f) issueDrawShadowOperation(Matrix4::identity(), handler);
333    issueOperations<DeferOperationHandler>(deferStruct.mRenderer, handler);
334}
335
336void RenderNode::deferNodeInParent(DeferStateStruct& deferStruct, const int level) {
337    DeferOperationHandler handler(deferStruct, level);
338    issueOperations<DeferOperationHandler>(deferStruct.mRenderer, handler);
339}
340
341class ReplayOperationHandler {
342public:
343    ReplayOperationHandler(ReplayStateStruct& replayStruct, int level)
344        : mReplayStruct(replayStruct), mLevel(level) {}
345    inline void operator()(DisplayListOp* operation, int saveCount, bool clipToBounds) {
346#if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS
347        properties().getReplayStruct().mRenderer.eventMark(operation->name());
348#endif
349        operation->replay(mReplayStruct, saveCount, mLevel, clipToBounds);
350    }
351    inline LinearAllocator& allocator() { return *(mReplayStruct.mAllocator); }
352    inline void startMark(const char* name) {
353        mReplayStruct.mRenderer.startMark(name);
354    }
355    inline void endMark() {
356        mReplayStruct.mRenderer.endMark();
357        DISPLAY_LIST_LOGD("%*sDone (%p, %s), returning %d", level * 2, "", this, mName.string(),
358                mReplayStruct.mDrawGlStatus);
359    }
360    inline int level() { return mLevel; }
361    inline int replayFlags() { return mReplayStruct.mReplayFlags; }
362
363private:
364    ReplayStateStruct& mReplayStruct;
365    const int mLevel;
366};
367
368void RenderNode::replayNodeTree(ReplayStateStruct& replayStruct) {
369    ReplayOperationHandler handler(replayStruct, 0);
370    if (properties().getTranslationZ() > 0.0f) issueDrawShadowOperation(Matrix4::identity(), handler);
371    issueOperations<ReplayOperationHandler>(replayStruct.mRenderer, handler);
372}
373
374void RenderNode::replayNodeInParent(ReplayStateStruct& replayStruct, const int level) {
375    ReplayOperationHandler handler(replayStruct, level);
376    issueOperations<ReplayOperationHandler>(replayStruct.mRenderer, handler);
377}
378
379void RenderNode::buildZSortedChildList(Vector<ZDrawDisplayListOpPair>& zTranslatedNodes) {
380    if (mDisplayListData == NULL || mDisplayListData->children().size() == 0) return;
381
382    for (unsigned int i = 0; i < mDisplayListData->children().size(); i++) {
383        DrawDisplayListOp* childOp = mDisplayListData->children()[i];
384        RenderNode* child = childOp->mDisplayList;
385        float childZ = child->properties().getTranslationZ();
386
387        if (childZ != 0.0f) {
388            zTranslatedNodes.add(ZDrawDisplayListOpPair(childZ, childOp));
389            childOp->mSkipInOrderDraw = true;
390        } else if (!child->properties().getProjectBackwards()) {
391            // regular, in order drawing DisplayList
392            childOp->mSkipInOrderDraw = false;
393        }
394    }
395
396    // Z sort 3d children (stable-ness makes z compare fall back to standard drawing order)
397    std::stable_sort(zTranslatedNodes.begin(), zTranslatedNodes.end());
398}
399
400template <class T>
401void RenderNode::issueDrawShadowOperation(const Matrix4& transformFromParent, T& handler) {
402    if (properties().getAlpha() <= 0.0f) return;
403
404    mat4 shadowMatrixXY(transformFromParent);
405    applyViewPropertyTransforms(shadowMatrixXY);
406
407    // Z matrix needs actual 3d transformation, so mapped z values will be correct
408    mat4 shadowMatrixZ(transformFromParent);
409    applyViewPropertyTransforms(shadowMatrixZ, true);
410
411    const SkPath* outlinePath = properties().getOutline().getPath();
412    const RevealClip& revealClip = properties().getRevealClip();
413    const SkPath* revealClipPath = revealClip.hasConvexClip()
414            ?  revealClip.getPath() : NULL; // only pass the reveal clip's path if it's convex
415
416    /**
417     * The drawing area of the caster is always the same as the its perimeter (which
418     * the shadow system uses) *except* in the inverse clip case. Inform the shadow
419     * system that the caster's drawing area (as opposed to its perimeter) has been
420     * clipped, so that it knows the caster can't be opaque.
421     */
422    bool casterUnclipped = !revealClip.willClip() || revealClip.hasConvexClip();
423
424    DisplayListOp* shadowOp  = new (handler.allocator()) DrawShadowOp(
425            shadowMatrixXY, shadowMatrixZ,
426            properties().getAlpha(), casterUnclipped,
427            properties().getWidth(), properties().getHeight(),
428            outlinePath, revealClipPath);
429    handler(shadowOp, PROPERTY_SAVECOUNT, properties().getClipToBounds());
430}
431
432#define SHADOW_DELTA 0.1f
433
434template <class T>
435void RenderNode::issueOperationsOf3dChildren(const Vector<ZDrawDisplayListOpPair>& zTranslatedNodes,
436        ChildrenSelectMode mode, OpenGLRenderer& renderer, T& handler) {
437    const int size = zTranslatedNodes.size();
438    if (size == 0
439            || (mode == kNegativeZChildren && zTranslatedNodes[0].key > 0.0f)
440            || (mode == kPositiveZChildren && zTranslatedNodes[size - 1].key < 0.0f)) {
441        // no 3d children to draw
442        return;
443    }
444
445    /**
446     * Draw shadows and (potential) casters mostly in order, but allow the shadows of casters
447     * with very similar Z heights to draw together.
448     *
449     * This way, if Views A & B have the same Z height and are both casting shadows, the shadows are
450     * underneath both, and neither's shadow is drawn on top of the other.
451     */
452    const size_t nonNegativeIndex = findNonNegativeIndex(zTranslatedNodes);
453    size_t drawIndex, shadowIndex, endIndex;
454    if (mode == kNegativeZChildren) {
455        drawIndex = 0;
456        endIndex = nonNegativeIndex;
457        shadowIndex = endIndex; // draw no shadows
458    } else {
459        drawIndex = nonNegativeIndex;
460        endIndex = size;
461        shadowIndex = drawIndex; // potentially draw shadow for each pos Z child
462    }
463    float lastCasterZ = 0.0f;
464    while (shadowIndex < endIndex || drawIndex < endIndex) {
465        if (shadowIndex < endIndex) {
466            DrawDisplayListOp* casterOp = zTranslatedNodes[shadowIndex].value;
467            RenderNode* caster = casterOp->mDisplayList;
468            const float casterZ = zTranslatedNodes[shadowIndex].key;
469            // attempt to render the shadow if the caster about to be drawn is its caster,
470            // OR if its caster's Z value is similar to the previous potential caster
471            if (shadowIndex == drawIndex || casterZ - lastCasterZ < SHADOW_DELTA) {
472                caster->issueDrawShadowOperation(casterOp->mTransformFromParent, handler);
473
474                lastCasterZ = casterZ; // must do this even if current caster not casting a shadow
475                shadowIndex++;
476                continue;
477            }
478        }
479
480        // only the actual child DL draw needs to be in save/restore,
481        // since it modifies the renderer's matrix
482        int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag);
483
484        DrawDisplayListOp* childOp = zTranslatedNodes[drawIndex].value;
485        RenderNode* child = childOp->mDisplayList;
486
487        renderer.concatMatrix(childOp->mTransformFromParent);
488        childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone
489        handler(childOp, renderer.getSaveCount() - 1, properties().getClipToBounds());
490        childOp->mSkipInOrderDraw = true;
491
492        renderer.restoreToCount(restoreTo);
493        drawIndex++;
494    }
495}
496
497template <class T>
498void RenderNode::issueOperationsOfProjectedChildren(OpenGLRenderer& renderer, T& handler) {
499    for (size_t i = 0; i < mProjectedNodes.size(); i++) {
500        DrawDisplayListOp* childOp = mProjectedNodes[i];
501
502        // matrix save, concat, and restore can be done safely without allocating operations
503        int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag);
504        renderer.concatMatrix(childOp->mTransformFromCompositingAncestor);
505        childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone
506        handler(childOp, renderer.getSaveCount() - 1, properties().getClipToBounds());
507        childOp->mSkipInOrderDraw = true;
508        renderer.restoreToCount(restoreTo);
509    }
510}
511
512/**
513 * This function serves both defer and replay modes, and will organize the displayList's component
514 * operations for a single frame:
515 *
516 * Every 'simple' state operation that affects just the matrix and alpha (or other factors of
517 * DeferredDisplayState) may be issued directly to the renderer, but complex operations (with custom
518 * defer logic) and operations in displayListOps are issued through the 'handler' which handles the
519 * defer vs replay logic, per operation
520 */
521template <class T>
522void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) {
523    const int level = handler.level();
524    if (mDisplayListData->isEmpty() || properties().getAlpha() <= 0) {
525        DISPLAY_LIST_LOGD("%*sEmpty display list (%p, %s)", level * 2, "", this, mName.string());
526        return;
527    }
528
529    handler.startMark(mName.string());
530
531#if DEBUG_DISPLAY_LIST
532    Rect* clipRect = renderer.getClipRect();
533    DISPLAY_LIST_LOGD("%*sStart display list (%p, %s), clipRect: %.0f, %.0f, %.0f, %.0f",
534            level * 2, "", this, mName.string(), clipRect->left, clipRect->top,
535            clipRect->right, clipRect->bottom);
536#endif
537
538    LinearAllocator& alloc = handler.allocator();
539    int restoreTo = renderer.getSaveCount();
540    handler(new (alloc) SaveOp(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag),
541            PROPERTY_SAVECOUNT, properties().getClipToBounds());
542
543    DISPLAY_LIST_LOGD("%*sSave %d %d", (level + 1) * 2, "",
544            SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag, restoreTo);
545
546    setViewProperties<T>(renderer, handler);
547
548    bool quickRejected = properties().getClipToBounds()
549            && renderer.quickRejectConservative(0, 0, properties().getWidth(), properties().getHeight());
550    if (!quickRejected) {
551        Vector<ZDrawDisplayListOpPair> zTranslatedNodes;
552        buildZSortedChildList(zTranslatedNodes);
553
554        // for 3d root, draw children with negative z values
555        issueOperationsOf3dChildren(zTranslatedNodes, kNegativeZChildren, renderer, handler);
556
557        DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
558        const int saveCountOffset = renderer.getSaveCount() - 1;
559        const int projectionReceiveIndex = mDisplayListData->projectionReceiveIndex;
560        for (unsigned int i = 0; i < mDisplayListData->displayListOps.size(); i++) {
561            DisplayListOp *op = mDisplayListData->displayListOps[i];
562
563#if DEBUG_DISPLAY_LIST
564            op->output(level + 1);
565#endif
566            logBuffer.writeCommand(level, op->name());
567            handler(op, saveCountOffset, properties().getClipToBounds());
568
569            if (CC_UNLIKELY(i == projectionReceiveIndex && mProjectedNodes.size() > 0)) {
570                issueOperationsOfProjectedChildren(renderer, handler);
571            }
572        }
573
574        // for 3d root, draw children with positive z values
575        issueOperationsOf3dChildren(zTranslatedNodes, kPositiveZChildren, renderer, handler);
576    }
577
578    DISPLAY_LIST_LOGD("%*sRestoreToCount %d", (level + 1) * 2, "", restoreTo);
579    handler(new (alloc) RestoreToCountOp(restoreTo),
580            PROPERTY_SAVECOUNT, properties().getClipToBounds());
581    renderer.setOverrideLayerAlpha(1.0f);
582
583    handler.endMark();
584}
585
586} /* namespace uirenderer */
587} /* namespace android */
588