RenderNode.h revision 8b083206aef627b6445a8c6be8bf5bb1d778a7f8
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); 1908b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu void removeAnimator(const sp<BaseRenderNodeAnimator>& animator); 1918b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu 1928b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu // This can only happen during pushStaging() 1938b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu void onAnimatorTargetChanged(BaseRenderNodeAnimator* animator) { 1948b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu mAnimatorManager.onAnimatorTargetChanged(animator); 1958b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu } 196668f0e38ef0277d55d3118af37e17b8c435df85cJohn Reck 197119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck AnimatorManager& animators() { return mAnimatorManager; } 198119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck 19969e5adffb19135d51bde8e458f4907d7265f3e23Chris Craik void applyViewPropertyTransforms(mat4& matrix, bool true3dTransform = false) const; 20069e5adffb19135d51bde8e458f4907d7265f3e23Chris Craik 201b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik bool nothingToDraw() const { 202b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik const Outline& outline = properties().getOutline(); 203003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik return mDisplayList == nullptr 204b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik || properties().getAlpha() <= 0 205b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik || (outline.getShouldClip() && outline.isEmpty()) 206b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik || properties().getScaleX() == 0 207b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik || properties().getScaleY() == 0; 208b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik } 209b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik 2100b7e8245db728d127ada698be63d78b33fc6e4daChris Craik const DisplayList* getDisplayList() const { 2110b7e8245db728d127ada698be63d78b33fc6e4daChris Craik return mDisplayList; 212b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik } 2130b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#if HWUI_NEW_OPS 2140b7e8245db728d127ada698be63d78b33fc6e4daChris Craik OffscreenBuffer* getLayer() const { return mLayer; } 2150b7e8245db728d127ada698be63d78b33fc6e4daChris Craik OffscreenBuffer** getLayerHandle() { return &mLayer; } // ugh... 2160b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#endif 217b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik 218f648108f83d4e74811919e9811efb8fcc184b8a3John Reck class ANDROID_API PositionListener { 219f648108f83d4e74811919e9811efb8fcc184b8a3John Reck public: 220f648108f83d4e74811919e9811efb8fcc184b8a3John Reck virtual ~PositionListener() {} 221f648108f83d4e74811919e9811efb8fcc184b8a3John Reck virtual void onPositionUpdated(RenderNode& node, const TreeInfo& info) = 0; 222f648108f83d4e74811919e9811efb8fcc184b8a3John Reck }; 223f648108f83d4e74811919e9811efb8fcc184b8a3John Reck 224f648108f83d4e74811919e9811efb8fcc184b8a3John Reck // Note this is not thread safe, this needs to be called 225f648108f83d4e74811919e9811efb8fcc184b8a3John Reck // before the RenderNode is used for drawing. 226f648108f83d4e74811919e9811efb8fcc184b8a3John Reck // RenderNode takes ownership of the pointer 227f648108f83d4e74811919e9811efb8fcc184b8a3John Reck ANDROID_API void setPositionListener(PositionListener* listener) { 228f648108f83d4e74811919e9811efb8fcc184b8a3John Reck mPositionListener.reset(listener); 229f648108f83d4e74811919e9811efb8fcc184b8a3John Reck } 230f648108f83d4e74811919e9811efb8fcc184b8a3John Reck 231113e0824d6bddf4376240681f9cf6a2deded9498John Reckprivate: 232a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik typedef key_value_pair_t<float, DrawRenderNodeOp*> ZDrawRenderNodeOpPair; 233113e0824d6bddf4376240681f9cf6a2deded9498John Reck 234272a685f17cc4828257e521a6f62b7b17870f75eJohn Reck static size_t findNonNegativeIndex(const std::vector<ZDrawRenderNodeOpPair>& nodes) { 235113e0824d6bddf4376240681f9cf6a2deded9498John Reck for (size_t i = 0; i < nodes.size(); i++) { 236113e0824d6bddf4376240681f9cf6a2deded9498John Reck if (nodes[i].key >= 0.0f) return i; 237113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 238113e0824d6bddf4376240681f9cf6a2deded9498John Reck return nodes.size(); 239113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 240113e0824d6bddf4376240681f9cf6a2deded9498John Reck 241b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik enum class ChildrenSelectMode { 242b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik NegativeZChildren, 243b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik PositiveZChildren 244113e0824d6bddf4376240681f9cf6a2deded9498John Reck }; 245113e0824d6bddf4376240681f9cf6a2deded9498John Reck 2468d1f2120fe80b23ab03c7168e3b6b2d13bafe2e7Chris Craik void computeOrderingImpl(renderNodeOp_t* opState, 2478d1f2120fe80b23ab03c7168e3b6b2d13bafe2e7Chris Craik std::vector<renderNodeOp_t*>* compositedChildrenOfProjectionSurface, 248113e0824d6bddf4376240681f9cf6a2deded9498John Reck const mat4* transformFromProjectionSurface); 249113e0824d6bddf4376240681f9cf6a2deded9498John Reck 250113e0824d6bddf4376240681f9cf6a2deded9498John Reck template <class T> 251b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik inline void setViewProperties(OpenGLRenderer& renderer, T& handler); 252113e0824d6bddf4376240681f9cf6a2deded9498John Reck 253003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik void buildZSortedChildList(const DisplayList::Chunk& chunk, 254272a685f17cc4828257e521a6f62b7b17870f75eJohn Reck std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes); 255113e0824d6bddf4376240681f9cf6a2deded9498John Reck 256b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik template<class T> 257b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik inline void issueDrawShadowOperation(const Matrix4& transformFromParent, T& handler); 258b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik 259113e0824d6bddf4376240681f9cf6a2deded9498John Reck template <class T> 260c3e75f9d54b3629b3fd27afafa2e07bd07dad9b3Chris Craik inline void issueOperationsOf3dChildren(ChildrenSelectMode mode, 261272a685f17cc4828257e521a6f62b7b17870f75eJohn Reck const Matrix4& initialTransform, const std::vector<ZDrawRenderNodeOpPair>& zTranslatedNodes, 26280d4902196899d1325cd9f52c06ae0174cf9bd4cChris Craik OpenGLRenderer& renderer, T& handler); 263113e0824d6bddf4376240681f9cf6a2deded9498John Reck 264113e0824d6bddf4376240681f9cf6a2deded9498John Reck template <class T> 265b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik inline void issueOperationsOfProjectedChildren(OpenGLRenderer& renderer, T& handler); 266113e0824d6bddf4376240681f9cf6a2deded9498John Reck 267b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik /** 268b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik * Issue the RenderNode's operations into a handler, recursing for subtrees through 269a7090e0cfd7c719a6d4c03aae34f5db98754cbddChris Craik * DrawRenderNodeOp's defer() or replay() methods 270b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik */ 271113e0824d6bddf4376240681f9cf6a2deded9498John Reck template <class T> 272b265e2ca50b6ceb2fd2987ef1f7d063b1bde19aeChris Craik inline void issueOperations(OpenGLRenderer& renderer, T& handler); 273113e0824d6bddf4376240681f9cf6a2deded9498John Reck 274113e0824d6bddf4376240681f9cf6a2deded9498John Reck class TextContainer { 275113e0824d6bddf4376240681f9cf6a2deded9498John Reck public: 276113e0824d6bddf4376240681f9cf6a2deded9498John Reck size_t length() const { 277113e0824d6bddf4376240681f9cf6a2deded9498John Reck return mByteLength; 278113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 279113e0824d6bddf4376240681f9cf6a2deded9498John Reck 280113e0824d6bddf4376240681f9cf6a2deded9498John Reck const char* text() const { 281113e0824d6bddf4376240681f9cf6a2deded9498John Reck return (const char*) mText; 282113e0824d6bddf4376240681f9cf6a2deded9498John Reck } 283113e0824d6bddf4376240681f9cf6a2deded9498John Reck 284113e0824d6bddf4376240681f9cf6a2deded9498John Reck size_t mByteLength; 285113e0824d6bddf4376240681f9cf6a2deded9498John Reck const char* mText; 286113e0824d6bddf4376240681f9cf6a2deded9498John Reck }; 287113e0824d6bddf4376240681f9cf6a2deded9498John Reck 288b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik 289b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik void syncProperties(); 290b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik void syncDisplayList(); 291b565df13a9e5c7b1d7d93bdfa4a793752d66d3ccChris Craik 292a766cb2bce5db9108c0266fbebea6aa18d5713ffChris Craik void prepareTreeImpl(TreeInfo& info, bool functorsNeedLayer); 29325fbb3fa1138675379102a44405852555cefccbdJohn Reck void pushStagingPropertiesChanges(TreeInfo& info); 29425fbb3fa1138675379102a44405852555cefccbdJohn Reck void pushStagingDisplayListChanges(TreeInfo& info); 295003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik void prepareSubTree(TreeInfo& info, bool functorsNeedLayer, DisplayList* subtree); 2960b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#if !HWUI_NEW_OPS 29725fbb3fa1138675379102a44405852555cefccbdJohn Reck void applyLayerPropertiesToLayer(TreeInfo& info); 2980b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#endif 299a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck void prepareLayer(TreeInfo& info, uint32_t dirtyMask); 30025fbb3fa1138675379102a44405852555cefccbdJohn Reck void pushLayerUpdate(TreeInfo& info); 301003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik void deleteDisplayList(); 3020a97330b98dd633b58dcfff405d94476c89e867dJohn Reck void damageSelf(TreeInfo& info); 303dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck 304dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck void incParentRefCount() { mParentCount++; } 305dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck void decParentRefCount(); 3068de65a8e05285df52a1e6f0c1d5616dd233298a7John Reck 307113e0824d6bddf4376240681f9cf6a2deded9498John Reck String8 mName; 308113e0824d6bddf4376240681f9cf6a2deded9498John Reck 309ff941dcd815021bb20d6504eb486acb1e50592c3John Reck uint32_t mDirtyPropertyFields; 310113e0824d6bddf4376240681f9cf6a2deded9498John Reck RenderProperties mProperties; 311d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck RenderProperties mStagingProperties; 312d0a0b2a3140bfb1819a116413ce9d81886697a07John Reck 313003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik bool mNeedsDisplayListSync; 314003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik // WARNING: Do not delete this directly, you must go through deleteDisplayList()! 315003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik DisplayList* mDisplayList; 316003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik DisplayList* mStagingDisplayList; 317113e0824d6bddf4376240681f9cf6a2deded9498John Reck 31868bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck friend class AnimatorManager; 31968bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck AnimatorManager mAnimatorManager; 320e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck 32125fbb3fa1138675379102a44405852555cefccbdJohn Reck // Owned by RT. Lifecycle is managed by prepareTree(), with the exception 32225fbb3fa1138675379102a44405852555cefccbdJohn Reck // being in ~RenderNode() which may happen on any thread. 3230b7e8245db728d127ada698be63d78b33fc6e4daChris Craik layer_t* mLayer = nullptr; 32425fbb3fa1138675379102a44405852555cefccbdJohn Reck 325113e0824d6bddf4376240681f9cf6a2deded9498John Reck /** 326113e0824d6bddf4376240681f9cf6a2deded9498John Reck * Draw time state - these properties are only set and used during rendering 327113e0824d6bddf4376240681f9cf6a2deded9498John Reck */ 328113e0824d6bddf4376240681f9cf6a2deded9498John Reck 329113e0824d6bddf4376240681f9cf6a2deded9498John Reck // for projection surfaces, contains a list of all children items 3308d1f2120fe80b23ab03c7168e3b6b2d13bafe2e7Chris Craik std::vector<renderNodeOp_t*> mProjectedNodes; 331dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck 332dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck // How many references our parent(s) have to us. Typically this should alternate 333dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck // between 2 and 1 (when a staging push happens we inc first then dec) 334dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck // When this hits 0 we are no longer in the tree, so any hardware resources 335dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck // (specifically Layers) should be released. 336dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck // This is *NOT* thread-safe, and should therefore only be tracking 337003cc3dec8e2a92e51086fbcd5ee1bb236efa701Chris Craik // mDisplayList, not mStagingDisplayList. 338dcba6725e8b9d3eba9ad7a01258d6aa974feafbaJohn Reck uint32_t mParentCount; 339f648108f83d4e74811919e9811efb8fcc184b8a3John Reck 340f648108f83d4e74811919e9811efb8fcc184b8a3John Reck std::unique_ptr<PositionListener> mPositionListener; 341113e0824d6bddf4376240681f9cf6a2deded9498John Reck}; // class RenderNode 342113e0824d6bddf4376240681f9cf6a2deded9498John Reck 343113e0824d6bddf4376240681f9cf6a2deded9498John Reck} /* namespace uirenderer */ 344113e0824d6bddf4376240681f9cf6a2deded9498John Reck} /* namespace android */ 345113e0824d6bddf4376240681f9cf6a2deded9498John Reck 346113e0824d6bddf4376240681f9cf6a2deded9498John Reck#endif /* RENDERNODE_H */ 347