John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 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 | #ifndef RENDERNODE_H |
| 17 | #define RENDERNODE_H |
| 18 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 19 | #include <SkCamera.h> |
| 20 | #include <SkMatrix.h> |
| 21 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 22 | #include <utils/LinearAllocator.h> |
| 23 | #include <utils/RefBase.h> |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 24 | #include <utils/String8.h> |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 25 | |
| 26 | #include <cutils/compiler.h> |
| 27 | |
| 28 | #include <androidfw/ResourceTypes.h> |
| 29 | |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 30 | #include "AnimatorManager.h" |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 31 | #include "Debug.h" |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 32 | #include "DisplayList.h" |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 33 | #include "Matrix.h" |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 34 | #include "RenderProperties.h" |
| 35 | |
John Reck | 272a685 | 2015-07-29 16:48:58 -0700 | [diff] [blame] | 36 | #include <vector> |
| 37 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 38 | class SkBitmap; |
| 39 | class SkPaint; |
| 40 | class SkPath; |
| 41 | class SkRegion; |
| 42 | |
| 43 | namespace android { |
| 44 | namespace uirenderer { |
| 45 | |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 46 | class CanvasState; |
Chris Craik | db663fe | 2015-04-20 13:34:45 -0700 | [diff] [blame] | 47 | class DisplayListCanvas; |
Chris Craik | 0b7e824 | 2015-10-28 16:50:44 -0700 | [diff] [blame] | 48 | class DisplayListOp; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 49 | class OpenGLRenderer; |
| 50 | class Rect; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 51 | class SkiaShader; |
| 52 | |
Chris Craik | 0b7e824 | 2015-10-28 16:50:44 -0700 | [diff] [blame] | 53 | #if HWUI_NEW_OPS |
Chris Craik | f158b49 | 2016-01-12 14:45:08 -0800 | [diff] [blame] | 54 | class FrameBuilder; |
Chris Craik | 0b7e824 | 2015-10-28 16:50:44 -0700 | [diff] [blame] | 55 | class OffscreenBuffer; |
Chris Craik | 8d1f212 | 2015-11-24 16:40:09 -0800 | [diff] [blame] | 56 | struct RenderNodeOp; |
Chris Craik | 0b7e824 | 2015-10-28 16:50:44 -0700 | [diff] [blame] | 57 | typedef OffscreenBuffer layer_t; |
Chris Craik | 8d1f212 | 2015-11-24 16:40:09 -0800 | [diff] [blame] | 58 | typedef RenderNodeOp renderNodeOp_t; |
Chris Craik | 0b7e824 | 2015-10-28 16:50:44 -0700 | [diff] [blame] | 59 | #else |
| 60 | class Layer; |
| 61 | typedef Layer layer_t; |
Chris Craik | 8d1f212 | 2015-11-24 16:40:09 -0800 | [diff] [blame] | 62 | typedef DrawRenderNodeOp renderNodeOp_t; |
Chris Craik | 0b7e824 | 2015-10-28 16:50:44 -0700 | [diff] [blame] | 63 | #endif |
| 64 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 65 | class ClipRectOp; |
Chris Craik | 8d1f212 | 2015-11-24 16:40:09 -0800 | [diff] [blame] | 66 | class DrawRenderNodeOp; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 67 | class SaveLayerOp; |
| 68 | class SaveOp; |
| 69 | class RestoreToCountOp; |
Tom Hudson | 2dc236b | 2014-10-15 15:46:42 -0400 | [diff] [blame] | 70 | class TreeInfo; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 71 | |
John Reck | e248bd1 | 2015-08-05 13:53:53 -0700 | [diff] [blame] | 72 | namespace proto { |
| 73 | class RenderNode; |
| 74 | } |
| 75 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 76 | /** |
| 77 | * Primary class for storing recorded canvas commands, as well as per-View/ViewGroup display properties. |
| 78 | * |
| 79 | * Recording of canvas commands is somewhat similar to SkPicture, except the canvas-recording |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 80 | * functionality is split between DisplayListCanvas (which manages the recording), DisplayList |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 81 | * (which holds the actual data), and DisplayList (which holds properties and performs playback onto |
| 82 | * a renderer). |
| 83 | * |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 84 | * Note that DisplayList is swapped out from beneath an individual RenderNode when a view's |
| 85 | * recorded stream of canvas operations is refreshed. The RenderNode (and its properties) stay |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 86 | * attached. |
| 87 | */ |
John Reck | 087bc0c | 2014-04-04 16:20:08 -0700 | [diff] [blame] | 88 | class RenderNode : public VirtualLightRefBase { |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 89 | friend class TestUtils; // allow TestUtils to access syncDisplayList / syncProperties |
Chris Craik | f158b49 | 2016-01-12 14:45:08 -0800 | [diff] [blame] | 90 | friend class FrameBuilder; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 91 | public: |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 92 | enum DirtyPropertyMask { |
| 93 | GENERIC = 1 << 1, |
| 94 | TRANSLATION_X = 1 << 2, |
| 95 | TRANSLATION_Y = 1 << 3, |
| 96 | TRANSLATION_Z = 1 << 4, |
| 97 | SCALE_X = 1 << 5, |
| 98 | SCALE_Y = 1 << 6, |
| 99 | ROTATION = 1 << 7, |
| 100 | ROTATION_X = 1 << 8, |
| 101 | ROTATION_Y = 1 << 9, |
| 102 | X = 1 << 10, |
| 103 | Y = 1 << 11, |
| 104 | Z = 1 << 12, |
| 105 | ALPHA = 1 << 13, |
John Reck | a7c2ea2 | 2014-08-08 13:21:00 -0700 | [diff] [blame] | 106 | DISPLAY_LIST = 1 << 14, |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 107 | }; |
| 108 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 109 | ANDROID_API RenderNode(); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 110 | ANDROID_API virtual ~RenderNode(); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 111 | |
| 112 | // See flags defined in DisplayList.java |
| 113 | enum ReplayFlag { |
| 114 | kReplayFlag_ClipChildren = 0x1 |
| 115 | }; |
| 116 | |
John Reck | 443a714 | 2014-09-04 17:40:05 -0700 | [diff] [blame] | 117 | void debugDumpLayers(const char* prefix); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 118 | |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 119 | ANDROID_API void setStagingDisplayList(DisplayList* newData); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 120 | |
| 121 | void computeOrdering(); |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 122 | |
Chris Craik | 80d4902 | 2014-06-20 15:03:43 -0700 | [diff] [blame] | 123 | void defer(DeferStateStruct& deferStruct, const int level); |
| 124 | void replay(ReplayStateStruct& replayStruct, const int level); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 125 | |
| 126 | ANDROID_API void output(uint32_t level = 1); |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 127 | ANDROID_API int getDebugSize(); |
John Reck | e248bd1 | 2015-08-05 13:53:53 -0700 | [diff] [blame] | 128 | void copyTo(proto::RenderNode* node); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 129 | |
| 130 | bool isRenderable() const { |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 131 | return mDisplayList && !mDisplayList->isEmpty(); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 132 | } |
| 133 | |
John Reck | a447d29 | 2014-06-11 18:39:44 -0700 | [diff] [blame] | 134 | bool hasProjectionReceiver() const { |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 135 | return mDisplayList && mDisplayList->projectionReceiveIndex >= 0; |
John Reck | a447d29 | 2014-06-11 18:39:44 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Chris Craik | defb7f3 | 2014-04-08 18:17:07 -0700 | [diff] [blame] | 138 | const char* getName() const { |
| 139 | return mName.string(); |
| 140 | } |
| 141 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 142 | void setName(const char* name) { |
| 143 | if (name) { |
| 144 | char* lastPeriod = strrchr(name, '.'); |
| 145 | if (lastPeriod) { |
| 146 | mName.setTo(lastPeriod + 1); |
| 147 | } else { |
| 148 | mName.setTo(name); |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 153 | bool isPropertyFieldDirty(DirtyPropertyMask field) const { |
| 154 | return mDirtyPropertyFields & field; |
| 155 | } |
| 156 | |
| 157 | void setPropertyFieldsDirty(uint32_t fields) { |
| 158 | mDirtyPropertyFields |= fields; |
| 159 | } |
| 160 | |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 161 | const RenderProperties& properties() const { |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 162 | return mProperties; |
| 163 | } |
| 164 | |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 165 | RenderProperties& animatorProperties() { |
| 166 | return mProperties; |
| 167 | } |
| 168 | |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 169 | const RenderProperties& stagingProperties() { |
| 170 | return mStagingProperties; |
| 171 | } |
| 172 | |
| 173 | RenderProperties& mutateStagingProperties() { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 174 | return mStagingProperties; |
| 175 | } |
| 176 | |
Chris Craik | 76caecf | 2015-11-02 19:17:45 -0800 | [diff] [blame] | 177 | int getWidth() const { |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 178 | return properties().getWidth(); |
| 179 | } |
| 180 | |
Chris Craik | 76caecf | 2015-11-02 19:17:45 -0800 | [diff] [blame] | 181 | int getHeight() const { |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 182 | return properties().getHeight(); |
| 183 | } |
| 184 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 185 | ANDROID_API virtual void prepareTree(TreeInfo& info); |
John Reck | dcba672 | 2014-07-08 13:59:49 -0700 | [diff] [blame] | 186 | void destroyHardwareResources(); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 187 | |
| 188 | // UI thread only! |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 189 | ANDROID_API void addAnimator(const sp<BaseRenderNodeAnimator>& animator); |
Doris Liu | 8b08320 | 2016-02-19 21:46:06 +0000 | [diff] [blame] | 190 | void removeAnimator(const sp<BaseRenderNodeAnimator>& animator); |
| 191 | |
| 192 | // This can only happen during pushStaging() |
| 193 | void onAnimatorTargetChanged(BaseRenderNodeAnimator* animator) { |
| 194 | mAnimatorManager.onAnimatorTargetChanged(animator); |
| 195 | } |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 196 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 197 | AnimatorManager& animators() { return mAnimatorManager; } |
| 198 | |
Chris Craik | 69e5adf | 2014-08-14 13:34:01 -0700 | [diff] [blame] | 199 | void applyViewPropertyTransforms(mat4& matrix, bool true3dTransform = false) const; |
| 200 | |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 201 | bool nothingToDraw() const { |
| 202 | const Outline& outline = properties().getOutline(); |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 203 | return mDisplayList == nullptr |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 204 | || properties().getAlpha() <= 0 |
| 205 | || (outline.getShouldClip() && outline.isEmpty()) |
| 206 | || properties().getScaleX() == 0 |
| 207 | || properties().getScaleY() == 0; |
| 208 | } |
| 209 | |
Chris Craik | 0b7e824 | 2015-10-28 16:50:44 -0700 | [diff] [blame] | 210 | const DisplayList* getDisplayList() const { |
| 211 | return mDisplayList; |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 212 | } |
Chris Craik | 0b7e824 | 2015-10-28 16:50:44 -0700 | [diff] [blame] | 213 | #if HWUI_NEW_OPS |
| 214 | OffscreenBuffer* getLayer() const { return mLayer; } |
| 215 | OffscreenBuffer** getLayerHandle() { return &mLayer; } // ugh... |
| 216 | #endif |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 217 | |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 218 | class ANDROID_API PositionListener { |
| 219 | public: |
| 220 | virtual ~PositionListener() {} |
| 221 | virtual void onPositionUpdated(RenderNode& node, const TreeInfo& info) = 0; |
| 222 | }; |
| 223 | |
| 224 | // Note this is not thread safe, this needs to be called |
| 225 | // before the RenderNode is used for drawing. |
| 226 | // RenderNode takes ownership of the pointer |
| 227 | ANDROID_API void setPositionListener(PositionListener* listener) { |
| 228 | mPositionListener.reset(listener); |
| 229 | } |
| 230 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 231 | private: |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 232 | typedef key_value_pair_t<float, DrawRenderNodeOp*> ZDrawRenderNodeOpPair; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 233 | |
John Reck | 272a685 | 2015-07-29 16:48:58 -0700 | [diff] [blame] | 234 | static size_t findNonNegativeIndex(const std::vector<ZDrawRenderNodeOpPair>& nodes) { |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 235 | for (size_t i = 0; i < nodes.size(); i++) { |
| 236 | if (nodes[i].key >= 0.0f) return i; |
| 237 | } |
| 238 | return nodes.size(); |
| 239 | } |
| 240 | |
Chris Craik | b9ce116d | 2015-08-20 15:14:06 -0700 | [diff] [blame] | 241 | enum class ChildrenSelectMode { |
| 242 | NegativeZChildren, |
| 243 | PositiveZChildren |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 244 | }; |
| 245 | |
Chris Craik | 8d1f212 | 2015-11-24 16:40:09 -0800 | [diff] [blame] | 246 | void computeOrderingImpl(renderNodeOp_t* opState, |
| 247 | std::vector<renderNodeOp_t*>* compositedChildrenOfProjectionSurface, |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 248 | const mat4* transformFromProjectionSurface); |
| 249 | |
| 250 | template <class T> |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 251 | inline void setViewProperties(OpenGLRenderer& renderer, T& handler); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 252 | |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 253 | void buildZSortedChildList(const DisplayList::Chunk& chunk, |
John Reck | 272a685 | 2015-07-29 16:48:58 -0700 | [diff] [blame] | 254 | std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 255 | |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 256 | template<class T> |
| 257 | inline void issueDrawShadowOperation(const Matrix4& transformFromParent, T& handler); |
| 258 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 259 | template <class T> |
Chris Craik | c3e75f9 | 2014-08-27 15:34:52 -0700 | [diff] [blame] | 260 | inline void issueOperationsOf3dChildren(ChildrenSelectMode mode, |
John Reck | 272a685 | 2015-07-29 16:48:58 -0700 | [diff] [blame] | 261 | const Matrix4& initialTransform, const std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes, |
Chris Craik | 80d4902 | 2014-06-20 15:03:43 -0700 | [diff] [blame] | 262 | OpenGLRenderer& renderer, T& handler); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 263 | |
| 264 | template <class T> |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 265 | inline void issueOperationsOfProjectedChildren(OpenGLRenderer& renderer, T& handler); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 266 | |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 267 | /** |
| 268 | * Issue the RenderNode's operations into a handler, recursing for subtrees through |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 269 | * DrawRenderNodeOp's defer() or replay() methods |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 270 | */ |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 271 | template <class T> |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 272 | inline void issueOperations(OpenGLRenderer& renderer, T& handler); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 273 | |
| 274 | class TextContainer { |
| 275 | public: |
| 276 | size_t length() const { |
| 277 | return mByteLength; |
| 278 | } |
| 279 | |
| 280 | const char* text() const { |
| 281 | return (const char*) mText; |
| 282 | } |
| 283 | |
| 284 | size_t mByteLength; |
| 285 | const char* mText; |
| 286 | }; |
| 287 | |
Chris Craik | b565df1 | 2015-10-05 13:00:52 -0700 | [diff] [blame] | 288 | |
| 289 | void syncProperties(); |
| 290 | void syncDisplayList(); |
| 291 | |
Chris Craik | a766cb2 | 2015-06-08 16:49:43 -0700 | [diff] [blame] | 292 | void prepareTreeImpl(TreeInfo& info, bool functorsNeedLayer); |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 293 | void pushStagingPropertiesChanges(TreeInfo& info); |
| 294 | void pushStagingDisplayListChanges(TreeInfo& info); |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 295 | void prepareSubTree(TreeInfo& info, bool functorsNeedLayer, DisplayList* subtree); |
Chris Craik | 0b7e824 | 2015-10-28 16:50:44 -0700 | [diff] [blame] | 296 | #if !HWUI_NEW_OPS |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 297 | void applyLayerPropertiesToLayer(TreeInfo& info); |
Chris Craik | 0b7e824 | 2015-10-28 16:50:44 -0700 | [diff] [blame] | 298 | #endif |
John Reck | a7c2ea2 | 2014-08-08 13:21:00 -0700 | [diff] [blame] | 299 | void prepareLayer(TreeInfo& info, uint32_t dirtyMask); |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 300 | void pushLayerUpdate(TreeInfo& info); |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 301 | void deleteDisplayList(); |
John Reck | 0a97330 | 2014-07-16 13:29:45 -0700 | [diff] [blame] | 302 | void damageSelf(TreeInfo& info); |
John Reck | dcba672 | 2014-07-08 13:59:49 -0700 | [diff] [blame] | 303 | |
| 304 | void incParentRefCount() { mParentCount++; } |
| 305 | void decParentRefCount(); |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 306 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 307 | String8 mName; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 308 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 309 | uint32_t mDirtyPropertyFields; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 310 | RenderProperties mProperties; |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 311 | RenderProperties mStagingProperties; |
| 312 | |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 313 | bool mNeedsDisplayListSync; |
| 314 | // WARNING: Do not delete this directly, you must go through deleteDisplayList()! |
| 315 | DisplayList* mDisplayList; |
| 316 | DisplayList* mStagingDisplayList; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 317 | |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 318 | friend class AnimatorManager; |
| 319 | AnimatorManager mAnimatorManager; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 320 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 321 | // Owned by RT. Lifecycle is managed by prepareTree(), with the exception |
| 322 | // being in ~RenderNode() which may happen on any thread. |
Chris Craik | 0b7e824 | 2015-10-28 16:50:44 -0700 | [diff] [blame] | 323 | layer_t* mLayer = nullptr; |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 324 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 325 | /** |
| 326 | * Draw time state - these properties are only set and used during rendering |
| 327 | */ |
| 328 | |
| 329 | // for projection surfaces, contains a list of all children items |
Chris Craik | 8d1f212 | 2015-11-24 16:40:09 -0800 | [diff] [blame] | 330 | std::vector<renderNodeOp_t*> mProjectedNodes; |
John Reck | dcba672 | 2014-07-08 13:59:49 -0700 | [diff] [blame] | 331 | |
| 332 | // How many references our parent(s) have to us. Typically this should alternate |
| 333 | // between 2 and 1 (when a staging push happens we inc first then dec) |
| 334 | // When this hits 0 we are no longer in the tree, so any hardware resources |
| 335 | // (specifically Layers) should be released. |
| 336 | // This is *NOT* thread-safe, and should therefore only be tracking |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 337 | // mDisplayList, not mStagingDisplayList. |
John Reck | dcba672 | 2014-07-08 13:59:49 -0700 | [diff] [blame] | 338 | uint32_t mParentCount; |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 339 | |
| 340 | std::unique_ptr<PositionListener> mPositionListener; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 341 | }; // class RenderNode |
| 342 | |
| 343 | } /* namespace uirenderer */ |
| 344 | } /* namespace android */ |
| 345 | |
| 346 | #endif /* RENDERNODE_H */ |