summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/rotator/screen_rotation.cc11
-rw-r--r--ash/rotator/screen_rotation.h3
-rw-r--r--ash/shelf/app_list_button.cc4
-rw-r--r--ash/wm/overview/window_selector_panels.cc4
-rw-r--r--ash/wm/window_animations.cc2
-rw-r--r--ash/wm/workspace_controller.cc10
-rw-r--r--ui/app_list/views/pulsing_block_view.cc10
-rw-r--r--ui/compositor/layer_animation_element.cc99
-rw-r--r--ui/compositor/layer_animation_element.h27
-rw-r--r--ui/compositor/layer_animation_element_unittest.cc11
-rw-r--r--ui/compositor/layer_animation_observer.cc13
-rw-r--r--ui/compositor/layer_animation_sequence.cc23
-rw-r--r--ui/compositor/layer_animation_sequence.h4
-rw-r--r--ui/compositor/layer_animation_sequence_unittest.cc38
-rw-r--r--ui/compositor/layer_animator.cc48
-rw-r--r--ui/compositor/layer_animator.h3
-rw-r--r--ui/compositor/layer_animator_unittest.cc6
-rw-r--r--ui/compositor/scoped_layer_animation_settings.cc8
-rw-r--r--ui/compositor/test/layer_animator_test_controller.cc3
-rw-r--r--ui/views/corewm/window_animations.cc7
20 files changed, 114 insertions, 220 deletions
diff --git a/ash/rotator/screen_rotation.cc b/ash/rotator/screen_rotation.cc
index 9352d81..02b13a0 100644
--- a/ash/rotator/screen_rotation.cc
+++ b/ash/rotator/screen_rotation.cc
@@ -31,7 +31,7 @@ base::TimeDelta GetTransitionDuration(int degrees) {
} // namespace
ScreenRotation::ScreenRotation(int degrees, ui::Layer* layer)
- : ui::LayerAnimationElement(GetProperties(),
+ : ui::LayerAnimationElement(LayerAnimationElement::TRANSFORM,
GetTransitionDuration(degrees)),
degrees_(degrees) {
InitTransform(layer);
@@ -120,13 +120,4 @@ void ScreenRotation::OnGetTarget(TargetValue* target) const {
void ScreenRotation::OnAbort(ui::LayerAnimationDelegate* delegate) {
}
-// static
-const ui::LayerAnimationElement::AnimatableProperties&
-ScreenRotation::GetProperties() {
- static ui::LayerAnimationElement::AnimatableProperties properties;
- if (properties.empty())
- properties.insert(ui::LayerAnimationElement::TRANSFORM);
- return properties;
-}
-
} // namespace ash
diff --git a/ash/rotator/screen_rotation.h b/ash/rotator/screen_rotation.h
index 2f9616a..66caaf6 100644
--- a/ash/rotator/screen_rotation.h
+++ b/ash/rotator/screen_rotation.h
@@ -45,9 +45,6 @@ class ASH_EXPORT ScreenRotation : public ui::LayerAnimationElement {
virtual void OnGetTarget(TargetValue* target) const OVERRIDE;
virtual void OnAbort(ui::LayerAnimationDelegate* delegate) OVERRIDE;
- static const ui::LayerAnimationElement::AnimatableProperties&
- GetProperties();
-
scoped_ptr<ui::InterpolatedTransform> interpolated_transform_;
// The number of degrees to rotate.
diff --git a/ash/shelf/app_list_button.cc b/ash/shelf/app_list_button.cc
index 673ed11..3fef94a 100644
--- a/ash/shelf/app_list_button.cc
+++ b/ash/shelf/app_list_button.cc
@@ -67,11 +67,9 @@ void AppListButton::StartLoadingAnimation() {
base::TimeDelta::FromMilliseconds(kAnimationDurationInMs)));
}
- ui::LayerAnimationElement::AnimatableProperties opacity_properties;
- opacity_properties.insert(ui::LayerAnimationElement::OPACITY);
opacity_sequence->AddElement(
ui::LayerAnimationElement::CreatePauseElement(
- opacity_properties,
+ ui::LayerAnimationElement::OPACITY,
base::TimeDelta::FromMilliseconds(kAnimationDurationInMs)));
// LayerAnimator takes ownership of the sequences.
diff --git a/ash/wm/overview/window_selector_panels.cc b/ash/wm/overview/window_selector_panels.cc
index 914b848..38ae9f6 100644
--- a/ash/wm/overview/window_selector_panels.cc
+++ b/ash/wm/overview/window_selector_panels.cc
@@ -73,10 +73,8 @@ views::Widget* ScopedTransformPanelWindow::GetCalloutWidget() {
void ScopedTransformPanelWindow::RestoreCallout() {
scoped_ptr<ui::LayerAnimationSequence> sequence(
new ui::LayerAnimationSequence);
- ui::LayerAnimationElement::AnimatableProperties paused_properties;
- paused_properties.insert(ui::LayerAnimationElement::OPACITY);
sequence->AddElement(ui::LayerAnimationElement::CreatePauseElement(
- paused_properties, base::TimeDelta::FromMilliseconds(
+ ui::LayerAnimationElement::OPACITY, base::TimeDelta::FromMilliseconds(
ScopedTransformOverviewWindow::kTransitionMilliseconds)));
sequence->AddElement(ui::LayerAnimationElement::CreateOpacityElement(1,
base::TimeDelta::FromMilliseconds(
diff --git a/ash/wm/window_animations.cc b/ash/wm/window_animations.cc
index 71d73f3..ae7188a 100644
--- a/ash/wm/window_animations.cc
+++ b/ash/wm/window_animations.cc
@@ -122,7 +122,7 @@ void AddLayerAnimationsForMinimize(aura::Window* window, bool show) {
// to save bandwidth and reduce jank.
if (!show) {
window->layer()->GetAnimator()->SchedulePauseForProperties(
- (duration * 3) / 4, ui::LayerAnimationElement::OPACITY, -1);
+ (duration * 3) / 4, ui::LayerAnimationElement::OPACITY);
}
// Fade in and out quickly when the window is small to reduce jank.
diff --git a/ash/wm/workspace_controller.cc b/ash/wm/workspace_controller.cc
index 1b9fd85..1f89908 100644
--- a/ash/wm/workspace_controller.cc
+++ b/ash/wm/workspace_controller.cc
@@ -127,12 +127,10 @@ void WorkspaceController::DoInitialAnimation() {
settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
viewport_->layer()->GetAnimator()->SchedulePauseForProperties(
base::TimeDelta::FromMilliseconds(kInitialPauseTimeMS),
- ui::LayerAnimationElement::TRANSFORM,
- ui::LayerAnimationElement::OPACITY,
- ui::LayerAnimationElement::BRIGHTNESS,
- ui::LayerAnimationElement::VISIBILITY,
- -1);
-
+ ui::LayerAnimationElement::TRANSFORM |
+ ui::LayerAnimationElement::OPACITY |
+ ui::LayerAnimationElement::BRIGHTNESS |
+ ui::LayerAnimationElement::VISIBILITY);
settings.SetTweenType(gfx::Tween::EASE_OUT);
settings.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS));
diff --git a/ui/app_list/views/pulsing_block_view.cc b/ui/app_list/views/pulsing_block_view.cc
index aa2c273..373ceef 100644
--- a/ui/app_list/views/pulsing_block_view.cc
+++ b/ui/app_list/views/pulsing_block_view.cc
@@ -50,18 +50,14 @@ void SchedulePulsingAnimation(ui::Layer* layer) {
base::TimeDelta::FromMilliseconds(kAnimationDurationInMs)));
}
- ui::LayerAnimationElement::AnimatableProperties opacity_properties;
- opacity_properties.insert(ui::LayerAnimationElement::OPACITY);
opacity_sequence->AddElement(
ui::LayerAnimationElement::CreatePauseElement(
- opacity_properties,
- base::TimeDelta::FromMilliseconds(kAnimationDurationInMs)));
+ ui::LayerAnimationElement::OPACITY,
+ base::TimeDelta::FromMilliseconds(kAnimationDurationInMs)));
- ui::LayerAnimationElement::AnimatableProperties transform_properties;
- transform_properties.insert(ui::LayerAnimationElement::TRANSFORM);
transform_sequence->AddElement(
ui::LayerAnimationElement::CreatePauseElement(
- transform_properties,
+ ui::LayerAnimationElement::TRANSFORM,
base::TimeDelta::FromMilliseconds(kAnimationDurationInMs)));
std::vector<ui::LayerAnimationSequence*> animations;
diff --git a/ui/compositor/layer_animation_element.cc b/ui/compositor/layer_animation_element.cc
index 76f8ab7..a8f628a 100644
--- a/ui/compositor/layer_animation_element.cc
+++ b/ui/compositor/layer_animation_element.cc
@@ -29,7 +29,7 @@ const int kFastDurationScaleFactor = 4;
// Pause -----------------------------------------------------------------------
class Pause : public LayerAnimationElement {
public:
- Pause(const AnimatableProperties& properties, base::TimeDelta duration)
+ Pause(AnimatableProperties properties, base::TimeDelta duration)
: LayerAnimationElement(properties, duration) {
}
virtual ~Pause() {}
@@ -51,7 +51,7 @@ class Pause : public LayerAnimationElement {
class TransformTransition : public LayerAnimationElement {
public:
TransformTransition(const gfx::Transform& target, base::TimeDelta duration)
- : LayerAnimationElement(GetProperties(), duration),
+ : LayerAnimationElement(TRANSFORM, duration),
target_(target) {
}
virtual ~TransformTransition() {}
@@ -74,12 +74,6 @@ class TransformTransition : public LayerAnimationElement {
virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
private:
- static AnimatableProperties GetProperties() {
- AnimatableProperties properties;
- properties.insert(LayerAnimationElement::TRANSFORM);
- return properties;
- }
-
gfx::Transform start_;
const gfx::Transform target_;
@@ -92,7 +86,7 @@ class InterpolatedTransformTransition : public LayerAnimationElement {
public:
InterpolatedTransformTransition(InterpolatedTransform* interpolated_transform,
base::TimeDelta duration)
- : LayerAnimationElement(GetProperties(), duration),
+ : LayerAnimationElement(TRANSFORM, duration),
interpolated_transform_(interpolated_transform) {
}
virtual ~InterpolatedTransformTransition() {}
@@ -114,12 +108,6 @@ class InterpolatedTransformTransition : public LayerAnimationElement {
virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
private:
- static AnimatableProperties GetProperties() {
- AnimatableProperties properties;
- properties.insert(LayerAnimationElement::TRANSFORM);
- return properties;
- }
-
scoped_ptr<InterpolatedTransform> interpolated_transform_;
DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformTransition);
@@ -130,7 +118,7 @@ class InterpolatedTransformTransition : public LayerAnimationElement {
class BoundsTransition : public LayerAnimationElement {
public:
BoundsTransition(const gfx::Rect& target, base::TimeDelta duration)
- : LayerAnimationElement(GetProperties(), duration),
+ : LayerAnimationElement(BOUNDS, duration),
target_(target) {
}
virtual ~BoundsTransition() {}
@@ -153,12 +141,6 @@ class BoundsTransition : public LayerAnimationElement {
virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
private:
- static AnimatableProperties GetProperties() {
- AnimatableProperties properties;
- properties.insert(LayerAnimationElement::BOUNDS);
- return properties;
- }
-
gfx::Rect start_;
const gfx::Rect target_;
@@ -170,7 +152,7 @@ class BoundsTransition : public LayerAnimationElement {
class OpacityTransition : public LayerAnimationElement {
public:
OpacityTransition(float target, base::TimeDelta duration)
- : LayerAnimationElement(GetProperties(), duration),
+ : LayerAnimationElement(OPACITY, duration),
start_(0.0f),
target_(target) {
}
@@ -194,12 +176,6 @@ class OpacityTransition : public LayerAnimationElement {
virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
private:
- static AnimatableProperties GetProperties() {
- AnimatableProperties properties;
- properties.insert(LayerAnimationElement::OPACITY);
- return properties;
- }
-
float start_;
const float target_;
@@ -211,7 +187,7 @@ class OpacityTransition : public LayerAnimationElement {
class VisibilityTransition : public LayerAnimationElement {
public:
VisibilityTransition(bool target, base::TimeDelta duration)
- : LayerAnimationElement(GetProperties(), duration),
+ : LayerAnimationElement(VISIBILITY, duration),
start_(false),
target_(target) {
}
@@ -234,12 +210,6 @@ class VisibilityTransition : public LayerAnimationElement {
virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
private:
- static AnimatableProperties GetProperties() {
- AnimatableProperties properties;
- properties.insert(LayerAnimationElement::VISIBILITY);
- return properties;
- }
-
bool start_;
const bool target_;
@@ -251,7 +221,7 @@ class VisibilityTransition : public LayerAnimationElement {
class BrightnessTransition : public LayerAnimationElement {
public:
BrightnessTransition(float target, base::TimeDelta duration)
- : LayerAnimationElement(GetProperties(), duration),
+ : LayerAnimationElement(BRIGHTNESS, duration),
start_(0.0f),
target_(target) {
}
@@ -275,12 +245,6 @@ class BrightnessTransition : public LayerAnimationElement {
virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
private:
- static AnimatableProperties GetProperties() {
- AnimatableProperties properties;
- properties.insert(LayerAnimationElement::BRIGHTNESS);
- return properties;
- }
-
float start_;
const float target_;
@@ -292,7 +256,7 @@ class BrightnessTransition : public LayerAnimationElement {
class GrayscaleTransition : public LayerAnimationElement {
public:
GrayscaleTransition(float target, base::TimeDelta duration)
- : LayerAnimationElement(GetProperties(), duration),
+ : LayerAnimationElement(GRAYSCALE, duration),
start_(0.0f),
target_(target) {
}
@@ -316,12 +280,6 @@ class GrayscaleTransition : public LayerAnimationElement {
virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
private:
- static AnimatableProperties GetProperties() {
- AnimatableProperties properties;
- properties.insert(LayerAnimationElement::GRAYSCALE);
- return properties;
- }
-
float start_;
const float target_;
@@ -333,7 +291,7 @@ class GrayscaleTransition : public LayerAnimationElement {
class ColorTransition : public LayerAnimationElement {
public:
ColorTransition(SkColor target, base::TimeDelta duration)
- : LayerAnimationElement(GetProperties(), duration),
+ : LayerAnimationElement(COLOR, duration),
start_(SK_ColorBLACK),
target_(target) {
}
@@ -357,12 +315,6 @@ class ColorTransition : public LayerAnimationElement {
virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
private:
- static AnimatableProperties GetProperties() {
- AnimatableProperties properties;
- properties.insert(LayerAnimationElement::COLOR);
- return properties;
- }
-
SkColor start_;
const SkColor target_;
@@ -373,7 +325,7 @@ class ColorTransition : public LayerAnimationElement {
class ThreadedLayerAnimationElement : public LayerAnimationElement {
public:
- ThreadedLayerAnimationElement(const AnimatableProperties& properties,
+ ThreadedLayerAnimationElement(AnimatableProperties properties,
base::TimeDelta duration)
: LayerAnimationElement(properties, duration) {
}
@@ -433,7 +385,7 @@ class ThreadedLayerAnimationElement : public LayerAnimationElement {
class ThreadedOpacityTransition : public ThreadedLayerAnimationElement {
public:
ThreadedOpacityTransition(float target, base::TimeDelta duration)
- : ThreadedLayerAnimationElement(GetProperties(), duration),
+ : ThreadedLayerAnimationElement(OPACITY, duration),
start_(0.0f),
target_(target) {
}
@@ -477,12 +429,6 @@ class ThreadedOpacityTransition : public ThreadedLayerAnimationElement {
}
private:
- static AnimatableProperties GetProperties() {
- AnimatableProperties properties;
- properties.insert(LayerAnimationElement::OPACITY);
- return properties;
- }
-
float start_;
const float target_;
@@ -495,7 +441,7 @@ class ThreadedTransformTransition : public ThreadedLayerAnimationElement {
public:
ThreadedTransformTransition(const gfx::Transform& target,
base::TimeDelta duration)
- : ThreadedLayerAnimationElement(GetProperties(), duration),
+ : ThreadedLayerAnimationElement(TRANSFORM, duration),
target_(target) {
}
virtual ~ThreadedTransformTransition() {}
@@ -543,12 +489,6 @@ class ThreadedTransformTransition : public ThreadedLayerAnimationElement {
}
private:
- static AnimatableProperties GetProperties() {
- AnimatableProperties properties;
- properties.insert(LayerAnimationElement::TRANSFORM);
- return properties;
- }
-
gfx::Transform start_;
gfx::Transform cc_start_;
const gfx::Transform target_;
@@ -652,16 +592,10 @@ class InverseTransformTransition : public ThreadedLayerAnimationElement {
return to_return;
}
- static AnimatableProperties GetProperties() {
- AnimatableProperties properties;
- properties.insert(LayerAnimationElement::TRANSFORM);
- return properties;
- }
-
template <typename T>
static T CheckAndCast(const LayerAnimationElement* element) {
- const AnimatableProperties& properties = element->properties();
- DCHECK(properties.find(TRANSFORM) != properties.end());
+ AnimatableProperties properties = element->properties();
+ DCHECK(properties & TRANSFORM);
return static_cast<T>(element);
}
@@ -705,8 +639,7 @@ LayerAnimationElement::TargetValue::TargetValue(
// LayerAnimationElement -------------------------------------------------------
LayerAnimationElement::LayerAnimationElement(
- const AnimatableProperties& properties,
- base::TimeDelta duration)
+ AnimatableProperties properties, base::TimeDelta duration)
: first_frame_(true),
properties_(properties),
duration_(GetEffectiveDuration(duration)),
@@ -920,7 +853,7 @@ LayerAnimationElement* LayerAnimationElement::CreateGrayscaleElement(
// static
LayerAnimationElement* LayerAnimationElement::CreatePauseElement(
- const AnimatableProperties& properties,
+ AnimatableProperties properties,
base::TimeDelta duration) {
return new Pause(properties, duration);
}
diff --git a/ui/compositor/layer_animation_element.h b/ui/compositor/layer_animation_element.h
index 1127424..0b880a4 100644
--- a/ui/compositor/layer_animation_element.h
+++ b/ui/compositor/layer_animation_element.h
@@ -28,13 +28,18 @@ class LayerAnimationDelegate;
class COMPOSITOR_EXPORT LayerAnimationElement {
public:
enum AnimatableProperty {
- TRANSFORM = 0,
- BOUNDS,
- OPACITY,
- VISIBILITY,
- BRIGHTNESS,
- GRAYSCALE,
- COLOR,
+ UNKNOWN = 0,
+ TRANSFORM = (1 << 0),
+ BOUNDS = (1 << 1),
+ OPACITY = (1 << 2),
+ VISIBILITY = (1 << 3),
+ BRIGHTNESS = (1 << 4),
+ GRAYSCALE = (1 << 5),
+ COLOR = (1 << 6),
+
+ // Used when iterating over properties.
+ FIRST_PROPERTY = TRANSFORM,
+ SENTINEL = (1 << 7)
};
static AnimatableProperty ToAnimatableProperty(
@@ -54,9 +59,9 @@ class COMPOSITOR_EXPORT LayerAnimationElement {
SkColor color;
};
- typedef std::set<AnimatableProperty> AnimatableProperties;
+ typedef uint32 AnimatableProperties;
- LayerAnimationElement(const AnimatableProperties& properties,
+ LayerAnimationElement(AnimatableProperties properties,
base::TimeDelta duration);
virtual ~LayerAnimationElement();
@@ -124,7 +129,7 @@ class COMPOSITOR_EXPORT LayerAnimationElement {
// Creates an element that pauses the given properties. The caller owns the
// return value.
static LayerAnimationElement* CreatePauseElement(
- const AnimatableProperties& properties,
+ AnimatableProperties properties,
base::TimeDelta duration);
// Creates an element that transitions to the given color. The caller owns the
@@ -178,7 +183,7 @@ class COMPOSITOR_EXPORT LayerAnimationElement {
void GetTargetValue(TargetValue* target) const;
// The properties that the element modifies.
- const AnimatableProperties& properties() const { return properties_; }
+ AnimatableProperties properties() const { return properties_; }
// Whether this element animates on the compositor thread.
virtual bool IsThreaded() const;
diff --git a/ui/compositor/layer_animation_element_unittest.cc b/ui/compositor/layer_animation_element_unittest.cc
index 8871a2c9..45de8d3 100644
--- a/ui/compositor/layer_animation_element_unittest.cc
+++ b/ui/compositor/layer_animation_element_unittest.cc
@@ -314,12 +314,11 @@ TEST(LayerAnimationElementTest, GrayscaleElement) {
// Check that the pause element progresses the delegate as expected and
// that the element can be reused after it completes.
TEST(LayerAnimationElementTest, PauseElement) {
- LayerAnimationElement::AnimatableProperties properties;
- properties.insert(LayerAnimationElement::TRANSFORM);
- properties.insert(LayerAnimationElement::BOUNDS);
- properties.insert(LayerAnimationElement::OPACITY);
- properties.insert(LayerAnimationElement::BRIGHTNESS);
- properties.insert(LayerAnimationElement::GRAYSCALE);
+ LayerAnimationElement::AnimatableProperties properties =
+ LayerAnimationElement::TRANSFORM | LayerAnimationElement::BOUNDS |
+ LayerAnimationElement::OPACITY | LayerAnimationElement::BRIGHTNESS |
+ LayerAnimationElement::GRAYSCALE;
+
base::TimeTicks start_time;
base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
diff --git a/ui/compositor/layer_animation_observer.cc b/ui/compositor/layer_animation_observer.cc
index 88db4c6..658a835 100644
--- a/ui/compositor/layer_animation_observer.cc
+++ b/ui/compositor/layer_animation_observer.cc
@@ -140,11 +140,16 @@ void ImplicitAnimationObserver::CheckCompleted() {
void ImplicitAnimationObserver::UpdatePropertyAnimationStatus(
LayerAnimationSequence* sequence,
AnimationStatus status) {
- const LayerAnimationElement::AnimatableProperties& properties =
+ LayerAnimationElement::AnimatableProperties properties =
sequence->properties();
- for (LayerAnimationElement::AnimatableProperties::const_iterator i =
- properties.begin(); i != properties.end(); ++i) {
- property_animation_status_[(*i)] = status;
+ for (unsigned i = LayerAnimationElement::FIRST_PROPERTY;
+ i != LayerAnimationElement::SENTINEL;
+ i = i << 1) {
+ if (i & properties) {
+ LayerAnimationElement::AnimatableProperty property =
+ static_cast<LayerAnimationElement::AnimatableProperty>(i);
+ property_animation_status_[property] = status;
+ }
}
}
diff --git a/ui/compositor/layer_animation_sequence.cc b/ui/compositor/layer_animation_sequence.cc
index 9ebf1e0..94b664b 100644
--- a/ui/compositor/layer_animation_sequence.cc
+++ b/ui/compositor/layer_animation_sequence.cc
@@ -16,7 +16,8 @@
namespace ui {
LayerAnimationSequence::LayerAnimationSequence()
- : is_cyclic_(false),
+ : properties_(LayerAnimationElement::UNKNOWN),
+ is_cyclic_(false),
last_element_(0),
waiting_for_group_start_(false),
animation_group_id_(0),
@@ -25,7 +26,8 @@ LayerAnimationSequence::LayerAnimationSequence()
}
LayerAnimationSequence::LayerAnimationSequence(LayerAnimationElement* element)
- : is_cyclic_(false),
+ : properties_(LayerAnimationElement::UNKNOWN),
+ is_cyclic_(false),
last_element_(0),
waiting_for_group_start_(false),
animation_group_id_(0),
@@ -178,20 +180,13 @@ void LayerAnimationSequence::Abort(LayerAnimationDelegate* delegate) {
}
void LayerAnimationSequence::AddElement(LayerAnimationElement* element) {
- properties_.insert(element->properties().begin(),
- element->properties().end());
+ properties_ |= element->properties();
elements_.push_back(make_linked_ptr(element));
}
bool LayerAnimationSequence::HasConflictingProperty(
- const LayerAnimationElement::AnimatableProperties& other) const {
- LayerAnimationElement::AnimatableProperties intersection;
- std::insert_iterator<LayerAnimationElement::AnimatableProperties> ii(
- intersection, intersection.begin());
- std::set_intersection(properties_.begin(), properties_.end(),
- other.begin(), other.end(),
- ii);
- return (intersection.size() > 0);
+ LayerAnimationElement::AnimatableProperties other) const {
+ return (properties_ & other) != LayerAnimationElement::UNKNOWN;
}
bool LayerAnimationSequence::IsFirstElementThreaded() const {
@@ -219,11 +214,11 @@ void LayerAnimationSequence::OnThreadedAnimationStarted(
return;
size_t current_index = last_element_ % elements_.size();
- const LayerAnimationElement::AnimatableProperties& element_properties =
+ LayerAnimationElement::AnimatableProperties element_properties =
elements_[current_index]->properties();
LayerAnimationElement::AnimatableProperty event_property =
LayerAnimationElement::ToAnimatableProperty(event.target_property);
- DCHECK(element_properties.find(event_property) != element_properties.end());
+ DCHECK(element_properties & event_property);
elements_[current_index]->set_effective_start_time(
base::TimeTicks::FromInternalValue(
event.monotonic_time * base::Time::kMicrosecondsPerSecond));
diff --git a/ui/compositor/layer_animation_sequence.h b/ui/compositor/layer_animation_sequence.h
index 53ce8d6..19635ad 100644
--- a/ui/compositor/layer_animation_sequence.h
+++ b/ui/compositor/layer_animation_sequence.h
@@ -81,7 +81,7 @@ class COMPOSITOR_EXPORT LayerAnimationSequence
void Abort(LayerAnimationDelegate* delegate);
// All properties modified by the sequence.
- const LayerAnimationElement::AnimatableProperties& properties() const {
+ LayerAnimationElement::AnimatableProperties properties() const {
return properties_;
}
@@ -96,7 +96,7 @@ class COMPOSITOR_EXPORT LayerAnimationSequence
// Returns true if this sequence has at least one element conflicting with a
// property in |other|.
bool HasConflictingProperty(
- const LayerAnimationElement::AnimatableProperties& other) const;
+ LayerAnimationElement::AnimatableProperties other) const;
// Returns true if the first element animates on the compositor thread.
bool IsFirstElementThreaded() const;
diff --git a/ui/compositor/layer_animation_sequence_unittest.cc b/ui/compositor/layer_animation_sequence_unittest.cc
index 3b45917..86f9ecf 100644
--- a/ui/compositor/layer_animation_sequence_unittest.cc
+++ b/ui/compositor/layer_animation_sequence_unittest.cc
@@ -28,9 +28,10 @@ TEST(LayerAnimationSequenceTest, NoElement) {
start_time += base::TimeDelta::FromSeconds(1);
sequence.set_start_time(start_time);
EXPECT_TRUE(sequence.IsFinished(start_time));
- EXPECT_TRUE(sequence.properties().size() == 0);
- LayerAnimationElement::AnimatableProperties properties;
- EXPECT_FALSE(sequence.HasConflictingProperty(properties));
+ EXPECT_EQ(static_cast<LayerAnimationElement::AnimatableProperties>(
+ LayerAnimationElement::UNKNOWN),
+ sequence.properties());
+ EXPECT_FALSE(sequence.HasConflictingProperty(LayerAnimationElement::UNKNOWN));
}
// Check that the sequences progresses the delegate as expected when it contains
@@ -62,9 +63,9 @@ TEST(LayerAnimationSequenceTest, SingleElement) {
EXPECT_FLOAT_EQ(target, delegate.GetBrightnessForAnimation());
}
- EXPECT_TRUE(sequence.properties().size() == 1);
- EXPECT_TRUE(sequence.properties().find(LayerAnimationElement::BRIGHTNESS) !=
- sequence.properties().end());
+ EXPECT_EQ(static_cast<LayerAnimationElement::AnimatableProperties>(
+ LayerAnimationElement::BRIGHTNESS),
+ sequence.properties());
}
// Check that the sequences progresses the delegate as expected when it contains
@@ -105,9 +106,9 @@ TEST(LayerAnimationSequenceTest, SingleThreadedElement) {
EXPECT_FLOAT_EQ(target, delegate.GetOpacityForAnimation());
}
- EXPECT_TRUE(sequence.properties().size() == 1);
- EXPECT_TRUE(sequence.properties().find(LayerAnimationElement::OPACITY) !=
- sequence.properties().end());
+ EXPECT_EQ(static_cast<LayerAnimationElement::AnimatableProperties>(
+ LayerAnimationElement::OPACITY),
+ sequence.properties());
}
// Check that the sequences progresses the delegate as expected when it contains
@@ -125,11 +126,8 @@ TEST(LayerAnimationSequenceTest, MultipleElement) {
LayerAnimationElement::CreateOpacityElement(target_opacity, delta));
// Pause bounds for a second.
- LayerAnimationElement::AnimatableProperties properties;
- properties.insert(LayerAnimationElement::BOUNDS);
-
- sequence.AddElement(
- LayerAnimationElement::CreatePauseElement(properties, delta));
+ sequence.AddElement(LayerAnimationElement::CreatePauseElement(
+ LayerAnimationElement::BOUNDS, delta));
gfx::Transform start_transform, target_transform, middle_transform;
start_transform.Rotate(-30.0);
@@ -196,13 +194,11 @@ TEST(LayerAnimationSequenceTest, MultipleElement) {
delegate.GetTransformForAnimation());
}
- EXPECT_TRUE(sequence.properties().size() == 3);
- EXPECT_TRUE(sequence.properties().find(LayerAnimationElement::OPACITY) !=
- sequence.properties().end());
- EXPECT_TRUE(sequence.properties().find(LayerAnimationElement::TRANSFORM) !=
- sequence.properties().end());
- EXPECT_TRUE(sequence.properties().find(LayerAnimationElement::BOUNDS) !=
- sequence.properties().end());
+ EXPECT_EQ(
+ static_cast<LayerAnimationElement::AnimatableProperties>(
+ LayerAnimationElement::OPACITY | LayerAnimationElement::TRANSFORM |
+ LayerAnimationElement::BOUNDS),
+ sequence.properties());
}
// Check that a sequence can still be aborted if it has cycled many times.
diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc
index 0fad04a..0454152 100644
--- a/ui/compositor/layer_animator.cc
+++ b/ui/compositor/layer_animator.cc
@@ -188,12 +188,12 @@ void LayerAnimator::StartTogether(
}
// Collect all the affected properties.
- LayerAnimationElement::AnimatableProperties animated_properties;
+ LayerAnimationElement::AnimatableProperties animated_properties =
+ LayerAnimationElement::UNKNOWN;
+
std::vector<LayerAnimationSequence*>::const_iterator iter;
- for (iter = animations.begin(); iter != animations.end(); ++iter) {
- animated_properties.insert((*iter)->properties().begin(),
- (*iter)->properties().end());
- }
+ for (iter = animations.begin(); iter != animations.end(); ++iter)
+ animated_properties |= (*iter)->properties();
// Starting a zero duration pause that affects all the animated properties
// will prevent any of the sequences from animating until there are no
@@ -227,12 +227,12 @@ void LayerAnimator::ScheduleTogether(
scoped_refptr<LayerAnimator> retain(this);
// Collect all the affected properties.
- LayerAnimationElement::AnimatableProperties animated_properties;
+ LayerAnimationElement::AnimatableProperties animated_properties =
+ LayerAnimationElement::UNKNOWN;
+
std::vector<LayerAnimationSequence*>::const_iterator iter;
- for (iter = animations.begin(); iter != animations.end(); ++iter) {
- animated_properties.insert((*iter)->properties().begin(),
- (*iter)->properties().end());
- }
+ for (iter = animations.begin(); iter != animations.end(); ++iter)
+ animated_properties |= (*iter)->properties();
// Scheduling a zero duration pause that affects all the animated properties
// will prevent any of the sequences from animating until there are no
@@ -260,16 +260,7 @@ void LayerAnimator::ScheduleTogether(
void LayerAnimator::SchedulePauseForProperties(
base::TimeDelta duration,
- LayerAnimationElement::AnimatableProperty property,
- ...) {
- ui::LayerAnimationElement::AnimatableProperties properties_to_pause;
- va_list marker;
- va_start(marker, property);
- for (int p = static_cast<int>(property); p != -1; p = va_arg(marker, int)) {
- properties_to_pause.insert(
- static_cast<LayerAnimationElement::AnimatableProperty>(p));
- }
- va_end(marker);
+ LayerAnimationElement::AnimatableProperties properties_to_pause) {
ScheduleAnimation(new ui::LayerAnimationSequence(
ui::LayerAnimationElement::CreatePauseElement(
properties_to_pause, duration)));
@@ -279,10 +270,8 @@ bool LayerAnimator::IsAnimatingProperty(
LayerAnimationElement::AnimatableProperty property) const {
for (AnimationQueue::const_iterator queue_iter = animation_queue_.begin();
queue_iter != animation_queue_.end(); ++queue_iter) {
- if ((*queue_iter)->properties().find(property) !=
- (*queue_iter)->properties().end()) {
+ if ((*queue_iter)->properties() & property)
return true;
- }
}
return false;
}
@@ -556,8 +545,7 @@ LayerAnimator::RunningAnimation* LayerAnimator::GetRunningAnimation(
PurgeDeletedAnimations();
for (RunningAnimations::iterator iter = running_animations_.begin();
iter != running_animations_.end(); ++iter) {
- if ((*iter).sequence()->properties().find(property) !=
- (*iter).sequence()->properties().end())
+ if ((*iter).sequence()->properties() & property)
return &(*iter);
}
return NULL;
@@ -708,13 +696,14 @@ void LayerAnimator::ProcessQueue() {
do {
started_sequence = false;
// Build a list of all currently animated properties.
- LayerAnimationElement::AnimatableProperties animated;
+ LayerAnimationElement::AnimatableProperties animated =
+ LayerAnimationElement::UNKNOWN;
for (RunningAnimations::const_iterator iter = running_animations_.begin();
iter != running_animations_.end(); ++iter) {
if (!(*iter).is_sequence_alive())
continue;
- animated.insert((*iter).sequence()->properties().begin(),
- (*iter).sequence()->properties().end());
+
+ animated |= (*iter).sequence()->properties();
}
// Try to find an animation that doesn't conflict with an animated
@@ -744,8 +733,7 @@ void LayerAnimator::ProcessQueue() {
// the first element because it animates the transform, too. We cannot
// start the second element, either, because the first element animates
// bounds too, and needs to go first.
- animated.insert(sequences[i]->properties().begin(),
- sequences[i]->properties().end());
+ animated |= sequences[i]->properties();
}
// If we started a sequence, try again. We may be able to start several.
diff --git a/ui/compositor/layer_animator.h b/ui/compositor/layer_animator.h
index ad3754d..a1e0ad2 100644
--- a/ui/compositor/layer_animator.h
+++ b/ui/compositor/layer_animator.h
@@ -138,8 +138,7 @@ class COMPOSITOR_EXPORT LayerAnimator
// End the list with -1.
void SchedulePauseForProperties(
base::TimeDelta duration,
- LayerAnimationElement::AnimatableProperty property,
- ...);
+ LayerAnimationElement::AnimatableProperties properties_to_pause);
// Returns true if there is an animation in the queue (animations remain in
// the queue until they complete, so this includes running animations).
diff --git a/ui/compositor/layer_animator_unittest.cc b/ui/compositor/layer_animator_unittest.cc
index 7c52200..ed73965 100644
--- a/ui/compositor/layer_animator_unittest.cc
+++ b/ui/compositor/layer_animator_unittest.cc
@@ -2185,9 +2185,9 @@ TEST(LayerAnimatorTest, Color) {
TEST(LayerAnimatorTest, SchedulePauseForProperties) {
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION);
- animator->SchedulePauseForProperties(base::TimeDelta::FromMilliseconds(100),
- LayerAnimationElement::TRANSFORM,
- LayerAnimationElement::BOUNDS, -1);
+ animator->SchedulePauseForProperties(
+ base::TimeDelta::FromMilliseconds(100),
+ LayerAnimationElement::TRANSFORM | LayerAnimationElement::BOUNDS);
EXPECT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::TRANSFORM));
EXPECT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS));
EXPECT_FALSE(animator->IsAnimatingProperty(LayerAnimationElement::OPACITY));
diff --git a/ui/compositor/scoped_layer_animation_settings.cc b/ui/compositor/scoped_layer_animation_settings.cc
index 84456ee..9ab0673 100644
--- a/ui/compositor/scoped_layer_animation_settings.cc
+++ b/ui/compositor/scoped_layer_animation_settings.cc
@@ -61,10 +61,10 @@ class InvertingObserver : public ImplicitAnimationObserver {
"Inverse supported only for single element sequences.";
LayerAnimationElement* element = sequence->FirstElement();
- LayerAnimationElement::AnimatableProperties transform_property;
- transform_property.insert(LayerAnimationElement::TRANSFORM);
- DCHECK(transform_property == element->properties())
- << "Only transform animations are currently invertible.";
+ DCHECK_EQ(static_cast<LayerAnimationElement::AnimatableProperties>(
+ LayerAnimationElement::TRANSFORM),
+ element->properties())
+ << "Only transform animations are currently invertible.";
scoped_ptr<LayerAnimationElement> to_return(
LayerAnimationElement::CreateInverseTransformElement(base, element));
diff --git a/ui/compositor/test/layer_animator_test_controller.cc b/ui/compositor/test/layer_animator_test_controller.cc
index b7b8c40..befbd44 100644
--- a/ui/compositor/test/layer_animator_test_controller.cc
+++ b/ui/compositor/test/layer_animator_test_controller.cc
@@ -41,8 +41,7 @@ void LayerAnimatorTestController::StartThreadedAnimationsIfNeeded() {
continue;
LayerAnimationElement* element = sequence->CurrentElement();
- if (element->properties().find(animatable_property) ==
- element->properties().end())
+ if (!(element->properties() & animatable_property))
continue;
if (!element->Started() ||
diff --git a/ui/views/corewm/window_animations.cc b/ui/views/corewm/window_animations.cc
index d5d4da7..1f90b40 100644
--- a/ui/views/corewm/window_animations.cc
+++ b/ui/views/corewm/window_animations.cc
@@ -358,10 +358,8 @@ void AnimateBounce(aura::Window* window) {
scoped_ptr<ui::LayerAnimationSequence> sequence(
new ui::LayerAnimationSequence);
sequence->AddElement(CreateGrowShrinkElement(window, true));
- ui::LayerAnimationElement::AnimatableProperties paused_properties;
- paused_properties.insert(ui::LayerAnimationElement::BOUNDS);
sequence->AddElement(ui::LayerAnimationElement::CreatePauseElement(
- paused_properties,
+ ui::LayerAnimationElement::BOUNDS,
base::TimeDelta::FromMilliseconds(
kWindowAnimation_Bounce_DurationMS *
(100 - 2 * kWindowAnimation_Bounce_GrowShrinkDurationPercent) /
@@ -382,8 +380,7 @@ void AddLayerAnimationsForRotate(aura::Window* window, bool show) {
new HidingWindowAnimationObserver(window);
window->layer()->GetAnimator()->SchedulePauseForProperties(
duration * (100 - kWindowAnimation_Rotate_OpacityDurationPercent) / 100,
- ui::LayerAnimationElement::OPACITY,
- -1);
+ ui::LayerAnimationElement::OPACITY);
}
scoped_ptr<ui::LayerAnimationElement> opacity(
ui::LayerAnimationElement::CreateOpacityElement(