RenderNode.h revision b565df13a9e5c7b1d7d93bdfa4a793752d66d3cc
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; 47113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass DisplayListOp; 48db663fe83f976107fd8fd9307d871b37d9e47370Chris Craikclass DisplayListCanvas; 49113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass OpenGLRenderer; 50113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass Rect; 51113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass Layer; 52113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SkiaShader; 53113e0824d6bddf4376240681f9cf6a2deded9498John Reck 54113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass ClipRectOp; 55113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SaveLayerOp; 56113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass SaveOp; 57113e0824d6bddf4376240681f9cf6a2deded9498John Reckclass RestoreToCountOp; 58a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craikclass DrawRenderNodeOp; 592dc236b2bae13b9a0ed9b3f7320502aecd7983b3Tom Hudsonclass TreeInfo; 60113e0824d6bddf4376240681f9cf6a2deded9498John Reck 61e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Recknamespace proto { 62e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reckclass RenderNode; 63e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck} 64e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn 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 69db663fe83f976107fd8fd9307d871b37d9e47370Chris Craik * functionality is split between DisplayListCanvas (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 { 78b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craikfriend class TestUtils; // allow TestUtils to access syncDisplayList / syncProperties 79113e0824d6bddf4376240681f9cf6a2deded9498John Reckpublic: 80ff941dcd815021bb20d6504eb486acb1e50592c3John Reck enum DirtyPropertyMask { 81ff941dcd815021bb20d6504eb486acb1e50592c3John Reck GENERIC = 1 << 1, 82ff941dcd815021bb20d6504eb486acb1e50592c3John Reck TRANSLATION_X = 1 << 2, 83ff941dcd815021bb20d6504eb486acb1e50592c3John Reck TRANSLATION_Y = 1 << 3, 84ff941dcd815021bb20d6504eb486acb1e50592c3John Reck TRANSLATION_Z = 1 << 4, 85ff941dcd815021bb20d6504eb486acb1e50592c3John Reck SCALE_X = 1 << 5, 86ff941dcd815021bb20d6504eb486acb1e50592c3John Reck SCALE_Y = 1 << 6, 87ff941dcd815021bb20d6504eb486acb1e50592c3John Reck ROTATION = 1 << 7, 88ff941dcd815021bb20d6504eb486acb1e50592c3John Reck ROTATION_X = 1 << 8, 89ff941dcd815021bb20d6504eb486acb1e50592c3John Reck ROTATION_Y = 1 << 9, 90ff941dcd815021bb20d6504eb486acb1e50592c3John Reck X = 1 << 10, 91ff941dcd815021bb20d6504eb486acb1e50592c3John Reck Y = 1 << 11, 92ff941dcd815021bb20d6504eb486acb1e50592c3John Reck Z = 1 << 12, 93ff941dcd815021bb20d6504eb486acb1e50592c3John Reck ALPHA = 1 << 13, 94a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck DISPLAY_LIST = 1 << 14, 95ff941dcd815021bb20d6504eb486acb1e50592c3John Reck }; 96ff941dcd815021bb20d6504eb486acb1e50592c3John Reck 97113e0824d6bddf4376240681f9cf6a2deded9498John Reck ANDROID_API RenderNode(); 98e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck ANDROID_API virtual ~RenderNode(); 99113e0824d6bddf4376240681f9cf6a2deded9498John Reck 100113e0824d6bddf4376240681f9cf6a2deded9498John Reck // See flags defined in DisplayList.java 101113e0824d6bddf4376240681f9cf6a2deded9498John Reck enum ReplayFlag { 102113e0824d6bddf4376240681f9cf6a2deded9498John Reck kReplayFlag_ClipChildren = 0x1 103113e0824d6bddf4376240681f9cf6a2deded9498John Reck }; 104113e0824d6bddf4376240681f9cf6a2deded9498John Reck 105443a714fa7c0dd07fee3527cc5bc3d3ca1fb7d44John Reck void debugDumpLayers(const char* prefix); 106113e0824d6bddf4376240681f9cf6a2deded9498John Reck 1078de65a8e05285df52a1e6f0c1d5616dd233298a7John Reck ANDROID_API void setStagingDisplayList(DisplayListData* newData); 108113e0824d6bddf4376240681f9cf6a2deded9498John Reck 109113e0824d6bddf4376240681f9cf6a2deded9498John Reck void computeOrdering(); 110b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik 11180d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik void defer(DeferStateStruct& deferStruct, const int level); 11280d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik void replay(ReplayStateStruct& replayStruct, const int level); 113113e0824d6bddf4376240681f9cf6a2deded9498John Reck 114113e0824d6bddf4376240681f9cf6a2deded9498John Reck ANDROID_API void output(uint32_t level = 1); 115fe5e7b7346a54537b980796ceeca66bfdbd05561John Reck ANDROID_API int getDebugSize(); 116e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck void copyTo(proto::RenderNode* node); 117113e0824d6bddf4376240681f9cf6a2deded9498John Reck 118113e0824d6bddf4376240681f9cf6a2deded9498John Reck bool isRenderable() const { 1198afd0f245cc0c4a0366f39f41b5f78e47ee83be3Chris Craik return mDisplayListData && !mDisplayListData->isEmpty(); 120113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 121113e0824d6bddf4376240681f9cf6a2deded9498John Reck 122a447d29c65fb811cd184775a3476101a1cede929John Reck bool hasProjectionReceiver() const { 123a447d29c65fb811cd184775a3476101a1cede929John Reck return mDisplayListData && mDisplayListData->projectionReceiveIndex >= 0; 124a447d29c65fb811cd184775a3476101a1cede929John Reck } 125a447d29c65fb811cd184775a3476101a1cede929John Reck 126defb7f37fe67ef2389666f7adc5da1260df87017Chris Craik const char* getName() const { 127defb7f37fe67ef2389666f7adc5da1260df87017Chris Craik return mName.string(); 128defb7f37fe67ef2389666f7adc5da1260df87017Chris Craik } 129defb7f37fe67ef2389666f7adc5da1260df87017Chris Craik 130113e0824d6bddf4376240681f9cf6a2deded9498John Reck void setName(const char* name) { 131113e0824d6bddf4376240681f9cf6a2deded9498John Reck if (name) { 132113e0824d6bddf4376240681f9cf6a2deded9498John Reck char* lastPeriod = strrchr(name, '.'); 133113e0824d6bddf4376240681f9cf6a2deded9498John Reck if (lastPeriod) { 134113e0824d6bddf4376240681f9cf6a2deded9498John Reck mName.setTo(lastPeriod + 1); 135113e0824d6bddf4376240681f9cf6a2deded9498John Reck } else { 136113e0824d6bddf4376240681f9cf6a2deded9498John Reck mName.setTo(name); 137113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 138113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 139113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 140113e0824d6bddf4376240681f9cf6a2deded9498John Reck 141ff941dcd815021bb20d6504eb486acb1e50592c3John Reck bool isPropertyFieldDirty(DirtyPropertyMask field) const { 142ff941dcd815021bb20d6504eb486acb1e50592c3John Reck return mDirtyPropertyFields & field; 143ff941dcd815021bb20d6504eb486acb1e50592c3John Reck } 144ff941dcd815021bb20d6504eb486acb1e50592c3John Reck 145ff941dcd815021bb20d6504eb486acb1e50592c3John Reck void setPropertyFieldsDirty(uint32_t fields) { 146ff941dcd815021bb20d6504eb486acb1e50592c3John Reck mDirtyPropertyFields |= fields; 147ff941dcd815021bb20d6504eb486acb1e50592c3John Reck } 148ff941dcd815021bb20d6504eb486acb1e50592c3John Reck 149e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck const RenderProperties& properties() const { 150113e0824d6bddf4376240681f9cf6a2deded9498John Reck return mProperties; 151113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 152113e0824d6bddf4376240681f9cf6a2deded9498John Reck 15352244fff29042926e21fa897ef5ab11148e35299John Reck RenderProperties& animatorProperties() { 15452244fff29042926e21fa897ef5ab11148e35299John Reck return mProperties; 15552244fff29042926e21fa897ef5ab11148e35299John Reck } 15652244fff29042926e21fa897ef5ab11148e35299John Reck 157d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck const RenderProperties& stagingProperties() { 158d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck return mStagingProperties; 159d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck } 160d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck 161d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck RenderProperties& mutateStagingProperties() { 162d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck return mStagingProperties; 163d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck } 164d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck 165113e0824d6bddf4376240681f9cf6a2deded9498John Reck int getWidth() { 166113e0824d6bddf4376240681f9cf6a2deded9498John Reck return properties().getWidth(); 167113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 168113e0824d6bddf4376240681f9cf6a2deded9498John Reck 169113e0824d6bddf4376240681f9cf6a2deded9498John Reck int getHeight() { 170113e0824d6bddf4376240681f9cf6a2deded9498John Reck return properties().getHeight(); 171113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 172113e0824d6bddf4376240681f9cf6a2deded9498John Reck 173e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck ANDROID_API virtual void prepareTree(TreeInfo& info); 174dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck void destroyHardwareResources(); 175e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck 176e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck // UI thread only! 17768bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck ANDROID_API void addAnimator(const sp<BaseRenderNodeAnimator>& animator); 178668f0e38ef0277d55d3118af37e17b8c435df85cJohn Reck 179119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck AnimatorManager& animators() { return mAnimatorManager; } 180119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck 181b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik // Returns false if the properties dictate the subtree contained in this RenderNode won't render 182b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik bool applyViewProperties(CanvasState& canvasState) const; 183b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik 18469e5adffb19135d51bde8e458f4907d7265f3e23Chris Craik void applyViewPropertyTransforms(mat4& matrix, bool true3dTransform = false) const; 18569e5adffb19135d51bde8e458f4907d7265f3e23Chris Craik 186b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik bool nothingToDraw() const { 187b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik const Outline& outline = properties().getOutline(); 188b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik return mDisplayListData == nullptr 189b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik || properties().getAlpha() <= 0 190b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik || (outline.getShouldClip() && outline.isEmpty()) 191b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik || properties().getScaleX() == 0 192b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik || properties().getScaleY() == 0; 193b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik } 194b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik 195b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik // Only call if RenderNode has DisplayListData... 196b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik const DisplayListData& getDisplayListData() const { 197b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik return *mDisplayListData; 198b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik } 199b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik 200113e0824d6bddf4376240681f9cf6a2deded9498John Reckprivate: 201a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik typedef key_value_pair_t<float, DrawRenderNodeOp*> ZDrawRenderNodeOpPair; 202113e0824d6bddf4376240681f9cf6a2deded9498John Reck 203272a685f17cc4828257e521a6f62b7b17870f75eJohn Reck static size_t findNonNegativeIndex(const std::vector<ZDrawRenderNodeOpPair>& nodes) { 204113e0824d6bddf4376240681f9cf6a2deded9498John Reck for (size_t i = 0; i < nodes.size(); i++) { 205113e0824d6bddf4376240681f9cf6a2deded9498John Reck if (nodes[i].key >= 0.0f) return i; 206113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 207113e0824d6bddf4376240681f9cf6a2deded9498John Reck return nodes.size(); 208113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 209113e0824d6bddf4376240681f9cf6a2deded9498John Reck 210b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik enum class ChildrenSelectMode { 211b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik NegativeZChildren, 212b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik PositiveZChildren 213113e0824d6bddf4376240681f9cf6a2deded9498John Reck }; 214113e0824d6bddf4376240681f9cf6a2deded9498John Reck 215a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik void computeOrderingImpl(DrawRenderNodeOp* opState, 216272a685f17cc4828257e521a6f62b7b17870f75eJohn Reck std::vector<DrawRenderNodeOp*>* compositedChildrenOfProjectionSurface, 217113e0824d6bddf4376240681f9cf6a2deded9498John Reck const mat4* transformFromProjectionSurface); 218113e0824d6bddf4376240681f9cf6a2deded9498John Reck 219113e0824d6bddf4376240681f9cf6a2deded9498John Reck template <class T> 220b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik inline void setViewProperties(OpenGLRenderer& renderer, T& handler); 221113e0824d6bddf4376240681f9cf6a2deded9498John Reck 2228afd0f245cc0c4a0366f39f41b5f78e47ee83be3Chris Craik void buildZSortedChildList(const DisplayListData::Chunk& chunk, 223272a685f17cc4828257e521a6f62b7b17870f75eJohn Reck std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes); 224113e0824d6bddf4376240681f9cf6a2deded9498John Reck 225b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik template<class T> 226b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik inline void issueDrawShadowOperation(const Matrix4& transformFromParent, T& handler); 227b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik 228113e0824d6bddf4376240681f9cf6a2deded9498John Reck template <class T> 229c3e75f9d54b3629b3fd27afafa2e07bd07dad9b3Chris Craik inline void issueOperationsOf3dChildren(ChildrenSelectMode mode, 230272a685f17cc4828257e521a6f62b7b17870f75eJohn Reck const Matrix4& initialTransform, const std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes, 23180d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik OpenGLRenderer& renderer, T& handler); 232113e0824d6bddf4376240681f9cf6a2deded9498John Reck 233113e0824d6bddf4376240681f9cf6a2deded9498John Reck template <class T> 234b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik inline void issueOperationsOfProjectedChildren(OpenGLRenderer& renderer, T& handler); 235113e0824d6bddf4376240681f9cf6a2deded9498John Reck 236b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik /** 237b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik * Issue the RenderNode's operations into a handler, recursing for subtrees through 238a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik * DrawRenderNodeOp's defer() or replay() methods 239b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik */ 240113e0824d6bddf4376240681f9cf6a2deded9498John Reck template <class T> 241b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik inline void issueOperations(OpenGLRenderer& renderer, T& handler); 242113e0824d6bddf4376240681f9cf6a2deded9498John Reck 243113e0824d6bddf4376240681f9cf6a2deded9498John Reck class TextContainer { 244113e0824d6bddf4376240681f9cf6a2deded9498John Reck public: 245113e0824d6bddf4376240681f9cf6a2deded9498John Reck size_t length() const { 246113e0824d6bddf4376240681f9cf6a2deded9498John Reck return mByteLength; 247113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 248113e0824d6bddf4376240681f9cf6a2deded9498John Reck 249113e0824d6bddf4376240681f9cf6a2deded9498John Reck const char* text() const { 250113e0824d6bddf4376240681f9cf6a2deded9498John Reck return (const char*) mText; 251113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 252113e0824d6bddf4376240681f9cf6a2deded9498John Reck 253113e0824d6bddf4376240681f9cf6a2deded9498John Reck size_t mByteLength; 254113e0824d6bddf4376240681f9cf6a2deded9498John Reck const char* mText; 255113e0824d6bddf4376240681f9cf6a2deded9498John Reck }; 256113e0824d6bddf4376240681f9cf6a2deded9498John Reck 257b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik 258b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik void syncProperties(); 259b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik void syncDisplayList(); 260b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik 261a766cb2bce5db9108c0266fbebea6aa18d5713ffChris Craik void prepareTreeImpl(TreeInfo& info, bool functorsNeedLayer); 26225fbb3fa1138675379102a44405852555cefccbdJohn Reck void pushStagingPropertiesChanges(TreeInfo& info); 26325fbb3fa1138675379102a44405852555cefccbdJohn Reck void pushStagingDisplayListChanges(TreeInfo& info); 264a766cb2bce5db9108c0266fbebea6aa18d5713ffChris Craik void prepareSubTree(TreeInfo& info, bool functorsNeedLayer, DisplayListData* subtree); 26525fbb3fa1138675379102a44405852555cefccbdJohn Reck void applyLayerPropertiesToLayer(TreeInfo& info); 266a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck void prepareLayer(TreeInfo& info, uint32_t dirtyMask); 26725fbb3fa1138675379102a44405852555cefccbdJohn Reck void pushLayerUpdate(TreeInfo& info); 268dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck void deleteDisplayListData(); 2690a97330b98dd633b58dcfff405d94476c89e867dJohn Reck void damageSelf(TreeInfo& info); 270dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck 271dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck void incParentRefCount() { mParentCount++; } 272dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck void decParentRefCount(); 2738de65a8e05285df52a1e6f0c1d5616dd233298a7John Reck 274113e0824d6bddf4376240681f9cf6a2deded9498John Reck String8 mName; 275113e0824d6bddf4376240681f9cf6a2deded9498John Reck 276ff941dcd815021bb20d6504eb486acb1e50592c3John Reck uint32_t mDirtyPropertyFields; 277113e0824d6bddf4376240681f9cf6a2deded9498John Reck RenderProperties mProperties; 278d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck RenderProperties mStagingProperties; 279d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck 2808de65a8e05285df52a1e6f0c1d5616dd233298a7John Reck bool mNeedsDisplayListDataSync; 281dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck // WARNING: Do not delete this directly, you must go through deleteDisplayListData()! 282113e0824d6bddf4376240681f9cf6a2deded9498John Reck DisplayListData* mDisplayListData; 2838de65a8e05285df52a1e6f0c1d5616dd233298a7John Reck DisplayListData* mStagingDisplayListData; 284113e0824d6bddf4376240681f9cf6a2deded9498John Reck 28568bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck friend class AnimatorManager; 28668bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck AnimatorManager mAnimatorManager; 287e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck 28825fbb3fa1138675379102a44405852555cefccbdJohn Reck // Owned by RT. Lifecycle is managed by prepareTree(), with the exception 28925fbb3fa1138675379102a44405852555cefccbdJohn Reck // being in ~RenderNode() which may happen on any thread. 29025fbb3fa1138675379102a44405852555cefccbdJohn Reck Layer* mLayer; 29125fbb3fa1138675379102a44405852555cefccbdJohn Reck 292113e0824d6bddf4376240681f9cf6a2deded9498John Reck /** 293113e0824d6bddf4376240681f9cf6a2deded9498John Reck * Draw time state - these properties are only set and used during rendering 294113e0824d6bddf4376240681f9cf6a2deded9498John Reck */ 295113e0824d6bddf4376240681f9cf6a2deded9498John Reck 296113e0824d6bddf4376240681f9cf6a2deded9498John Reck // for projection surfaces, contains a list of all children items 297272a685f17cc4828257e521a6f62b7b17870f75eJohn Reck std::vector<DrawRenderNodeOp*> mProjectedNodes; 298dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck 299dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck // How many references our parent(s) have to us. Typically this should alternate 300dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck // between 2 and 1 (when a staging push happens we inc first then dec) 301dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck // When this hits 0 we are no longer in the tree, so any hardware resources 302dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck // (specifically Layers) should be released. 303dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck // This is *NOT* thread-safe, and should therefore only be tracking 304dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck // mDisplayListData, not mStagingDisplayListData. 305dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck uint32_t mParentCount; 306113e0824d6bddf4376240681f9cf6a2deded9498John Reck}; // class RenderNode 307113e0824d6bddf4376240681f9cf6a2deded9498John Reck 308113e0824d6bddf4376240681f9cf6a2deded9498John Reck} /* namespace uirenderer */ 309113e0824d6bddf4376240681f9cf6a2deded9498John Reck} /* namespace android */ 310113e0824d6bddf4376240681f9cf6a2deded9498John Reck 311113e0824d6bddf4376240681f9cf6a2deded9498John Reck#endif /* RENDERNODE_H */ 312