summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-12 01:53:49 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-12 01:53:49 +0000
commitc8756fbeef2763cd62d7174d4e0253c51864fe7b (patch)
treeb9f200690c8420ea37a4652bb599ea3b91a9a1b3 /webkit
parente7cede117cf24104a57b6dd9c43e9c5f2a602063 (diff)
downloadchromium_src-c8756fbeef2763cd62d7174d4e0253c51864fe7b.zip
chromium_src-c8756fbeef2763cd62d7174d4e0253c51864fe7b.tar.gz
chromium_src-c8756fbeef2763cd62d7174d4e0253c51864fe7b.tar.bz2
Implement WebKit::WebUnitTestSupport::createLayerTreeViewForTesting()
This provides an implementation WebKit::WebUnitTestSupport::createLayerTreeViewForTesting() for webkit_unit_tests that want to instantiate compositing support and need initialization to succeed but do not need to actually render anything. Critically, this sort of view does not depend on any particular client or settings. This appears to be a lot of code, but it's actually a bit of movement and very little new code. The primary movement is extracting most of the test class cc/test/fake_web_graphics_context3d.h into cc/fake_web_graphics_context3d.h so that it can be exported to other modules as a regular class. This is necessary since webkit_unit_tests are in a different component and must use only the normally exported parts of the cc library. cc/test/test_web_graphics_context3d.h has all of the extra bells and whistles and assertions for cc_unittests. WebLayerTreeViewImplForTesting uses a very simple context and does not depend on an external client at all. This results in two subtle but very significant properties (which are the point of this whole exercise) - the unit tests no longer depend on WebLayerTreeViewClient or WebGraphicsContext3D at all. The entire notion of what the context type is now entirely hidden in the chromium side of the codebase and can be swapped out for something else (like gpu::GLES2Interface) without any further changes on the WebKit side. After this patch, the only remaining caller of WebCompositorSupport::createLayerTreeView in the WebKit tree is WebViewHost, which needs to instantiate a view that can render pixels (using mesa) for DumpRenderTree. I'll address that separately. BUG=175383 Review URL: https://codereview.chromium.org/12211110 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181817 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/compositor_bindings/compositor_bindings.gyp2
-rw-r--r--webkit/compositor_bindings/web_compositor_support_impl.cc32
-rw-r--r--webkit/compositor_bindings/web_compositor_support_impl.h6
-rw-r--r--webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc187
-rw-r--r--webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h84
-rw-r--r--webkit/support/test_webkit_platform_support.cc15
-rw-r--r--webkit/support/test_webkit_platform_support.h7
-rw-r--r--webkit/support/webkit_support.gypi1
8 files changed, 314 insertions, 20 deletions
diff --git a/webkit/compositor_bindings/compositor_bindings.gyp b/webkit/compositor_bindings/compositor_bindings.gyp
index 5d6f9cf..b1d87b2 100644
--- a/webkit/compositor_bindings/compositor_bindings.gyp
+++ b/webkit/compositor_bindings/compositor_bindings.gyp
@@ -37,6 +37,8 @@
'web_to_ccvideo_frame_provider.h',
'web_layer_tree_view_impl.cc',
'web_layer_tree_view_impl.h',
+ 'web_layer_tree_view_impl_for_testing.cc',
+ 'web_layer_tree_view_impl_for_testing.h',
'web_scrollbar_layer_impl.cc',
'web_scrollbar_layer_impl.h',
'web_solid_color_layer_impl.cc',
diff --git a/webkit/compositor_bindings/web_compositor_support_impl.cc b/webkit/compositor_bindings/web_compositor_support_impl.cc
index 067f384..705f74f 100644
--- a/webkit/compositor_bindings/web_compositor_support_impl.cc
+++ b/webkit/compositor_bindings/web_compositor_support_impl.cc
@@ -80,22 +80,6 @@ void WebCompositorSupportImpl::shutdown() {
impl_thread_message_loop_proxy_ = NULL;
}
-WebLayerTreeView* WebCompositorSupportImpl::createLayerTreeView(
- WebLayerTreeViewClient* client, const WebLayer& root,
- const WebLayerTreeView::Settings& settings) {
- DCHECK(initialized_);
- scoped_ptr<WebKit::WebLayerTreeViewImpl> layerTreeViewImpl(
- new WebKit::WebLayerTreeViewImpl(client));
- scoped_ptr<cc::Thread> impl_thread;
- if (impl_thread_message_loop_proxy_)
- impl_thread = cc::ThreadImpl::createForDifferentThread(
- impl_thread_message_loop_proxy_);
- if (!layerTreeViewImpl->initialize(settings, impl_thread.Pass()))
- return NULL;
- layerTreeViewImpl->setRootLayer(root);
- return layerTreeViewImpl.release();
-}
-
WebKit::WebCompositorOutputSurface*
WebCompositorSupportImpl::createOutputSurfaceFor3D(
WebKit::WebGraphicsContext3D* context) {
@@ -171,4 +155,20 @@ WebTransformOperations* WebCompositorSupportImpl::createTransformOperations() {
return new WebTransformOperationsImpl();
}
+WebLayerTreeView* WebCompositorSupportImpl::createLayerTreeView(
+ WebLayerTreeViewClient* client, const WebLayer& root,
+ const WebLayerTreeView::Settings& settings) {
+ DCHECK(initialized_);
+ scoped_ptr<WebKit::WebLayerTreeViewImpl> layerTreeViewImpl(
+ new WebKit::WebLayerTreeViewImpl(client));
+ scoped_ptr<cc::Thread> impl_thread;
+ if (impl_thread_message_loop_proxy_)
+ impl_thread = cc::ThreadImpl::createForDifferentThread(
+ impl_thread_message_loop_proxy_);
+ if (!layerTreeViewImpl->initialize(settings, impl_thread.Pass()))
+ return NULL;
+ layerTreeViewImpl->setRootLayer(root);
+ return layerTreeViewImpl.release();
+}
+
} // namespace webkit
diff --git a/webkit/compositor_bindings/web_compositor_support_impl.h b/webkit/compositor_bindings/web_compositor_support_impl.h
index d964613..1765b0f 100644
--- a/webkit/compositor_bindings/web_compositor_support_impl.h
+++ b/webkit/compositor_bindings/web_compositor_support_impl.h
@@ -29,9 +29,6 @@ class WebCompositorSupportImpl : public WebKit::WebCompositorSupport {
virtual void initialize(WebKit::WebThread* implThread);
virtual bool isThreadingEnabled();
virtual void shutdown();
- virtual WebKit::WebLayerTreeView* createLayerTreeView(
- WebKit::WebLayerTreeViewClient* client, const WebKit::WebLayer& root,
- const WebKit::WebLayerTreeView::Settings& settings);
virtual WebKit::WebCompositorOutputSurface* createOutputSurfaceFor3D(
WebKit::WebGraphicsContext3D* context);
virtual WebKit::WebCompositorOutputSurface* createOutputSurfaceForSoftware();
@@ -62,6 +59,9 @@ class WebCompositorSupportImpl : public WebKit::WebCompositorSupport {
virtual WebKit::WebTransformOperations*
createTransformOperations();
+ virtual WebKit::WebLayerTreeView* createLayerTreeView(
+ WebKit::WebLayerTreeViewClient* client, const WebKit::WebLayer& root,
+ const WebKit::WebLayerTreeView::Settings& settings);
private:
scoped_refptr<base::MessageLoopProxy> impl_thread_message_loop_proxy_;
bool initialized_;
diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc b/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc
new file mode 100644
index 0000000..41e089f
--- /dev/null
+++ b/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc
@@ -0,0 +1,187 @@
+// 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/compositor_bindings/web_layer_tree_view_impl_for_testing.h"
+
+#include "base/command_line.h"
+#include "base/string_number_conversions.h"
+#include "cc/fake_web_graphics_context_3d.h"
+#include "cc/font_atlas.h"
+#include "cc/input_handler.h"
+#include "cc/layer.h"
+#include "cc/layer_tree_host.h"
+#include "cc/switches.h"
+#include "cc/thread.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandler.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewClient.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
+#include "webkit/compositor_bindings/web_compositor_support_output_surface.h"
+#include "webkit/compositor_bindings/web_layer_impl.h"
+#include "webkit/compositor_bindings/web_rendering_stats_impl.h"
+#include "webkit/compositor_bindings/web_to_ccinput_handler_adapter.h"
+
+namespace WebKit {
+
+WebLayerTreeViewImplForTesting::WebLayerTreeViewImplForTesting() {}
+
+WebLayerTreeViewImplForTesting::~WebLayerTreeViewImplForTesting() {}
+
+bool WebLayerTreeViewImplForTesting::initialize() {
+ layer_tree_host_ = cc::LayerTreeHost::create(this, cc::LayerTreeSettings(),
+ scoped_ptr<cc::Thread>());
+ if (!layer_tree_host_.get())
+ return false;
+ return true;
+}
+
+void WebLayerTreeViewImplForTesting::setSurfaceReady() {
+ layer_tree_host_->setSurfaceReady();
+}
+
+void WebLayerTreeViewImplForTesting::setRootLayer(const WebLayer& root) {
+ layer_tree_host_->setRootLayer(
+ static_cast<const WebLayerImpl*>(&root)->layer());
+}
+
+void WebLayerTreeViewImplForTesting::clearRootLayer() {
+ layer_tree_host_->setRootLayer(scoped_refptr<cc::Layer>());
+}
+
+void WebLayerTreeViewImplForTesting::setViewportSize(
+ const WebSize& layout_viewport_size, const WebSize& device_viewport_size) {
+ layer_tree_host_->setViewportSize(layout_viewport_size, device_viewport_size);
+}
+
+WebSize WebLayerTreeViewImplForTesting::layoutViewportSize() const {
+ return layer_tree_host_->layoutViewportSize();
+}
+
+WebSize WebLayerTreeViewImplForTesting::deviceViewportSize() const {
+ return layer_tree_host_->deviceViewportSize();
+}
+
+void WebLayerTreeViewImplForTesting::setDeviceScaleFactor(
+ float device_scale_factor) {
+ layer_tree_host_->setDeviceScaleFactor(device_scale_factor);
+}
+
+float WebLayerTreeViewImplForTesting::deviceScaleFactor() const {
+ return layer_tree_host_->deviceScaleFactor();
+}
+
+void WebLayerTreeViewImplForTesting::setBackgroundColor(WebColor color) {
+ layer_tree_host_->setBackgroundColor(color);
+}
+
+void WebLayerTreeViewImplForTesting::setHasTransparentBackground(
+ bool transparent) {
+ layer_tree_host_->setHasTransparentBackground(transparent);
+}
+
+void WebLayerTreeViewImplForTesting::setVisible(bool visible) {
+ layer_tree_host_->setVisible(visible);
+}
+
+void WebLayerTreeViewImplForTesting::setPageScaleFactorAndLimits(
+ float page_scale_factor, float minimum, float maximum) {
+ layer_tree_host_->setPageScaleFactorAndLimits(page_scale_factor, minimum,
+ maximum);
+}
+
+void WebLayerTreeViewImplForTesting::startPageScaleAnimation(
+ const WebPoint& scroll, bool use_anchor, float new_page_scale,
+ double duration_sec) {
+}
+
+void WebLayerTreeViewImplForTesting::setNeedsAnimate() {
+ layer_tree_host_->setNeedsAnimate();
+}
+
+void WebLayerTreeViewImplForTesting::setNeedsRedraw() {
+ layer_tree_host_->setNeedsRedraw();
+}
+
+bool WebLayerTreeViewImplForTesting::commitRequested() const {
+ return layer_tree_host_->commitRequested();
+}
+
+void WebLayerTreeViewImplForTesting::composite() {
+ layer_tree_host_->composite();
+}
+
+void WebLayerTreeViewImplForTesting::updateAnimations(
+ double frame_begin_timeSeconds) {
+ base::TimeTicks frame_begin_time = base::TimeTicks::FromInternalValue(
+ frame_begin_timeSeconds * base::Time::kMicrosecondsPerMillisecond);
+ layer_tree_host_->updateAnimations(frame_begin_time);
+}
+
+void WebLayerTreeViewImplForTesting::didStopFlinging() {
+}
+
+bool WebLayerTreeViewImplForTesting::compositeAndReadback(void* pixels,
+ const WebRect& rect) {
+ return layer_tree_host_->compositeAndReadback(pixels, rect);
+}
+
+void WebLayerTreeViewImplForTesting::finishAllRendering() {
+ layer_tree_host_->finishAllRendering();
+}
+
+void WebLayerTreeViewImplForTesting::setDeferCommits(bool defer_commits) {
+ layer_tree_host_->setDeferCommits(defer_commits);
+}
+
+void WebLayerTreeViewImplForTesting::renderingStats(WebRenderingStats&) const {
+}
+
+void WebLayerTreeViewImplForTesting::willBeginFrame() {
+}
+
+void WebLayerTreeViewImplForTesting::didBeginFrame() {
+}
+
+void WebLayerTreeViewImplForTesting::animate(
+ double monotonic_frame_begin_time) { }
+
+void WebLayerTreeViewImplForTesting::layout() { }
+
+void WebLayerTreeViewImplForTesting::applyScrollAndScale(
+ gfx::Vector2d scroll_delta, float page_scale) {
+}
+
+scoped_ptr<cc::OutputSurface>
+ WebLayerTreeViewImplForTesting::createOutputSurface() {
+ scoped_ptr<WebGraphicsContext3D> context3d(
+ new cc::FakeWebGraphicsContext3D);
+ return webkit::WebCompositorSupportOutputSurface::Create3d(
+ context3d.Pass()).PassAs<cc::OutputSurface>();
+}
+
+void WebLayerTreeViewImplForTesting::didRecreateOutputSurface(bool success) { }
+
+scoped_ptr<cc::InputHandler>
+ WebLayerTreeViewImplForTesting::createInputHandler() {
+ return scoped_ptr<cc::InputHandler>();
+}
+
+void WebLayerTreeViewImplForTesting::willCommit() { }
+
+void WebLayerTreeViewImplForTesting::didCommit() { }
+
+void WebLayerTreeViewImplForTesting::didCommitAndDrawFrame() { }
+
+void WebLayerTreeViewImplForTesting::didCompleteSwapBuffers() { }
+
+void WebLayerTreeViewImplForTesting::scheduleComposite() { }
+
+scoped_ptr<cc::FontAtlas> WebLayerTreeViewImplForTesting::createFontAtlas() {
+ return scoped_ptr<cc::FontAtlas>();
+}
+
+} // namespace WebKit
diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h b/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h
new file mode 100644
index 0000000..72d39b2
--- /dev/null
+++ b/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h
@@ -0,0 +1,84 @@
+// 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_COMPOSITOR_BINDINGS_WEB_LAYER_TREE_VIEW_IMPL_FOR_TESTING_H_
+#define WEBKIT_COMPOSITOR_BINDINGS_WEB_LAYER_TREE_VIEW_IMPL_FOR_TESTING_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "cc/layer_tree_host_client.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h"
+#include "webkit/compositor_bindings/webkit_compositor_bindings_export.h"
+
+namespace cc {
+class FontAtlas;
+class LayerTreeHost;
+}
+
+namespace WebKit {
+class WebLayer;
+class WebLayerTreeViewClient;
+class WebLayerTreeViewClientAdapter;
+
+class WebLayerTreeViewImplForTesting : public WebKit::WebLayerTreeView,
+ public cc::LayerTreeHostClient {
+ public:
+ WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebLayerTreeViewImplForTesting();
+ virtual ~WebLayerTreeViewImplForTesting();
+
+ WEBKIT_COMPOSITOR_BINDINGS_EXPORT bool initialize();
+
+ // WebLayerTreeView implementation.
+ virtual void setSurfaceReady();
+ virtual void setRootLayer(const WebLayer&);
+ virtual void clearRootLayer();
+ virtual void setViewportSize(const WebSize& layout_viewport_size,
+ const WebSize& device_viewport_size);
+ virtual WebSize layoutViewportSize() const;
+ virtual WebSize deviceViewportSize() const;
+ virtual void setDeviceScaleFactor(float);
+ virtual float deviceScaleFactor() const;
+ virtual void setBackgroundColor(WebColor);
+ virtual void setHasTransparentBackground(bool);
+ virtual void setVisible(bool);
+ virtual void setPageScaleFactorAndLimits(float page_scale_factor,
+ float minimum,
+ float maximum);
+ virtual void startPageScaleAnimation(const WebPoint& destination,
+ bool use_anchor, float new_page_scale,
+ double duration_sec);
+ virtual void setNeedsAnimate();
+ virtual void setNeedsRedraw();
+ virtual bool commitRequested() const;
+ virtual void composite();
+ virtual void updateAnimations(double frame_begin_time);
+ virtual void didStopFlinging();
+ virtual bool compositeAndReadback(void* pixels, const WebRect&);
+ virtual void finishAllRendering();
+ virtual void setDeferCommits(bool defer_commits);
+ virtual void renderingStats(WebRenderingStats&) const;
+
+ // cc::LayerTreeHostClient implementation.
+ virtual void willBeginFrame() OVERRIDE;
+ virtual void didBeginFrame() OVERRIDE;
+ virtual void animate(double monotonic_frame_begin_time) OVERRIDE;
+ virtual void layout() OVERRIDE;
+ virtual void applyScrollAndScale(gfx::Vector2d scroll_delta, float page_scale)
+ OVERRIDE;
+ virtual scoped_ptr<cc::OutputSurface> createOutputSurface() OVERRIDE;
+ virtual void didRecreateOutputSurface(bool success) OVERRIDE;
+ virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE;
+ virtual void willCommit() OVERRIDE;
+ virtual void didCommit() OVERRIDE;
+ virtual void didCommitAndDrawFrame() OVERRIDE;
+ virtual void didCompleteSwapBuffers() OVERRIDE;
+ virtual void scheduleComposite() OVERRIDE;
+ virtual scoped_ptr<cc::FontAtlas> createFontAtlas();
+
+ private:
+ scoped_ptr<cc::LayerTreeHost> layer_tree_host_;
+};
+
+} // namespace Web_kit
+
+#endif // WEBKIT_COMPOSITOR_BINDINGS_WEB_LAYER_TREE_VIEW_IMPL_FOR_TESTING_H_
diff --git a/webkit/support/test_webkit_platform_support.cc b/webkit/support/test_webkit_platform_support.cc
index c4ea206..e9f1961 100644
--- a/webkit/support/test_webkit_platform_support.cc
+++ b/webkit/support/test_webkit_platform_support.cc
@@ -31,6 +31,7 @@
#include "third_party/hyphen/hyphen.h"
#include "v8/include/v8.h"
#include "webkit/appcache/web_application_cache_host_impl.h"
+#include "webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h"
#include "webkit/database/vfs_backend.h"
#include "webkit/glue/simple_webmimeregistry_impl.h"
#include "webkit/glue/webclipboard_impl.h"
@@ -648,3 +649,17 @@ WebKit::WebString TestWebKitPlatformSupport::webKitRootDir() {
return webkit_support::GetWebKitRootDir();
}
+#if HAVE_CREATELAYERTREEVIEWFORTESTING
+WebKit::WebLayerTreeView*
+ TestWebKitPlatformSupport::createLayerTreeViewForTesting(
+ TestViewType type) {
+ // TODO(jamesr): Support TestViewTypeLayoutTest.
+ DCHECK_EQ(TestViewTypeUnitTest, type);
+ scoped_ptr<WebKit::WebLayerTreeViewImplForTesting> view(
+ new WebKit::WebLayerTreeViewImplForTesting);
+ if (!view->initialize())
+ return NULL;
+ return view.release();
+}
+#endif
+
diff --git a/webkit/support/test_webkit_platform_support.h b/webkit/support/test_webkit_platform_support.h
index 8bf4f5a..ac824f2 100644
--- a/webkit/support/test_webkit_platform_support.h
+++ b/webkit/support/test_webkit_platform_support.h
@@ -27,7 +27,8 @@
class TestShellWebBlobRegistryImpl;
namespace WebKit {
- class WebAudioDevice;
+class WebAudioDevice;
+class WebLayerTreeView;
}
typedef struct _HyphenDict HyphenDict;
@@ -159,6 +160,10 @@ class TestWebKitPlatformSupport :
virtual void unregisterAllMockedURLs();
virtual void serveAsynchronousMockedRequests();
virtual WebKit::WebString webKitRootDir();
+#if HAVE_CREATELAYERTREEVIEWFORTESTING
+ virtual WebKit::WebLayerTreeView* createLayerTreeViewForTesting(
+ TestViewType type);
+#endif
private:
TestShellWebMimeRegistryImpl mime_registry_;
diff --git a/webkit/support/webkit_support.gypi b/webkit/support/webkit_support.gypi
index a15b168..b3be7fa 100644
--- a/webkit/support/webkit_support.gypi
+++ b/webkit/support/webkit_support.gypi
@@ -23,6 +23,7 @@
'<(DEPTH)/ui/gl/gl.gyp:gl',
'<(DEPTH)/ui/ui.gyp:shell_dialogs',
'<(DEPTH)/ui/ui.gyp:ui',
+ '<(DEPTH)/webkit/compositor_bindings/compositor_bindings.gyp:webkit_compositor_bindings',
'glue',
'user_agent',
'webkit_base',