TreeInfo.h revision f648108f83d4e74811919e9811efb8fcc184b8a3
1e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck/* 2e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * Copyright (C) 2014 The Android Open Source Project 3e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * 4e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * Licensed under the Apache License, Version 2.0 (the "License"); 5e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * you may not use this file except in compliance with the License. 6e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * You may obtain a copy of the License at 7e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * 8e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * http://www.apache.org/licenses/LICENSE-2.0 9e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * 10e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * Unless required by applicable law or agreed to in writing, software 11e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * distributed under the License is distributed on an "AS IS" BASIS, 12e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * See the License for the specific language governing permissions and 14e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * limitations under the License. 15e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck */ 16e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck#ifndef TREEINFO_H 17e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck#define TREEINFO_H 18e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck 190b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#include "utils/Macros.h" 20c25e506f7fc08790c0532f927f31310a2ca778b7John Reck 21e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck#include <utils/Timers.h> 22e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck 230b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#include <string> 24e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck 25e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Recknamespace android { 26e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Recknamespace uirenderer { 27e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck 28998a6d81896df8b662cc10ddeb35087b78b38d72John Recknamespace renderthread { 29998a6d81896df8b662cc10ddeb35087b78b38d72John Reckclass CanvasContext; 30998a6d81896df8b662cc10ddeb35087b78b38d72John Reck} 31998a6d81896df8b662cc10ddeb35087b78b38d72John Reck 322dc236b2bae13b9a0ed9b3f7320502aecd7983b3Tom Hudsonclass DamageAccumulator; 330b7e8245db728d127ada698be63d78b33fc6e4daChris Craikclass LayerUpdateQueue; 3425fbb3fa1138675379102a44405852555cefccbdJohn Reckclass OpenGLRenderer; 353b20251a355c88193c439f928a84ae69483fb488John Reckclass RenderState; 36e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck 37c25e506f7fc08790c0532f927f31310a2ca778b7John Reckclass ErrorHandler { 38c25e506f7fc08790c0532f927f31310a2ca778b7John Reckpublic: 39c25e506f7fc08790c0532f927f31310a2ca778b7John Reck virtual void onError(const std::string& message) = 0; 40c25e506f7fc08790c0532f927f31310a2ca778b7John Reckprotected: 41c25e506f7fc08790c0532f927f31310a2ca778b7John Reck ~ErrorHandler() {} 42c25e506f7fc08790c0532f927f31310a2ca778b7John Reck}; 43c25e506f7fc08790c0532f927f31310a2ca778b7John Reck 44e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck// This would be a struct, but we want to PREVENT_COPY_AND_ASSIGN 45e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reckclass TreeInfo { 46e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck PREVENT_COPY_AND_ASSIGN(TreeInfo); 47e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reckpublic: 48e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck enum TraversalMode { 49e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck // The full monty - sync, push, run animators, etc... Used by DrawFrameTask 50e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck // May only be used if both the UI thread and RT thread are blocked on the 51e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck // prepare 52e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck MODE_FULL, 53e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck // Run only what can be done safely on RT thread. Currently this only means 54e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck // animators, but potentially things like SurfaceTexture updates 55e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck // could be handled by this as well if there are no listeners 56e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck MODE_RT_ONLY, 57e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck }; 58e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck 59e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik TreeInfo(TraversalMode mode, renderthread::CanvasContext& canvasContext) 60e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik : mode(mode) 61e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik , prepareTextures(mode == MODE_FULL) 62e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik , canvasContext(canvasContext) 6368bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck {} 6468bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck 65ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne TraversalMode mode; 66e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck // TODO: Remove this? Currently this is used to signal to stop preparing 67e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck // textures if we run out of cache space. 68e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck bool prepareTextures; 69e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik renderthread::CanvasContext& canvasContext; 709eb9f6f8cbbbd87d45da8071aa54cb066a797723John Reck // TODO: buildLayer uses this to suppress running any animations, but this 719eb9f6f8cbbbd87d45da8071aa54cb066a797723John Reck // should probably be refactored somehow. The reason this is done is 729eb9f6f8cbbbd87d45da8071aa54cb066a797723John Reck // because buildLayer is not setup for injecting the animationHook, as well 739eb9f6f8cbbbd87d45da8071aa54cb066a797723John Reck // as this being otherwise wasted work as all the animators will be 749eb9f6f8cbbbd87d45da8071aa54cb066a797723John Reck // re-evaluated when the frame is actually drawn 75e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik bool runAnimations = true; 7669e5adffb19135d51bde8e458f4907d7265f3e23Chris Craik 7769e5adffb19135d51bde8e458f4907d7265f3e23Chris Craik // Must not be null during actual usage 78e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik DamageAccumulator* damageAccumulator = nullptr; 790b7e8245db728d127ada698be63d78b33fc6e4daChris Craik 800b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#if HWUI_NEW_OPS 810b7e8245db728d127ada698be63d78b33fc6e4daChris Craik LayerUpdateQueue* layerUpdateQueue = nullptr; 820b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#else 8325fbb3fa1138675379102a44405852555cefccbdJohn Reck // The renderer that will be drawing the next frame. Use this to push any 8425fbb3fa1138675379102a44405852555cefccbdJohn Reck // layer updates or similar. May be NULL. 85e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik OpenGLRenderer* renderer = nullptr; 860b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#endif 87e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik ErrorHandler* errorHandler = nullptr; 88f9be77940e365036fecd8cc0e491e8545c34e79bJohn Reck 89f648108f83d4e74811919e9811efb8fcc184b8a3John Reck // Frame number for use with synchronized surfaceview position updating 90f648108f83d4e74811919e9811efb8fcc184b8a3John Reck int64_t frameNumber = -1; 91f648108f83d4e74811919e9811efb8fcc184b8a3John Reck int32_t windowInsetLeft = 0; 92f648108f83d4e74811919e9811efb8fcc184b8a3John Reck int32_t windowInsetTop = 0; 93f648108f83d4e74811919e9811efb8fcc184b8a3John Reck bool updateWindowPositions = false; 94f648108f83d4e74811919e9811efb8fcc184b8a3John Reck 95f9be77940e365036fecd8cc0e491e8545c34e79bJohn Reck struct Out { 96e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik bool hasFunctors = false; 97f9be77940e365036fecd8cc0e491e8545c34e79bJohn Reck // This is only updated if evaluateAnimations is true 98e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik bool hasAnimations = false; 99f9be77940e365036fecd8cc0e491e8545c34e79bJohn Reck // This is set to true if there is an animation that RenderThread cannot 100f9be77940e365036fecd8cc0e491e8545c34e79bJohn Reck // animate itself, such as if hasFunctors is true 101f9be77940e365036fecd8cc0e491e8545c34e79bJohn Reck // This is only set if hasAnimations is true 102e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik bool requiresUiRedraw = false; 103a5dda645da738da7b4ae15e28fa7d93d3b04b94fJohn Reck // This is set to true if draw() can be called this frame 104a5dda645da738da7b4ae15e28fa7d93d3b04b94fJohn Reck // false means that we must delay until the next vsync pulse as frame 105a5dda645da738da7b4ae15e28fa7d93d3b04b94fJohn Reck // production is outrunning consumption 106a5dda645da738da7b4ae15e28fa7d93d3b04b94fJohn Reck // NOTE that if this is false CanvasContext will set either requiresUiRedraw 107a5dda645da738da7b4ae15e28fa7d93d3b04b94fJohn Reck // *OR* will post itself for the next vsync automatically, use this 108a5dda645da738da7b4ae15e28fa7d93d3b04b94fJohn Reck // only to avoid calling draw() 109e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik bool canDrawThisFrame = true; 110f9be77940e365036fecd8cc0e491e8545c34e79bJohn Reck } out; 111e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck 112e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck // TODO: Damage calculations 113e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck}; 114e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck 115e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck} /* namespace uirenderer */ 116e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck} /* namespace android */ 117e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck 118e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck#endif /* TREEINFO_H */ 119