summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorvollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-28 12:24:32 +0000
committervollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-28 12:24:32 +0000
commit04f726bb47f45d2603fa64f53e2213aeb0ff64c2 (patch)
tree323f06d4c278cb3c658f457e57f2f196a576d9ba /views
parentc3b92bfa40aed1f312195936873b05ec0abd4aa7 (diff)
downloadchromium_src-04f726bb47f45d2603fa64f53e2213aeb0ff64c2.zip
chromium_src-04f726bb47f45d2603fa64f53e2213aeb0ff64c2.tar.gz
chromium_src-04f726bb47f45d2603fa64f53e2213aeb0ff64c2.tar.bz2
Enable the new layer animation framework.
Depends on http://codereview.chromium.org/8247009/ BUG=None TEST=None Review URL: http://codereview.chromium.org/8362006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107715 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/desktop/desktop_window_view.cc15
-rw-r--r--views/layer_property_setter.cc59
-rw-r--r--views/layer_property_setter.h51
-rw-r--r--views/view.cc36
-rw-r--r--views/view.h11
-rw-r--r--views/view_unittest.cc55
-rw-r--r--views/views.gyp5
-rw-r--r--views/widget/native_widget_views.cc8
8 files changed, 48 insertions, 192 deletions
diff --git a/views/desktop/desktop_window_view.cc b/views/desktop/desktop_window_view.cc
index 24f0249..65d4801 100644
--- a/views/desktop/desktop_window_view.cc
+++ b/views/desktop/desktop_window_view.cc
@@ -7,9 +7,10 @@
#include "base/utf_string_conversions.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/transform.h"
+#include "ui/gfx/compositor/layer.h"
+#include "ui/gfx/compositor/layer_animator.h"
#include "views/desktop/desktop_background.h"
#include "views/desktop/desktop_window_manager.h"
-#include "views/layer_property_setter.h"
#include "views/widget/native_widget_view.h"
#include "views/widget/native_widget_views.h"
#include "views/widget/widget.h"
@@ -160,12 +161,20 @@ void DesktopWindowView::CreateTestWindow(const string16& title,
initial_bounds);
window->Show();
+ NativeWidgetViews* native_widget_views =
+ static_cast<NativeWidgetViews*>(window->native_widget());
+
if (rotate) {
ui::Transform transform;
transform.SetRotate(90.0f);
transform.SetTranslateX(window->GetWindowScreenBounds().width());
- static_cast<NativeWidgetViews*>(window->native_widget())->GetView()->
- SetTransform(transform);
+ native_widget_views->GetView()->SetTransform(transform);
+ }
+
+ native_widget_views->GetView()->SetPaintToLayer(true);
+ if (native_widget_views->GetView()->layer()) {
+ native_widget_views->GetView()->layer()->SetAnimator(
+ ui::LayerAnimator::CreateImplicitAnimator());
}
}
diff --git a/views/layer_property_setter.cc b/views/layer_property_setter.cc
deleted file mode 100644
index 26f203f..0000000
--- a/views/layer_property_setter.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "views/layer_property_setter.h"
-
-#include "base/memory/scoped_ptr.h"
-#include "ui/gfx/compositor/compositor.h"
-#include "ui/gfx/compositor/layer.h"
-
-namespace views {
-
-namespace {
-
-// DefaultSetter ---------------------------------------------------------------
-
-class DefaultSetter : public LayerPropertySetter {
- public:
- DefaultSetter();
-
- // LayerPropertySetter:
- virtual void Installed(ui::Layer* layer) OVERRIDE;
- virtual void Uninstalled(ui::Layer* layer) OVERRIDE;
- virtual void SetTransform(ui::Layer* layer,
- const ui::Transform& transform) OVERRIDE;
- virtual void SetBounds(ui::Layer* layer, const gfx::Rect& bounds) OVERRIDE;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DefaultSetter);
-};
-
-DefaultSetter::DefaultSetter() {
-}
-
-void DefaultSetter::Installed(ui::Layer* layer) {
-}
-
-void DefaultSetter::Uninstalled(ui::Layer* layer) {
-}
-
-void DefaultSetter::SetTransform(ui::Layer* layer,
- const ui::Transform& transform) {
- layer->SetTransform(transform);
-}
-
-void DefaultSetter::SetBounds(ui::Layer* layer, const gfx::Rect& bounds) {
- layer->SetBounds(bounds);
-}
-
-} // namespace
-
-// LayerPropertySetter ---------------------------------------------------------
-
-// static
-LayerPropertySetter* LayerPropertySetter::CreateDefaultSetter() {
- return new DefaultSetter;
-}
-
-} // namespace views
diff --git a/views/layer_property_setter.h b/views/layer_property_setter.h
deleted file mode 100644
index 9db167d..0000000
--- a/views/layer_property_setter.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_GFX_COMPOSITOR_LAYER_PROPERTY_SETTER_H_
-#define UI_GFX_COMPOSITOR_LAYER_PROPERTY_SETTER_H_
-#pragma once
-
-#include "views/views_export.h"
-
-namespace gfx {
-class Rect;
-}
-
-namespace ui {
-class Layer;
-class Transform;
-}
-
-namespace views {
-
-// When a property of layer needs to be changed it is set by way of
-// LayerPropertySetter. This enables LayerPropertySetter to animate property
-// changes.
-class VIEWS_EXPORT LayerPropertySetter {
- public:
- // Creates a LayerPropertySetter that immediately sets the values on the
- // layer. Ownership returns to caller.
- static LayerPropertySetter* CreateDefaultSetter();
-
- virtual ~LayerPropertySetter() {}
-
- // Invoked when the LayerPropertySetter is to be used for a particular Layer.
- // This is invoked whenever a new Layer is created. A LayerPropertySetter is
- // only associated with one Layer at a time.
- virtual void Installed(ui::Layer* layer) = 0;
-
- // Invoked when the Layer is destroyed.
- virtual void Uninstalled(ui::Layer* layer) = 0;
-
- // Sets the transform on the Layer.
- virtual void SetTransform(ui::Layer* layer,
- const ui::Transform& transform) = 0;
-
- // Sets the bounds of the layer.
- virtual void SetBounds(ui::Layer* layer, const gfx::Rect& bounds) = 0;
-};
-
-} // namespace views
-
-#endif // UI_GFX_COMPOSITOR_LAYER_PROPERTY_SETTER_H_
diff --git a/views/view.cc b/views/view.cc
index 060eb15..d9b744a8 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -18,6 +18,7 @@
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/compositor/compositor.h"
#include "ui/gfx/compositor/layer.h"
+#include "ui/gfx/compositor/layer_animator.h"
#include "ui/gfx/interpolated_transform.h"
#include "ui/gfx/path.h"
#include "ui/gfx/point3.h"
@@ -25,7 +26,6 @@
#include "views/background.h"
#include "views/context_menu_controller.h"
#include "views/drag_controller.h"
-#include "views/layer_property_setter.h"
#include "views/layout/layout_manager.h"
#include "views/views_delegate.h"
#include "views/widget/native_widget_private.h"
@@ -424,7 +424,7 @@ const ui::Transform& View::GetTransform() const {
void View::SetTransform(const ui::Transform& transform) {
if (!transform.HasChange()) {
if (layer()) {
- layer_property_setter_->SetTransform(layer(), transform);
+ layer()->SetTransform(transform);
if (!paint_to_layer_)
DestroyLayer();
} else {
@@ -433,7 +433,7 @@ void View::SetTransform(const ui::Transform& transform) {
} else {
if (!layer())
CreateLayer();
- layer_property_setter_->SetTransform(layer(), transform);
+ layer()->SetTransform(transform);
layer()->ScheduleDraw();
}
}
@@ -447,20 +447,6 @@ void View::SetPaintToLayer(bool paint_to_layer) {
}
}
-void View::SetLayerPropertySetter(LayerPropertySetter* setter) {
- DCHECK(layer());
- LayerPropertySetter* old_setter = layer_property_setter_.get();
- if (!layer() || (old_setter && old_setter == setter))
- return;
- if (!setter)
- setter = LayerPropertySetter::CreateDefaultSetter();
-
- if (old_setter)
- old_setter->Uninstalled(layer());
- layer_property_setter_.reset(setter);
- layer_property_setter_->Installed(layer());
-}
-
// RTL positioning -------------------------------------------------------------
gfx::Rect View::GetMirroredBounds() const {
@@ -1157,8 +1143,7 @@ void View::UpdateChildLayerVisibility(bool ancestor_visible) {
void View::UpdateChildLayerBounds(const gfx::Point& offset) {
if (layer()) {
- layer_property_setter_->SetBounds(layer(), gfx::Rect(offset.x(), offset.y(),
- width(), height()));
+ layer()->SetBounds(gfx::Rect(offset.x(), offset.y(), width(), height()));
} else {
for (int i = 0, count = child_count(); i < count; ++i) {
gfx::Point new_offset(offset.x() + child_at(i)->x(),
@@ -1174,7 +1159,7 @@ void View::OnPaintLayer(gfx::Canvas* canvas) {
PaintCommon(canvas);
}
-void View::OnLayerAnimationEnded(const ui::Animation* animation) {
+void View::OnLayerAnimationEnded(const ui::LayerAnimationSequence* animation) {
}
void View::ReorderLayers() {
@@ -1599,9 +1584,9 @@ void View::BoundsChanged(const gfx::Rect& previous_bounds) {
gfx::Point offset;
parent_->CalculateOffsetToAncestorWithLayer(&offset, NULL);
offset.Offset(x(), y());
- layer_property_setter_->SetBounds(layer(), gfx::Rect(offset, size()));
+ layer()->SetBounds(gfx::Rect(offset, size()));
} else {
- layer_property_setter_->SetBounds(layer(), bounds_);
+ layer()->SetBounds(bounds_);
}
// TODO(beng): this seems redundant with the SchedulePaint at the top of
// this function. explore collapsing.
@@ -1785,10 +1770,6 @@ void View::CreateLayer() {
layer_.reset(new ui::Layer(NULL));
layer_->set_delegate(this);
- if (layer_property_setter_.get())
- layer_property_setter_->Installed(layer());
- else
- SetLayerPropertySetter(NULL);
UpdateParentLayers();
UpdateLayerVisibility();
@@ -1859,9 +1840,6 @@ void View::DestroyLayer() {
new_parent->Add(children[i]);
}
- if (layer_property_setter_.get())
- layer_property_setter_->Uninstalled(layer());
-
layer_.reset();
if (new_parent)
diff --git a/views/view.h b/views/view.h
index d86c805..945e381 100644
--- a/views/view.h
+++ b/views/view.h
@@ -36,6 +36,7 @@ namespace ui {
struct AccessibleViewState;
class Compositor;
class Layer;
+class LayerAnimationSequence;
class Texture;
class ThemeProvider;
class Transform;
@@ -55,7 +56,6 @@ class DragController;
class FocusManager;
class FocusTraversable;
class InputMethod;
-class LayerPropertySetter;
class LayoutManager;
class ScrollView;
class TextInputClient;
@@ -286,11 +286,6 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// Compositor.
void SetPaintToLayer(bool paint_to_layer);
- // Sets the LayerPropertySetter for this view. A value of NULL resets the
- // LayerPropertySetter to the default (immediate). Can only be called on a
- // View that has a layer().
- void SetLayerPropertySetter(LayerPropertySetter* setter);
-
const ui::Layer* layer() const { return layer_.get(); }
ui::Layer* layer() { return layer_.get(); }
@@ -990,7 +985,8 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// Overridden from ui::LayerDelegate:
virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE;
- virtual void OnLayerAnimationEnded(const ui::Animation* animation) OVERRIDE;
+ virtual void OnLayerAnimationEnded(
+ const ui::LayerAnimationSequence* animation) OVERRIDE;
// Finds the layer that this view paints to (it may belong to an ancestor
// view), then reorders the immediate children of that layer to match the
@@ -1400,7 +1396,6 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
bool paint_to_layer_;
scoped_ptr<ui::Layer> layer_;
- scoped_ptr<LayerPropertySetter> layer_property_setter_;
// Accelerators --------------------------------------------------------------
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index 55a20f0..a9f7859 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -15,6 +15,7 @@
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/compositor/compositor.h"
#include "ui/gfx/compositor/layer.h"
+#include "ui/gfx/compositor/layer_animator.h"
#include "ui/gfx/compositor/test_compositor.h"
#include "ui/gfx/compositor/test_texture.h"
#include "ui/gfx/path.h"
@@ -28,7 +29,6 @@
#include "views/events/event.h"
#include "views/focus/accelerator_handler.h"
#include "views/focus/view_storage.h"
-#include "views/layer_property_setter.h"
#include "views/test/views_test_base.h"
#include "views/touchui/gesture_manager.h"
#include "views/view.h"
@@ -2444,44 +2444,27 @@ TEST_F(ViewTest, GetViewByID) {
namespace {
-// Test implementation of LayerPropertySetter;
-class TestLayerPropertySetter : public LayerPropertySetter {
+// Test implementation of LayerAnimator.
+class TestLayerAnimator : public ui::LayerAnimator {
public:
- TestLayerPropertySetter();
+ TestLayerAnimator();
- bool installed() const { return installed_; }
const gfx::Rect& last_bounds() const { return last_bounds_; }
- // LayerPropertySetter:
- virtual void Installed(ui::Layer* layer) OVERRIDE;
- virtual void Uninstalled(ui::Layer* layer) OVERRIDE;
- virtual void SetTransform(ui::Layer* layer,
- const ui::Transform& transform) OVERRIDE;
- virtual void SetBounds(ui::Layer* layer, const gfx::Rect& bounds) OVERRIDE;
+ // LayerAnimator.
+ virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
private:
- bool installed_;
gfx::Rect last_bounds_;
- DISALLOW_COPY_AND_ASSIGN(TestLayerPropertySetter);
+ DISALLOW_COPY_AND_ASSIGN(TestLayerAnimator);
};
-TestLayerPropertySetter::TestLayerPropertySetter() : installed_(false) {}
-
-void TestLayerPropertySetter::Installed(ui::Layer* layer) {
- installed_ = true;
-}
-
-void TestLayerPropertySetter::Uninstalled(ui::Layer* layer) {
- installed_ = false;
-}
-
-void TestLayerPropertySetter::SetTransform(ui::Layer* layer,
- const ui::Transform& transform) {
+TestLayerAnimator::TestLayerAnimator()
+ : ui::LayerAnimator(base::TimeDelta::FromMilliseconds(0)) {
}
-void TestLayerPropertySetter::SetBounds(ui::Layer* layer,
- const gfx::Rect& bounds) {
+void TestLayerAnimator::SetBounds(const gfx::Rect& bounds) {
last_bounds_ = bounds;
}
@@ -2676,28 +2659,22 @@ TEST_F(ViewLayerTest, NestedLayerToggling) {
EXPECT_EQ(v1->layer(), v3->layer()->parent());
}
-TEST_F(ViewLayerTest, LayerPropertySetter) {
+TEST_F(ViewLayerTest, LayerAnimator) {
View* content_view = new View;
widget()->SetContentsView(content_view);
View* v1 = new View;
content_view->AddChildView(v1);
v1->SetPaintToLayer(true);
- TestLayerPropertySetter* setter = new TestLayerPropertySetter;
- v1->SetLayerPropertySetter(setter);
- EXPECT_TRUE(setter->installed());
-
- // Turn off the layer, which should trigger uninstall.
- v1->SetPaintToLayer(false);
- EXPECT_FALSE(setter->installed());
+ EXPECT_TRUE(v1->layer() != NULL);
- v1->SetPaintToLayer(true);
- EXPECT_TRUE(setter->installed());
+ TestLayerAnimator* animator = new TestLayerAnimator();
+ v1->layer()->SetAnimator(animator);
gfx::Rect bounds(1, 2, 3, 4);
v1->SetBoundsRect(bounds);
- EXPECT_EQ(bounds, setter->last_bounds());
- // TestLayerPropertySetter doesn't update the layer.
+ EXPECT_EQ(bounds, animator->last_bounds());
+ // TestLayerAnimator doesn't update the layer.
EXPECT_NE(bounds, v1->layer()->bounds());
}
diff --git a/views/views.gyp b/views/views.gyp
index 2232df8..b10b530 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -301,8 +301,6 @@
'ime/text_input_client.h',
'ime/text_input_type_tracker.h',
'ime/text_input_type_tracker.cc',
- 'layer_property_setter.cc',
- 'layer_property_setter.h',
'layout/box_layout.cc',
'layout/box_layout.h',
'layout/fill_layout.cc',
@@ -661,7 +659,7 @@
'sources/': [
['exclude', '../ui/aura/test/test_desktop_delegate.cc'],
['exclude', '../ui/aura/test/test_desktop_delegate.h'],
- ],
+ ],
}],
['OS!="mac"', {
'dependencies': [
@@ -852,6 +850,7 @@
'../ui/ui.gyp:ui',
'../ui/ui.gyp:ui_resources',
'../ui/ui.gyp:ui_resources_standard',
+ '../ui/gfx/compositor/compositor.gyp:compositor',
'views',
'views_desktop_lib',
],
diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc
index 4ed77ca..7d2632d 100644
--- a/views/widget/native_widget_views.cc
+++ b/views/widget/native_widget_views.cc
@@ -6,6 +6,8 @@
#include "base/bind.h"
#include "ui/gfx/compositor/compositor.h"
+#include "ui/gfx/compositor/layer.h"
+#include "ui/gfx/compositor/layer_animator.h"
#include "views/view.h"
#include "views/views_delegate.h"
#include "views/widget/native_widget_view.h"
@@ -462,6 +464,9 @@ void NativeWidgetViews::Maximize() {
}
void NativeWidgetViews::Minimize() {
+ if (view_->layer() && view_->layer()->GetAnimator()->is_animating())
+ return;
+
gfx::Rect view_bounds = view_->bounds();
gfx::Rect parent_bounds = view_->parent()->bounds();
@@ -503,6 +508,9 @@ bool NativeWidgetViews::IsMinimized() const {
}
void NativeWidgetViews::Restore() {
+ if (view_->layer() && view_->layer()->GetAnimator()->is_animating())
+ return;
+
window_state_ = ui::SHOW_STATE_NORMAL;
view_->SetBoundsRect(restored_bounds_);
view_->SetTransform(restored_transform_);