John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 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 ANIMATORMANAGER_H |
| 17 | #define ANIMATORMANAGER_H |
| 18 | |
| 19 | #include <vector> |
| 20 | |
| 21 | #include <cutils/compiler.h> |
| 22 | #include <utils/StrongPointer.h> |
| 23 | |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 24 | #include "utils/Macros.h" |
| 25 | |
| 26 | namespace android { |
| 27 | namespace uirenderer { |
| 28 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 29 | class AnimationHandle; |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 30 | class BaseRenderNodeAnimator; |
| 31 | class RenderNode; |
Tom Hudson | 2dc236b | 2014-10-15 15:46:42 -0400 | [diff] [blame] | 32 | class TreeInfo; |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 33 | |
| 34 | // Responsible for managing the animators for a single RenderNode |
| 35 | class AnimatorManager { |
| 36 | PREVENT_COPY_AND_ASSIGN(AnimatorManager); |
| 37 | public: |
| 38 | AnimatorManager(RenderNode& parent); |
| 39 | ~AnimatorManager(); |
| 40 | |
| 41 | void addAnimator(const sp<BaseRenderNodeAnimator>& animator); |
Doris Liu | 8b08320 | 2016-02-19 21:46:06 +0000 | [diff] [blame] | 42 | void removeAnimator(const sp<BaseRenderNodeAnimator>& animator); |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 43 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 44 | void setAnimationHandle(AnimationHandle* handle); |
| 45 | bool hasAnimationHandle() { return mAnimationHandle; } |
| 46 | |
| 47 | void pushStaging(); |
Doris Liu | 8b08320 | 2016-02-19 21:46:06 +0000 | [diff] [blame] | 48 | void onAnimatorTargetChanged(BaseRenderNodeAnimator* animator); |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 49 | |
John Reck | a7c2ea2 | 2014-08-08 13:21:00 -0700 | [diff] [blame] | 50 | // Returns the combined dirty mask of all animators run |
| 51 | uint32_t animate(TreeInfo& info); |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 52 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 53 | void animateNoDamage(TreeInfo& info); |
| 54 | |
John Reck | e2478d4 | 2014-09-03 16:46:05 -0700 | [diff] [blame] | 55 | // Hard-ends all animators. May only be called on the UI thread. |
| 56 | ANDROID_API void endAllStagingAnimators(); |
| 57 | |
| 58 | // Hard-ends all animators that have been pushed. Used for cleanup if |
| 59 | // the ActivityContext is being destroyed |
| 60 | void endAllActiveAnimators(); |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 61 | |
| 62 | bool hasAnimators() { return mAnimators.size(); } |
| 63 | |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 64 | private: |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 65 | uint32_t animateCommon(TreeInfo& info); |
| 66 | |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 67 | RenderNode& mParent; |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 68 | AnimationHandle* mAnimationHandle; |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 69 | |
| 70 | // To improve the efficiency of resizing & removing from the vector |
Doris Liu | c4bb185 | 2016-02-19 21:39:21 +0000 | [diff] [blame] | 71 | std::vector< sp<BaseRenderNodeAnimator> > mNewAnimators; |
| 72 | std::vector< sp<BaseRenderNodeAnimator> > mAnimators; |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | } /* namespace uirenderer */ |
| 76 | } /* namespace android */ |
| 77 | |
| 78 | #endif /* ANIMATORMANAGER_H */ |