TreeInfo.h revision a447d29c65fb811cd184775a3476101a1cede929
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 TREEINFO_H 17#define TREEINFO_H 18 19#include <utils/Timers.h> 20 21#include "DamageAccumulator.h" 22#include "utils/Macros.h" 23 24namespace android { 25namespace uirenderer { 26 27class BaseRenderNodeAnimator; 28class AnimationListener; 29 30class AnimationHook { 31public: 32 virtual void callOnFinished(BaseRenderNodeAnimator* animator, AnimationListener* listener) = 0; 33protected: 34 ~AnimationHook() {} 35}; 36 37// This would be a struct, but we want to PREVENT_COPY_AND_ASSIGN 38class TreeInfo { 39 PREVENT_COPY_AND_ASSIGN(TreeInfo); 40public: 41 enum TraversalMode { 42 // The full monty - sync, push, run animators, etc... Used by DrawFrameTask 43 // May only be used if both the UI thread and RT thread are blocked on the 44 // prepare 45 MODE_FULL, 46 // Run only what can be done safely on RT thread. Currently this only means 47 // animators, but potentially things like SurfaceTexture updates 48 // could be handled by this as well if there are no listeners 49 MODE_RT_ONLY, 50 // The subtree is being detached. Maybe. If the RenderNode is present 51 // in both the old and new display list's children then it will get a 52 // MODE_MAYBE_DETACHING followed shortly by a MODE_FULL. 53 // Push any pending display list changes in case it is detached, 54 // but don't evaluate animators and such as if it isn't detached as a 55 // MODE_FULL will follow shortly. 56 MODE_MAYBE_DETACHING, 57 // TODO: TRIM_MEMORY? 58 }; 59 60 explicit TreeInfo(TraversalMode mode) 61 : mode(mode) 62 , frameTimeMs(0) 63 , animationHook(NULL) 64 , prepareTextures(mode == MODE_FULL) 65 , damageAccumulator(NullDamageAccumulator::instance()) 66 {} 67 68 const TraversalMode mode; 69 nsecs_t frameTimeMs; 70 AnimationHook* animationHook; 71 // TODO: Remove this? Currently this is used to signal to stop preparing 72 // textures if we run out of cache space. 73 bool prepareTextures; 74 // Must not be null 75 IDamageAccumulator* damageAccumulator; 76 77 struct Out { 78 Out() 79 : hasFunctors(false) 80 , hasAnimations(false) 81 , requiresUiRedraw(false) 82 , canDrawThisFrame(true) 83 {} 84 bool hasFunctors; 85 // This is only updated if evaluateAnimations is true 86 bool hasAnimations; 87 // This is set to true if there is an animation that RenderThread cannot 88 // animate itself, such as if hasFunctors is true 89 // This is only set if hasAnimations is true 90 bool requiresUiRedraw; 91 // This is set to true if draw() can be called this frame 92 // false means that we must delay until the next vsync pulse as frame 93 // production is outrunning consumption 94 // NOTE that if this is false CanvasContext will set either requiresUiRedraw 95 // *OR* will post itself for the next vsync automatically, use this 96 // only to avoid calling draw() 97 bool canDrawThisFrame; 98 } out; 99 100 // TODO: Damage calculations 101}; 102 103} /* namespace uirenderer */ 104} /* namespace android */ 105 106#endif /* TREEINFO_H */ 107