transform_animation_curve_adapter.h revision d0247b1b59f9c528cb6df88b4f2b9afaf80d181e
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 34 private: 35 gfx::Tween::Type tween_type_; 36 gfx::Transform initial_value_; 37 gfx::Transform target_value_; 38 gfx::DecomposedTransform decomposed_initial_value_; 39 gfx::DecomposedTransform decomposed_target_value_; 40 base::TimeDelta duration_; 41 42 DISALLOW_ASSIGN(TransformAnimationCurveAdapter); 43}; 44 45class COMPOSITOR_EXPORT InverseTransformCurveAdapter 46 : public cc::TransformAnimationCurve { 47 public: 48 InverseTransformCurveAdapter(TransformAnimationCurveAdapter base_curve, 49 gfx::Transform initial_value, 50 base::TimeDelta duration); 51 52 virtual ~InverseTransformCurveAdapter(); 53 54 virtual double Duration() const OVERRIDE; 55 virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE; 56 virtual gfx::Transform GetValue(double t) const OVERRIDE; 57 virtual bool AnimatedBoundsForBox(const gfx::BoxF& box, 58 gfx::BoxF* bounds) const OVERRIDE; 59 60 private: 61 TransformAnimationCurveAdapter base_curve_; 62 gfx::Transform initial_value_; 63 gfx::Transform effective_initial_value_; 64 base::TimeDelta duration_; 65 66 DISALLOW_ASSIGN(InverseTransformCurveAdapter); 67}; 68 69} // namespace ui 70 71#endif // UI_COMPOSITOR_TRANSFORM_ANIMATION_CURVE_ADAPTER_H_ 72 73