summaryrefslogtreecommitdiffstats
path: root/ui/compositor
diff options
context:
space:
mode:
authorbruthig <bruthig@chromium.org>2015-04-30 15:37:59 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-30 22:38:34 +0000
commit356c58857c6e47ff5fd1beddbe8ed72c0be15fbe (patch)
tree3632d7262a35c07a40859a42022b7d659d33e872 /ui/compositor
parent5a679fca95cf220f1a4f076233ad58f6dc60fb4b (diff)
downloadchromium_src-356c58857c6e47ff5fd1beddbe8ed72c0be15fbe.zip
chromium_src-356c58857c6e47ff5fd1beddbe8ed72c0be15fbe.tar.gz
chromium_src-356c58857c6e47ff5fd1beddbe8ed72c0be15fbe.tar.bz2
Fixed the LayerAnimationElement::TargetValue(LayerAnimationDelegate*) constructor to properly pull the SkColor from the delegate.
The constructor was incorrectly casting the SkColor to a float before assigning it and this caused loss of precision. TEST=TargetValueTest.VerifyTestLayerAnimationDelegateConstructor BUG=483134 Review URL: https://codereview.chromium.org/1119853002 Cr-Commit-Position: refs/heads/master@{#327814}
Diffstat (limited to 'ui/compositor')
-rw-r--r--ui/compositor/layer_animation_element.cc6
-rw-r--r--ui/compositor/layer_animation_element_unittest.cc31
2 files changed, 34 insertions, 3 deletions
diff --git a/ui/compositor/layer_animation_element.cc b/ui/compositor/layer_animation_element.cc
index 9a528e5..7c3cf8c 100644
--- a/ui/compositor/layer_animation_element.cc
+++ b/ui/compositor/layer_animation_element.cc
@@ -599,13 +599,13 @@ LayerAnimationElement::TargetValue::TargetValue()
LayerAnimationElement::TargetValue::TargetValue(
const LayerAnimationDelegate* delegate)
: bounds(delegate ? delegate->GetBoundsForAnimation() : gfx::Rect()),
- transform(delegate ?
- delegate->GetTransformForAnimation() : gfx::Transform()),
+ transform(delegate ? delegate->GetTransformForAnimation()
+ : gfx::Transform()),
opacity(delegate ? delegate->GetOpacityForAnimation() : 0.0f),
visibility(delegate ? delegate->GetVisibilityForAnimation() : false),
brightness(delegate ? delegate->GetBrightnessForAnimation() : 0.0f),
grayscale(delegate ? delegate->GetGrayscaleForAnimation() : 0.0f),
- color(delegate ? delegate->GetColorForAnimation() : 0.0f) {
+ color(delegate ? delegate->GetColorForAnimation() : SK_ColorTRANSPARENT) {
}
// LayerAnimationElement -------------------------------------------------------
diff --git a/ui/compositor/layer_animation_element_unittest.cc b/ui/compositor/layer_animation_element_unittest.cc
index 5cc4f93..b58765a 100644
--- a/ui/compositor/layer_animation_element_unittest.cc
+++ b/ui/compositor/layer_animation_element_unittest.cc
@@ -20,6 +20,37 @@ namespace ui {
namespace {
+// Verify that the TargetValue(TestLayerAnimationDelegate*) constructor
+// correctly assigns values. See www.crbug.com/483134.
+TEST(TargetValueTest, VerifyLayerAnimationDelegateConstructor) {
+ const gfx::Rect kBounds(1, 2, 3, 5);
+ const gfx::Transform kTransform(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f);
+ const float kOpacity = 1.235f;
+ const bool kVisibility = false;
+ const float kBrightness = 2.358f;
+ const float kGrayscale = 2.5813f;
+ const SkColor kColor = SK_ColorCYAN;
+
+ TestLayerAnimationDelegate delegate;
+ delegate.SetBoundsFromAnimation(kBounds);
+ delegate.SetTransformFromAnimation(kTransform);
+ delegate.SetOpacityFromAnimation(kOpacity);
+ delegate.SetVisibilityFromAnimation(kVisibility);
+ delegate.SetBrightnessFromAnimation(kBrightness);
+ delegate.SetGrayscaleFromAnimation(kGrayscale);
+ delegate.SetColorFromAnimation(kColor);
+
+ LayerAnimationElement::TargetValue target_value(&delegate);
+
+ EXPECT_EQ(kBounds, target_value.bounds);
+ EXPECT_EQ(kTransform, target_value.transform);
+ EXPECT_FLOAT_EQ(kOpacity, target_value.opacity);
+ EXPECT_EQ(kVisibility, target_value.visibility);
+ EXPECT_FLOAT_EQ(kBrightness, target_value.brightness);
+ EXPECT_FLOAT_EQ(kGrayscale, target_value.grayscale);
+ EXPECT_EQ(SK_ColorCYAN, target_value.color);
+}
+
// Check that the transformation element progresses the delegate as expected and
// that the element can be reused after it completes.
TEST(LayerAnimationElementTest, TransformElement) {