RenderNode.h revision 119907cd2575c56b1ebf66348b52e67aaf6a88d8
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#ifndef LOG_TAG
20113e0824d6bddf4376240681f9cf6a2deded9498John Reck    #define LOG_TAG "OpenGLRenderer"
21113e0824d6bddf4376240681f9cf6a2deded9498John Reck#endif
22113e0824d6bddf4376240681f9cf6a2deded9498John Reck
23113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <SkCamera.h>
24113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <SkMatrix.h>
25113e0824d6bddf4376240681f9cf6a2deded9498John Reck
26113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <utils/LinearAllocator.h>
27113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <utils/RefBase.h>
28113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <utils/String8.h>
29113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <utils/Vector.h>
30113e0824d6bddf4376240681f9cf6a2deded9498John Reck
31113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <cutils/compiler.h>
32113e0824d6bddf4376240681f9cf6a2deded9498John Reck
33113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include <androidfw/ResourceTypes.h>
34113e0824d6bddf4376240681f9cf6a2deded9498John Reck
3568bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck#include "AnimatorManager.h"
36a447d29c65fb811cd184775a3476101a1cede929John Reck#include "DamageAccumulator.h"
37113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include "Debug.h"
38113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include "Matrix.h"
39113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include "DeferredDisplayList.h"
40113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include "DisplayList.h"
41113e0824d6bddf4376240681f9cf6a2deded9498John Reck#include "RenderProperties.h"
42e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck#include "TreeInfo.h"
43113e0824d6bddf4376240681f9cf6a2deded9498John Reck
44113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SkBitmap;
45113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SkPaint;
46113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SkPath;
47113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SkRegion;
48113e0824d6bddf4376240681f9cf6a2deded9498John Reck
49113e0824d6bddf4376240681f9cf6a2deded9498John Recknamespace android {
50113e0824d6bddf4376240681f9cf6a2deded9498John Recknamespace uirenderer {
51113e0824d6bddf4376240681f9cf6a2deded9498John Reck
52113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass DisplayListOp;
53113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass DisplayListRenderer;
54113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass OpenGLRenderer;
55113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass Rect;
56113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass Layer;
57113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SkiaShader;
58113e0824d6bddf4376240681f9cf6a2deded9498John Reck
59113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass ClipRectOp;
60113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SaveLayerOp;
61113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SaveOp;
62113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass RestoreToCountOp;
63a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craikclass DrawRenderNodeOp;
64113e0824d6bddf4376240681f9cf6a2deded9498John Reck
65113e0824d6bddf4376240681f9cf6a2deded9498John Reck/**
66113e0824d6bddf4376240681f9cf6a2deded9498John Reck * Primary class for storing recorded canvas commands, as well as per-View/ViewGroup display properties.
67113e0824d6bddf4376240681f9cf6a2deded9498John Reck *
68113e0824d6bddf4376240681f9cf6a2deded9498John Reck * Recording of canvas commands is somewhat similar to SkPicture, except the canvas-recording
69113e0824d6bddf4376240681f9cf6a2deded9498John Reck * functionality is split between DisplayListRenderer (which manages the recording), DisplayListData
70113e0824d6bddf4376240681f9cf6a2deded9498John Reck * (which holds the actual data), and DisplayList (which holds properties and performs playback onto
71113e0824d6bddf4376240681f9cf6a2deded9498John Reck * a renderer).
72113e0824d6bddf4376240681f9cf6a2deded9498John Reck *
73113e0824d6bddf4376240681f9cf6a2deded9498John Reck * Note that DisplayListData is swapped out from beneath an individual DisplayList when a view's
74113e0824d6bddf4376240681f9cf6a2deded9498John Reck * recorded stream of canvas operations is refreshed. The DisplayList (and its properties) stay
75113e0824d6bddf4376240681f9cf6a2deded9498John Reck * attached.
76113e0824d6bddf4376240681f9cf6a2deded9498John Reck */
77087bc0c14bdccf7c258dce0cdef46a69a839b427John Reckclass RenderNode : public VirtualLightRefBase {
78113e0824d6bddf4376240681f9cf6a2deded9498John Reckpublic:
79ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    enum DirtyPropertyMask {
80ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        GENERIC         = 1 << 1,
81ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        TRANSLATION_X   = 1 << 2,
82ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        TRANSLATION_Y   = 1 << 3,
83ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        TRANSLATION_Z   = 1 << 4,
84ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        SCALE_X         = 1 << 5,
85ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        SCALE_Y         = 1 << 6,
86ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        ROTATION        = 1 << 7,
87ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        ROTATION_X      = 1 << 8,
88ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        ROTATION_Y      = 1 << 9,
89ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        X               = 1 << 10,
90ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        Y               = 1 << 11,
91ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        Z               = 1 << 12,
92ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        ALPHA           = 1 << 13,
93a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck        DISPLAY_LIST    = 1 << 14,
94ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    };
95ff941dcd815021bb20d6504eb486acb1e50592c3John Reck
96113e0824d6bddf4376240681f9cf6a2deded9498John Reck    ANDROID_API RenderNode();
97e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck    ANDROID_API virtual ~RenderNode();
98113e0824d6bddf4376240681f9cf6a2deded9498John Reck
99113e0824d6bddf4376240681f9cf6a2deded9498John Reck    // See flags defined in DisplayList.java
100113e0824d6bddf4376240681f9cf6a2deded9498John Reck    enum ReplayFlag {
101113e0824d6bddf4376240681f9cf6a2deded9498John Reck        kReplayFlag_ClipChildren = 0x1
102113e0824d6bddf4376240681f9cf6a2deded9498John Reck    };
103113e0824d6bddf4376240681f9cf6a2deded9498John Reck
104113e0824d6bddf4376240681f9cf6a2deded9498John Reck    ANDROID_API static void outputLogBuffer(int fd);
105113e0824d6bddf4376240681f9cf6a2deded9498John Reck
1068de65a8e05285df52a1e6f0c1d5616dd233298a7John Reck    ANDROID_API void setStagingDisplayList(DisplayListData* newData);
107113e0824d6bddf4376240681f9cf6a2deded9498John Reck
108113e0824d6bddf4376240681f9cf6a2deded9498John Reck    void computeOrdering();
109b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik
11080d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik    void defer(DeferStateStruct& deferStruct, const int level);
11180d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik    void replay(ReplayStateStruct& replayStruct, const int level);
112113e0824d6bddf4376240681f9cf6a2deded9498John Reck
113113e0824d6bddf4376240681f9cf6a2deded9498John Reck    ANDROID_API void output(uint32_t level = 1);
114fe5e7b7346a54537b980796ceeca66bfdbd05561John Reck    ANDROID_API int getDebugSize();
115113e0824d6bddf4376240681f9cf6a2deded9498John Reck
116113e0824d6bddf4376240681f9cf6a2deded9498John Reck    bool isRenderable() const {
1178afd0f245cc0c4a0366f39f41b5f78e47ee83be3Chris Craik        return mDisplayListData && !mDisplayListData->isEmpty();
118113e0824d6bddf4376240681f9cf6a2deded9498John Reck    }
119113e0824d6bddf4376240681f9cf6a2deded9498John Reck
120a447d29c65fb811cd184775a3476101a1cede929John Reck    bool hasProjectionReceiver() const {
121a447d29c65fb811cd184775a3476101a1cede929John Reck        return mDisplayListData && mDisplayListData->projectionReceiveIndex >= 0;
122a447d29c65fb811cd184775a3476101a1cede929John Reck    }
123a447d29c65fb811cd184775a3476101a1cede929John Reck
124defb7f37fe67ef2389666f7adc5da1260df87017Chris Craik    const char* getName() const {
125defb7f37fe67ef2389666f7adc5da1260df87017Chris Craik        return mName.string();
126defb7f37fe67ef2389666f7adc5da1260df87017Chris Craik    }
127defb7f37fe67ef2389666f7adc5da1260df87017Chris Craik
128113e0824d6bddf4376240681f9cf6a2deded9498John Reck    void setName(const char* name) {
129113e0824d6bddf4376240681f9cf6a2deded9498John Reck        if (name) {
130113e0824d6bddf4376240681f9cf6a2deded9498John Reck            char* lastPeriod = strrchr(name, '.');
131113e0824d6bddf4376240681f9cf6a2deded9498John Reck            if (lastPeriod) {
132113e0824d6bddf4376240681f9cf6a2deded9498John Reck                mName.setTo(lastPeriod + 1);
133113e0824d6bddf4376240681f9cf6a2deded9498John Reck            } else {
134113e0824d6bddf4376240681f9cf6a2deded9498John Reck                mName.setTo(name);
135113e0824d6bddf4376240681f9cf6a2deded9498John Reck            }
136113e0824d6bddf4376240681f9cf6a2deded9498John Reck        }
137113e0824d6bddf4376240681f9cf6a2deded9498John Reck    }
138113e0824d6bddf4376240681f9cf6a2deded9498John Reck
139ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    bool isPropertyFieldDirty(DirtyPropertyMask field) const {
140ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        return mDirtyPropertyFields & field;
141ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    }
142ff941dcd815021bb20d6504eb486acb1e50592c3John Reck
143ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    void setPropertyFieldsDirty(uint32_t fields) {
144ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        mDirtyPropertyFields |= fields;
145ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    }
146ff941dcd815021bb20d6504eb486acb1e50592c3John Reck
147e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck    const RenderProperties& properties() const {
148113e0824d6bddf4376240681f9cf6a2deded9498John Reck        return mProperties;
149113e0824d6bddf4376240681f9cf6a2deded9498John Reck    }
150113e0824d6bddf4376240681f9cf6a2deded9498John Reck
15152244fff29042926e21fa897ef5ab11148e35299John Reck    RenderProperties& animatorProperties() {
15252244fff29042926e21fa897ef5ab11148e35299John Reck        return mProperties;
15352244fff29042926e21fa897ef5ab11148e35299John Reck    }
15452244fff29042926e21fa897ef5ab11148e35299John Reck
155d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    const RenderProperties& stagingProperties() {
156d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        return mStagingProperties;
157d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    }
158d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
159d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    RenderProperties& mutateStagingProperties() {
160d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck        return mStagingProperties;
161d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    }
162d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
163113e0824d6bddf4376240681f9cf6a2deded9498John Reck    int getWidth() {
164113e0824d6bddf4376240681f9cf6a2deded9498John Reck        return properties().getWidth();
165113e0824d6bddf4376240681f9cf6a2deded9498John Reck    }
166113e0824d6bddf4376240681f9cf6a2deded9498John Reck
167113e0824d6bddf4376240681f9cf6a2deded9498John Reck    int getHeight() {
168113e0824d6bddf4376240681f9cf6a2deded9498John Reck        return properties().getHeight();
169113e0824d6bddf4376240681f9cf6a2deded9498John Reck    }
170113e0824d6bddf4376240681f9cf6a2deded9498John Reck
171e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck    ANDROID_API virtual void prepareTree(TreeInfo& info);
172dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    void destroyHardwareResources();
173e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
174e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck    // UI thread only!
17568bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    ANDROID_API void addAnimator(const sp<BaseRenderNodeAnimator>& animator);
176668f0e38ef0277d55d3118af37e17b8c435df85cJohn Reck
177119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck    AnimatorManager& animators() { return mAnimatorManager; }
178119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck
17969e5adffb19135d51bde8e458f4907d7265f3e23Chris Craik    void applyViewPropertyTransforms(mat4& matrix, bool true3dTransform = false) const;
18069e5adffb19135d51bde8e458f4907d7265f3e23Chris Craik
181113e0824d6bddf4376240681f9cf6a2deded9498John Reckprivate:
182a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik    typedef key_value_pair_t<float, DrawRenderNodeOp*> ZDrawRenderNodeOpPair;
183113e0824d6bddf4376240681f9cf6a2deded9498John Reck
184a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik    static size_t findNonNegativeIndex(const Vector<ZDrawRenderNodeOpPair>& nodes) {
185113e0824d6bddf4376240681f9cf6a2deded9498John Reck        for (size_t i = 0; i < nodes.size(); i++) {
186113e0824d6bddf4376240681f9cf6a2deded9498John Reck            if (nodes[i].key >= 0.0f) return i;
187113e0824d6bddf4376240681f9cf6a2deded9498John Reck        }
188113e0824d6bddf4376240681f9cf6a2deded9498John Reck        return nodes.size();
189113e0824d6bddf4376240681f9cf6a2deded9498John Reck    }
190113e0824d6bddf4376240681f9cf6a2deded9498John Reck
191113e0824d6bddf4376240681f9cf6a2deded9498John Reck    enum ChildrenSelectMode {
192113e0824d6bddf4376240681f9cf6a2deded9498John Reck        kNegativeZChildren,
193113e0824d6bddf4376240681f9cf6a2deded9498John Reck        kPositiveZChildren
194113e0824d6bddf4376240681f9cf6a2deded9498John Reck    };
195113e0824d6bddf4376240681f9cf6a2deded9498John Reck
196a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik    void computeOrderingImpl(DrawRenderNodeOp* opState,
1973f085429fd47ebd32ac2463b3eae2a5a6c17be25Chris Craik            const SkPath* outlineOfProjectionSurface,
198a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik            Vector<DrawRenderNodeOp*>* compositedChildrenOfProjectionSurface,
199113e0824d6bddf4376240681f9cf6a2deded9498John Reck            const mat4* transformFromProjectionSurface);
200113e0824d6bddf4376240681f9cf6a2deded9498John Reck
201113e0824d6bddf4376240681f9cf6a2deded9498John Reck    template <class T>
202b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik    inline void setViewProperties(OpenGLRenderer& renderer, T& handler);
203113e0824d6bddf4376240681f9cf6a2deded9498John Reck
2048afd0f245cc0c4a0366f39f41b5f78e47ee83be3Chris Craik    void buildZSortedChildList(const DisplayListData::Chunk& chunk,
2058afd0f245cc0c4a0366f39f41b5f78e47ee83be3Chris Craik            Vector<ZDrawRenderNodeOpPair>& zTranslatedNodes);
206113e0824d6bddf4376240681f9cf6a2deded9498John Reck
207b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik    template<class T>
208b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik    inline void issueDrawShadowOperation(const Matrix4& transformFromParent, T& handler);
209b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik
210113e0824d6bddf4376240681f9cf6a2deded9498John Reck    template <class T>
21180d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik    inline int issueOperationsOfNegZChildren(
212a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik            const Vector<ZDrawRenderNodeOpPair>& zTranslatedNodes,
21380d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik            OpenGLRenderer& renderer, T& handler);
21480d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik    template <class T>
21580d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik    inline void issueOperationsOfPosZChildren(int shadowRestoreTo,
216a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik            const Vector<ZDrawRenderNodeOpPair>& zTranslatedNodes,
21780d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik            OpenGLRenderer& renderer, T& handler);
21880d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik    template <class T>
219a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik    inline void issueOperationsOf3dChildren(const Vector<ZDrawRenderNodeOpPair>& zTranslatedNodes,
220113e0824d6bddf4376240681f9cf6a2deded9498John Reck            ChildrenSelectMode mode, OpenGLRenderer& renderer, T& handler);
221113e0824d6bddf4376240681f9cf6a2deded9498John Reck
222113e0824d6bddf4376240681f9cf6a2deded9498John Reck    template <class T>
223b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik    inline void issueOperationsOfProjectedChildren(OpenGLRenderer& renderer, T& handler);
224113e0824d6bddf4376240681f9cf6a2deded9498John Reck
225b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik    /**
226b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik     * Issue the RenderNode's operations into a handler, recursing for subtrees through
227a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik     * DrawRenderNodeOp's defer() or replay() methods
228b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik     */
229113e0824d6bddf4376240681f9cf6a2deded9498John Reck    template <class T>
230b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik    inline void issueOperations(OpenGLRenderer& renderer, T& handler);
231113e0824d6bddf4376240681f9cf6a2deded9498John Reck
232113e0824d6bddf4376240681f9cf6a2deded9498John Reck    class TextContainer {
233113e0824d6bddf4376240681f9cf6a2deded9498John Reck    public:
234113e0824d6bddf4376240681f9cf6a2deded9498John Reck        size_t length() const {
235113e0824d6bddf4376240681f9cf6a2deded9498John Reck            return mByteLength;
236113e0824d6bddf4376240681f9cf6a2deded9498John Reck        }
237113e0824d6bddf4376240681f9cf6a2deded9498John Reck
238113e0824d6bddf4376240681f9cf6a2deded9498John Reck        const char* text() const {
239113e0824d6bddf4376240681f9cf6a2deded9498John Reck            return (const char*) mText;
240113e0824d6bddf4376240681f9cf6a2deded9498John Reck        }
241113e0824d6bddf4376240681f9cf6a2deded9498John Reck
242113e0824d6bddf4376240681f9cf6a2deded9498John Reck        size_t mByteLength;
243113e0824d6bddf4376240681f9cf6a2deded9498John Reck        const char* mText;
244113e0824d6bddf4376240681f9cf6a2deded9498John Reck    };
245113e0824d6bddf4376240681f9cf6a2deded9498John Reck
246f4198b713e43c0c0f9adac74203cf24c2a49b802John Reck    void prepareTreeImpl(TreeInfo& info);
24725fbb3fa1138675379102a44405852555cefccbdJohn Reck    void pushStagingPropertiesChanges(TreeInfo& info);
24825fbb3fa1138675379102a44405852555cefccbdJohn Reck    void pushStagingDisplayListChanges(TreeInfo& info);
249f4198b713e43c0c0f9adac74203cf24c2a49b802John Reck    void prepareSubTree(TreeInfo& info, DisplayListData* subtree);
25025fbb3fa1138675379102a44405852555cefccbdJohn Reck    void applyLayerPropertiesToLayer(TreeInfo& info);
251a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck    void prepareLayer(TreeInfo& info, uint32_t dirtyMask);
25225fbb3fa1138675379102a44405852555cefccbdJohn Reck    void pushLayerUpdate(TreeInfo& info);
253dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    void deleteDisplayListData();
2540a97330b98dd633b58dcfff405d94476c89e867dJohn Reck    void damageSelf(TreeInfo& info);
255dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck
256dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    void incParentRefCount() { mParentCount++; }
257dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    void decParentRefCount();
2588de65a8e05285df52a1e6f0c1d5616dd233298a7John Reck
259113e0824d6bddf4376240681f9cf6a2deded9498John Reck    String8 mName;
260113e0824d6bddf4376240681f9cf6a2deded9498John Reck
261ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    uint32_t mDirtyPropertyFields;
262113e0824d6bddf4376240681f9cf6a2deded9498John Reck    RenderProperties mProperties;
263d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck    RenderProperties mStagingProperties;
264d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck
2658de65a8e05285df52a1e6f0c1d5616dd233298a7John Reck    bool mNeedsDisplayListDataSync;
266dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    // WARNING: Do not delete this directly, you must go through deleteDisplayListData()!
267113e0824d6bddf4376240681f9cf6a2deded9498John Reck    DisplayListData* mDisplayListData;
2688de65a8e05285df52a1e6f0c1d5616dd233298a7John Reck    DisplayListData* mStagingDisplayListData;
269113e0824d6bddf4376240681f9cf6a2deded9498John Reck
27068bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    friend class AnimatorManager;
27168bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    AnimatorManager mAnimatorManager;
272e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
27325fbb3fa1138675379102a44405852555cefccbdJohn Reck    // Owned by RT. Lifecycle is managed by prepareTree(), with the exception
27425fbb3fa1138675379102a44405852555cefccbdJohn Reck    // being in ~RenderNode() which may happen on any thread.
27525fbb3fa1138675379102a44405852555cefccbdJohn Reck    Layer* mLayer;
27625fbb3fa1138675379102a44405852555cefccbdJohn Reck
277113e0824d6bddf4376240681f9cf6a2deded9498John Reck    /**
278113e0824d6bddf4376240681f9cf6a2deded9498John Reck     * Draw time state - these properties are only set and used during rendering
279113e0824d6bddf4376240681f9cf6a2deded9498John Reck     */
280113e0824d6bddf4376240681f9cf6a2deded9498John Reck
281113e0824d6bddf4376240681f9cf6a2deded9498John Reck    // for projection surfaces, contains a list of all children items
282a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik    Vector<DrawRenderNodeOp*> mProjectedNodes;
283dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck
284dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    // How many references our parent(s) have to us. Typically this should alternate
285dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    // between 2 and 1 (when a staging push happens we inc first then dec)
286dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    // When this hits 0 we are no longer in the tree, so any hardware resources
287dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    // (specifically Layers) should be released.
288dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    // This is *NOT* thread-safe, and should therefore only be tracking
289dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    // mDisplayListData, not mStagingDisplayListData.
290dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck    uint32_t mParentCount;
291113e0824d6bddf4376240681f9cf6a2deded9498John Reck}; // class RenderNode
292113e0824d6bddf4376240681f9cf6a2deded9498John Reck
293113e0824d6bddf4376240681f9cf6a2deded9498John Reck} /* namespace uirenderer */
294113e0824d6bddf4376240681f9cf6a2deded9498John Reck} /* namespace android */
295113e0824d6bddf4376240681f9cf6a2deded9498John Reck
296113e0824d6bddf4376240681f9cf6a2deded9498John Reck#endif /* RENDERNODE_H */
297