transform_animation_curve_adapter.h revision e5d81f57cb97b3b6b7fccc9c5610d21eb81db09d
1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef UI_COMPOSITOR_TRANSFORM_ANIMATION_CURVE_ADAPTER_H_ 6#define UI_COMPOSITOR_TRANSFORM_ANIMATION_CURVE_ADAPTER_H_ 7 8#include "base/time/time.h" 9#include "cc/animation/animation_curve.h" 10#include "ui/compositor/compositor_export.h" 11#include "ui/gfx/animation/tween.h" 12#include "ui/gfx/transform.h" 13#include "ui/gfx/transform_util.h" 14 15namespace ui { 16 17class COMPOSITOR_EXPORT TransformAnimationCurveAdapter 18 : public cc::TransformAnimationCurve { 19 public: 20 TransformAnimationCurveAdapter(gfx::Tween::Type tween_type, 21 gfx::Transform intial_value, 22 gfx::Transform target_value, 23 base::TimeDelta duration); 24 25 virtual ~TransformAnimationCurveAdapter(); 26 27 // TransformAnimationCurve implementation. 28 virtual double Duration() const OVERRIDE; 29 virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE; 30 virtual gfx::Transform GetValue(double t) const OVERRIDE; 31 virtual bool AnimatedBoundsForBox(const gfx::BoxF& box, 32 gfx::BoxF* bounds) const OVERRIDE; 33 virtual bool AffectsScale() const OVERRIDE; 34 35 private: 36 gfx::Tween::Type tween_type_; 37 gfx::Transform initial_value_; 38 gfx::Transform target_value_; 39 gfx::DecomposedTransform decomposed_initial_value_; 40 gfx::DecomposedTransform decomposed_target_value_; 41 base::TimeDelta duration_; 42 43 DISALLOW_ASSIGN(TransformAnimationCurveAdapter); 44}; 45 46class COMPOSITOR_EXPORT InverseTransformCurveAdapter 47 : public cc::TransformAnimationCurve { 48 public: 49 InverseTransformCurveAdapter(TransformAnimationCurveAdapter base_curve, 50 gfx::Transform initial_value, 51 base::TimeDelta duration); 52 53 virtual ~InverseTransformCurveAdapter(); 54 55 virtual double Duration() const OVERRIDE; 56 virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE; 57 virtual gfx::Transform GetValue(double t) const OVERRIDE; 58 virtual bool AnimatedBoundsForBox(const gfx::BoxF& box, 59 gfx::BoxF* bounds) const OVERRIDE; 60 virtual bool AffectsScale() const OVERRIDE; 61 62 private: 63 TransformAnimationCurveAdapter base_curve_; 64 gfx::Transform initial_value_; 65 gfx::Transform effective_initial_value_; 66 base::TimeDelta duration_; 67 68 DISALLOW_ASSIGN(InverseTransformCurveAdapter); 69}; 70 71} // namespace ui 72 73#endif // UI_COMPOSITOR_TRANSFORM_ANIMATION_CURVE_ADAPTER_H_ 74 75