RenderNode.h revision f648108f83d4e74811919e9811efb8fcc184b8a3
1113e0824d6bddf4376240681f9cf6a2deded9498John Reck/*
2113e0824d6bddf4376240681f9cf6a2deded9498John Reck * Copyright (C) 2014 The Android Open Source Project
3113e0824d6bddf4376240681f9cf6a2deded9498John Reck *
4113e0824d6bddf4376240681f9cf6a2deded9498John Reck * Licensed under the Apache License, Version 2.0 (the "License");
5113e0824d6bddf4376240681f9cf6a2deded9498John Reck * you may not use this file except in compliance with the License.
6113e0824d6bddf4376240681f9cf6a2deded9498John Reck * You may obtain a copy of the License at
7113e0824d6bddf4376240681f9cf6a2deded9498John Reck *
8113e0824d6bddf4376240681f9cf6a2deded9498John Reck *      http://www.apache.org/licenses/LICENSE-2.0
9113e0824d6bddf4376240681f9cf6a2deded9498John Reck *
10113e0824d6bddf4376240681f9cf6a2deded9498John Reck * Unless required by applicable law or agreed to in writing, software
11113e0824d6bddf4376240681f9cf6a2deded9498John Reck * distributed under the License is distributed on an "AS IS" BASIS,
12113e0824d6bddf4376240681f9cf6a2deded9498John Reck * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13113e0824d6bddf4376240681f9cf6a2deded9498John Reck * See the License for the specific language governing permissions and
14113e0824d6bddf4376240681f9cf6a2deded9498John Reck * limitations under the License.
15113e0824d6bddf4376240681f9cf6a2deded9498John Reck */
16113e0824d6bddf4376240681f9cf6a2deded9498John Reck#ifndef RENDERNODE_H
17113e0824d6bddf4376240681f9cf6a2deded9498John Reck#define RENDERNODE_H
18113e0824d6bddf4376240681f9cf6a2deded9498John Reck
19113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <SkCamera.h>
20113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <SkMatrix.h>
21113e0824d6bddf4376240681f9cf6a2deded9498John Reck
22113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <utils/LinearAllocator.h>
23113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <utils/RefBase.h>
24113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <utils/String8.h>
25113e0824d6bddf4376240681f9cf6a2deded9498John Reck
26113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <cutils/compiler.h>
27113e0824d6bddf4376240681f9cf6a2deded9498John Reck
28113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <androidfw/ResourceTypes.h>
29113e0824d6bddf4376240681f9cf6a2deded9498John Reck
3068bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck#include "AnimatorManager.h"
31113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include "Debug.h"
32113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include "DisplayList.h"
33b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik#include "Matrix.h"
34113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include "RenderProperties.h"
35113e0824d6bddf4376240681f9cf6a2deded9498John Reck
36272a685f17cc4828257e521a6f62b7b17870f75eJohn Reck#include <vector>
37272a685f17cc4828257e521a6f62b7b17870f75eJohn Reck
38113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SkBitmap;
39113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SkPaint;
40113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SkPath;
41113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SkRegion;
42113e0824d6bddf4376240681f9cf6a2deded9498John Reck
43113e0824d6bddf4376240681f9cf6a2deded9498John Recknamespace android {
44113e0824d6bddf4376240681f9cf6a2deded9498John Recknamespace uirenderer {
45113e0824d6bddf4376240681f9cf6a2deded9498John Reck
46b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craikclass CanvasState;
47db663fe83f976107fd8fd9307d871b37d9e47370Chris Craikclass DisplayListCanvas;
480b7e8245db728d127ada698be63d78b33fc6e4daChris Craikclass DisplayListOp;
49113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass OpenGLRenderer;
50113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass Rect;
51113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SkiaShader;
52113e0824d6bddf4376240681f9cf6a2deded9498John Reck
530b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#if HWUI_NEW_OPS
54f158b49c888f722194afe5a80539a2b020c130bcChris Craikclass FrameBuilder;
550b7e8245db728d127ada698be63d78b33fc6e4daChris Craikclass OffscreenBuffer;
568d1f2120fe80b23ab03c7168e3b6b2d13bafe2e7Chris Craikstruct RenderNodeOp;
570b7e8245db728d127ada698be63d78b33fc6e4daChris Craiktypedef OffscreenBuffer layer_t;
588d1f2120fe80b23ab03c7168e3b6b2d13bafe2e7Chris Craiktypedef RenderNodeOp renderNodeOp_t;
590b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#else
600b7e8245db728d127ada698be63d78b33fc6e4daChris Craikclass Layer;
610b7e8245db728d127ada698be63d78b33fc6e4daChris Craiktypedef Layer layer_t;
628d1f2120fe80b23ab03c7168e3b6b2d13bafe2e7Chris Craiktypedef DrawRenderNodeOp renderNodeOp_t;
630b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#endif
640b7e8245db728d127ada698be63d78b33fc6e4daChris Craik
65113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass ClipRectOp;
668d1f2120fe80b23ab03c7168e3b6b2d13bafe2e7Chris Craikclass DrawRenderNodeOp;
67113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SaveLayerOp;
68113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SaveOp;
69113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass RestoreToCountOp;
702dc236b2bae13b9a0ed9b3f7320502aecd7983b3Tom Hudsonclass TreeInfo;
71113e0824d6bddf4376240681f9cf6a2deded9498John Reck
72e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Recknamespace proto {
73e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reckclass RenderNode;
74e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck}
75e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck
76113e0824d6bddf4376240681f9cf6a2deded9498John Reck/**
77113e0824d6bddf4376240681f9cf6a2deded9498John Reck * Primary class for storing recorded canvas commands, as well as per-View/ViewGroup display properties.
78113e0824d6bddf4376240681f9cf6a2deded9498John Reck *
79113e0824d6bddf4376240681f9cf6a2deded9498John Reck * Recording of canvas commands is somewhat similar to SkPicture, except the canvas-recording
80003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik * functionality is split between DisplayListCanvas (which manages the recording), DisplayList
81113e0824d6bddf4376240681f9cf6a2deded9498John Reck * (which holds the actual data), and DisplayList (which holds properties and performs playback onto
82113e0824d6bddf4376240681f9cf6a2deded9498John Reck * a renderer).
83113e0824d6bddf4376240681f9cf6a2deded9498John Reck *
84003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik * Note that DisplayList is swapped out from beneath an individual RenderNode when a view's
85003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik * recorded stream of canvas operations is refreshed. The RenderNode (and its properties) stay
86113e0824d6bddf4376240681f9cf6a2deded9498John Reck * attached.
87113e0824d6bddf4376240681f9cf6a2deded9498John Reck */
88087bc0c14bdccf7c258dce0cdef46a69a839b427John Reckclass RenderNode : public VirtualLightRefBase {
89b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craikfriend class TestUtils; // allow TestUtils to access syncDisplayList / syncProperties
90f158b49c888f722194afe5a80539a2b020c130bcChris Craikfriend class FrameBuilder;
91113e0824d6bddf4376240681f9cf6a2deded9498John Reckpublic:
92ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    enum DirtyPropertyMask {
93ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        GENERIC         = 1 << 1,
94ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        TRANSLATION_X   = 1 << 2,
95ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        TRANSLATION_Y   = 1 << 3,
96ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        TRANSLATION_Z   = 1 << 4,
97ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        SCALE_X         = 1 << 5,
98ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        SCALE_Y         = 1 << 6,
99ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        ROTATION        = 1 << 7,
100ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        ROTATION_X      = 1 << 8,
101ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        ROTATION_Y      = 1 << 9,
102ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        X               = 1 << 10,
103ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        Y               = 1 << 11,
104ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        Z               = 1 << 12,
105ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        ALPHA           = 1 << 13,
106a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck        DISPLAY_LIST    = 1 << 14,
107ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    };
108ff941dcd815021bb20d6504eb486acb1e50592c3John Reck
109113e0824d6bddf4376240681f9cf6a2deded9498John Reck    ANDROID_API RenderNode();
110e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck    ANDROID_API virtual ~RenderNode();
111113e0824d6bddf4376240681f9cf6a2deded9498John Reck
112113e0824d6bddf4376240681f9cf6a2deded9498John Reck    // See flags defined in DisplayList.java
113113e0824d6bddf4376240681f9cf6a2deded9498John Reck    enum ReplayFlag {
114113e0824d6bddf4376240681f9cf6a2deded9498John Reck        kReplayFlag_ClipChildren = 0x1
115113e0824d6bddf4376240681f9cf6a2deded9498John Reck    };
116113e0824d6bddf4376240681f9cf6a2deded9498John Reck
117443a714fa7c0dd07fee3527cc5bc3d3ca1fb7d44John Reck    void debugDumpLayers(const char* prefix);
118113e0824d6bddf4376240681f9cf6a2deded9498John Reck
119003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik    ANDROID_API void setStagingDisplayList(DisplayList* newData);
120113e0824d6bddf4376240681f9cf6a2deded9498John Reck
121113e0824d6bddf4376240681f9cf6a2deded9498John Reck    void computeOrdering();
122b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik
12380d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik    void defer(DeferStateStruct& deferStruct, const int level);
12480d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik    void replay(ReplayStateStruct& replayStruct, const int level);
125113e0824d6bddf4376240681f9cf6a2deded9498John Reck
126113e0824d6bddf4376240681f9cf6a2deded9498John Reck    ANDROID_API void output(uint32_t level = 1);
127fe5e7b7346a54537b980796ceeca66bfdbd05561John Reck    ANDROID_API int getDebugSize();
128e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck    void copyTo(proto::RenderNode* node);
129113e0824d6bddf4376240681f9cf6a2deded9498John Reck
130113e0824d6bddf4376240681f9cf6a2deded9498John Reck    bool isRenderable() const {
131003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik        return mDisplayList && !mDisplayList->isEmpty();
132113e0824d6bddf4376240681f9cf6a2deded9498John Reck    }
133113e0824d6bddf4376240681f9cf6a2deded9498John Reck
134a447d29c65fb811cd184775a3476101a1cede929John Reck    bool hasProjectionReceiver() const {
135003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik        return mDisplayList && mDisplayList->projectionReceiveIndex >= 0;
136a447d29c65fb811cd184775a3476101a1cede929John Reck    }
137a447d29c65fb811cd184775a3476101a1cede929John Reck
138defb7f37fe67ef2389666f7adc5da1260df87017Chris Craik    const char* getName() const {
139defb7f37fe67ef2389666f7adc5da1260df87017Chris Craik        return mName.string();
140defb7f37fe67ef2389666f7adc5da1260df87017Chris Craik    }
141defb7f37fe67ef2389666f7adc5da1260df87017Chris Craik
142113e0824d6bddf4376240681f9cf6a2deded9498John Reck    void setName(const char* name) {
143113e0824d6bddf4376240681f9cf6a2deded9498John Reck        if (name) {
144113e0824d6bddf4376240681f9cf6a2deded9498John Reck            char* lastPeriod = strrchr(name, '.');
145113e0824d6bddf4376240681f9cf6a2deded9498John Reck            if (lastPeriod) {
146113e0824d6bddf4376240681f9cf6a2deded9498John Reck                mName.setTo(lastPeriod + 1);
147113e0824d6bddf4376240681f9cf6a2deded9498John Reck            } else {
148113e0824d6bddf4376240681f9cf6a2deded9498John Reck                mName.setTo(name);
149113e0824d6bddf4376240681f9cf6a2deded9498John Reck            }
150113e0824d6bddf4376240681f9cf6a2deded9498John Reck        }
151113e0824d6bddf4376240681f9cf6a2deded9498John Reck    }
152113e0824d6bddf4376240681f9cf6a2deded9498John Reck
153ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    bool isPropertyFieldDirty(DirtyPropertyMask field) const {
154ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        return mDirtyPropertyFields & field;
155ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    }
156ff941dcd815021bb20d6504eb486acb1e50592c3John Reck
157ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    void setPropertyFieldsDirty(uint32_t fields) {
158ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        mDirtyPropertyFields |= fields;
159ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    }
160ff941dcd815021bb20d6504eb486acb1e50592c3John Reck
161e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck    const RenderProperties& properties() const {
162113e0824d6bddf4376240681f9cf6a2deded9498John Reck        return mProperties;
163113e0824d6bddf4376240681f9cf6a2deded9498John Reck    }
164113e0824d6bddf4376240681f9cf6a2deded9498John Reck
16552244fff29042926e21fa897ef5ab11148e35299John Reck    RenderProperties& animatorProperties() {
16652244fff29042926e21fa897ef5ab11148e35299John Reck        return mProperties;
16752244fff29042926e21fa897ef5ab11148e35299John Reck    }
16852244fff29042926e21fa897ef5ab11148e35299John Reck
169d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    const RenderProperties& stagingProperties() {
170d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        return mStagingProperties;
171d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    }
172d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
173d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    RenderProperties& mutateStagingProperties() {
174d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        return mStagingProperties;
175d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    }
176d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
17776caecf421b42e9b8294a65f62ff2d90b55a337bChris Craik    int getWidth() const {
178113e0824d6bddf4376240681f9cf6a2deded9498John Reck        return properties().getWidth();
179113e0824d6bddf4376240681f9cf6a2deded9498John Reck    }
180113e0824d6bddf4376240681f9cf6a2deded9498John Reck
18176caecf421b42e9b8294a65f62ff2d90b55a337bChris Craik    int getHeight() const {
182113e0824d6bddf4376240681f9cf6a2deded9498John Reck        return properties().getHeight();
183113e0824d6bddf4376240681f9cf6a2deded9498John Reck    }
184113e0824d6bddf4376240681f9cf6a2deded9498John Reck
185e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck    ANDROID_API virtual void prepareTree(TreeInfo& info);
186dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    void destroyHardwareResources();
187e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
188e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck    // UI thread only!
18968bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    ANDROID_API void addAnimator(const sp<BaseRenderNodeAnimator>& animator);
190668f0e38ef0277d55d3118af37e17b8c435df85cJohn Reck
191119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck    AnimatorManager& animators() { return mAnimatorManager; }
192119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck
19369e5adffb19135d51bde8e458f4907d7265f3e23Chris Craik    void applyViewPropertyTransforms(mat4& matrix, bool true3dTransform = false) const;
19469e5adffb19135d51bde8e458f4907d7265f3e23Chris Craik
195b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik    bool nothingToDraw() const {
196b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik        const Outline& outline = properties().getOutline();
197003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik        return mDisplayList == nullptr
198b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik                || properties().getAlpha() <= 0
199b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik                || (outline.getShouldClip() && outline.isEmpty())
200b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik                || properties().getScaleX() == 0
201b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik                || properties().getScaleY() == 0;
202b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik    }
203b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik
2040b7e8245db728d127ada698be63d78b33fc6e4daChris Craik    const DisplayList* getDisplayList() const {
2050b7e8245db728d127ada698be63d78b33fc6e4daChris Craik        return mDisplayList;
206b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik    }
2070b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#if HWUI_NEW_OPS
2080b7e8245db728d127ada698be63d78b33fc6e4daChris Craik    OffscreenBuffer* getLayer() const { return mLayer; }
2090b7e8245db728d127ada698be63d78b33fc6e4daChris Craik    OffscreenBuffer** getLayerHandle() { return &mLayer; } // ugh...
2100b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#endif
211b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik
212f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    class ANDROID_API PositionListener {
213f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    public:
214f648108f83d4e74811919e9811efb8fcc184b8a3John Reck        virtual ~PositionListener() {}
215f648108f83d4e74811919e9811efb8fcc184b8a3John Reck        virtual void onPositionUpdated(RenderNode& node, const TreeInfo& info) = 0;
216f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    };
217f648108f83d4e74811919e9811efb8fcc184b8a3John Reck
218f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    // Note this is not thread safe, this needs to be called
219f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    // before the RenderNode is used for drawing.
220f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    // RenderNode takes ownership of the pointer
221f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    ANDROID_API void setPositionListener(PositionListener* listener) {
222f648108f83d4e74811919e9811efb8fcc184b8a3John Reck        mPositionListener.reset(listener);
223f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    }
224f648108f83d4e74811919e9811efb8fcc184b8a3John Reck
225113e0824d6bddf4376240681f9cf6a2deded9498John Reckprivate:
226a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik    typedef key_value_pair_t<float, DrawRenderNodeOp*> ZDrawRenderNodeOpPair;
227113e0824d6bddf4376240681f9cf6a2deded9498John Reck
228272a685f17cc4828257e521a6f62b7b17870f75eJohn Reck    static size_t findNonNegativeIndex(const std::vector<ZDrawRenderNodeOpPair>& nodes) {
229113e0824d6bddf4376240681f9cf6a2deded9498John Reck        for (size_t i = 0; i < nodes.size(); i++) {
230113e0824d6bddf4376240681f9cf6a2deded9498John Reck            if (nodes[i].key >= 0.0f) return i;
231113e0824d6bddf4376240681f9cf6a2deded9498John Reck        }
232113e0824d6bddf4376240681f9cf6a2deded9498John Reck        return nodes.size();
233113e0824d6bddf4376240681f9cf6a2deded9498John Reck    }
234113e0824d6bddf4376240681f9cf6a2deded9498John Reck
235b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik    enum class ChildrenSelectMode {
236b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik        NegativeZChildren,
237b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik        PositiveZChildren
238113e0824d6bddf4376240681f9cf6a2deded9498John Reck    };
239113e0824d6bddf4376240681f9cf6a2deded9498John Reck
2408d1f2120fe80b23ab03c7168e3b6b2d13bafe2e7Chris Craik    void computeOrderingImpl(renderNodeOp_t* opState,
2418d1f2120fe80b23ab03c7168e3b6b2d13bafe2e7Chris Craik            std::vector<renderNodeOp_t*>* compositedChildrenOfProjectionSurface,
242113e0824d6bddf4376240681f9cf6a2deded9498John Reck            const mat4* transformFromProjectionSurface);
243113e0824d6bddf4376240681f9cf6a2deded9498John Reck
244113e0824d6bddf4376240681f9cf6a2deded9498John Reck    template <class T>
245b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik    inline void setViewProperties(OpenGLRenderer& renderer, T& handler);
246113e0824d6bddf4376240681f9cf6a2deded9498John Reck
247003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik    void buildZSortedChildList(const DisplayList::Chunk& chunk,
248272a685f17cc4828257e521a6f62b7b17870f75eJohn Reck            std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes);
249113e0824d6bddf4376240681f9cf6a2deded9498John Reck
250b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik    template<class T>
251b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik    inline void issueDrawShadowOperation(const Matrix4& transformFromParent, T& handler);
252b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik
253113e0824d6bddf4376240681f9cf6a2deded9498John Reck    template <class T>
254c3e75f9d54b3629b3fd27afafa2e07bd07dad9b3Chris Craik    inline void issueOperationsOf3dChildren(ChildrenSelectMode mode,
255272a685f17cc4828257e521a6f62b7b17870f75eJohn Reck            const Matrix4& initialTransform, const std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes,
25680d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik            OpenGLRenderer& renderer, T& handler);
257113e0824d6bddf4376240681f9cf6a2deded9498John Reck
258113e0824d6bddf4376240681f9cf6a2deded9498John Reck    template <class T>
259b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik    inline void issueOperationsOfProjectedChildren(OpenGLRenderer& renderer, T& handler);
260113e0824d6bddf4376240681f9cf6a2deded9498John Reck
261b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik    /**
262b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik     * Issue the RenderNode's operations into a handler, recursing for subtrees through
263a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik     * DrawRenderNodeOp's defer() or replay() methods
264b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik     */
265113e0824d6bddf4376240681f9cf6a2deded9498John Reck    template <class T>
266b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik    inline void issueOperations(OpenGLRenderer& renderer, T& handler);
267113e0824d6bddf4376240681f9cf6a2deded9498John Reck
268113e0824d6bddf4376240681f9cf6a2deded9498John Reck    class TextContainer {
269113e0824d6bddf4376240681f9cf6a2deded9498John Reck    public:
270113e0824d6bddf4376240681f9cf6a2deded9498John Reck        size_t length() const {
271113e0824d6bddf4376240681f9cf6a2deded9498John Reck            return mByteLength;
272113e0824d6bddf4376240681f9cf6a2deded9498John Reck        }
273113e0824d6bddf4376240681f9cf6a2deded9498John Reck
274113e0824d6bddf4376240681f9cf6a2deded9498John Reck        const char* text() const {
275113e0824d6bddf4376240681f9cf6a2deded9498John Reck            return (const char*) mText;
276113e0824d6bddf4376240681f9cf6a2deded9498John Reck        }
277113e0824d6bddf4376240681f9cf6a2deded9498John Reck
278113e0824d6bddf4376240681f9cf6a2deded9498John Reck        size_t mByteLength;
279113e0824d6bddf4376240681f9cf6a2deded9498John Reck        const char* mText;
280113e0824d6bddf4376240681f9cf6a2deded9498John Reck    };
281113e0824d6bddf4376240681f9cf6a2deded9498John Reck
282b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik
283b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik    void syncProperties();
284b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik    void syncDisplayList();
285b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik
286a766cb2bce5db9108c0266fbebea6aa18d5713ffChris Craik    void prepareTreeImpl(TreeInfo& info, bool functorsNeedLayer);
28725fbb3fa1138675379102a44405852555cefccbdJohn Reck    void pushStagingPropertiesChanges(TreeInfo& info);
28825fbb3fa1138675379102a44405852555cefccbdJohn Reck    void pushStagingDisplayListChanges(TreeInfo& info);
289003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik    void prepareSubTree(TreeInfo& info, bool functorsNeedLayer, DisplayList* subtree);
2900b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#if !HWUI_NEW_OPS
29125fbb3fa1138675379102a44405852555cefccbdJohn Reck    void applyLayerPropertiesToLayer(TreeInfo& info);
2920b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#endif
293a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck    void prepareLayer(TreeInfo& info, uint32_t dirtyMask);
29425fbb3fa1138675379102a44405852555cefccbdJohn Reck    void pushLayerUpdate(TreeInfo& info);
295003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik    void deleteDisplayList();
2960a97330b98dd633b58dcfff405d94476c89e867dJohn Reck    void damageSelf(TreeInfo& info);
297dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck
298dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    void incParentRefCount() { mParentCount++; }
299dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    void decParentRefCount();
3008de65a8e05285df52a1e6f0c1d5616dd233298a7John Reck
301113e0824d6bddf4376240681f9cf6a2deded9498John Reck    String8 mName;
302113e0824d6bddf4376240681f9cf6a2deded9498John Reck
303ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    uint32_t mDirtyPropertyFields;
304113e0824d6bddf4376240681f9cf6a2deded9498John Reck    RenderProperties mProperties;
305d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    RenderProperties mStagingProperties;
306d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
307003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik    bool mNeedsDisplayListSync;
308003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik    // WARNING: Do not delete this directly, you must go through deleteDisplayList()!
309003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik    DisplayList* mDisplayList;
310003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik    DisplayList* mStagingDisplayList;
311113e0824d6bddf4376240681f9cf6a2deded9498John Reck
31268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    friend class AnimatorManager;
31368bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    AnimatorManager mAnimatorManager;
314e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
31525fbb3fa1138675379102a44405852555cefccbdJohn Reck    // Owned by RT. Lifecycle is managed by prepareTree(), with the exception
31625fbb3fa1138675379102a44405852555cefccbdJohn Reck    // being in ~RenderNode() which may happen on any thread.
3170b7e8245db728d127ada698be63d78b33fc6e4daChris Craik    layer_t* mLayer = nullptr;
31825fbb3fa1138675379102a44405852555cefccbdJohn Reck
319113e0824d6bddf4376240681f9cf6a2deded9498John Reck    /**
320113e0824d6bddf4376240681f9cf6a2deded9498John Reck     * Draw time state - these properties are only set and used during rendering
321113e0824d6bddf4376240681f9cf6a2deded9498John Reck     */
322113e0824d6bddf4376240681f9cf6a2deded9498John Reck
323113e0824d6bddf4376240681f9cf6a2deded9498John Reck    // for projection surfaces, contains a list of all children items
3248d1f2120fe80b23ab03c7168e3b6b2d13bafe2e7Chris Craik    std::vector<renderNodeOp_t*> mProjectedNodes;
325dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck
326dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    // How many references our parent(s) have to us. Typically this should alternate
327dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    // between 2 and 1 (when a staging push happens we inc first then dec)
328dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    // When this hits 0 we are no longer in the tree, so any hardware resources
329dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    // (specifically Layers) should be released.
330dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    // This is *NOT* thread-safe, and should therefore only be tracking
331003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik    // mDisplayList, not mStagingDisplayList.
332dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    uint32_t mParentCount;
333f648108f83d4e74811919e9811efb8fcc184b8a3John Reck
334f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    std::unique_ptr<PositionListener> mPositionListener;
335113e0824d6bddf4376240681f9cf6a2deded9498John Reck}; // class RenderNode
336113e0824d6bddf4376240681f9cf6a2deded9498John Reck
337113e0824d6bddf4376240681f9cf6a2deded9498John Reck} /* namespace uirenderer */
338113e0824d6bddf4376240681f9cf6a2deded9498John Reck} /* namespace android */
339113e0824d6bddf4376240681f9cf6a2deded9498John Reck
340113e0824d6bddf4376240681f9cf6a2deded9498John Reck#endif /* RENDERNODE_H */
341