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

Side by Side Diff: Source/core/animation/DoubleStyleInterpolation.cpp

Issue 811993002: Animation: Implement DoubleStyleInterpolation in StringKeyframe (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Opacity runs on compositor Created 5 years, 11 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/animation/DoubleStyleInterpolation.h" 6 #include "core/animation/DoubleStyleInterpolation.h"
7 7
8 #include "core/css/CSSCalculationValue.h" 8 #include "core/css/CSSCalculationValue.h"
9 #include "core/css/CSSPrimitiveValue.h" 9 #include "core/css/CSSPrimitiveValue.h"
10 #include "core/css/resolver/StyleBuilder.h" 10 #include "core/css/resolver/StyleBuilder.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 PassOwnPtrWillBeRawPtr<InterpolableValue> DoubleStyleInterpolation::doubleToInte rpolableValue(const CSSValue& value) 14 PassOwnPtrWillBeRawPtr<InterpolableValue> DoubleStyleInterpolation::doubleToInte rpolableValue(const CSSValue& value)
15 { 15 {
16 ASSERT(canCreateFrom(value)); 16 ASSERT(canCreateFrom(value));
17 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value); 17 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value);
18 return InterpolableNumber::create(primitive.getDoubleValue()); 18 return InterpolableNumber::create(primitive.getDoubleValue());
19 } 19 }
20 20
21 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToDo uble(InterpolableValue* value, ClampRange clamp) 21 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToDo uble(InterpolableValue* value, ClampRange clamp)
22 { 22 {
23 ASSERT(value->isNumber()); 23 ASSERT(value->isNumber());
24 double doubleValue = toInterpolableNumber(value)->value(); 24 double doubleValue = toInterpolableNumber(value)->value();
25 if (clamp == ClampOpacity) { 25 switch (clamp) {
26 doubleValue = clampTo<float>(doubleValue, 0, nextafterf(1, 0)); 26 case NoClamp:
27 // Do nothing
28 break;
29 case ClampOpacity:
30 doubleValue = clampTo<float>(doubleValue, 0, nextafter(0.9999, 0));
alancutter (OOO until 2018) 2015/01/19 02:52:30 Why did this change?
jadeg 2015/01/22 22:14:23 Done.
31 break;
32 case ClampInteger:
33 doubleValue = floor(doubleValue);
34 break;
35 case ClampZoom:
36 doubleValue = clampTo<float>(doubleValue, 0.0000000000000000000000000000 00000000000000001);
alancutter (OOO until 2018) 2015/01/19 02:52:30 nextafterf(0, 1)?
jadeg 2015/01/22 22:14:23 This clamps to zero, not the correct value
37 break;
38 case ClampOrphans:
39 doubleValue = clampTo<int>((doubleValue + 0.5), 1);
40 break;
41 case ClampOne:
42 doubleValue = clampTo<float>(doubleValue, 1);
43 break;
44 case ClampZero:
45 doubleValue = clampTo<float>(doubleValue, 0);
46 break;
27 } 47 }
28 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_NUMBER) ; 48 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_NUMBER) ;
29 } 49 }
30 50
31 bool DoubleStyleInterpolation::canCreateFrom(const CSSValue& value) 51 bool DoubleStyleInterpolation::canCreateFrom(const CSSValue& value)
32 { 52 {
33 return value.isPrimitiveValue() && toCSSPrimitiveValue(value).isNumber(); 53 return value.isPrimitiveValue() && toCSSPrimitiveValue(value).isNumber();
34 } 54 }
35 55
36 void DoubleStyleInterpolation::apply(StyleResolverState& state) const 56 void DoubleStyleInterpolation::apply(StyleResolverState& state) const
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 || startRotationType != endRotationType) 130 || startRotationType != endRotationType)
111 return nullptr; 131 return nullptr;
112 132
113 return adoptRefWillBeNoop(new DoubleStyleInterpolation( 133 return adoptRefWillBeNoop(new DoubleStyleInterpolation(
114 motionRotationToInterpolableValue(start), 134 motionRotationToInterpolableValue(start),
115 motionRotationToInterpolableValue(end), 135 motionRotationToInterpolableValue(end),
116 id, NoClamp, startRotationType == MotionRotationAuto)); 136 id, NoClamp, startRotationType == MotionRotationAuto));
117 } 137 }
118 138
119 } 139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698