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