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

Side by Side Diff: sky/engine/core/animation/animatable/AnimatableLength.cpp

Issue 711203002: Remove zoom() and effectiveZoom(). (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 30 matching lines...) Expand all
41 double clampNumber(double value, ValueRange range) 41 double clampNumber(double value, ValueRange range)
42 { 42 {
43 if (range == ValueRangeNonNegative) 43 if (range == ValueRangeNonNegative)
44 return std::max(value, 0.0); 44 return std::max(value, 0.0);
45 ASSERT(range == ValueRangeAll); 45 ASSERT(range == ValueRangeAll);
46 return value; 46 return value;
47 } 47 }
48 48
49 } // namespace 49 } // namespace
50 50
51 AnimatableLength::AnimatableLength(const Length& length, float zoom) 51 AnimatableLength::AnimatableLength(const Length& length)
52 { 52 {
53 ASSERT(zoom);
54 PixelsAndPercent pixelsAndPercent = length.pixelsAndPercent(); 53 PixelsAndPercent pixelsAndPercent = length.pixelsAndPercent();
55 m_pixels = pixelsAndPercent.pixels / zoom; 54 m_pixels = pixelsAndPercent.pixels;
56 m_percent = pixelsAndPercent.percent; 55 m_percent = pixelsAndPercent.percent;
57 m_hasPixels = length.type() != Percent; 56 m_hasPixels = length.type() != Percent;
58 m_hasPercent = !length.isFixed(); 57 m_hasPercent = !length.isFixed();
59 } 58 }
60 59
61 Length AnimatableLength::length(float zoom, ValueRange range) const 60 Length AnimatableLength::length(ValueRange range) const
62 { 61 {
63 if (!m_hasPercent) 62 if (!m_hasPercent)
64 return Length(clampNumber(m_pixels, range) * zoom, Fixed); 63 return Length(clampNumber(m_pixels, range), Fixed);
65 if (!m_hasPixels) 64 if (!m_hasPixels)
66 return Length(clampNumber(m_percent, range), Percent); 65 return Length(clampNumber(m_percent, range), Percent);
67 return Length(CalculationValue::create(PixelsAndPercent(m_pixels * zoom, m_p ercent), range)); 66 return Length(CalculationValue::create(PixelsAndPercent(m_pixels, m_percent) , range));
68 } 67 }
69 68
70 PassRefPtr<AnimatableValue> AnimatableLength::interpolateTo(const AnimatableValu e* value, double fraction) const 69 PassRefPtr<AnimatableValue> AnimatableLength::interpolateTo(const AnimatableValu e* value, double fraction) const
71 { 70 {
72 const AnimatableLength* length = toAnimatableLength(value); 71 const AnimatableLength* length = toAnimatableLength(value);
73 return create(blend(m_pixels, length->m_pixels, fraction), blend(m_percent, length->m_percent, fraction), 72 return create(blend(m_pixels, length->m_pixels, fraction), blend(m_percent, length->m_percent, fraction),
74 m_hasPixels || length->m_hasPixels, m_hasPercent || length->m_hasPercent ); 73 m_hasPixels || length->m_hasPixels, m_hasPercent || length->m_hasPercent );
75 } 74 }
76 75
77 bool AnimatableLength::equalTo(const AnimatableValue* value) const 76 bool AnimatableLength::equalTo(const AnimatableValue* value) const
78 { 77 {
79 const AnimatableLength* length = toAnimatableLength(value); 78 const AnimatableLength* length = toAnimatableLength(value);
80 return m_pixels == length->m_pixels && m_percent == length->m_percent && m_h asPixels == length->m_hasPixels && m_hasPercent == length->m_hasPercent; 79 return m_pixels == length->m_pixels && m_percent == length->m_percent && m_h asPixels == length->m_hasPixels && m_hasPercent == length->m_hasPercent;
81 } 80 }
82 81
83 } // namespace blink 82 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/animation/animatable/AnimatableLength.h ('k') | sky/engine/core/animation/animatable/AnimatableLengthTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698