summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-26 22:13:52 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-26 22:13:52 +0000
commit3cae03e46fe52323a347e2c18f17b4dc8ca20396 (patch)
treec01f95f6937f94e33f42de0c9308c98619008192
parent1e3085fb1f75fa65dbd7ce58ce8e87069d86e8a6 (diff)
downloadchromium_src-3cae03e46fe52323a347e2c18f17b4dc8ca20396.zip
chromium_src-3cae03e46fe52323a347e2c18f17b4dc8ca20396.tar.gz
chromium_src-3cae03e46fe52323a347e2c18f17b4dc8ca20396.tar.bz2
cc: Create a AnimationDelegate interface and an adapter class in compositor_bindings.
Instead of having cc/ talk directly to the WebKit::WebAnimationDelegate, we create an abstract interface in cc/ that it can talk to. In the compositor_bindings, we implement this class, and forward the function calls made into it over to the WebKit implementation. BUG=None TEST=cc_unittests, webkit_compositor_bindings_unittests R=jamesr@chromium.org Review URL: https://codereview.chromium.org/17755003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208800 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/DEPS1
-rw-r--r--cc/animation/animation_delegate.h21
-rw-r--r--cc/animation/layer_animation_controller.cc10
-rw-r--r--cc/animation/layer_animation_controller.h9
-rw-r--r--cc/animation/layer_animation_controller_unittest.cc12
-rw-r--r--cc/cc.gyp1
-rw-r--r--cc/layers/layer.cc1
-rw-r--r--cc/layers/layer.h4
-rw-r--r--cc/test/layer_tree_test.h10
-rw-r--r--cc/trees/layer_tree_host_unittest_animation.cc20
-rw-r--r--webkit/renderer/compositor_bindings/compositor_bindings.gyp2
-rw-r--r--webkit/renderer/compositor_bindings/web_layer_impl.cc7
-rw-r--r--webkit/renderer/compositor_bindings/web_layer_impl.h7
-rw-r--r--webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.cc23
-rw-r--r--webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h32
15 files changed, 121 insertions, 39 deletions
diff --git a/cc/DEPS b/cc/DEPS
index fd9e45e..d5e7baa 100644
--- a/cc/DEPS
+++ b/cc/DEPS
@@ -11,7 +11,6 @@ include_rules = [
"+ui/gl",
# DO NOT ADD ANY NEW WEBKIT HEADERS TO THIS LIST.
# TODO(danakj): Drop dependencies on WebKit Platform API from cc.
- "+third_party/WebKit/public/platform/WebAnimationDelegate.h",
"+third_party/WebKit/public/platform/WebGraphicsContext3D.h",
"+third_party/WebKit/public/platform/WebGraphicsMemoryAllocation.h",
"+third_party/WebKit/public/platform/WebLayerScrollClient.h",
diff --git a/cc/animation/animation_delegate.h b/cc/animation/animation_delegate.h
new file mode 100644
index 0000000..c9367b8
--- /dev/null
+++ b/cc/animation/animation_delegate.h
@@ -0,0 +1,21 @@
+// Copyright 2013 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 CC_ANIMATION_ANIMATION_DELEGATE_H_
+#define CC_ANIMATION_ANIMATION_DELEGATE_H_
+
+namespace cc {
+
+class AnimationDelegate {
+ public:
+ virtual void NotifyAnimationStarted(double time) = 0;
+ virtual void NotifyAnimationFinished(double time) = 0;
+
+ protected:
+ virtual ~AnimationDelegate() {}
+};
+
+} // namespace cc
+
+#endif // CC_ANIMATION_ANIMATION_DELEGATE_H_
diff --git a/cc/animation/layer_animation_controller.cc b/cc/animation/layer_animation_controller.cc
index 902e394..5823b79 100644
--- a/cc/animation/layer_animation_controller.cc
+++ b/cc/animation/layer_animation_controller.cc
@@ -7,11 +7,11 @@
#include <algorithm>
#include "cc/animation/animation.h"
+#include "cc/animation/animation_delegate.h"
#include "cc/animation/animation_registrar.h"
#include "cc/animation/keyframed_animation_curve.h"
#include "cc/animation/layer_animation_value_observer.h"
#include "cc/base/scoped_ptr_algorithm.h"
-#include "third_party/WebKit/public/platform/WebAnimationDelegate.h"
#include "ui/gfx/transform.h"
namespace cc {
@@ -264,7 +264,7 @@ void LayerAnimationController::NotifyAnimationStarted(
FOR_EACH_OBSERVER(LayerAnimationEventObserver, event_observers_,
OnAnimationStarted(event));
if (layer_animation_delegate_)
- layer_animation_delegate_->notifyAnimationStarted(wall_clock_time);
+ layer_animation_delegate_->NotifyAnimationStarted(wall_clock_time);
return;
}
@@ -279,7 +279,7 @@ void LayerAnimationController::NotifyAnimationStarted(
FOR_EACH_OBSERVER(LayerAnimationEventObserver, event_observers_,
OnAnimationStarted(event));
if (layer_animation_delegate_)
- layer_animation_delegate_->notifyAnimationStarted(wall_clock_time);
+ layer_animation_delegate_->NotifyAnimationStarted(wall_clock_time);
return;
}
@@ -291,7 +291,7 @@ void LayerAnimationController::NotifyAnimationFinished(
double wall_clock_time) {
if (event.is_impl_only) {
if (layer_animation_delegate_)
- layer_animation_delegate_->notifyAnimationFinished(wall_clock_time);
+ layer_animation_delegate_->NotifyAnimationFinished(wall_clock_time);
return;
}
@@ -300,7 +300,7 @@ void LayerAnimationController::NotifyAnimationFinished(
active_animations_[i]->target_property() == event.target_property) {
active_animations_[i]->set_received_finished_event(true);
if (layer_animation_delegate_)
- layer_animation_delegate_->notifyAnimationFinished(wall_clock_time);
+ layer_animation_delegate_->NotifyAnimationFinished(wall_clock_time);
return;
}
diff --git a/cc/animation/layer_animation_controller.h b/cc/animation/layer_animation_controller.h
index 3997767..e595ad0 100644
--- a/cc/animation/layer_animation_controller.h
+++ b/cc/animation/layer_animation_controller.h
@@ -17,15 +17,12 @@
#include "cc/base/scoped_ptr_vector.h"
#include "ui/gfx/transform.h"
-namespace WebKit {
-class WebAnimationDelegate;
-}
-
namespace gfx { class Transform; }
namespace cc {
class Animation;
+class AnimationDelegate;
class AnimationRegistrar;
class KeyframeValueList;
class LayerAnimationValueObserver;
@@ -99,7 +96,7 @@ class CC_EXPORT LayerAnimationController
void AddEventObserver(LayerAnimationEventObserver* observer);
void RemoveEventObserver(LayerAnimationEventObserver* observer);
- void set_layer_animation_delegate(WebKit::WebAnimationDelegate* delegate) {
+ void set_layer_animation_delegate(AnimationDelegate* delegate) {
layer_animation_delegate_ = delegate;
}
@@ -161,7 +158,7 @@ class CC_EXPORT LayerAnimationController
ObserverList<LayerAnimationValueObserver> value_observers_;
ObserverList<LayerAnimationEventObserver> event_observers_;
- WebKit::WebAnimationDelegate* layer_animation_delegate_;
+ AnimationDelegate* layer_animation_delegate_;
DISALLOW_COPY_AND_ASSIGN(LayerAnimationController);
};
diff --git a/cc/animation/layer_animation_controller_unittest.cc b/cc/animation/layer_animation_controller_unittest.cc
index 11c8ff1..2e06f5c 100644
--- a/cc/animation/layer_animation_controller_unittest.cc
+++ b/cc/animation/layer_animation_controller_unittest.cc
@@ -6,12 +6,12 @@
#include "cc/animation/animation.h"
#include "cc/animation/animation_curve.h"
+#include "cc/animation/animation_delegate.h"
#include "cc/animation/keyframed_animation_curve.h"
#include "cc/animation/transform_operations.h"
#include "cc/test/animation_test_common.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/WebKit/public/platform/WebAnimationDelegate.h"
#include "ui/gfx/transform.h"
namespace cc {
@@ -378,17 +378,17 @@ TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) {
EXPECT_TRUE(end_transform_event->is_impl_only);
}
-class FakeWebAnimationDelegate : public WebKit::WebAnimationDelegate {
+class FakeAnimationDelegate : public AnimationDelegate {
public:
- FakeWebAnimationDelegate()
+ FakeAnimationDelegate()
: started_(false),
finished_(false) {}
- virtual void notifyAnimationStarted(double time) OVERRIDE {
+ virtual void NotifyAnimationStarted(double time) OVERRIDE {
started_ = true;
}
- virtual void notifyAnimationFinished(double time) OVERRIDE {
+ virtual void NotifyAnimationFinished(double time) OVERRIDE {
finished_ = true;
}
@@ -415,7 +415,7 @@ TEST(LayerAnimationControllerTest,
scoped_refptr<LayerAnimationController> controller(
LayerAnimationController::Create(0));
controller->AddValueObserver(&dummy);
- FakeWebAnimationDelegate delegate;
+ FakeAnimationDelegate delegate;
controller->set_layer_animation_delegate(&delegate);
scoped_ptr<Animation> to_add(CreateAnimation(
diff --git a/cc/cc.gyp b/cc/cc.gyp
index 02a392b..bbbc32e 100644
--- a/cc/cc.gyp
+++ b/cc/cc.gyp
@@ -10,6 +10,7 @@
'animation/animation.h',
'animation/animation_curve.cc',
'animation/animation_curve.h',
+ 'animation/animation_delegate.h',
'animation/animation_events.cc',
'animation/animation_events.h',
'animation/animation_id_provider.cc',
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 76cf18d..270d2cb 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -17,7 +17,6 @@
#include "cc/output/copy_output_result.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_impl.h"
-#include "third_party/WebKit/public/platform/WebAnimationDelegate.h"
#include "third_party/WebKit/public/platform/WebLayerScrollClient.h"
#include "third_party/skia/include/core/SkImageFilter.h"
#include "ui/gfx/rect_conversions.h"
diff --git a/cc/layers/layer.h b/cc/layers/layer.h
index 68f4a43..51a91cb 100644
--- a/cc/layers/layer.h
+++ b/cc/layers/layer.h
@@ -31,13 +31,13 @@
#include "ui/gfx/transform.h"
namespace WebKit {
-class WebAnimationDelegate;
class WebLayerScrollClient;
}
namespace cc {
class Animation;
+class AnimationDelegate;
struct AnimationEvent;
class CopyOutputRequest;
class LayerAnimationDelegate;
@@ -334,7 +334,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
void SetLayerAnimationControllerForTest(
scoped_refptr<LayerAnimationController> controller);
- void set_layer_animation_delegate(WebKit::WebAnimationDelegate* delegate) {
+ void set_layer_animation_delegate(AnimationDelegate* delegate) {
layer_animation_controller_->set_layer_animation_delegate(delegate);
}
diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h
index ba33b6e..1dbb861 100644
--- a/cc/test/layer_tree_test.h
+++ b/cc/test/layer_tree_test.h
@@ -7,10 +7,10 @@
#include "base/memory/ref_counted.h"
#include "base/threading/thread.h"
+#include "cc/animation/animation_delegate.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_host_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/WebKit/public/platform/WebAnimationDelegate.h"
namespace Webkit {
class WebGraphicsContext3D;
@@ -26,7 +26,7 @@ class LayerTreeHostImpl;
class FakeOutputSurface;
// Used by test stubs to notify the test when something interesting happens.
-class TestHooks : public WebKit::WebAnimationDelegate {
+class TestHooks : public AnimationDelegate {
public:
TestHooks();
virtual ~TestHooks();
@@ -67,9 +67,9 @@ class TestHooks : public WebKit::WebAnimationDelegate {
virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl,
bool visible) {}
- // Implementation of WebAnimationDelegate
- virtual void notifyAnimationStarted(double time) OVERRIDE {}
- virtual void notifyAnimationFinished(double time) OVERRIDE {}
+ // Implementation of AnimationDelegate:
+ virtual void NotifyAnimationStarted(double time) OVERRIDE {}
+ virtual void NotifyAnimationFinished(double time) OVERRIDE {}
virtual scoped_ptr<OutputSurface> CreateOutputSurface() = 0;
virtual scoped_refptr<cc::ContextProvider>
diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc
index 29cc4f4..df283de 100644
--- a/cc/trees/layer_tree_host_unittest_animation.cc
+++ b/cc/trees/layer_tree_host_unittest_animation.cc
@@ -148,7 +148,7 @@ class LayerTreeHostAnimationTestAddAnimation
}
}
- virtual void notifyAnimationStarted(double wall_clock_time) OVERRIDE {
+ virtual void NotifyAnimationStarted(double wall_clock_time) OVERRIDE {
received_animation_started_notification_ = true;
start_time_ = wall_clock_time;
if (num_animates_) {
@@ -239,7 +239,7 @@ class LayerTreeHostAnimationTestAnimationsGetDeleted
EndTest();
}
- virtual void notifyAnimationFinished(double time) OVERRIDE {
+ virtual void NotifyAnimationFinished(double time) OVERRIDE {
// Animations on the impl-side controller only get deleted during a commit,
// so we need to schedule a commit.
layer_tree_host()->SetNeedsCommit();
@@ -372,7 +372,7 @@ class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes
PostAddAnimationToMainThread(content_.get());
}
- virtual void notifyAnimationStarted(double time) OVERRIDE {
+ virtual void NotifyAnimationStarted(double time) OVERRIDE {
LayerAnimationController* controller =
layer_tree_host()->root_layer()->children()[0]->
layer_animation_controller();
@@ -427,7 +427,7 @@ class LayerTreeHostAnimationTestAnimationFinishedEvents
PostAddInstantAnimationToMainThread(layer_tree_host()->root_layer());
}
- virtual void notifyAnimationFinished(double time) OVERRIDE {
+ virtual void NotifyAnimationFinished(double time) OVERRIDE {
LayerAnimationController* controller =
layer_tree_host()->root_layer()->layer_animation_controller();
Animation* animation =
@@ -643,11 +643,11 @@ class LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw
PostAddAnimationToMainThread(content_.get());
}
- virtual void notifyAnimationStarted(double wall_clock_time) OVERRIDE {
+ virtual void NotifyAnimationStarted(double wall_clock_time) OVERRIDE {
started_times_++;
}
- virtual void notifyAnimationFinished(double wall_clock_time) OVERRIDE {
+ virtual void NotifyAnimationFinished(double wall_clock_time) OVERRIDE {
EndTest();
}
@@ -689,12 +689,12 @@ class LayerTreeHostAnimationTestRunAnimationWhenNotVisible
layer_tree_host()->SetVisible(false);
}
- virtual void notifyAnimationStarted(double wall_clock_time) OVERRIDE {
+ virtual void NotifyAnimationStarted(double wall_clock_time) OVERRIDE {
EXPECT_FALSE(visible_);
started_times_++;
}
- virtual void notifyAnimationFinished(double wall_clock_time) OVERRIDE {
+ virtual void NotifyAnimationFinished(double wall_clock_time) OVERRIDE {
EXPECT_FALSE(visible_);
EXPECT_EQ(1, started_times_);
EndTest();
@@ -773,13 +773,13 @@ class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations
}
}
- virtual void notifyAnimationStarted(double wall_clock_time) OVERRIDE {
+ virtual void NotifyAnimationStarted(double wall_clock_time) OVERRIDE {
if (TestEnded())
return;
started_times_++;
}
- virtual void notifyAnimationFinished(double wall_clock_time) OVERRIDE {
+ virtual void NotifyAnimationFinished(double wall_clock_time) OVERRIDE {
// We should be checkerboarding already, but it should still finish the
// first animation.
EXPECT_EQ(2, added_animations_);
diff --git a/webkit/renderer/compositor_bindings/compositor_bindings.gyp b/webkit/renderer/compositor_bindings/compositor_bindings.gyp
index e2c7551..518413b 100644
--- a/webkit/renderer/compositor_bindings/compositor_bindings.gyp
+++ b/webkit/renderer/compositor_bindings/compositor_bindings.gyp
@@ -29,6 +29,8 @@
'web_layer_impl_fixed_bounds.h',
'web_to_ccscrollbar_theme_painter_adapter.cc',
'web_to_ccscrollbar_theme_painter_adapter.h',
+ 'web_to_cc_animation_delegate_adapter.cc',
+ 'web_to_cc_animation_delegate_adapter.h',
'web_scrollbar_layer_impl.cc',
'web_scrollbar_layer_impl.h',
'web_solid_color_layer_impl.cc',
diff --git a/webkit/renderer/compositor_bindings/web_layer_impl.cc b/webkit/renderer/compositor_bindings/web_layer_impl.cc
index 4baa9ae..d46b9e1 100644
--- a/webkit/renderer/compositor_bindings/web_layer_impl.cc
+++ b/webkit/renderer/compositor_bindings/web_layer_impl.cc
@@ -17,6 +17,7 @@
#include "third_party/skia/include/utils/SkMatrix44.h"
#include "webkit/renderer/compositor_bindings/web_animation_impl.h"
#include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h"
+#include "webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h"
using cc::Animation;
using cc::Layer;
@@ -191,7 +192,9 @@ void WebLayerImpl::setCompositingReasons(
void WebLayerImpl::setAnimationDelegate(
WebKit::WebAnimationDelegate* delegate) {
- layer_->set_layer_animation_delegate(delegate);
+ animation_delegate_adapter_.reset(
+ new WebToCCAnimationDelegateAdapter(delegate));
+ layer_->set_layer_animation_delegate(animation_delegate_adapter_.get());
}
bool WebLayerImpl::addAnimation(WebKit::WebAnimation* animation) {
@@ -362,4 +365,4 @@ bool WebLayerImpl::isOrphan() const { return !layer_->layer_tree_host(); }
Layer* WebLayerImpl::layer() const { return layer_.get(); }
-} // namespace WebKit
+} // namespace webkit
diff --git a/webkit/renderer/compositor_bindings/web_layer_impl.h b/webkit/renderer/compositor_bindings/web_layer_impl.h
index 7f41271..f0916d8 100644
--- a/webkit/renderer/compositor_bindings/web_layer_impl.h
+++ b/webkit/renderer/compositor_bindings/web_layer_impl.h
@@ -6,6 +6,7 @@
#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_LAYER_IMPL_H_
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "third_party/WebKit/public/platform/WebAnimation.h"
#include "third_party/WebKit/public/platform/WebColor.h"
#include "third_party/WebKit/public/platform/WebCompositingReasons.h"
@@ -33,6 +34,8 @@ struct WebFloatRect;
namespace webkit {
+class WebToCCAnimationDelegateAdapter;
+
class WebLayerImpl : public WebKit::WebLayer {
public:
WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebLayerImpl();
@@ -121,9 +124,11 @@ class WebLayerImpl : public WebKit::WebLayer {
scoped_refptr<cc::Layer> layer_;
private:
+ scoped_ptr<WebToCCAnimationDelegateAdapter> animation_delegate_adapter_;
+
DISALLOW_COPY_AND_ASSIGN(WebLayerImpl);
};
-} // namespace WebKit
+} // namespace webkit
#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_LAYER_IMPL_H_
diff --git a/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.cc b/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.cc
new file mode 100644
index 0000000..a39448b
--- /dev/null
+++ b/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.cc
@@ -0,0 +1,23 @@
+// Copyright 2013 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 "webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h"
+
+#include "third_party/WebKit/public/platform/WebAnimationDelegate.h"
+
+namespace webkit {
+
+WebToCCAnimationDelegateAdapter::WebToCCAnimationDelegateAdapter(
+ WebKit::WebAnimationDelegate* delegate)
+ : delegate_(delegate) {}
+
+void WebToCCAnimationDelegateAdapter::NotifyAnimationStarted(double time) {
+ delegate_->notifyAnimationStarted(time);
+}
+
+void WebToCCAnimationDelegateAdapter::NotifyAnimationFinished(double time) {
+ delegate_->notifyAnimationFinished(time);
+}
+
+} // namespace webkit
diff --git a/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h b/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h
new file mode 100644
index 0000000..d59693d
--- /dev/null
+++ b/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h
@@ -0,0 +1,32 @@
+// Copyright 2013 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_TO_CC_ANIMATION_DELEGATE_ADAPTER_H_
+#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_TO_CC_ANIMATION_DELEGATE_ADAPTER_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "cc/animation/animation_delegate.h"
+
+namespace WebKit { class WebAnimationDelegate; }
+
+namespace webkit {
+
+class WebToCCAnimationDelegateAdapter : public cc::AnimationDelegate {
+ public:
+ explicit WebToCCAnimationDelegateAdapter(
+ WebKit::WebAnimationDelegate* delegate);
+
+ private:
+ virtual void NotifyAnimationStarted(double time) OVERRIDE;
+ virtual void NotifyAnimationFinished(double time) OVERRIDE;
+
+ WebKit::WebAnimationDelegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebToCCAnimationDelegateAdapter);
+};
+
+} // namespace webkit
+
+#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_TO_CC_ANIMATION_DELEGATE_ADAPTER_H_