2 * Copyright (C) 2014 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef ANIMATORMANAGER_H
17 #define ANIMATORMANAGER_H
21 #include <cutils/compiler.h>
22 #include <utils/StrongPointer.h>
24 #include "utils/Macros.h"
27 namespace uirenderer {
29 class AnimationHandle;
30 class BaseRenderNodeAnimator;
34 // Responsible for managing the animators for a single RenderNode
35 class AnimatorManager {
36 PREVENT_COPY_AND_ASSIGN(AnimatorManager);
38 AnimatorManager(RenderNode& parent);
41 void addAnimator(const sp<BaseRenderNodeAnimator>& animator);
42 void removeAnimator(const sp<BaseRenderNodeAnimator>& animator);
44 void setAnimationHandle(AnimationHandle* handle);
45 bool hasAnimationHandle() { return mAnimationHandle; }
48 void onAnimatorTargetChanged(BaseRenderNodeAnimator* animator);
50 // Returns the combined dirty mask of all animators run
51 uint32_t animate(TreeInfo& info);
53 void animateNoDamage(TreeInfo& info);
55 // Hard-ends all animators. May only be called on the UI thread.
56 ANDROID_API void endAllStagingAnimators();
58 // Hard-ends all animators that have been pushed. Used for cleanup if
59 // the ActivityContext is being destroyed
60 void endAllActiveAnimators();
62 bool hasAnimators() { return mAnimators.size(); }
65 uint32_t animateCommon(TreeInfo& info);
68 AnimationHandle* mAnimationHandle;
70 // To improve the efficiency of resizing & removing from the vector
71 std::vector< sp<BaseRenderNodeAnimator> > mNewAnimators;
72 std::vector< sp<BaseRenderNodeAnimator> > mAnimators;
75 } /* namespace uirenderer */
76 } /* namespace android */
78 #endif /* ANIMATORMANAGER_H */