summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorvollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-28 12:59:37 +0000
committervollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-28 12:59:37 +0000
commit37ae3e6e3c42080eff48cd1376d80fc5daa19447 (patch)
tree563980bab57be367f8e0d608515d132169a34898 /views
parent406afd5c0d3e74cc74b68a7c390e0ccda2472313 (diff)
downloadchromium_src-37ae3e6e3c42080eff48cd1376d80fc5daa19447.zip
chromium_src-37ae3e6e3c42080eff48cd1376d80fc5daa19447.tar.gz
chromium_src-37ae3e6e3c42080eff48cd1376d80fc5daa19447.tar.bz2
Revert 107715 - Enable the new layer animation framework.
Depends on http://codereview.chromium.org/8247009/ BUG=None TEST=None Review URL: http://codereview.chromium.org/8362006 TBR=sky@chromium.org Review URL: http://codereview.chromium.org/8400059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107720 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, 192 insertions, 48 deletions
diff --git a/views/desktop/desktop_window_view.cc b/views/desktop/desktop_window_view.cc
index 65d4801..24f0249 100644
--- a/views/desktop/desktop_window_view.cc
+++ b/views/desktop/desktop_window_view.cc
@@ -7,10 +7,9 @@
#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"
@@ -161,20 +160,12 @@ 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());
- 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());
+ static_cast<NativeWidgetViews*>(window->native_widget())->GetView()->
+ SetTransform(transform);
}
}
diff --git a/views/layer_property_setter.cc b/views/layer_property_setter.cc
new file mode 100644
index 0000000..26f203f
--- /dev/null
+++ b/views/layer_property_setter.cc
@@ -0,0 +1,59 @@
+// 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
new file mode 100644
index 0000000..9db167d
--- /dev/null
+++ b/views/layer_property_setter.h
@@ -0,0 +1,51 @@
+// 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 d9b744a8..060eb15 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -18,7 +18,6 @@
#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"
@@ -26,6 +25,7 @@
#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()->SetTransform(transform);
+ layer_property_setter_->SetTransform(layer(), transform);
if (!paint_to_layer_)
DestroyLayer();
} else {
@@ -433,7 +433,7 @@ void View::SetTransform(const ui::Transform& transform) {
} else {
if (!layer())
CreateLayer();
- layer()->SetTransform(transform);
+ layer_property_setter_->SetTransform(layer(), transform);
layer()->ScheduleDraw();
}
}
@@ -447,6 +447,20 @@ 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 {
@@ -1143,7 +1157,8 @@ void View::UpdateChildLayerVisibility(bool ancestor_visible) {
void View::UpdateChildLayerBounds(const gfx::Point& offset) {
if (layer()) {
- layer()->SetBounds(gfx::Rect(offset.x(), offset.y(), width(), height()));
+ layer_property_setter_->SetBounds(layer(), 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(),
@@ -1159,7 +1174,7 @@ void View::OnPaintLayer(gfx::Canvas* canvas) {
PaintCommon(canvas);
}
-void View::OnLayerAnimationEnded(const ui::LayerAnimationSequence* animation) {
+void View::OnLayerAnimationEnded(const ui::Animation* animation) {
}
void View::ReorderLayers() {
@@ -1584,9 +1599,9 @@ void View::BoundsChanged(const gfx::Rect& previous_bounds) {
gfx::Point offset;
parent_->CalculateOffsetToAncestorWithLayer(&offset, NULL);
offset.Offset(x(), y());
- layer()->SetBounds(gfx::Rect(offset, size()));
+ layer_property_setter_->SetBounds(layer(), gfx::Rect(offset, size()));
} else {
- layer()->SetBounds(bounds_);
+ layer_property_setter_->SetBounds(layer(), bounds_);
}
// TODO(beng): this seems redundant with the SchedulePaint at the top of
// this function. explore collapsing.
@@ -1770,6 +1785,10 @@ 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();
@@ -1840,6 +1859,9 @@ 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 945e381..d86c805 100644
--- a/views/view.h
+++ b/views/view.h
@@ -36,7 +36,6 @@ namespace ui {
struct AccessibleViewState;
class Compositor;
class Layer;
-class LayerAnimationSequence;
class Texture;
class ThemeProvider;
class Transform;
@@ -56,6 +55,7 @@ class DragController;
class FocusManager;
class FocusTraversable;
class InputMethod;
+class LayerPropertySetter;
class LayoutManager;
class ScrollView;
class TextInputClient;
@@ -286,6 +286,11 @@ 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(); }
@@ -985,8 +990,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// Overridden from ui::LayerDelegate:
virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE;
- virtual void OnLayerAnimationEnded(
- const ui::LayerAnimationSequence* animation) OVERRIDE;
+ virtual void OnLayerAnimationEnded(const ui::Animation* 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
@@ -1396,6 +1400,7 @@ 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 a9f7859..55a20f0 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -15,7 +15,6 @@
#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"
@@ -29,6 +28,7 @@
#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,27 +2444,44 @@ TEST_F(ViewTest, GetViewByID) {
namespace {
-// Test implementation of LayerAnimator.
-class TestLayerAnimator : public ui::LayerAnimator {
+// Test implementation of LayerPropertySetter;
+class TestLayerPropertySetter : public LayerPropertySetter {
public:
- TestLayerAnimator();
+ TestLayerPropertySetter();
+ bool installed() const { return installed_; }
const gfx::Rect& last_bounds() const { return last_bounds_; }
- // LayerAnimator.
- virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
+ // 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:
+ bool installed_;
gfx::Rect last_bounds_;
- DISALLOW_COPY_AND_ASSIGN(TestLayerAnimator);
+ DISALLOW_COPY_AND_ASSIGN(TestLayerPropertySetter);
};
-TestLayerAnimator::TestLayerAnimator()
- : ui::LayerAnimator(base::TimeDelta::FromMilliseconds(0)) {
+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) {
}
-void TestLayerAnimator::SetBounds(const gfx::Rect& bounds) {
+void TestLayerPropertySetter::SetBounds(ui::Layer* layer,
+ const gfx::Rect& bounds) {
last_bounds_ = bounds;
}
@@ -2659,22 +2676,28 @@ TEST_F(ViewLayerTest, NestedLayerToggling) {
EXPECT_EQ(v1->layer(), v3->layer()->parent());
}
-TEST_F(ViewLayerTest, LayerAnimator) {
+TEST_F(ViewLayerTest, LayerPropertySetter) {
View* content_view = new View;
widget()->SetContentsView(content_view);
View* v1 = new View;
content_view->AddChildView(v1);
v1->SetPaintToLayer(true);
- EXPECT_TRUE(v1->layer() != NULL);
+ 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());
- TestLayerAnimator* animator = new TestLayerAnimator();
- v1->layer()->SetAnimator(animator);
+ v1->SetPaintToLayer(true);
+ EXPECT_TRUE(setter->installed());
gfx::Rect bounds(1, 2, 3, 4);
v1->SetBoundsRect(bounds);
- EXPECT_EQ(bounds, animator->last_bounds());
- // TestLayerAnimator doesn't update the layer.
+ EXPECT_EQ(bounds, setter->last_bounds());
+ // TestLayerPropertySetter doesn't update the layer.
EXPECT_NE(bounds, v1->layer()->bounds());
}
diff --git a/views/views.gyp b/views/views.gyp
index 650b83e..57e9c0b 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -301,6 +301,8 @@
'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',
@@ -659,7 +661,7 @@
'sources/': [
['exclude', '../ui/aura/test/test_desktop_delegate.cc'],
['exclude', '../ui/aura/test/test_desktop_delegate.h'],
- ],
+ ],
}],
['OS!="mac"', {
'dependencies': [
@@ -852,7 +854,6 @@
'../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 7d2632d..4ed77ca 100644
--- a/views/widget/native_widget_views.cc
+++ b/views/widget/native_widget_views.cc
@@ -6,8 +6,6 @@
#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"
@@ -464,9 +462,6 @@ 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();
@@ -508,9 +503,6 @@ 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_);