blob: 8355f83ea37c31cfa0421a3d1f7e11b4f9148bc9 [file] [log] [blame]
John Recke45b1fd2014-04-15 09:50:16 -07001/*
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
John Recke45b1fd2014-04-15 09:50:16 -070019#include <utils/Timers.h>
John Recke45b1fd2014-04-15 09:50:16 -070020
21namespace android {
22namespace uirenderer {
23
John Reckff941dc2014-05-14 16:34:14 -070024class BaseRenderNodeAnimator;
John Reck52244ff2014-05-01 21:27:37 -070025class AnimationListener;
John Recke45b1fd2014-04-15 09:50:16 -070026
John Reck52244ff2014-05-01 21:27:37 -070027class AnimationHook {
John Recke45b1fd2014-04-15 09:50:16 -070028public:
John Reckff941dc2014-05-14 16:34:14 -070029 virtual void callOnFinished(BaseRenderNodeAnimator* animator, AnimationListener* listener) = 0;
John Recke45b1fd2014-04-15 09:50:16 -070030protected:
John Reck52244ff2014-05-01 21:27:37 -070031 ~AnimationHook() {}
John Recke45b1fd2014-04-15 09:50:16 -070032};
33
34struct TreeInfo {
35 // The defaults here should be safe for everyone but DrawFrameTask to use as-is.
36 TreeInfo()
John Reckf9be7792014-05-02 18:21:16 -070037 : frameTimeMs(0)
38 , animationHook(NULL)
39 , prepareTextures(false)
40 , performStagingPush(true)
41 , evaluateAnimations(false)
John Recke45b1fd2014-04-15 09:50:16 -070042 {}
43
John Reckf9be7792014-05-02 18:21:16 -070044 nsecs_t frameTimeMs;
45 AnimationHook* animationHook;
John Recke45b1fd2014-04-15 09:50:16 -070046 bool prepareTextures;
47 bool performStagingPush;
John Recke45b1fd2014-04-15 09:50:16 -070048 bool evaluateAnimations;
John Reckf9be7792014-05-02 18:21:16 -070049
50 struct Out {
51 Out()
52 : hasFunctors(false)
53 , hasAnimations(false)
54 , requiresUiRedraw(false)
John Recka5dda642014-05-22 15:43:54 -070055 , canDrawThisFrame(true)
John Reckf9be7792014-05-02 18:21:16 -070056 {}
57 bool hasFunctors;
58 // This is only updated if evaluateAnimations is true
59 bool hasAnimations;
60 // This is set to true if there is an animation that RenderThread cannot
61 // animate itself, such as if hasFunctors is true
62 // This is only set if hasAnimations is true
63 bool requiresUiRedraw;
John Recka5dda642014-05-22 15:43:54 -070064 // This is set to true if draw() can be called this frame
65 // false means that we must delay until the next vsync pulse as frame
66 // production is outrunning consumption
67 // NOTE that if this is false CanvasContext will set either requiresUiRedraw
68 // *OR* will post itself for the next vsync automatically, use this
69 // only to avoid calling draw()
70 bool canDrawThisFrame;
John Reckf9be7792014-05-02 18:21:16 -070071 } out;
John Recke45b1fd2014-04-15 09:50:16 -070072
73 // TODO: Damage calculations
74};
75
76} /* namespace uirenderer */
77} /* namespace android */
78
79#endif /* TREEINFO_H */