Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: sky/engine/core/animation/animatable/AnimatableValue.h

Issue 1229273004: Remove Animations and Transitions. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef SKY_ENGINE_CORE_ANIMATION_ANIMATABLE_ANIMATABLEVALUE_H_
32 #define SKY_ENGINE_CORE_ANIMATION_ANIMATABLE_ANIMATABLEVALUE_H_
33
34 #include "sky/engine/core/css/CSSValue.h"
35 #include "sky/engine/wtf/RefCounted.h"
36
37 namespace blink {
38
39 class AnimatableValue : public RefCounted<AnimatableValue> {
40 public:
41 virtual ~AnimatableValue() { }
42
43 static const AnimatableValue* neutralValue();
44
45 static PassRefPtr<AnimatableValue> interpolate(const AnimatableValue*, const AnimatableValue*, double fraction);
46 static double distance(const AnimatableValue* from, const AnimatableValue* t o);
47 static bool usesDefaultInterpolation(const AnimatableValue* from, const Anim atableValue* to)
48 {
49 return !from->isSameType(to) || from->usesDefaultInterpolationWith(to);
50 }
51
52 bool equals(const AnimatableValue* value) const
53 {
54 return isSameType(value) && equalTo(value);
55 }
56 bool equals(const AnimatableValue& value) const
57 {
58 return equals(&value);
59 }
60
61 bool isClipPathOperation() const { return type() == TypeClipPathOperation; }
62 bool isColor() const { return type() == TypeColor; }
63 bool isDouble() const { return type() == TypeDouble; }
64 bool isFilterOperations() const { return type() == TypeFilterOperations; }
65 bool isImage() const { return type() == TypeImage; }
66 bool isLength() const { return type() == TypeLength; }
67 bool isLengthBox() const { return type() == TypeLengthBox; }
68 bool isLengthBoxAndBool() const { return type() == TypeLengthBoxAndBool; }
69 bool isLengthPoint() const { return type() == TypeLengthPoint; }
70 bool isLengthPoint3D() const { return type() == TypeLengthPoint3D; }
71 bool isLengthSize() const { return type() == TypeLengthSize; }
72 bool isNeutral() const { return type() == TypeNeutral; }
73 bool isRepeatable() const { return type() == TypeRepeatable; }
74 bool isShadow() const { return type() == TypeShadow; }
75 bool isShapeValue() const { return type() == TypeShapeValue; }
76 bool isStrokeDasharrayList() const { return type() == TypeStrokeDasharrayLis t; }
77 bool isTransform() const { return type() == TypeTransform; }
78 bool isUnknown() const { return type() == TypeUnknown; }
79
80 bool isSameType(const AnimatableValue* value) const
81 {
82 ASSERT(value);
83 return value->type() == type();
84 }
85
86 protected:
87 enum AnimatableType {
88 TypeClipPathOperation,
89 TypeColor,
90 TypeDouble,
91 TypeFilterOperations,
92 TypeImage,
93 TypeLength,
94 TypeLengthBox,
95 TypeLengthBoxAndBool,
96 TypeLengthPoint,
97 TypeLengthPoint3D,
98 TypeLengthSize,
99 TypeNeutral,
100 TypeRepeatable,
101 TypeShadow,
102 TypeShapeValue,
103 TypeStrokeDasharrayList,
104 TypeTransform,
105 TypeUnknown,
106 };
107
108 virtual bool usesDefaultInterpolationWith(const AnimatableValue* value) cons t { return false; }
109 virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue*, do uble fraction) const = 0;
110 static PassRefPtr<AnimatableValue> defaultInterpolateTo(const AnimatableValu e* left, const AnimatableValue* right, double fraction) { return takeConstRef((f raction < 0.5) ? left : right); }
111
112 template <class T>
113 static PassRefPtr<T> takeConstRef(const T* value) { return PassRefPtr<T>(con st_cast<T*>(value)); }
114
115 private:
116 virtual AnimatableType type() const = 0;
117 // Implementations can assume that the object being compared has the same ty pe as the object this is called on
118 virtual bool equalTo(const AnimatableValue*) const = 0;
119
120 virtual double distanceTo(const AnimatableValue*) const;
121
122 template <class Keyframe> friend class KeyframeEffectModel;
123 };
124
125 #define DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(thisType, predicate) \
126 DEFINE_TYPE_CASTS(thisType, AnimatableValue, value, value->predicate, value. predicate)
127
128 } // namespace blink
129
130 #endif // SKY_ENGINE_CORE_ANIMATION_ANIMATABLE_ANIMATABLEVALUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698