168bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck/* 268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck * Copyright (C) 2014 The Android Open Source Project 368bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck * 468bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck * Licensed under the Apache License, Version 2.0 (the "License"); 568bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck * you may not use this file except in compliance with the License. 668bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck * You may obtain a copy of the License at 768bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck * 868bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck * http://www.apache.org/licenses/LICENSE-2.0 968bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck * 1068bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck * Unless required by applicable law or agreed to in writing, software 1168bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck * distributed under the License is distributed on an "AS IS" BASIS, 1268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1368bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck * See the License for the specific language governing permissions and 1468bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck * limitations under the License. 1568bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck */ 1668bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck#ifndef ANIMATORMANAGER_H 1768bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck#define ANIMATORMANAGER_H 1868bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck 1968bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck#include <vector> 2068bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck 2168bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck#include <cutils/compiler.h> 2268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck#include <utils/StrongPointer.h> 2368bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck 2468bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck#include "TreeInfo.h" 2568bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck#include "utils/Macros.h" 2668bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck 2768bfe0a37a0dcef52abd81688d8520c5d16e1a85John Recknamespace android { 2868bfe0a37a0dcef52abd81688d8520c5d16e1a85John Recknamespace uirenderer { 2968bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck 30119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reckclass AnimationHandle; 3168bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reckclass BaseRenderNodeAnimator; 3268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reckclass RenderNode; 3368bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck 3468bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck// Responsible for managing the animators for a single RenderNode 3568bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reckclass AnimatorManager { 3668bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck PREVENT_COPY_AND_ASSIGN(AnimatorManager); 3768bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reckpublic: 3868bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck AnimatorManager(RenderNode& parent); 3968bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck ~AnimatorManager(); 4068bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck 4168bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck void addAnimator(const sp<BaseRenderNodeAnimator>& animator); 4268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck 43119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck void setAnimationHandle(AnimationHandle* handle); 44119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck bool hasAnimationHandle() { return mAnimationHandle; } 45119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck 46119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck void pushStaging(); 47119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck 48a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck // Returns the combined dirty mask of all animators run 49a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck uint32_t animate(TreeInfo& info); 5068bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck 51119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck void animateNoDamage(TreeInfo& info); 52119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck 53e2478d45ccbe5b6abb360ac9d44771b5f4a50bdeJohn Reck // Hard-ends all animators. May only be called on the UI thread. 54e2478d45ccbe5b6abb360ac9d44771b5f4a50bdeJohn Reck ANDROID_API void endAllStagingAnimators(); 55e2478d45ccbe5b6abb360ac9d44771b5f4a50bdeJohn Reck 56e2478d45ccbe5b6abb360ac9d44771b5f4a50bdeJohn Reck // Hard-ends all animators that have been pushed. Used for cleanup if 57e2478d45ccbe5b6abb360ac9d44771b5f4a50bdeJohn Reck // the ActivityContext is being destroyed 58e2478d45ccbe5b6abb360ac9d44771b5f4a50bdeJohn Reck void endAllActiveAnimators(); 59119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck 60119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck bool hasAnimators() { return mAnimators.size(); } 61119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck 6268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reckprivate: 63119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck uint32_t animateCommon(TreeInfo& info); 64119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck 6568bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck RenderNode& mParent; 66119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck AnimationHandle* mAnimationHandle; 6768bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck 6868bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck // To improve the efficiency of resizing & removing from the vector 6968bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck // use manual ref counting instead of sp<>. 7068bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck std::vector<BaseRenderNodeAnimator*> mNewAnimators; 7168bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck std::vector<BaseRenderNodeAnimator*> mAnimators; 7268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck}; 7368bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck 7468bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck} /* namespace uirenderer */ 7568bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck} /* namespace android */ 7668bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck 7768bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck#endif /* ANIMATORMANAGER_H */ 78