diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-07 21:43:16 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-07 21:43:16 +0000 |
commit | a46f329337fb3568d73453a28e23124933b8fda7 (patch) | |
tree | ff3f80e9527604104b6b47341ba89c0ebef870ba /cc | |
parent | f850763f96d4b98b4ebf8fa0270b3ac77da169e7 (diff) | |
download | chromium_src-a46f329337fb3568d73453a28e23124933b8fda7.zip chromium_src-a46f329337fb3568d73453a28e23124933b8fda7.tar.gz chromium_src-a46f329337fb3568d73453a28e23124933b8fda7.tar.bz2 |
cc: Move WebCompositorOutputSurface and related classes into cc/
This moves:
- WebKit::WebCompositorOutputSurface to cc::OutputSurface
- WebKit::WebCompositorOutputSurfaceClient to cc::OutputSurfaceClient
- Webkit::WebCompositorSoftwareOutputDevice to cc::SoftwareOutputDevice
They become new files in cc/ so they are chromified style. This affects
the various call-sites. This allows us to pass cc::CompositorFrame
directly, without any need for WebCompositorFrame.
BUG=146080
Depends on: https://bugs.webkit.org/show_bug.cgi?id=103967
Review URL: https://codereview.chromium.org/11348371
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171847 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
41 files changed, 425 insertions, 308 deletions
@@ -7,6 +7,8 @@ include_rules = [ "+ui/gfx", "+ui/gl", # TODO(danakj): Drop dependencies on WebKit Platform API from cc. + "+third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurface.h", "+third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h", "+third_party/WebKit/Source/Platform/chromium/public/WebGraphicsMemoryAllocation.h", + "+third_party/WebKit/Source/Platform/chromium/public/WebImage.h", ] diff --git a/cc/active_animation_unittest.cc b/cc/active_animation_unittest.cc index 2e7a959..58961a7 100644 --- a/cc/active_animation_unittest.cc +++ b/cc/active_animation_unittest.cc @@ -8,8 +8,6 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -using namespace WebKitTests; - namespace cc { namespace { @@ -118,6 +118,7 @@ 'occlusion_tracker.cc', 'occlusion_tracker.h', 'output_surface.h', + 'output_surface_client.h', 'overdraw_metrics.cc', 'overdraw_metrics.h', 'page_scale_animation.cc', @@ -212,6 +213,7 @@ 'single_thread_proxy.h', 'skpicture_content_layer_updater.cc', 'skpicture_content_layer_updater.h', + 'software_output_device.h', 'software_renderer.cc', 'software_renderer.h', 'solid_color_draw_quad.cc', diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index 1c735f4..1781533 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -79,8 +79,10 @@ 'test/fake_proxy.cc', 'test/fake_proxy.h', 'test/fake_tile_manager_client.h', - 'test/fake_web_compositor_output_surface.h', - 'test/fake_web_compositor_software_output_device.h', + 'test/fake_output_surface.cc', + 'test/fake_output_surface.h', + 'test/fake_software_output_device.cc', + 'test/fake_software_output_device.h', 'test/fake_web_graphics_context_3d.h', 'test/fake_web_scrollbar_theme_geometry.h', 'test/geometry_test_utils.cc', diff --git a/cc/delegated_renderer_layer_impl_unittest.cc b/cc/delegated_renderer_layer_impl_unittest.cc index 08ca76c..70dd2f5 100644 --- a/cc/delegated_renderer_layer_impl_unittest.cc +++ b/cc/delegated_renderer_layer_impl_unittest.cc @@ -15,7 +15,6 @@ #include "cc/test/fake_layer_tree_host_impl.h" #include "cc/test/fake_output_surface.h" #include "cc/test/fake_proxy.h" -#include "cc/test/fake_web_compositor_output_surface.h" #include "cc/test/fake_web_graphics_context_3d.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/mock_quad_culler.h" @@ -23,7 +22,6 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/transform.h" -using WebKit::FakeWebCompositorOutputSurface; using WebKit::FakeWebGraphicsContext3D; using namespace WebKitTests; diff --git a/cc/gl_renderer_unittest.cc b/cc/gl_renderer_unittest.cc index 909ca59..e4dcc54 100644 --- a/cc/gl_renderer_unittest.cc +++ b/cc/gl_renderer_unittest.cc @@ -9,7 +9,7 @@ #include "cc/resource_provider.h" #include "cc/test/fake_impl_proxy.h" #include "cc/test/fake_layer_tree_host_impl.h" -#include "cc/test/fake_web_compositor_output_surface.h" +#include "cc/test/fake_output_surface.h" #include "cc/test/fake_web_graphics_context_3d.h" #include "cc/test/render_pass_test_common.h" #include "testing/gmock/include/gmock/gmock.h" @@ -123,7 +123,7 @@ protected: GLRendererTest() : m_suggestHaveBackbufferYes(1, true) , m_suggestHaveBackbufferNo(1, false) - , m_context(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FrameCountingMemoryAllocationSettingContext()))) + , m_context(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FrameCountingMemoryAllocationSettingContext()))) , m_resourceProvider(ResourceProvider::create(m_context.get())) , m_renderer(&m_mockClient, m_resourceProvider.get()) { @@ -139,7 +139,7 @@ protected: m_renderer.swapBuffers(); } - FrameCountingMemoryAllocationSettingContext* context() { return static_cast<FrameCountingMemoryAllocationSettingContext*>(m_context->context3D()); } + FrameCountingMemoryAllocationSettingContext* context() { return static_cast<FrameCountingMemoryAllocationSettingContext*>(m_context->Context3D()); } WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes; WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo; @@ -305,7 +305,7 @@ public: TEST(GLRendererTest2, initializationDoesNotMakeSynchronousCalls) { FakeRendererClient mockClient; - scoped_ptr<OutputSurface> context(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ForbidSynchronousCallContext))); + scoped_ptr<OutputSurface> context(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ForbidSynchronousCallContext))); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get())); FakeRendererGL renderer(&mockClient, resourceProvider.get()); @@ -348,7 +348,7 @@ private: TEST(GLRendererTest2, initializationWithQuicklyLostContextDoesNotAssert) { FakeRendererClient mockClient; - scoped_ptr<OutputSurface> context(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new LoseContextOnFirstGetContext))); + scoped_ptr<OutputSurface> context(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new LoseContextOnFirstGetContext))); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get())); FakeRendererGL renderer(&mockClient, resourceProvider.get()); @@ -370,7 +370,7 @@ public: TEST(GLRendererTest2, initializationWithoutGpuMemoryManagerExtensionSupportShouldDefaultToNonZeroAllocation) { FakeRendererClient mockClient; - scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ContextThatDoesNotSupportMemoryManagmentExtensions))); + scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ContextThatDoesNotSupportMemoryManagmentExtensions))); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); FakeRendererGL renderer(&mockClient, resourceProvider.get()); @@ -397,8 +397,8 @@ private: TEST(GLRendererTest2, opaqueBackground) { FakeRendererClient mockClient; - scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); - ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->context3D()); + scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); + ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->Context3D()); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); FakeRendererGL renderer(&mockClient, resourceProvider.get()); @@ -420,8 +420,8 @@ TEST(GLRendererTest2, opaqueBackground) TEST(GLRendererTest2, transparentBackground) { FakeRendererClient mockClient; - scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); - ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->context3D()); + scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); + ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->Context3D()); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); FakeRendererGL renderer(&mockClient, resourceProvider.get()); @@ -471,8 +471,8 @@ private: TEST(GLRendererTest2, visibilityChangeIsLastCall) { FakeRendererClient mockClient; - scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new VisibilityChangeIsLastCallTrackingContext))); - VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityChangeIsLastCallTrackingContext*>(outputSurface->context3D()); + scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new VisibilityChangeIsLastCallTrackingContext))); + VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityChangeIsLastCallTrackingContext*>(outputSurface->Context3D()); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); FakeRendererGL renderer(&mockClient, resourceProvider.get()); @@ -523,8 +523,8 @@ private: TEST(GLRendererTest2, activeTextureState) { FakeRendererClient fakeClient; - scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); - TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->context3D()); + scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); + TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->Context3D()); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); FakeRendererGL renderer(&fakeClient, resourceProvider.get()); diff --git a/cc/heads_up_display_unittest.cc b/cc/heads_up_display_unittest.cc index 9fb133a..1bbdbf2 100644 --- a/cc/heads_up_display_unittest.cc +++ b/cc/heads_up_display_unittest.cc @@ -7,8 +7,6 @@ #include "cc/layer_tree_host.h" #include "cc/test/layer_tree_test_common.h" -using namespace WebKitTests; - namespace cc { namespace { diff --git a/cc/io_surface_layer_impl.cc b/cc/io_surface_layer_impl.cc index f600721..0ab1221 100644 --- a/cc/io_surface_layer_impl.cc +++ b/cc/io_surface_layer_impl.cc @@ -31,7 +31,7 @@ IOSurfaceLayerImpl::~IOSurfaceLayerImpl() OutputSurface* outputSurface = layerTreeHostImpl()->outputSurface(); // FIXME: Implement this path for software compositing. - WebKit::WebGraphicsContext3D* context3d = outputSurface->context3D(); + WebKit::WebGraphicsContext3D* context3d = outputSurface->Context3D(); if (context3d) context3d->deleteTexture(m_ioSurfaceTextureId); } diff --git a/cc/layer_animation_controller_unittest.cc b/cc/layer_animation_controller_unittest.cc index 0310663..88ccd16 100644 --- a/cc/layer_animation_controller_unittest.cc +++ b/cc/layer_animation_controller_unittest.cc @@ -11,8 +11,6 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/transform.h" -using namespace WebKitTests; - namespace cc { namespace { diff --git a/cc/layer_tree_host_client.h b/cc/layer_tree_host_client.h index ad28443..6657f59 100644 --- a/cc/layer_tree_host_client.h +++ b/cc/layer_tree_host_client.h @@ -11,13 +11,10 @@ namespace gfx { class Vector2d; } -namespace WebKit { -class WebCompositorOutputSurface; -} - namespace cc { class FontAtlas; class InputHandler; +class OutputSurface; class LayerTreeHostClient { public: @@ -27,7 +24,7 @@ public: virtual void animate(double frameBeginTime) = 0; virtual void layout() = 0; virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale) = 0; - virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() = 0; + virtual scoped_ptr<OutputSurface> createOutputSurface() = 0; virtual void didRecreateOutputSurface(bool success) = 0; virtual scoped_ptr<InputHandler> createInputHandler() = 0; virtual void willCommit() = 0; diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index ec45331..d9a2a08 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -793,16 +793,19 @@ void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy m_client->setNeedsCommitOnImplThread(); } -void LayerTreeHostImpl::onVSyncParametersChanged(double monotonicTimebase, double intervalInSeconds) +void LayerTreeHostImpl::OnVSyncParametersChanged(base::TimeTicks timebase, base::TimeDelta interval) { - base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimebase * base::Time::kMicrosecondsPerSecond); - base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSeconds * base::Time::kMicrosecondsPerSecond); m_client->onVSyncParametersChanged(timebase, interval); } +void LayerTreeHostImpl::OnSendFrameToParentCompositorAck(const CompositorFrameAck&) +{ + // TODO(danakj): Implement this. +} + void LayerTreeHostImpl::OnCanDrawStateChangedForTree(LayerTreeImpl*) { - m_client->onCanDrawStateChanged(canDraw()); + m_client->onCanDrawStateChanged(canDraw()); } void LayerTreeHostImpl::drawLayers(FrameData& frame) @@ -958,7 +961,7 @@ bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<OutputSurface> outputSurfa m_resourceProvider.reset(); m_outputSurface.reset(); - if (!outputSurface->bindToClient(this)) + if (!outputSurface->BindToClient(this)) return false; scoped_ptr<ResourceProvider> resourceProvider = ResourceProvider::create(outputSurface.get()); @@ -968,10 +971,10 @@ bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<OutputSurface> outputSurfa if (m_settings.implSidePainting) m_tileManager.reset(new TileManager(this, resourceProvider.get(), m_settings.numRasterThreads)); - if (outputSurface->context3D()) + if (outputSurface->Context3D()) m_renderer = GLRenderer::create(this, resourceProvider.get()); - else if (outputSurface->softwareDevice()) - m_renderer = SoftwareRenderer::create(this, resourceProvider.get(), outputSurface->softwareDevice()); + else if (outputSurface->SoftwareDevice()) + m_renderer = SoftwareRenderer::create(this, resourceProvider.get(), outputSurface->SoftwareDevice()); if (!m_renderer) return false; diff --git a/cc/layer_tree_host_impl.h b/cc/layer_tree_host_impl.h index 5328230..891d3e11 100644 --- a/cc/layer_tree_host_impl.h +++ b/cc/layer_tree_host_impl.h @@ -13,13 +13,13 @@ #include "cc/cc_export.h" #include "cc/input_handler.h" #include "cc/layer_tree_impl.h" +#include "cc/output_surface_client.h" #include "cc/render_pass.h" #include "cc/render_pass_sink.h" #include "cc/renderer.h" #include "cc/tile_manager.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/rect.h" -#include <public/WebCompositorOutputSurfaceClient.h> namespace cc { @@ -115,7 +115,7 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, public TileManagerClient, public LayerTreeImplClient, public AnimationRegistrar, - public NON_EXPORTED_BASE(WebKit::WebCompositorOutputSurfaceClient) { + public OutputSurfaceClient { typedef std::vector<LayerImpl*> LayerList; typedef base::hash_set<LayerAnimationController*> AnimationControllerSet; @@ -179,8 +179,9 @@ public: virtual void ScheduleManageTiles() OVERRIDE; virtual void ScheduleCheckForCompletedSetPixels() OVERRIDE; - // WebCompositorOutputSurfaceClient implementation. - virtual void onVSyncParametersChanged(double monotonicTimebase, double intervalInSeconds) OVERRIDE; + // OutputSurfaceClient implementation. + virtual void OnVSyncParametersChanged(base::TimeTicks timebase, base::TimeDelta interval) OVERRIDE; + virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck&) OVERRIDE; // LayerTreeImplClient implementation. virtual void OnCanDrawStateChangedForTree(LayerTreeImpl*) OVERRIDE; diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc index 9cc385f..965cfb9 100644 --- a/cc/layer_tree_host_impl_unittest.cc +++ b/cc/layer_tree_host_impl_unittest.cc @@ -23,8 +23,8 @@ #include "cc/single_thread_proxy.h" #include "cc/solid_color_draw_quad.h" #include "cc/test/animation_test_common.h" +#include "cc/test/fake_output_surface.h" #include "cc/test/fake_proxy.h" -#include "cc/test/fake_web_compositor_output_surface.h" #include "cc/test/fake_web_graphics_context_3d.h" #include "cc/test/fake_web_scrollbar_theme_geometry.h" #include "cc/test/geometry_test_utils.h" @@ -209,7 +209,7 @@ public: protected: scoped_ptr<OutputSurface> createOutputSurface() { - return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<OutputSurface>(); + return FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<OutputSurface>(); } FakeProxy m_proxy; @@ -378,7 +378,7 @@ TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer) m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); // Initialization will fail here. - m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<OutputSurface>()); + m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<OutputSurface>()); m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); setupScrollAndContentsLayers(gfx::Size(100, 100)); @@ -1999,8 +1999,8 @@ protected: // viewport size is never set. TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) { - scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurface>(); - ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(outputSurface->context3D()); + scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurface>(); + ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(outputSurface->Context3D()); m_hostImpl->initializeRenderer(outputSurface.Pass()); scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl.get(), 1); @@ -2042,8 +2042,8 @@ private: // where it should request to swap only the subBuffer that is damaged. TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) { - scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).PassAs<OutputSurface>(); - PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrackerContext*>(outputSurface->context3D()); + scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).PassAs<OutputSurface>(); + PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrackerContext*>(outputSurface->Context3D()); // This test creates its own LayerTreeHostImpl, so // that we can force partial swap enabled. @@ -2257,8 +2257,8 @@ public: TEST_P(LayerTreeHostImplTest, noPartialSwap) { - scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); - MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3D()); + scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); + MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3D()); MockContextHarness harness(mockContext); // Run test case @@ -2291,8 +2291,8 @@ TEST_P(LayerTreeHostImplTest, noPartialSwap) TEST_P(LayerTreeHostImplTest, partialSwap) { - scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); - MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3D()); + scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); + MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3D()); MockContextHarness harness(mockContext); createLayerTreeHost(true, outputSurface.Pass()); @@ -2348,7 +2348,7 @@ public: static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, LayerTreeHostImplClient* client, Proxy* proxy) { - scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); + scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); LayerTreeSettings settings; settings.partialSwapEnabled = partialSwap; @@ -2504,7 +2504,7 @@ TEST_P(LayerTreeHostImplTest, finishAllRenderingAfterContextLost) m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); // The context initialization will fail, but we should still be able to call finishAllRendering() without any ill effects. - m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<OutputSurface>()); + m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<OutputSurface>()); m_hostImpl->finishAllRendering(); } @@ -2542,14 +2542,14 @@ TEST_P(LayerTreeHostImplTest, context3DLostDuringInitialize) for (unsigned i = 0; i < kMakeCurrentSuccessesNeededForSuccessfulInitialization; ++i) { // The context will get lost during initialization, we shouldn't crash. We // should also be in a consistent state. - EXPECT_FALSE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFailsEventually(i))).PassAs<OutputSurface>())); + EXPECT_FALSE(m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFailsEventually(i))).PassAs<OutputSurface>())); EXPECT_EQ(0, m_hostImpl->outputSurface()); EXPECT_EQ(0, m_hostImpl->renderer()); EXPECT_EQ(0, m_hostImpl->resourceProvider()); EXPECT_TRUE(m_hostImpl->initializeRenderer(createOutputSurface())); } - EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFailsEventually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))).PassAs<OutputSurface>())); + EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFailsEventually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))).PassAs<OutputSurface>())); EXPECT_TRUE(m_hostImpl->outputSurface()); EXPECT_TRUE(m_hostImpl->renderer()); EXPECT_TRUE(m_hostImpl->resourceProvider()); @@ -2896,7 +2896,7 @@ TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostOutputSurface) rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); // Use a context that supports IOSurfaces - m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<OutputSurface>()); + m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<OutputSurface>()); FakeVideoFrame hwVideoFrame( VideoFrame::WrapNativeTexture( @@ -2926,7 +2926,7 @@ TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostOutputSurface) // Lose the WebGraphicsContext3D, replacing it with a StrictWebGraphicsContext3DWithIOSurface, // that will warn if any resource from the previous context gets used. - m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface)).PassAs<OutputSurface>()); + m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface)).PassAs<OutputSurface>()); // Create dummy resources so that looking up an old resource will get an // invalid texture id mapping. @@ -3043,8 +3043,8 @@ TEST_P(LayerTreeHostImplTest, layersFreeTextures) rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); // Lose the WebGraphicsContext3D, replacing it with a TrackingWebGraphicsContext3D (which the LayerTreeHostImpl takes ownership of). - scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))); - TrackingWebGraphicsContext3D* trackingWebGraphicsContext3D = static_cast<TrackingWebGraphicsContext3D*>(outputSurface->context3D()); + scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))); + TrackingWebGraphicsContext3D* trackingWebGraphicsContext3D = static_cast<TrackingWebGraphicsContext3D*>(outputSurface->Context3D()); m_hostImpl->initializeRenderer(outputSurface.Pass()); m_hostImpl->setRootLayer(rootLayer.Pass()); @@ -3071,8 +3071,8 @@ public: TEST_P(LayerTreeHostImplTest, hasTransparentBackground) { - scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs<OutputSurface>(); - MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToFillScreenContext*>(outputSurface->context3D()); + scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs<OutputSurface>(); + MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToFillScreenContext*>(outputSurface->Context3D()); // Run test case createLayerTreeHost(false, outputSurface.Pass()); @@ -3116,7 +3116,7 @@ static void addDrawingLayerTo(LayerImpl* parent, int id, const gfx::Rect& layerR static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, LayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPtr, LayerImpl*& childPtr, const gfx::Size& rootSize) { - scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); + scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); layerTreeHostImpl->setViewportSize(rootSize, rootSize); @@ -3160,7 +3160,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithClipping) LayerImpl* rootPtr; LayerImpl* surfaceLayerPtr; - scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); + scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); gfx::Size rootSize(100, 100); @@ -3271,7 +3271,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion) LayerImpl* layerS1Ptr; LayerImpl* layerS2Ptr; - scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); + scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); gfx::Size rootSize(1000, 1000); @@ -3382,7 +3382,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) LayerImpl* layerS1Ptr; LayerImpl* layerS2Ptr; - scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); + scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); gfx::Size rootSize(1000, 1000); @@ -3494,7 +3494,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) LayerImpl* layerS1Ptr; LayerImpl* layerS2Ptr; - scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); + scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); gfx::Size rootSize(1000, 1000); @@ -3575,7 +3575,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned) LayerImpl* rootPtr; LayerImpl* layerS1Ptr; - scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); + scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); gfx::Size rootSize(1000, 1000); @@ -3659,7 +3659,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) LayerImpl* layerS1Ptr; LayerImpl* layerS2Ptr; - scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); + scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); gfx::Size rootSize(1000, 1000); @@ -3778,7 +3778,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithScissor) gfx::Rect childRect(10, 10, 50, 50); gfx::Rect grandChildRect(5, 5, 150, 150); - scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); + scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>(); myHostImpl->initializeRenderer(outputSurface.Pass()); root->setAnchorPoint(gfx::PointF(0, 0)); @@ -4520,7 +4520,7 @@ static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses) { scoped_ptr<OutputSurface> outputSurface(createOutputSurface()); - ASSERT_TRUE(outputSurface->context3D()); + ASSERT_TRUE(outputSurface->Context3D()); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(), &m_proxy)); diff --git a/cc/layer_tree_host_perftest.cc b/cc/layer_tree_host_perftest.cc index ca7031d..d1cc08c 100644 --- a/cc/layer_tree_host_perftest.cc +++ b/cc/layer_tree_host_perftest.cc @@ -21,7 +21,7 @@ namespace { static const int kTimeLimitMillis = 2000; -class LayerTreeHostPerfTest : public WebKitTests::ThreadedTest { +class LayerTreeHostPerfTest : public ThreadedTest { public: LayerTreeHostPerfTest() : num_draws_(0) { diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc index 7c63259..a1fbce3 100644 --- a/cc/layer_tree_host_unittest.cc +++ b/cc/layer_tree_host_unittest.cc @@ -13,8 +13,8 @@ #include "cc/single_thread_proxy.h" #include "cc/test/fake_content_layer_client.h" #include "cc/test/fake_layer_tree_host_client.h" +#include "cc/test/fake_output_surface.h" #include "cc/test/fake_proxy.h" -#include "cc/test/fake_web_compositor_output_surface.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/layer_tree_test_common.h" #include "cc/test/occlusion_tracker_test_common.h" @@ -1403,7 +1403,7 @@ public: virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { - CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->context3D()); + CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->Context3D()); switch (impl->activeTree()->source_frame_number()) { case 0: @@ -1437,7 +1437,7 @@ public: virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { - CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->context3D()); + CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->Context3D()); // Number of textures used for draw should always be one. EXPECT_EQ(1, context->numUsedTextures()); @@ -1507,7 +1507,7 @@ public: virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { - CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->context3D()); + CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->Context3D()); switch (impl->activeTree()->source_frame_number()) { case 0: @@ -1559,7 +1559,7 @@ public: virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { - CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->context3D()); + CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->Context3D()); // Number of textures used for drawing should two except for frame 4 // where the viewport only contains one layer. @@ -2960,9 +2960,9 @@ public: m_children.push_back(ContentLayerWithUpdateTracking::create(&m_client)); } - virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() + virtual scoped_ptr<OutputSurface> createOutputSurface() { - return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsContext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSurface>(); + return FakeOutputSurface::Create3d(CompositorFakeWebGraphicsContext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); } virtual void beginTest() diff --git a/cc/output_surface.h b/cc/output_surface.h index 9f91c32..3d62f18 100644 --- a/cc/output_surface.h +++ b/cc/output_surface.h @@ -5,7 +5,10 @@ #ifndef CC_OUTPUT_SURFACE_H_ #define CC_OUTPUT_SURFACE_H_ -#include <public/WebCompositorOutputSurface.h> +#define USE_CC_OUTPUT_SURFACE // TODO(danakj): Remove this. + +#include "cc/cc_export.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurface.h" namespace WebKit { class WebGraphicsContext3D; @@ -13,8 +16,47 @@ class WebGraphicsContext3D; namespace cc { -// TODO(danakj): Move WebCompositorOutputSurface implementation to here. -typedef WebKit::WebCompositorOutputSurface OutputSurface; +class CompositorFrame; +class OutputSurfaceClient; +class SoftwareOutputDevice; + +// Represents the output surface for a compositor. The compositor owns +// and manages its destruction. Its lifetime is: +// 1. Created on the main thread by the LayerTreeHost through its client. +// 2. Passed to the compositor thread and bound to a client via BindToClient. +// From here on, it will only be used on the compositor thread. +// 3. If the 3D context is lost, then the compositor will delete the output +// surface (on the compositor thread) and go back to step 1. +class CC_EXPORT OutputSurface : public WebKit::WebCompositorOutputSurface { + public: + virtual ~OutputSurface() {} + + // Called by the compositor on the compositor thread. This is a place where + // thread-specific data for the output surface can be initialized, since from + // this point on the output surface will only be used on the compositor + // thread. + virtual bool BindToClient(OutputSurfaceClient*) = 0; + + struct Capabilities { + Capabilities() + : has_parent_compositor(false) {} + + bool has_parent_compositor; + }; + + virtual const Capabilities& Capabilities() const = 0; + + // Obtain the 3d context or the software device associated with this output + // surface. Either of these may return a null pointer, but not both. + // In the event of a lost context, the entire output surface should be + // recreated. + virtual WebKit::WebGraphicsContext3D* Context3D() const = 0; + virtual SoftwareOutputDevice* SoftwareDevice() const = 0; + + // Sends frame data to the parent compositor. This should only be called when + // capabilities().has_parent_compositor. + virtual void SendFrameToParentCompositor(const CompositorFrame&) {} +}; } // namespace cc diff --git a/cc/output_surface_client.h b/cc/output_surface_client.h new file mode 100644 index 0000000..2c073b4 --- /dev/null +++ b/cc/output_surface_client.h @@ -0,0 +1,27 @@ +// Copyright 2012 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_OUTPUT_SURFACE_CLIENT_H_ +#define CC_OUTPUT_SURFACE_CLIENT_H_ + +#include "base/time.h" +#include "cc/cc_export.h" + +namespace cc { + +class CompositorFrameAck; + +class CC_EXPORT OutputSurfaceClient { + public: + virtual void OnVSyncParametersChanged(base::TimeTicks timebase, + base::TimeDelta interval) = 0; + virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck&) = 0; + + protected: + virtual ~OutputSurfaceClient() {} +}; + +} // namespace cc + +#endif // CC_OUTPUT_SURFACE_CLIENT_H_ @@ -9,7 +9,6 @@ #include "base/logging.h" #include "base/time.h" #include "base/memory/scoped_ptr.h" -#include <public/WebCompositorOutputSurface.h> #include "cc/cc_export.h" namespace gfx { diff --git a/cc/resource_provider.cc b/cc/resource_provider.cc index 956f390..bf6bd8b 100644 --- a/cc/resource_provider.cc +++ b/cc/resource_provider.cc @@ -125,7 +125,7 @@ scoped_ptr<ResourceProvider> ResourceProvider::create(OutputSurface* context) ResourceProvider::~ResourceProvider() { - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); if (!context3d || !context3d->makeContextCurrent()) return; m_textureUploader.reset(); @@ -135,7 +135,7 @@ ResourceProvider::~ResourceProvider() WebGraphicsContext3D* ResourceProvider::graphicsContext3D() { DCHECK(m_threadChecker.CalledOnValidThread()); - return m_outputSurface->context3D(); + return m_outputSurface->Context3D(); } bool ResourceProvider::inUseByConsumer(ResourceId id) @@ -168,7 +168,7 @@ ResourceProvider::ResourceId ResourceProvider::createGLTexture(int pool, const g DCHECK(m_threadChecker.CalledOnValidThread()); unsigned textureId = 0; - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); GLC(context3d, textureId = context3d->createTexture()); GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); @@ -207,7 +207,7 @@ ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture { DCHECK(m_threadChecker.CalledOnValidThread()); - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); @@ -243,17 +243,17 @@ void ResourceProvider::deleteResourceInternal(ResourceMap::iterator it) { Resource* resource = &it->second; if (resource->glId && !resource->external) { - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); GLC(context3d, context3d->deleteTexture(resource->glId)); } if (resource->glUploadQueryId) { - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); GLC(context3d, context3d->deleteQueryEXT(resource->glUploadQueryId)); } if (resource->glPixelBufferId) { - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId)); } @@ -297,7 +297,7 @@ void ResourceProvider::setPixels(ResourceId id, const uint8_t* image, const gfx: DCHECK(!resource->exported); if (resource->glId) { - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); DCHECK(m_textureUploader.get()); context3d->bindTexture(GL_TEXTURE_2D, resource->glId); @@ -360,7 +360,7 @@ void ResourceProvider::flushUploads() void ResourceProvider::flush() { DCHECK(m_threadChecker.CalledOnValidThread()); - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); if (context3d) context3d->flush(); } @@ -368,7 +368,7 @@ void ResourceProvider::flush() bool ResourceProvider::shallowFlushIfSupported() { DCHECK(m_threadChecker.CalledOnValidThread()); - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); if (!context3d || !m_useShallowFlush) return false; @@ -505,7 +505,7 @@ ResourceProvider::ResourceProvider(OutputSurface* context) bool ResourceProvider::initialize() { DCHECK(m_threadChecker.CalledOnValidThread()); - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); if (!context3d) { m_maxTextureSize = INT_MAX / 2; return true; @@ -570,7 +570,7 @@ void ResourceProvider::prepareSendToParent(const ResourceIdArray& resources, Tra DCHECK(m_threadChecker.CalledOnValidThread()); list->sync_point = 0; list->resources.clear(); - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); if (!context3d || !context3d->makeContextCurrent()) { // FIXME: Implement this path for software compositing. return; @@ -591,7 +591,7 @@ void ResourceProvider::prepareSendToChild(int child, const ResourceIdArray& reso DCHECK(m_threadChecker.CalledOnValidThread()); list->sync_point = 0; list->resources.clear(); - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); if (!context3d || !context3d->makeContextCurrent()) { // FIXME: Implement this path for software compositing. return; @@ -615,7 +615,7 @@ void ResourceProvider::prepareSendToChild(int child, const ResourceIdArray& reso void ResourceProvider::receiveFromChild(int child, const TransferableResourceList& resources) { DCHECK(m_threadChecker.CalledOnValidThread()); - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); if (!context3d || !context3d->makeContextCurrent()) { // FIXME: Implement this path for software compositing. return; @@ -647,7 +647,7 @@ void ResourceProvider::receiveFromChild(int child, const TransferableResourceLis void ResourceProvider::receiveFromParent(const TransferableResourceList& resources) { DCHECK(m_threadChecker.CalledOnValidThread()); - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); if (!context3d || !context3d->makeContextCurrent()) { // FIXME: Implement this path for software compositing. return; @@ -671,7 +671,7 @@ void ResourceProvider::receiveFromParent(const TransferableResourceList& resourc bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceId id, TransferableResource* resource) { DCHECK(m_threadChecker.CalledOnValidThread()); - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); ResourceMap::iterator it = m_resources.find(id); CHECK(it != m_resources.end()); Resource* source = &it->second; @@ -707,7 +707,7 @@ void ResourceProvider::acquirePixelBuffer(ResourceId id) DCHECK(!resource->exported); if (resource->glId) { - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); if (!resource->glPixelBufferId) resource->glPixelBufferId = context3d->createBuffer(); @@ -742,7 +742,7 @@ void ResourceProvider::releasePixelBuffer(ResourceId id) if (resource->glId) { DCHECK(resource->glPixelBufferId); - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); context3d->bindBuffer( GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, @@ -773,7 +773,7 @@ uint8_t* ResourceProvider::mapPixelBuffer(ResourceId id) DCHECK(!resource->exported); if (resource->glId) { - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); DCHECK(resource->glPixelBufferId); context3d->bindBuffer( @@ -803,7 +803,7 @@ void ResourceProvider::unmapPixelBuffer(ResourceId id) DCHECK(!resource->exported); if (resource->glId) { - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); DCHECK(resource->glPixelBufferId); context3d->bindBuffer( @@ -827,7 +827,7 @@ void ResourceProvider::setPixelsFromBuffer(ResourceId id) DCHECK(!resource->exported); if (resource->glId) { - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); DCHECK(resource->glPixelBufferId); context3d->bindTexture(GL_TEXTURE_2D, resource->glId); @@ -864,7 +864,7 @@ void ResourceProvider::setPixelsFromBuffer(ResourceId id) void ResourceProvider::bindForSampling(ResourceProvider::ResourceId resourceId, GLenum target, GLenum filter) { DCHECK(m_threadChecker.CalledOnValidThread()); - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); ResourceMap::iterator it = m_resources.find(resourceId); DCHECK(it != m_resources.end()); Resource* resource = &it->second; @@ -890,7 +890,7 @@ void ResourceProvider::beginSetPixels(ResourceId id) lockForWrite(id); if (resource->glId) { - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); DCHECK(resource->glPixelBufferId); context3d->bindTexture(GL_TEXTURE_2D, resource->glId); @@ -930,7 +930,7 @@ bool ResourceProvider::didSetPixelsComplete(ResourceId id) { DCHECK(resource->pendingSetPixels); if (resource->glId) { - WebGraphicsContext3D* context3d = m_outputSurface->context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); DCHECK(resource->glUploadQueryId); unsigned complete = 1; diff --git a/cc/resource_provider_unittest.cc b/cc/resource_provider_unittest.cc index db473d7..56d924b 100644 --- a/cc/resource_provider_unittest.cc +++ b/cc/resource_provider_unittest.cc @@ -9,7 +9,7 @@ #include "cc/scoped_ptr_deque.h" #include "cc/scoped_ptr_hash_map.h" #include "cc/test/compositor_fake_web_graphics_context_3d.h" -#include "cc/test/fake_web_compositor_output_surface.h" +#include "cc/test/fake_output_surface.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h" @@ -272,13 +272,13 @@ class ResourceProviderTest : public testing::TestWithParam<ResourceProvider::Res public: ResourceProviderTest() : m_sharedData(ContextSharedData::create()) - , m_outputSurface(FakeWebCompositorOutputSurface::create(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>().PassAs<WebKit::WebGraphicsContext3D>())) + , m_outputSurface(FakeOutputSurface::Create3d(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>().PassAs<WebKit::WebGraphicsContext3D>())) , m_resourceProvider(ResourceProvider::create(m_outputSurface.get())) { m_resourceProvider->setDefaultResourceType(GetParam()); } - ResourceProviderContext* context() { return static_cast<ResourceProviderContext*>(m_outputSurface->context3D()); } + ResourceProviderContext* context() { return static_cast<ResourceProviderContext*>(m_outputSurface->Context3D()); } void getResourcePixels(ResourceProvider::ResourceId id, const gfx::Size& size, WGC3Denum format, uint8_t* pixels) { @@ -417,7 +417,7 @@ TEST_P(ResourceProviderTest, TransferResources) if (GetParam() != ResourceProvider::GLTexture) return; - scoped_ptr<OutputSurface> childOutputSurface(FakeWebCompositorOutputSurface::create(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>())); + scoped_ptr<OutputSurface> childOutputSurface(FakeOutputSurface::Create3d(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>())); scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::create(childOutputSurface.get())); gfx::Size size(1, 1); @@ -493,7 +493,7 @@ TEST_P(ResourceProviderTest, TransferResources) EXPECT_FALSE(childResourceProvider->inUseByConsumer(id1)); EXPECT_FALSE(childResourceProvider->inUseByConsumer(id2)); - ResourceProviderContext* childContext3D = static_cast<ResourceProviderContext*>(childOutputSurface->context3D()); + ResourceProviderContext* childContext3D = static_cast<ResourceProviderContext*>(childOutputSurface->Context3D()); { ResourceProvider::ScopedReadLockGL lock(childResourceProvider.get(), id1); ASSERT_NE(0U, lock.textureId()); @@ -534,7 +534,7 @@ TEST_P(ResourceProviderTest, DeleteTransferredResources) if (GetParam() != ResourceProvider::GLTexture) return; - scoped_ptr<OutputSurface> childOutputSurface(FakeWebCompositorOutputSurface::create(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>())); + scoped_ptr<OutputSurface> childOutputSurface(FakeOutputSurface::Create3d(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>())); scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::create(childOutputSurface.get())); gfx::Size size(1, 1); @@ -595,8 +595,8 @@ TEST_P(ResourceProviderTest, ScopedSampler) if (GetParam() != ResourceProvider::GLTexture) return; - scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); - TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->context3D()); + scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); + TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->Context3D()); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); gfx::Size size(1, 1); diff --git a/cc/resource_update_controller_unittest.cc b/cc/resource_update_controller_unittest.cc index 4b324b6..3056f6e 100644 --- a/cc/resource_update_controller_unittest.cc +++ b/cc/resource_update_controller_unittest.cc @@ -5,8 +5,8 @@ #include "cc/resource_update_controller.h" #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread +#include "cc/test/fake_output_surface.h" #include "cc/test/fake_proxy.h" -#include "cc/test/fake_web_compositor_output_surface.h" #include "cc/test/fake_web_graphics_context_3d.h" #include "cc/test/scheduler_test_common.h" #include "cc/test/tiled_layer_test_common.h" @@ -121,7 +121,7 @@ public: protected: virtual void SetUp() { - m_outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new WebGraphicsContext3DForUploadTest(this))); + m_outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new WebGraphicsContext3DForUploadTest(this))); m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 300, 150); m_bitmap.allocPixels(); diff --git a/cc/scrollbar_layer_unittest.cc b/cc/scrollbar_layer_unittest.cc index 3aba55d..35bb5eb 100644 --- a/cc/scrollbar_layer_unittest.cc +++ b/cc/scrollbar_layer_unittest.cc @@ -128,7 +128,7 @@ TEST(ScrollbarLayerTest, scrollOffsetSynchronization) EXPECT_EQ(300, ccScrollbarLayer->maximum()); } -class ScrollbarLayerTestMaxTextureSize : public WebKitTests::ThreadedTest { +class ScrollbarLayerTestMaxTextureSize : public ThreadedTest { public: ScrollbarLayerTestMaxTextureSize() {} diff --git a/cc/software_output_device.h b/cc/software_output_device.h new file mode 100644 index 0000000..0581b2b --- /dev/null +++ b/cc/software_output_device.h @@ -0,0 +1,31 @@ +// Copyright 2012 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_SOFTWARE_OUTPUT_DEVICE_H_ +#define CC_SOFTWARE_OUTPUT_DEVICE_H_ + +#include "third_party/WebKit/Source/Platform/chromium/public/WebImage.h" +#include "ui/gfx/size.h" + +namespace cc { + +// This is a "tear-off" class providing software drawing support to +// OutputSurface, such as to a platform-provided window framebuffer. +class SoftwareOutputDevice { + public: + virtual ~SoftwareOutputDevice() {} + + // Lock the framebuffer and return a pointer to a WebImage referring to its + // pixels. Set forWrite if you intend to change the pixels. Readback + // is supported whether or not forWrite is set. + // TODO(danakj): Switch this from WebImage to a Skia type. + virtual WebKit::WebImage* Lock(bool forWrite) = 0; + virtual void Unlock() = 0; + + virtual void DidChangeViewportSize(gfx::Size) = 0; +}; + +} // namespace cc + +#endif // CC_SOFTWARE_OUTPUT_DEVICE_H_ diff --git a/cc/software_renderer.cc b/cc/software_renderer.cc index 1d7ad11..632f335 100644 --- a/cc/software_renderer.cc +++ b/cc/software_renderer.cc @@ -4,14 +4,13 @@ #include "cc/software_renderer.h" -#include <public/WebCompositorSoftwareOutputDevice.h> #include <public/WebImage.h> -#include <public/WebSize.h> #include "base/debug/trace_event.h" #include "cc/debug_border_draw_quad.h" #include "cc/math_util.h" #include "cc/render_pass_draw_quad.h" +#include "cc/software_output_device.h" #include "cc/solid_color_draw_quad.h" #include "cc/texture_draw_quad.h" #include "cc/tile_draw_quad.h" @@ -24,9 +23,6 @@ #include "ui/gfx/skia_util.h" #include "ui/gfx/transform.h" -using WebKit::WebCompositorSoftwareOutputDevice; -using WebKit::WebSize; - namespace cc { namespace { @@ -56,12 +52,12 @@ bool isScaleAndTranslate(const SkMatrix& matrix) } // anonymous namespace -scoped_ptr<SoftwareRenderer> SoftwareRenderer::create(RendererClient* client, ResourceProvider* resourceProvider, WebCompositorSoftwareOutputDevice* outputDevice) +scoped_ptr<SoftwareRenderer> SoftwareRenderer::create(RendererClient* client, ResourceProvider* resourceProvider, SoftwareOutputDevice* outputDevice) { return make_scoped_ptr(new SoftwareRenderer(client, resourceProvider, outputDevice)); } -SoftwareRenderer::SoftwareRenderer(RendererClient* client, ResourceProvider* resourceProvider, WebCompositorSoftwareOutputDevice* outputDevice) +SoftwareRenderer::SoftwareRenderer(RendererClient* client, ResourceProvider* resourceProvider, SoftwareOutputDevice* outputDevice) : DirectRenderer(client, resourceProvider) , m_visible(true) , m_outputDevice(outputDevice) @@ -89,13 +85,13 @@ const RendererCapabilities& SoftwareRenderer::capabilities() const void SoftwareRenderer::viewportChanged() { - m_outputDevice->didChangeViewportSize(WebSize(viewportSize().width(), viewportSize().height())); + m_outputDevice->DidChangeViewportSize(viewportSize()); } void SoftwareRenderer::beginDrawingFrame(DrawingFrame& frame) { TRACE_EVENT0("cc", "SoftwareRenderer::beginDrawingFrame"); - m_skRootCanvas = make_scoped_ptr(new SkCanvas(m_outputDevice->lock(true)->getSkBitmap())); + m_skRootCanvas = make_scoped_ptr(new SkCanvas(m_outputDevice->Lock(true)->getSkBitmap())); } void SoftwareRenderer::finishDrawingFrame(DrawingFrame& frame) @@ -104,7 +100,7 @@ void SoftwareRenderer::finishDrawingFrame(DrawingFrame& frame) m_currentFramebufferLock.reset(); m_skCurrentCanvas = 0; m_skRootCanvas.reset(); - m_outputDevice->unlock(); + m_outputDevice->Unlock(); } bool SoftwareRenderer::flippedFramebuffer() const @@ -370,12 +366,12 @@ bool SoftwareRenderer::swapBuffers() void SoftwareRenderer::getFramebufferPixels(void *pixels, const gfx::Rect& rect) { TRACE_EVENT0("cc", "SoftwareRenderer::getFramebufferPixels"); - SkBitmap fullBitmap = m_outputDevice->lock(false)->getSkBitmap(); + SkBitmap fullBitmap = m_outputDevice->Lock(false)->getSkBitmap(); SkBitmap subsetBitmap; SkIRect invertRect = SkIRect::MakeXYWH(rect.x(), viewportSize().height() - rect.bottom(), rect.width(), rect.height()); fullBitmap.extractSubset(&subsetBitmap, invertRect); subsetBitmap.copyPixelsTo(pixels, rect.width() * rect.height() * 4, rect.width() * 4); - m_outputDevice->unlock(); + m_outputDevice->Unlock(); } void SoftwareRenderer::setVisible(bool visible) diff --git a/cc/software_renderer.h b/cc/software_renderer.h index caac4f4..4bcfc3c 100644 --- a/cc/software_renderer.h +++ b/cc/software_renderer.h @@ -9,23 +9,20 @@ #include "cc/cc_export.h" #include "cc/direct_renderer.h" -namespace WebKit { -class WebCompositorSoftwareOutputDevice; -} - namespace cc { class DebugBorderDrawQuad; class RendererClient; +class RenderPassDrawQuad; class ResourceProvider; +class SoftwareOutputDevice; class SolidColorDrawQuad; class TextureDrawQuad; class TileDrawQuad; -class RenderPassDrawQuad; class CC_EXPORT SoftwareRenderer : public DirectRenderer { public: - static scoped_ptr<SoftwareRenderer> create(RendererClient*, ResourceProvider*, WebKit::WebCompositorSoftwareOutputDevice*); + static scoped_ptr<SoftwareRenderer> create(RendererClient*, ResourceProvider*, SoftwareOutputDevice*); virtual ~SoftwareRenderer(); virtual const RendererCapabilities& capabilities() const OVERRIDE; @@ -56,7 +53,7 @@ protected: virtual void ensureScissorTestDisabled() OVERRIDE; private: - SoftwareRenderer(RendererClient*, ResourceProvider*, WebKit::WebCompositorSoftwareOutputDevice*); + SoftwareRenderer(RendererClient*, ResourceProvider*, SoftwareOutputDevice*); bool isSoftwareResource(ResourceProvider::ResourceId) const; @@ -70,7 +67,7 @@ private: RendererCapabilities m_capabilities; bool m_visible; - WebKit::WebCompositorSoftwareOutputDevice* m_outputDevice; + SoftwareOutputDevice* m_outputDevice; scoped_ptr<SkCanvas> m_skRootCanvas; SkCanvas* m_skCurrentCanvas; SkPaint m_skCurrentPaint; diff --git a/cc/software_renderer_unittest.cc b/cc/software_renderer_unittest.cc index d720173..1e5eed2 100644 --- a/cc/software_renderer_unittest.cc +++ b/cc/software_renderer_unittest.cc @@ -9,8 +9,8 @@ #include "cc/render_pass_draw_quad.h" #include "cc/solid_color_draw_quad.h" #include "cc/test/animation_test_common.h" -#include "cc/test/fake_web_compositor_output_surface.h" -#include "cc/test/fake_web_compositor_software_output_device.h" +#include "cc/test/fake_output_surface.h" +#include "cc/test/fake_software_output_device.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/render_pass_test_common.h" #include "cc/tile_draw_quad.h" @@ -26,13 +26,13 @@ namespace { class SoftwareRendererTest : public testing::Test, public RendererClient { public: void initializeRenderer() { - m_outputSurface = FakeWebCompositorOutputSurface::createSoftware(scoped_ptr<WebKit::WebCompositorSoftwareOutputDevice>(new FakeWebCompositorSoftwareOutputDevice)); + m_outputSurface = FakeOutputSurface::CreateSoftware(scoped_ptr<SoftwareOutputDevice>(new FakeSoftwareOutputDevice)); m_resourceProvider = ResourceProvider::create(m_outputSurface.get()); m_renderer = SoftwareRenderer::create(this, resourceProvider(), softwareDevice()); } - WebCompositorSoftwareOutputDevice* softwareDevice() const { return m_outputSurface->softwareDevice(); } - FakeWebCompositorOutputSurface* outputSurface() const { return m_outputSurface.get(); } + SoftwareOutputDevice* softwareDevice() const { return m_outputSurface->SoftwareDevice(); } + FakeOutputSurface* outputSurface() const { return m_outputSurface.get(); } ResourceProvider* resourceProvider() const { return m_resourceProvider.get(); } SoftwareRenderer* renderer() const { return m_renderer.get(); } void setViewportSize(gfx::Size viewportSize) { m_viewportSize = viewportSize; } @@ -48,7 +48,7 @@ public: virtual bool hasImplThread() const OVERRIDE { return false; } protected: - scoped_ptr<FakeWebCompositorOutputSurface> m_outputSurface; + scoped_ptr<FakeOutputSurface> m_outputSurface; scoped_ptr<ResourceProvider> m_resourceProvider; scoped_ptr<SoftwareRenderer> m_renderer; gfx::Size m_viewportSize; diff --git a/cc/test/animation_test_common.cc b/cc/test/animation_test_common.cc index 73e0960..678f8de 100644 --- a/cc/test/animation_test_common.cc +++ b/cc/test/animation_test_common.cc @@ -70,7 +70,7 @@ int addAnimatedTransform(Target& target, double duration, int deltaX, int deltaY } // namespace -namespace WebKitTests { +namespace cc { FakeFloatAnimationCurve::FakeFloatAnimationCurve() : m_duration(1) @@ -185,4 +185,4 @@ int addAnimatedTransformToLayer(cc::LayerImpl& layer, double duration, int delta return addAnimatedTransform(*layer.layerAnimationController(), duration, deltaX, deltaY); } -} // namespace WebKitTests +} // namespace cc diff --git a/cc/test/animation_test_common.h b/cc/test/animation_test_common.h index c136f41..a45e9f0 100644 --- a/cc/test/animation_test_common.h +++ b/cc/test/animation_test_common.h @@ -14,7 +14,7 @@ class LayerImpl; class Layer; } -namespace WebKitTests { +namespace cc { class FakeFloatAnimationCurve : public cc::FloatAnimationCurve { public: @@ -69,6 +69,6 @@ int addOpacityTransitionToLayer(cc::LayerImpl&, double duration, float startOpac int addAnimatedTransformToLayer(cc::Layer&, double duration, int deltaX, int deltaY); int addAnimatedTransformToLayer(cc::LayerImpl&, double duration, int deltaX, int deltaY); -} // namespace WebKitTests +} // namespace cc #endif // CC_TEST_ANIMATION_TEST_COMMON_H_ diff --git a/cc/test/fake_layer_tree_host_client.cc b/cc/test/fake_layer_tree_host_client.cc index a2833b3..ff312f6 100644 --- a/cc/test/fake_layer_tree_host_client.cc +++ b/cc/test/fake_layer_tree_host_client.cc @@ -6,14 +6,14 @@ namespace cc { -scoped_ptr<WebKit::WebCompositorOutputSurface> FakeLayerImplTreeHostClient::createOutputSurface() +scoped_ptr<OutputSurface> FakeLayerImplTreeHostClient::createOutputSurface() { if (m_useSoftwareRendering) { - return WebKit::FakeWebCompositorOutputSurface::createSoftware(make_scoped_ptr(new WebKit::FakeWebCompositorSoftwareOutputDevice).PassAs<WebKit::WebCompositorSoftwareOutputDevice>()).PassAs<WebKit::WebCompositorOutputSurface>(); + return FakeOutputSurface::CreateSoftware(make_scoped_ptr(new FakeSoftwareOutputDevice).PassAs<SoftwareOutputDevice>()).PassAs<OutputSurface>(); } WebKit::WebGraphicsContext3D::Attributes attrs; - return WebKit::FakeWebCompositorOutputSurface::create(WebKit::CompositorFakeWebGraphicsContext3D::create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSurface>(); + return FakeOutputSurface::Create3d(WebKit::CompositorFakeWebGraphicsContext3D::create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); } scoped_ptr<InputHandler> FakeLayerImplTreeHostClient::createInputHandler() diff --git a/cc/test/fake_layer_tree_host_client.h b/cc/test/fake_layer_tree_host_client.h index 8d0cfd6..4cd9df3 100644 --- a/cc/test/fake_layer_tree_host_client.h +++ b/cc/test/fake_layer_tree_host_client.h @@ -9,7 +9,7 @@ #include "cc/input_handler.h" #include "cc/layer_tree_host.h" #include "cc/test/compositor_fake_web_graphics_context_3d.h" -#include "cc/test/fake_web_compositor_output_surface.h" +#include "cc/test/fake_output_surface.h" namespace cc { @@ -26,7 +26,7 @@ public: virtual void layout() OVERRIDE { } virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale) OVERRIDE { } - virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() OVERRIDE; + virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE; virtual void didRecreateOutputSurface(bool success) OVERRIDE { } virtual scoped_ptr<InputHandler> createInputHandler() OVERRIDE; virtual void willCommit() OVERRIDE { } diff --git a/cc/test/fake_output_surface.cc b/cc/test/fake_output_surface.cc new file mode 100644 index 0000000..6d1e972 --- /dev/null +++ b/cc/test/fake_output_surface.cc @@ -0,0 +1,46 @@ +// Copyright 2012 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 "cc/test/fake_output_surface.h" + +namespace cc { + +FakeOutputSurface::FakeOutputSurface( + scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { + context3d_ = context3d.Pass(); +} + +FakeOutputSurface::FakeOutputSurface( + scoped_ptr<SoftwareOutputDevice> software_device) { + software_device_ = software_device.Pass(); +} + +FakeOutputSurface::~FakeOutputSurface() {} + +bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { + if (!context3d_) + return true; + DCHECK(client); + if (!context3d_->makeContextCurrent()) + return false; + client_ = client; + return true; +} + +const struct OutputSurface::Capabilities& FakeOutputSurface::Capabilities() + const { + return capabilities_; +} + +WebKit::WebGraphicsContext3D* FakeOutputSurface::Context3D() const { + return context3d_.get(); +} + +SoftwareOutputDevice* FakeOutputSurface::SoftwareDevice() const { + return software_device_.get(); +} + +void FakeOutputSurface::SendFrameToParentCompositor(const CompositorFrame&) {} + +} // namespace cc diff --git a/cc/test/fake_output_surface.h b/cc/test/fake_output_surface.h index 69bce19..1150b05 100644 --- a/cc/test/fake_output_surface.h +++ b/cc/test/fake_output_surface.h @@ -5,18 +5,59 @@ #ifndef CC_TEST_FAKE_OUTPUT_SURFACE_H_ #define CC_TEST_FAKE_OUTPUT_SURFACE_H_ +#include "base/logging.h" +#include "base/memory/scoped_ptr.h" #include "cc/output_surface.h" #include "cc/test/compositor_fake_web_graphics_context_3d.h" -#include "cc/test/fake_web_compositor_output_surface.h" -#include <public/WebCompositorOutputSurface.h> +#include "cc/test/fake_software_output_device.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h" namespace cc { +class FakeOutputSurface : public OutputSurface { + public: + virtual ~FakeOutputSurface(); + + static inline scoped_ptr<FakeOutputSurface> Create3d( + scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { + return make_scoped_ptr(new FakeOutputSurface(context3d.Pass())); + } + + static inline scoped_ptr<FakeOutputSurface> CreateSoftware( + scoped_ptr<SoftwareOutputDevice> software_device) { + return make_scoped_ptr(new FakeOutputSurface(software_device.Pass())); + } + + virtual bool BindToClient(OutputSurfaceClient* client) OVERRIDE; + + virtual const struct Capabilities& Capabilities() const OVERRIDE; + + virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE; + virtual SoftwareOutputDevice* SoftwareDevice() const OVERRIDE; + + virtual void SendFrameToParentCompositor(const CompositorFrame&) OVERRIDE; + +private: + explicit FakeOutputSurface( + scoped_ptr<WebKit::WebGraphicsContext3D> context3d); + explicit FakeOutputSurface( + scoped_ptr<SoftwareOutputDevice> software_device); + + scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; + scoped_ptr<SoftwareOutputDevice> software_device_; + struct Capabilities capabilities_; + OutputSurfaceClient* client_; +}; + static inline scoped_ptr<cc::OutputSurface> createFakeOutputSurface() { - return WebKit::FakeWebCompositorOutputSurface::create(WebKit::CompositorFakeWebGraphicsContext3D::create(WebKit::WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<cc::OutputSurface>(); + return FakeOutputSurface::Create3d( + WebKit::CompositorFakeWebGraphicsContext3D::create( + WebKit::WebGraphicsContext3D::Attributes()) + .PassAs<WebKit::WebGraphicsContext3D>()) + .PassAs<cc::OutputSurface>(); } -} // namespace WebKit +} // namespace cc #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_ diff --git a/cc/test/fake_software_output_device.cc b/cc/test/fake_software_output_device.cc new file mode 100644 index 0000000..eebf2b9 --- /dev/null +++ b/cc/test/fake_software_output_device.cc @@ -0,0 +1,33 @@ +// Copyright 2012 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 "cc/test/fake_software_output_device.h" + +namespace cc { + +FakeSoftwareOutputDevice::FakeSoftwareOutputDevice() {} + +FakeSoftwareOutputDevice::~FakeSoftwareOutputDevice() {} + +WebKit::WebImage* FakeSoftwareOutputDevice::Lock(bool forWrite) { + DCHECK(device_); + image_ = device_->accessBitmap(forWrite); + return &image_; +} + +void FakeSoftwareOutputDevice::Unlock() { + image_.reset(); +} + +void FakeSoftwareOutputDevice::DidChangeViewportSize(gfx::Size size) { + if (device_.get() && + size.width() == device_->width() && + size.height() == device_->height()) + return; + + device_ = skia::AdoptRef(new SkDevice( + SkBitmap::kARGB_8888_Config, size.width(), size.height(), true)); +} + +} // namespace cc diff --git a/cc/test/fake_software_output_device.h b/cc/test/fake_software_output_device.h new file mode 100644 index 0000000..0ee28a3 --- /dev/null +++ b/cc/test/fake_software_output_device.h @@ -0,0 +1,33 @@ +// Copyright 2012 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_TEST_FAKE_SOFTWARE_OUTPUT_DEVICE_H_ +#define CC_TEST_FAKE_SOFTWARE_OUTPUT_DEVICE_H_ + +#include "base/logging.h" +#include "cc/software_output_device.h" +#include "skia/ext/refptr.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebImage.h" +#include "third_party/skia/include/core/SkDevice.h" + +namespace cc { + +class FakeSoftwareOutputDevice : public SoftwareOutputDevice { + public: + FakeSoftwareOutputDevice(); + virtual ~FakeSoftwareOutputDevice(); + + virtual WebKit::WebImage* Lock(bool forWrite) OVERRIDE; + virtual void Unlock() OVERRIDE; + + virtual void DidChangeViewportSize(gfx::Size size) OVERRIDE; + + private: + skia::RefPtr<SkDevice> device_; + WebKit::WebImage image_; +}; + +} // namespace cc + +#endif // CC_TEST_FAKE_SOFTWARE_OUTPUT_DEVICE_H_ diff --git a/cc/test/fake_web_compositor_output_surface.h b/cc/test/fake_web_compositor_output_surface.h deleted file mode 100644 index 3cd5b80..0000000 --- a/cc/test/fake_web_compositor_output_surface.h +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2012 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_TEST_FAKE_WEB_COMPOSITOR_OUTPUT_SURFACE_H_ -#define CC_TEST_FAKE_WEB_COMPOSITOR_OUTPUT_SURFACE_H_ - -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "cc/test/fake_web_compositor_software_output_device.h" -#include <public/WebCompositorOutputSurface.h> -#include <public/WebGraphicsContext3D.h> - -namespace WebKit { - -class FakeWebCompositorOutputSurface : public WebCompositorOutputSurface { -public: - static inline scoped_ptr<FakeWebCompositorOutputSurface> create(scoped_ptr<WebGraphicsContext3D> context3D) - { - return make_scoped_ptr(new FakeWebCompositorOutputSurface(context3D.Pass())); - } - - static inline scoped_ptr<FakeWebCompositorOutputSurface> createSoftware(scoped_ptr<WebCompositorSoftwareOutputDevice> softwareDevice) - { - return make_scoped_ptr(new FakeWebCompositorOutputSurface(softwareDevice.Pass())); - } - - virtual bool bindToClient(WebCompositorOutputSurfaceClient* client) OVERRIDE - { - if (!m_context3D) - return true; - DCHECK(client); - if (!m_context3D->makeContextCurrent()) - return false; - m_client = client; - return true; - } - - virtual const Capabilities& capabilities() const OVERRIDE - { - return m_capabilities; - } - - virtual WebGraphicsContext3D* context3D() const OVERRIDE - { - return m_context3D.get(); - } - virtual WebCompositorSoftwareOutputDevice* softwareDevice() const OVERRIDE - { - return m_softwareDevice.get(); - } - - virtual void sendFrameToParentCompositor(const WebCompositorFrame&) OVERRIDE - { - } - -private: - explicit FakeWebCompositorOutputSurface(scoped_ptr<WebGraphicsContext3D> context3D) - { - m_context3D = context3D.Pass(); - } - - explicit FakeWebCompositorOutputSurface(scoped_ptr<WebCompositorSoftwareOutputDevice> softwareDevice) - { - m_softwareDevice = softwareDevice.Pass(); - } - - scoped_ptr<WebGraphicsContext3D> m_context3D; - scoped_ptr<WebCompositorSoftwareOutputDevice> m_softwareDevice; - Capabilities m_capabilities; - WebCompositorOutputSurfaceClient* m_client; -}; - -} // namespace WebKit - -#endif // CC_TEST_FAKE_WEB_COMPOSITOR_OUTPUT_SURFACE_H_ diff --git a/cc/test/fake_web_compositor_software_output_device.h b/cc/test/fake_web_compositor_software_output_device.h deleted file mode 100644 index 6b17a5d..0000000 --- a/cc/test/fake_web_compositor_software_output_device.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2012 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_TEST_FAKE_WEB_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_ -#define CC_TEST_FAKE_WEB_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_ - -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "third_party/skia/include/core/SkDevice.h" -#include <public/WebCompositorSoftwareOutputDevice.h> -#include <public/WebImage.h> -#include <public/WebSize.h> - -namespace WebKit { - -class FakeWebCompositorSoftwareOutputDevice : public WebCompositorSoftwareOutputDevice { -public: - virtual WebImage* lock(bool forWrite) OVERRIDE - { - DCHECK(m_device.get()); - m_image = m_device->accessBitmap(forWrite); - return &m_image; - } - virtual void unlock() OVERRIDE - { - m_image.reset(); - } - - virtual void didChangeViewportSize(WebSize size) OVERRIDE - { - if (m_device.get() && size.width == m_device->width() && size.height == m_device->height()) - return; - - m_device.reset(new SkDevice(SkBitmap::kARGB_8888_Config, size.width, size.height, true)); - } - -private: - scoped_ptr<SkDevice> m_device; - WebImage m_image; -}; - -} // namespace WebKit - -#endif // CC_TEST_FAKE_WEB_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_ diff --git a/cc/test/layer_tree_test_common.cc b/cc/test/layer_tree_test_common.cc index a1b04e9..dd40f13 100644 --- a/cc/test/layer_tree_test_common.cc +++ b/cc/test/layer_tree_test_common.cc @@ -17,7 +17,7 @@ #include "cc/single_thread_proxy.h" #include "cc/thread_impl.h" #include "cc/test/animation_test_common.h" -#include "cc/test/fake_web_compositor_output_surface.h" +#include "cc/test/fake_output_surface.h" #include "cc/test/fake_web_graphics_context_3d.h" #include "cc/test/occlusion_tracker_test_common.h" #include "cc/test/tiled_layer_test_common.h" @@ -26,17 +26,9 @@ #include <public/WebFilterOperation.h> #include <public/WebFilterOperations.h> -using cc::FontAtlas; -using cc::InputHandler; -using cc::Layer; -using cc::LayerTreeHostImplClient; -using cc::LayerTreeSettings; -using cc::Proxy; -using cc::ScopedThreadProxy; - using namespace WebKit; -namespace WebKitTests { +namespace cc { scoped_ptr<CompositorFakeWebGraphicsContext3DWithTextureTracking> CompositorFakeWebGraphicsContext3DWithTextureTracking::create(Attributes attrs) { @@ -87,9 +79,9 @@ bool TestHooks::prepareToDrawOnThread(cc::LayerTreeHostImpl*) return true; } -scoped_ptr<WebCompositorOutputSurface> TestHooks::createOutputSurface() +scoped_ptr<OutputSurface> TestHooks::createOutputSurface() { - return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsContext3DWithTextureTracking::create(WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSurface>(); + return FakeOutputSurface::Create3d(CompositorFakeWebGraphicsContext3DWithTextureTracking::create(WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); } scoped_ptr<MockLayerTreeHostImpl> MockLayerTreeHostImpl::create(TestHooks* testHooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy) @@ -227,7 +219,7 @@ public: m_testHooks->applyScrollAndScale(scrollDelta, scale); } - virtual scoped_ptr<WebCompositorOutputSurface> createOutputSurface() OVERRIDE + virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE { return m_testHooks->createOutputSurface(); } @@ -503,4 +495,4 @@ void ThreadedTest::runTest(bool threaded) afterTest(); } -} // namespace WebKitTests +} // namespace cc diff --git a/cc/test/layer_tree_test_common.h b/cc/test/layer_tree_test_common.h index e85927d..ebc9c05 100644 --- a/cc/test/layer_tree_test_common.h +++ b/cc/test/layer_tree_test_common.h @@ -23,7 +23,7 @@ class LayerTreeHostImpl; class Thread; } -namespace WebKitTests { +namespace cc { // Used by test stubs to notify the test when something interesting happens. class TestHooks : public WebKit::WebAnimationDelegate { @@ -48,7 +48,7 @@ public: virtual void notifyAnimationStarted(double time) OVERRIDE { } virtual void notifyAnimationFinished(double time) OVERRIDE { } - virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface(); + virtual scoped_ptr<OutputSurface> createOutputSurface(); }; class TimeoutTask; diff --git a/cc/test/pixel_test_output_surface.cc b/cc/test/pixel_test_output_surface.cc index 46985b7..a7e1542 100644 --- a/cc/test/pixel_test_output_surface.cc +++ b/cc/test/pixel_test_output_surface.cc @@ -18,19 +18,22 @@ PixelTestOutputSurface::PixelTestOutputSurface() { PixelTestOutputSurface::~PixelTestOutputSurface() { } -bool PixelTestOutputSurface::bindToClient( - WebKit::WebCompositorOutputSurfaceClient*) { +bool PixelTestOutputSurface::BindToClient(OutputSurfaceClient*) { return context_->makeContextCurrent(); } -const WebKit::WebCompositorOutputSurface::Capabilities& - PixelTestOutputSurface::capabilities() const { - static WebKit::WebCompositorOutputSurface::Capabilities capabilities; +const struct OutputSurface::Capabilities& PixelTestOutputSurface::Capabilities() + const { + static struct OutputSurface::Capabilities capabilities; return capabilities; } -WebKit::WebGraphicsContext3D* PixelTestOutputSurface::context3D() const { +WebKit::WebGraphicsContext3D* PixelTestOutputSurface::Context3D() const { return context_.get(); } +SoftwareOutputDevice* PixelTestOutputSurface::SoftwareDevice() const { + return NULL; +} + } // namespace cc diff --git a/cc/test/pixel_test_output_surface.h b/cc/test/pixel_test_output_surface.h index f59e63c..ab9b161 100644 --- a/cc/test/pixel_test_output_surface.h +++ b/cc/test/pixel_test_output_surface.h @@ -19,11 +19,12 @@ class PixelTestOutputSurface : public OutputSurface { virtual ~PixelTestOutputSurface(); // OutputSurface overrides. - virtual bool bindToClient(WebKit::WebCompositorOutputSurfaceClient*) OVERRIDE; - virtual const WebKit::WebCompositorOutputSurface::Capabilities& capabilities() const OVERRIDE; - virtual WebKit::WebGraphicsContext3D* context3D() const OVERRIDE; - virtual void sendFrameToParentCompositor( - const WebKit::WebCompositorFrame&) OVERRIDE { } + virtual bool BindToClient(OutputSurfaceClient*) OVERRIDE; + virtual const struct OutputSurface::Capabilities& Capabilities() const + OVERRIDE; + virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE; + virtual SoftwareOutputDevice* SoftwareDevice() const OVERRIDE; + virtual void SendFrameToParentCompositor(const CompositorFrame&) OVERRIDE {} private: PixelTestOutputSurface(); diff --git a/cc/tree_synchronizer_unittest.cc b/cc/tree_synchronizer_unittest.cc index 893ed56..6759f20 100644 --- a/cc/tree_synchronizer_unittest.cc +++ b/cc/tree_synchronizer_unittest.cc @@ -15,8 +15,6 @@ #include "cc/test/fake_proxy.h" #include "testing/gtest/include/gtest/gtest.h" -using namespace WebKitTests; - namespace cc { namespace { |