From 0c8e440950082a2b7f5eae1410264f75acdd0885 Mon Sep 17 00:00:00 2001 From: loyso Date: Wed, 24 Feb 2016 20:12:30 -0800 Subject: CC Animation: Expose TargetProperty enum to be aliased in Blink Platform. TargetProperty is intended to be used as an alias in Source/platform/animation/CompositorTargetProperty.h This is slightly better then untyped approach used here: https://codereview.chromium.org/1599673002 where we setup struct with constants in it and pass uint32_t everywhere. An alternative approach with strongly typed enum considered too verbose: https://codereview.chromium.org/1698813002/ BUG=577016 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1700653002 Cr-Commit-Position: refs/heads/master@{#377501} --- cc/test/animation_test_common.cc | 19 +++++++++---------- cc/test/animation_test_common.h | 7 +++---- cc/test/animation_timelines_test_common.cc | 19 +++++++++---------- cc/test/animation_timelines_test_common.h | 20 ++++++++++---------- cc/test/test_hooks.h | 6 +++--- 5 files changed, 34 insertions(+), 37 deletions(-) (limited to 'cc/test') diff --git a/cc/test/animation_test_common.cc b/cc/test/animation_test_common.cc index f61e9bb..cc02e63 100644 --- a/cc/test/animation_test_common.cc +++ b/cc/test/animation_test_common.cc @@ -47,7 +47,7 @@ int AddOpacityTransition(Target* target, scoped_ptr animation(Animation::Create( std::move(curve), id, AnimationIdProvider::NextGroupId(), - Animation::OPACITY)); + TargetProperty::OPACITY)); animation->set_needs_synchronized_start_time(true); target->AddAnimation(std::move(animation)); @@ -74,7 +74,7 @@ int AddAnimatedTransform(Target* target, scoped_ptr animation(Animation::Create( std::move(curve), id, AnimationIdProvider::NextGroupId(), - Animation::TRANSFORM)); + TargetProperty::TRANSFORM)); animation->set_needs_synchronized_start_time(true); target->AddAnimation(std::move(animation)); @@ -119,9 +119,9 @@ int AddAnimatedFilter(Target* target, int id = AnimationIdProvider::NextAnimationId(); - scoped_ptr animation( - Animation::Create(std::move(curve), id, - AnimationIdProvider::NextGroupId(), Animation::FILTER)); + scoped_ptr animation(Animation::Create( + std::move(curve), id, AnimationIdProvider::NextGroupId(), + TargetProperty::FILTER)); animation->set_needs_synchronized_start_time(true); target->AddAnimation(std::move(animation)); @@ -417,7 +417,7 @@ int AddOpacityStepsToController(LayerAnimationController* target, scoped_ptr animation(Animation::Create( std::move(curve), id, AnimationIdProvider::NextGroupId(), - Animation::OPACITY)); + TargetProperty::OPACITY)); animation->set_needs_synchronized_start_time(true); target->AddAnimation(std::move(animation)); @@ -525,10 +525,9 @@ int AddOpacityTransitionToLayerWithPlayer( end_opacity, use_timing_function); } -void AbortAnimationsOnLayerWithPlayer( - int layer_id, - scoped_refptr timeline, - Animation::TargetProperty target_property) { +void AbortAnimationsOnLayerWithPlayer(int layer_id, + scoped_refptr timeline, + TargetProperty::Type target_property) { LayerAnimationController* controller = timeline->animation_host()->GetControllerForLayerId(layer_id); DCHECK(controller); diff --git a/cc/test/animation_test_common.h b/cc/test/animation_test_common.h index 19e7a7c..7a6fe0d 100644 --- a/cc/test/animation_test_common.h +++ b/cc/test/animation_test_common.h @@ -260,10 +260,9 @@ int AddOpacityTransitionToLayerWithPlayer( float end_opacity, bool use_timing_function); -void AbortAnimationsOnLayerWithPlayer( - int layer_id, - scoped_refptr timeline, - Animation::TargetProperty target_property); +void AbortAnimationsOnLayerWithPlayer(int layer_id, + scoped_refptr timeline, + TargetProperty::Type target_property); } // namespace cc diff --git a/cc/test/animation_timelines_test_common.cc b/cc/test/animation_timelines_test_common.cc index d3b80f6..f941736 100644 --- a/cc/test/animation_timelines_test_common.cc +++ b/cc/test/animation_timelines_test_common.cc @@ -31,7 +31,7 @@ void TestLayer::ClearMutatedProperties() { opacity_ = 0; brightness_ = 0; - for (int i = 0; i <= Animation::LAST_TARGET_PROPERTY; ++i) + for (int i = 0; i <= TargetProperty::LAST_TARGET_PROPERTY; ++i) mutated_properties_[i] = false; } @@ -129,10 +129,9 @@ void TestHostClient::UnregisterLayer(int layer_id, LayerTreeType tree_type) { layers_in_tree.erase(kv); } -bool TestHostClient::IsPropertyMutated( - int layer_id, - LayerTreeType tree_type, - Animation::TargetProperty property) const { +bool TestHostClient::IsPropertyMutated(int layer_id, + LayerTreeType tree_type, + TargetProperty::Type property) const { TestLayer* layer = FindTestLayer(layer_id, tree_type); return layer->is_property_mutated(property); } @@ -141,7 +140,7 @@ void TestHostClient::ExpectFilterPropertyMutated(int layer_id, LayerTreeType tree_type, float brightness) const { TestLayer* layer = FindTestLayer(layer_id, tree_type); - EXPECT_TRUE(layer->is_property_mutated(Animation::OPACITY)); + EXPECT_TRUE(layer->is_property_mutated(TargetProperty::OPACITY)); EXPECT_EQ(brightness, layer->brightness()); } @@ -149,7 +148,7 @@ void TestHostClient::ExpectOpacityPropertyMutated(int layer_id, LayerTreeType tree_type, float opacity) const { TestLayer* layer = FindTestLayer(layer_id, tree_type); - EXPECT_TRUE(layer->is_property_mutated(Animation::OPACITY)); + EXPECT_TRUE(layer->is_property_mutated(TargetProperty::OPACITY)); EXPECT_EQ(opacity, layer->opacity()); } @@ -158,7 +157,7 @@ void TestHostClient::ExpectTransformPropertyMutated(int layer_id, int transform_x, int transform_y) const { TestLayer* layer = FindTestLayer(layer_id, tree_type); - EXPECT_TRUE(layer->is_property_mutated(Animation::OPACITY)); + EXPECT_TRUE(layer->is_property_mutated(TargetProperty::OPACITY)); EXPECT_EQ(transform_x, layer->transform_x()); EXPECT_EQ(transform_y, layer->transform_y()); } @@ -180,13 +179,13 @@ TestAnimationDelegate::TestAnimationDelegate() void TestAnimationDelegate::NotifyAnimationStarted( base::TimeTicks monotonic_time, - Animation::TargetProperty target_property, + TargetProperty::Type target_property, int group) { started_ = true; } void TestAnimationDelegate::NotifyAnimationFinished( base::TimeTicks monotonic_time, - Animation::TargetProperty target_property, + TargetProperty::Type target_property, int group) { finished_ = true; } diff --git a/cc/test/animation_timelines_test_common.h b/cc/test/animation_timelines_test_common.h index 2f1388e..0d041b5 100644 --- a/cc/test/animation_timelines_test_common.h +++ b/cc/test/animation_timelines_test_common.h @@ -29,28 +29,28 @@ class TestLayer { void set_transform(int transform_x, int transform_y) { transform_x_ = transform_x; transform_y_ = transform_y; - mutated_properties_[Animation::TRANSFORM] = true; + mutated_properties_[TargetProperty::TRANSFORM] = true; } float opacity() const { return opacity_; } void set_opacity(float opacity) { opacity_ = opacity; - mutated_properties_[Animation::OPACITY] = true; + mutated_properties_[TargetProperty::OPACITY] = true; } float brightness() const { return brightness_; } void set_brightness(float brightness) { brightness_ = brightness; - mutated_properties_[Animation::FILTER] = true; + mutated_properties_[TargetProperty::FILTER] = true; } gfx::ScrollOffset scroll_offset() const { return scroll_offset_; } void set_scroll_offset(const gfx::ScrollOffset& scroll_offset) { scroll_offset_ = scroll_offset; - mutated_properties_[Animation::SCROLL_OFFSET] = true; + mutated_properties_[TargetProperty::SCROLL_OFFSET] = true; } - bool is_property_mutated(Animation::TargetProperty property) const { + bool is_property_mutated(TargetProperty::Type property) const { return mutated_properties_[property]; } @@ -64,7 +64,7 @@ class TestLayer { float brightness_; gfx::ScrollOffset scroll_offset_; - bool mutated_properties_[Animation::LAST_TARGET_PROPERTY + 1]; + bool mutated_properties_[TargetProperty::LAST_TARGET_PROPERTY + 1]; }; class TestHostClient : public MutatorHostClient { @@ -117,7 +117,7 @@ class TestHostClient : public MutatorHostClient { bool IsPropertyMutated(int layer_id, LayerTreeType tree_type, - Animation::TargetProperty property) const; + TargetProperty::Type property) const; void ExpectFilterPropertyMutated(int layer_id, LayerTreeType tree_type, @@ -147,13 +147,13 @@ class TestAnimationDelegate : public AnimationDelegate { TestAnimationDelegate(); void NotifyAnimationStarted(base::TimeTicks monotonic_time, - Animation::TargetProperty target_property, + TargetProperty::Type target_property, int group) override; void NotifyAnimationFinished(base::TimeTicks monotonic_time, - Animation::TargetProperty target_property, + TargetProperty::Type target_property, int group) override; void NotifyAnimationAborted(base::TimeTicks monotonic_time, - Animation::TargetProperty target_property, + TargetProperty::Type target_property, int group) override {} bool started_; bool finished_; diff --git a/cc/test/test_hooks.h b/cc/test/test_hooks.h index 30ebece..a00233d 100644 --- a/cc/test/test_hooks.h +++ b/cc/test/test_hooks.h @@ -129,13 +129,13 @@ class TestHooks : public AnimationDelegate { // Implementation of AnimationDelegate: void NotifyAnimationStarted(base::TimeTicks monotonic_time, - Animation::TargetProperty target_property, + TargetProperty::Type target_property, int group) override {} void NotifyAnimationFinished(base::TimeTicks monotonic_time, - Animation::TargetProperty target_property, + TargetProperty::Type target_property, int group) override {} void NotifyAnimationAborted(base::TimeTicks monotonic_time, - Animation::TargetProperty target_property, + TargetProperty::Type target_property, int group) override {} virtual void RequestNewOutputSurface() = 0; -- cgit v1.1