diff options
author | skaslev@chromium.org <skaslev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-13 23:59:50 +0000 |
---|---|---|
committer | skaslev@chromium.org <skaslev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-13 23:59:50 +0000 |
commit | 79a1be5675c89e740725d52fb56ba0295f3333be (patch) | |
tree | b22a153b187201e563cf16e91f1e46bf7ef4a33a | |
parent | 490ccaf2705fcda0afeefb717a023aa5e1fe8076 (diff) | |
download | chromium_src-79a1be5675c89e740725d52fb56ba0295f3333be.zip chromium_src-79a1be5675c89e740725d52fb56ba0295f3333be.tar.gz chromium_src-79a1be5675c89e740725d52fb56ba0295f3333be.tar.bz2 |
Have a common implementation of cc::OutputSurface instead of multiple duplicated ones.
Review URL: https://codereview.chromium.org/12041062
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182345 0039d316-1c4b-4281-b951-d872f2087c98
31 files changed, 199 insertions, 470 deletions
@@ -9,4 +9,6 @@ include_rules = [ "+ui/gl", # TODO(danakj): Drop dependencies on WebKit Platform API from cc. "+third_party/WebKit/Source/Platform/chromium/public", +# TODO(jamesr): Remove once cc depends on GLES2Interface instead of WGC3D + "+webkit/gpu", ] @@ -134,6 +134,7 @@ 'nine_patch_layer_impl.h', 'occlusion_tracker.cc', 'occlusion_tracker.h', + 'output_surface.cc', 'output_surface.h', 'output_surface_client.h', 'overdraw_metrics.cc', diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index 1f8d69c..b96b6e0 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -119,8 +119,6 @@ 'test/occlusion_tracker_test_common.h', 'test/paths.cc', 'test/paths.h', - 'test/pixel_test_output_surface.cc', - 'test/pixel_test_output_surface.h', 'test/render_pass_test_common.cc', 'test/render_pass_test_common.h', 'test/render_pass_test_utils.cc', diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc index 9ea15ac..42aaf8f 100644 --- a/cc/gl_renderer.cc +++ b/cc/gl_renderer.cc @@ -93,7 +93,7 @@ GLRenderer::GLRenderer(RendererClient* client, OutputSurface* outputSurface, Res , m_offscreenFramebufferId(0) , m_sharedGeometryQuad(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)) , m_outputSurface(outputSurface) - , m_context(outputSurface->Context3D()) + , m_context(outputSurface->context3d()) , m_isViewportChanged(false) , m_isBackbufferDiscarded(false) , m_discardBackbufferWhenNotVisible(false) diff --git a/cc/gl_renderer_pixeltest.cc b/cc/gl_renderer_pixeltest.cc index 5c505aa..46334f2 100644 --- a/cc/gl_renderer_pixeltest.cc +++ b/cc/gl_renderer_pixeltest.cc @@ -11,11 +11,11 @@ #include "cc/prioritized_resource_manager.h" #include "cc/resource_provider.h" #include "cc/test/paths.h" -#include "cc/test/pixel_test_output_surface.h" #include "cc/test/pixel_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/codec/png_codec.h" #include "ui/gl/gl_implementation.h" +#include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" namespace cc { namespace { @@ -53,7 +53,11 @@ class GLRendererPixelTest : public testing::Test { virtual void SetUp() { gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL); - output_surface_ = PixelTestOutputSurface::create(); + scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl> context3d( + new webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl); + context3d->Initialize(WebKit::WebGraphicsContext3D::Attributes(), NULL); + output_surface_.reset(new OutputSurface( + context3d.PassAs<WebKit::WebGraphicsContext3D>())); resource_provider_ = ResourceProvider::create(output_surface_.get()); renderer_ = GLRenderer::create(&fake_client_, output_surface_.get(), diff --git a/cc/gl_renderer_unittest.cc b/cc/gl_renderer_unittest.cc index d7e9b71..25706df 100644 --- a/cc/gl_renderer_unittest.cc +++ b/cc/gl_renderer_unittest.cc @@ -142,7 +142,7 @@ protected: m_renderer.swapBuffers(); } - FrameCountingMemoryAllocationSettingContext* context() { return static_cast<FrameCountingMemoryAllocationSettingContext*>(m_outputSurface->Context3D()); } + FrameCountingMemoryAllocationSettingContext* context() { return static_cast<FrameCountingMemoryAllocationSettingContext*>(m_outputSurface->context3d()); } WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes; WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo; @@ -401,7 +401,7 @@ TEST(GLRendererTest2, opaqueBackground) { FakeRendererClient mockClient; scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); - ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->Context3D()); + ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->context3d()); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.get()); @@ -424,7 +424,7 @@ TEST(GLRendererTest2, transparentBackground) { FakeRendererClient mockClient; scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); - ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->Context3D()); + ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->context3d()); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.get()); @@ -475,7 +475,7 @@ TEST(GLRendererTest2, visibilityChangeIsLastCall) { FakeRendererClient mockClient; scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new VisibilityChangeIsLastCallTrackingContext))); - VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityChangeIsLastCallTrackingContext*>(outputSurface->Context3D()); + VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityChangeIsLastCallTrackingContext*>(outputSurface->context3d()); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.get()); @@ -527,7 +527,7 @@ TEST(GLRendererTest2, activeTextureState) { FakeRendererClient fakeClient; scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); - TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->Context3D()); + TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->context3d()); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); FakeRendererGL renderer(&fakeClient, outputSurface.get(), resourceProvider.get()); @@ -594,7 +594,7 @@ TEST(GLRendererTest2, shouldClearRootRenderPass) { NoClearRootRenderPassFakeClient mockClient; scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new NoClearRootRenderPassMockContext))); - NoClearRootRenderPassMockContext* mockContext = static_cast<NoClearRootRenderPassMockContext*>(outputSurface->Context3D()); + NoClearRootRenderPassMockContext* mockContext = static_cast<NoClearRootRenderPassMockContext*>(outputSurface->context3d()); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); FakeRendererGL renderer(&mockClient, outputSurface.get(), resourceProvider.get()); EXPECT_TRUE(renderer.initialize()); diff --git a/cc/io_surface_layer_impl.cc b/cc/io_surface_layer_impl.cc index bf796fd..cc0d840 100644 --- a/cc/io_surface_layer_impl.cc +++ b/cc/io_surface_layer_impl.cc @@ -32,7 +32,7 @@ IOSurfaceLayerImpl::~IOSurfaceLayerImpl() OutputSurface* outputSurface = layerTreeImpl()->output_surface(); // 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_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index 06db701..e6c0de7 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -1071,12 +1071,12 @@ bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<OutputSurface> outputSurfa m_tileManager->SetRecordRenderingStats(m_debugState.recordRenderingStats()); } - if (outputSurface->Capabilities().has_parent_compositor) + if (outputSurface->capabilities().has_parent_compositor) m_renderer = DelegatingRenderer::Create(this, outputSurface.get(), resourceProvider.get()); - else if (outputSurface->Context3D()) + else if (outputSurface->context3d()) m_renderer = GLRenderer::create(this, outputSurface.get(), resourceProvider.get()); - else if (outputSurface->SoftwareDevice()) - m_renderer = SoftwareRenderer::create(this, resourceProvider.get(), outputSurface->SoftwareDevice()); + else if (outputSurface->software_device()) + m_renderer = SoftwareRenderer::create(this, resourceProvider.get(), outputSurface->software_device()); if (!m_renderer) return false; diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc index c3fdb74..c30b6b0 100644 --- a/cc/layer_tree_host_impl_unittest.cc +++ b/cc/layer_tree_host_impl_unittest.cc @@ -2107,7 +2107,7 @@ protected: TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) { scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurface>(); - ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(outputSurface->Context3D()); + ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(outputSurface->context3d()); m_hostImpl->initializeRenderer(outputSurface.Pass()); scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl->activeTree(), 1); @@ -2150,7 +2150,7 @@ private: TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) { scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).PassAs<OutputSurface>(); - PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrackerContext*>(outputSurface->Context3D()); + PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrackerContext*>(outputSurface->context3d()); // This test creates its own LayerTreeHostImpl, so // that we can force partial swap enabled. @@ -2360,7 +2360,7 @@ public: TEST_P(LayerTreeHostImplTest, noPartialSwap) { scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); - MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3D()); + MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3d()); MockContextHarness harness(mockContext); // Run test case @@ -2394,7 +2394,7 @@ TEST_P(LayerTreeHostImplTest, noPartialSwap) TEST_P(LayerTreeHostImplTest, partialSwap) { scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); - MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3D()); + MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3d()); MockContextHarness harness(mockContext); createLayerTreeHost(true, outputSurface.Pass()); @@ -2670,7 +2670,7 @@ public: TEST_P(LayerTreeHostImplTest, hasTransparentBackground) { scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs<OutputSurface>(); - MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToFillScreenContext*>(outputSurface->Context3D()); + MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToFillScreenContext*>(outputSurface->context3d()); // Run test case createLayerTreeHost(false, outputSurface.Pass()); @@ -4031,7 +4031,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(), outputSurface.get(), &m_proxy)); diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc index 896d5f5..44abd8f 100644 --- a/cc/layer_tree_host_unittest.cc +++ b/cc/layer_tree_host_unittest.cc @@ -1040,7 +1040,7 @@ public: { ASSERT_EQ(0u, m_layerTreeHost->settings().maxPartialTextureUpdates); - TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>(impl->outputSurface()->Context3D()); + TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>(impl->outputSurface()->context3d()); switch (impl->activeTree()->source_frame_number()) { case 0: @@ -1082,7 +1082,7 @@ public: virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { - TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>(impl->outputSurface()->Context3D()); + TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>(impl->outputSurface()->context3d()); // Number of textures used for draw should always be one for each layer. EXPECT_EQ(2, context->NumUsedTextures()); @@ -1172,7 +1172,7 @@ public: { ASSERT_EQ(1u, m_layerTreeHost->settings().maxPartialTextureUpdates); - TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>(impl->outputSurface()->Context3D()); + TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>(impl->outputSurface()->context3d()); switch (impl->activeTree()->source_frame_number()) { case 0: @@ -1257,7 +1257,7 @@ public: virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { - TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>(impl->outputSurface()->Context3D()); + TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>(impl->outputSurface()->context3d()); // Number of textures used for drawing should one per layer except for // frame 3 where the viewport only contains one layer. diff --git a/cc/output_surface.cc b/cc/output_surface.cc new file mode 100644 index 0000000..b489232 --- /dev/null +++ b/cc/output_surface.cc @@ -0,0 +1,47 @@ +// Copyright (c) 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 "cc/output_surface.h" + +#include "base/logging.h" + +namespace cc { + +OutputSurface::OutputSurface( + scoped_ptr<WebKit::WebGraphicsContext3D> context3d) + : client_(NULL), + context3d_(context3d.Pass()) { +} + +OutputSurface::OutputSurface( + scoped_ptr<cc::SoftwareOutputDevice> software_device) + : client_(NULL), + software_device_(software_device.Pass()) { +} + +OutputSurface::OutputSurface( + scoped_ptr<WebKit::WebGraphicsContext3D> context3d, + scoped_ptr<cc::SoftwareOutputDevice> software_device) + : client_(NULL), + context3d_(context3d.Pass()), + software_device_(software_device.Pass()) { +} + +OutputSurface::~OutputSurface() { +} + +bool OutputSurface::BindToClient( + cc::OutputSurfaceClient* client) { + DCHECK(client); + client_ = client; + if (!context3d_) + return true; + return context3d_->makeContextCurrent(); +} + +void OutputSurface::SendFrameToParentCompositor(CompositorFrame*) { + NOTIMPLEMENTED(); +} + +} // namespace cc diff --git a/cc/output_surface.h b/cc/output_surface.h index 4bc3180..de075e2 100644 --- a/cc/output_surface.h +++ b/cc/output_surface.h @@ -7,18 +7,16 @@ #define USE_CC_OUTPUT_SURFACE // TODO(danakj): Remove this. +#include "base/memory/scoped_ptr.h" #include "cc/cc_export.h" +#include "cc/software_output_device.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurface.h" - -namespace WebKit { -class WebGraphicsContext3D; -} +#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h" namespace cc { class CompositorFrame; class OutputSurfaceClient; -class SoftwareOutputDevice; // Represents the output surface for a compositor. The compositor owns // and manages its destruction. Its lifetime is: @@ -29,13 +27,14 @@ class SoftwareOutputDevice; // surface (on the compositor thread) and go back to step 1. class CC_EXPORT OutputSurface : public WebKit::WebCompositorOutputSurface { public: - virtual ~OutputSurface() {} + OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d); - // 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; + OutputSurface(scoped_ptr<cc::SoftwareOutputDevice> software_device); + + OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d, + scoped_ptr<cc::SoftwareOutputDevice> software_device); + + virtual ~OutputSurface(); struct Capabilities { Capabilities() @@ -44,23 +43,42 @@ class CC_EXPORT OutputSurface : public WebKit::WebCompositorOutputSurface { bool has_parent_compositor; }; - virtual const Capabilities& Capabilities() const = 0; + const Capabilities& capabilities() const { + return capabilities_; + } // 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; + WebKit::WebGraphicsContext3D* context3d() const { + return context3d_.get(); + } + + SoftwareOutputDevice* software_device() const { + return software_device_.get(); + } + + // 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*); // Sends frame data to the parent compositor. This should only be called when // capabilities().has_parent_compositor. The implementation may destroy or // steal the contents of the CompositorFrame passed in. - virtual void SendFrameToParentCompositor(CompositorFrame*) = 0; + virtual void SendFrameToParentCompositor(CompositorFrame*); // Notifies frame-rate smoothness preference. If true, all non-critical // processing should be stopped, or lowered in priority. virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} + + protected: + OutputSurfaceClient* client_; + struct cc::OutputSurface::Capabilities capabilities_; + scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; + scoped_ptr<cc::SoftwareOutputDevice> software_device_; }; } // namespace cc diff --git a/cc/resource_provider.cc b/cc/resource_provider.cc index 9cc122c..d394062 100644 --- a/cc/resource_provider.cc +++ b/cc/resource_provider.cc @@ -148,7 +148,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(); @@ -158,7 +158,7 @@ ResourceProvider::~ResourceProvider() WebGraphicsContext3D* ResourceProvider::graphicsContext3D() { DCHECK(m_threadChecker.CalledOnValidThread()); - return m_outputSurface->Context3D(); + return m_outputSurface->context3d(); } bool ResourceProvider::inUseByConsumer(ResourceId id) @@ -204,7 +204,7 @@ ResourceProvider::ResourceId ResourceProvider::createGLTexture(const gfx::Size& DCHECK_LE(size.height(), m_maxTextureSize); DCHECK(m_threadChecker.CalledOnValidThread()); - WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->context3d(); DCHECK(context3d); // Create and set texture properties. Allocation is delayed until needed. @@ -237,7 +237,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)); @@ -288,22 +288,22 @@ 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)); } if (!resource->mailbox.IsEmpty() && resource->external) { - WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->context3d(); DCHECK(context3d); unsigned syncPoint = resource->mailbox.sync_point(); if (resource->glId) { @@ -345,7 +345,7 @@ void ResourceProvider::setPixels(ResourceId id, const uint8_t* image, const gfx: if (resource->glId) { DCHECK(!resource->pendingSetPixels); - WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->context3d(); DCHECK(context3d); DCHECK(m_textureUploader.get()); context3d->bindTexture(GL_TEXTURE_2D, resource->glId); @@ -409,7 +409,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(); } @@ -417,7 +417,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; @@ -436,7 +436,7 @@ const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id) DCHECK(resource->allocated); // Uninitialized! Call setPixels or lockForWrite first. if (!resource->glId && resource->external && !resource->mailbox.IsEmpty()) { - WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->context3d(); DCHECK(context3d); if (resource->mailbox.sync_point()) { GLC(context3d, context3d->waitSyncPoint(resource->mailbox.sync_point())); @@ -588,7 +588,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; m_bestTextureFormat = GL_RGBA; @@ -659,7 +659,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; @@ -680,7 +680,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; @@ -704,7 +704,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; @@ -738,7 +738,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; @@ -762,7 +762,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; @@ -798,7 +798,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(); @@ -833,7 +833,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, @@ -864,7 +864,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( @@ -894,7 +894,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( @@ -920,7 +920,7 @@ void ResourceProvider::setPixelsFromBuffer(ResourceId id) lazyAllocate(resource); 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); @@ -957,7 +957,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; @@ -987,7 +987,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); @@ -1039,7 +1039,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; @@ -1066,7 +1066,7 @@ void ResourceProvider::abortSetPixels(ResourceId id) { DCHECK(resource->pendingSetPixels); if (resource->glId) { - WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->context3d(); DCHECK(context3d); DCHECK(resource->glUploadQueryId); // CHROMIUM_async_pixel_transfers currently doesn't have a way to @@ -1097,7 +1097,7 @@ void ResourceProvider::lazyAllocate(Resource* resource) { if (resource->allocated || !resource->glId) return; resource->allocated = true; - WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); + WebGraphicsContext3D* context3d = m_outputSurface->context3d(); gfx::Size& size = resource->size; GLenum format = resource->format; GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId)); diff --git a/cc/resource_provider_unittest.cc b/cc/resource_provider_unittest.cc index 2c28d02..0058d11 100644 --- a/cc/resource_provider_unittest.cc +++ b/cc/resource_provider_unittest.cc @@ -283,7 +283,7 @@ public: 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) { @@ -476,7 +476,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()); @@ -580,7 +580,7 @@ TEST_P(ResourceProviderTest, ScopedSampler) return; scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); - TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->Context3D()); + TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->context3d()); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); gfx::Size size(1, 1); @@ -631,7 +631,7 @@ TEST_P(ResourceProviderTest, ManagedResource) return; scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); - TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->Context3D()); + TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->context3d()); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); gfx::Size size(1, 1); @@ -686,7 +686,7 @@ TEST_P(ResourceProviderTest, TextureAllocation) uint8_t pixels[16] = {0}; int textureId = 123; - AllocationTrackingContext3D* context = static_cast<AllocationTrackingContext3D*>(outputSurface->Context3D()); + AllocationTrackingContext3D* context = static_cast<AllocationTrackingContext3D*>(outputSurface->context3d()); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); // Lazy allocation. Don't allocate when creating the resource. diff --git a/cc/software_renderer_unittest.cc b/cc/software_renderer_unittest.cc index 09a1f42..3d71a0e 100644 --- a/cc/software_renderer_unittest.cc +++ b/cc/software_renderer_unittest.cc @@ -37,7 +37,7 @@ public: m_renderer = SoftwareRenderer::create(this, resourceProvider(), softwareDevice()); } - SoftwareOutputDevice* softwareDevice() const { return m_outputSurface->SoftwareDevice(); } + SoftwareOutputDevice* softwareDevice() const { return m_outputSurface->software_device(); } FakeOutputSurface* outputSurface() const { return m_outputSurface.get(); } ResourceProvider* resourceProvider() const { return m_resourceProvider.get(); } SoftwareRenderer* renderer() const { return m_renderer.get(); } diff --git a/cc/test/DEPS b/cc/test/DEPS index 76f1349..73ee3d5 100644 --- a/cc/test/DEPS +++ b/cc/test/DEPS @@ -1,5 +1,3 @@ include_rules = [ "+ui/gl/", -# TODO(jamesr): Remove once cc depends on GLES2Interface instead of WGC3D - "+webkit/gpu", ] diff --git a/cc/test/fake_output_surface.cc b/cc/test/fake_output_surface.cc index ebbe783..0b9a6d3 100644 --- a/cc/test/fake_output_surface.cc +++ b/cc/test/fake_output_surface.cc @@ -8,41 +8,27 @@ namespace cc { FakeOutputSurface::FakeOutputSurface( scoped_ptr<WebKit::WebGraphicsContext3D> context3d, bool has_parent) - : num_sent_frames_(0) { - context3d_ = context3d.Pass(); + : OutputSurface(context3d.Pass()), + num_sent_frames_(0) { capabilities_.has_parent_compositor = has_parent; } FakeOutputSurface::FakeOutputSurface( scoped_ptr<SoftwareOutputDevice> software_device, bool has_parent) - : num_sent_frames_(0) { - software_device_ = software_device.Pass(); + : OutputSurface(software_device.Pass()), + num_sent_frames_(0) { capabilities_.has_parent_compositor = has_parent; } FakeOutputSurface::~FakeOutputSurface() {} -bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { - if (!context3d_) - return true; +bool FakeOutputSurface::BindToClient( + cc::OutputSurfaceClient* client) { 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(); + if (!context3d_) + return true; + return context3d_->makeContextCurrent(); } void FakeOutputSurface::SendFrameToParentCompositor( diff --git a/cc/test/fake_output_surface.h b/cc/test/fake_output_surface.h index 360e253..2ab7906 100644 --- a/cc/test/fake_output_surface.h +++ b/cc/test/fake_output_surface.h @@ -5,8 +5,6 @@ #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/compositor_frame.h" #include "cc/output_surface.h" #include "cc/test/fake_software_output_device.h" @@ -19,12 +17,12 @@ class FakeOutputSurface : public OutputSurface { public: virtual ~FakeOutputSurface(); - static inline scoped_ptr<FakeOutputSurface> Create3d( + static scoped_ptr<FakeOutputSurface> Create3d( scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); } - static inline scoped_ptr<FakeOutputSurface> Create3d() { + static scoped_ptr<FakeOutputSurface> Create3d() { scoped_ptr<WebKit::WebGraphicsContext3D> context3d = TestWebGraphicsContext3D::Create( WebKit::WebGraphicsContext3D::Attributes()) @@ -32,18 +30,18 @@ class FakeOutputSurface : public OutputSurface { return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); } - static inline scoped_ptr<FakeOutputSurface> CreateSoftware( + static scoped_ptr<FakeOutputSurface> CreateSoftware( scoped_ptr<SoftwareOutputDevice> software_device) { return make_scoped_ptr( new FakeOutputSurface(software_device.Pass(), false)); } - static inline scoped_ptr<FakeOutputSurface> CreateDelegating3d( + static scoped_ptr<FakeOutputSurface> CreateDelegating3d( scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true)); } - static inline scoped_ptr<FakeOutputSurface> CreateDelegating3d() { + static scoped_ptr<FakeOutputSurface> CreateDelegating3d() { scoped_ptr<WebKit::WebGraphicsContext3D> context3d = TestWebGraphicsContext3D::Create( WebKit::WebGraphicsContext3D::Attributes()) @@ -51,34 +49,27 @@ class FakeOutputSurface : public OutputSurface { return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true)); } - static inline scoped_ptr<FakeOutputSurface> CreateDelegatingSoftware( + static scoped_ptr<FakeOutputSurface> CreateDelegatingSoftware( scoped_ptr<SoftwareOutputDevice> software_device) { return make_scoped_ptr( new FakeOutputSurface(software_device.Pass(), true)); } - 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 bool BindToClient(OutputSurfaceClient*) OVERRIDE; virtual void SendFrameToParentCompositor(CompositorFrame*) OVERRIDE; CompositorFrame& last_sent_frame() { return last_sent_frame_; } size_t num_sent_frames() { return num_sent_frames_; } private: - explicit FakeOutputSurface( - scoped_ptr<WebKit::WebGraphicsContext3D> context3d, bool has_parent); - explicit FakeOutputSurface( - scoped_ptr<SoftwareOutputDevice> software_device, bool has_parent); - - scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; - scoped_ptr<SoftwareOutputDevice> software_device_; - struct Capabilities capabilities_; - OutputSurfaceClient* client_; + FakeOutputSurface( + scoped_ptr<WebKit::WebGraphicsContext3D> context3d, + bool has_parent); + + FakeOutputSurface( + scoped_ptr<SoftwareOutputDevice> software_device, + bool has_parent); + CompositorFrame last_sent_frame_; size_t num_sent_frames_; }; diff --git a/cc/test/pixel_test_output_surface.cc b/cc/test/pixel_test_output_surface.cc deleted file mode 100644 index a7e1542..0000000 --- a/cc/test/pixel_test_output_surface.cc +++ /dev/null @@ -1,39 +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. - -#include "cc/test/pixel_test_output_surface.h" - -#include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" - -namespace cc { - -PixelTestOutputSurface::PixelTestOutputSurface() { - scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl> - context(new webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl); - context->Initialize(WebKit::WebGraphicsContext3D::Attributes(), NULL); - context_ = context.PassAs<WebKit::WebGraphicsContext3D>(); -} - -PixelTestOutputSurface::~PixelTestOutputSurface() { -} - -bool PixelTestOutputSurface::BindToClient(OutputSurfaceClient*) { - return context_->makeContextCurrent(); -} - -const struct OutputSurface::Capabilities& PixelTestOutputSurface::Capabilities() - const { - static struct OutputSurface::Capabilities capabilities; - return capabilities; -} - -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 deleted file mode 100644 index 91d789f..0000000 --- a/cc/test/pixel_test_output_surface.h +++ /dev/null @@ -1,37 +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_PIXEL_TEST_GRAPHICS_CONTEXT_H_ -#define CC_TEST_PIXEL_TEST_GRAPHICS_CONTEXT_H_ - -#include "base/memory/scoped_ptr.h" -#include "cc/output_surface.h" - -namespace cc { - -class PixelTestOutputSurface : public OutputSurface { - public: - static scoped_ptr<PixelTestOutputSurface> create() { - return make_scoped_ptr(new PixelTestOutputSurface); - } - - virtual ~PixelTestOutputSurface(); - - // OutputSurface overrides. - 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(CompositorFrame*) OVERRIDE {} - - private: - PixelTestOutputSurface(); - - scoped_ptr<WebKit::WebGraphicsContext3D> context_; -}; - -} // namespace cc - -#endif // CC_TEST_PIXEL_TEST_GRAPHICS_CONTEXT_H_ diff --git a/cc/thread_proxy.cc b/cc/thread_proxy.cc index 45148a3..9e7773c 100644 --- a/cc/thread_proxy.cc +++ b/cc/thread_proxy.cc @@ -1028,7 +1028,7 @@ void ThreadProxy::initializeRendererOnImplThread(CompletionEvent* completion, bo capabilities->usingSwapCompleteCallback); int maxFramesPending = FrameRateController::kDefaultMaxFramesPending; - if (m_layerTreeHostImpl->outputSurface()->Capabilities().has_parent_compositor) + if (m_layerTreeHostImpl->outputSurface()->capabilities().has_parent_compositor) maxFramesPending = 1; m_schedulerOnImplThread->setMaxFramesPending(maxFramesPending); } diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc index a68db9b..4e80d9b 100644 --- a/content/browser/renderer_host/compositor_impl_android.cc +++ b/content/browser/renderer_host/compositor_impl_android.cc @@ -41,45 +41,6 @@ static bool g_initialized = false; static webkit_glue::WebThreadImpl* g_impl_thread = NULL; static bool g_use_direct_gl = false; -// Adapts a pure WebGraphicsContext3D into a cc::OutputSurface. -class WebGraphicsContextToOutputSurfaceAdapter : public cc::OutputSurface { - public: - explicit WebGraphicsContextToOutputSurfaceAdapter( - WebKit::WebGraphicsContext3D* context) - : context3d_(context), - client_(0) { - } - - virtual bool BindToClient(cc::OutputSurfaceClient* client) OVERRIDE { - DCHECK(client); - if (!context3d_->makeContextCurrent()) - return false; - client_ = client; - return true; - } - - virtual const struct Capabilities& Capabilities() const OVERRIDE { - return capabilities_; - } - - virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE { - return context3d_.get(); - } - - virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE { - return NULL; - } - - virtual void SendFrameToParentCompositor( - cc::CompositorFrame*) OVERRIDE { - } - - private: - scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; - struct Capabilities capabilities_; - cc::OutputSurfaceClient* client_; -}; - } // anonymous namespace namespace content { @@ -318,8 +279,8 @@ scoped_ptr<cc::OutputSurface> CompositorImpl::createOutputSurface() { attrs, window_, NULL)); - return scoped_ptr<cc::OutputSurface>( - new WebGraphicsContextToOutputSurfaceAdapter(context.release())); + return make_scoped_ptr(new cc::OutputSurface( + context.PassAs<WebKit::WebGraphicsContext3D>())); } else { DCHECK(window_ && surface_id_); WebKit::WebGraphicsContext3D::Attributes attrs; @@ -339,8 +300,8 @@ scoped_ptr<cc::OutputSurface> CompositorImpl::createOutputSurface() { LOG(ERROR) << "Failed to create 3D context for compositor."; return scoped_ptr<cc::OutputSurface>(); } - return scoped_ptr<cc::OutputSurface>( - new WebGraphicsContextToOutputSurfaceAdapter(context.release())); + return make_scoped_ptr(new cc::OutputSurface( + context.PassAs<WebKit::WebGraphicsContext3D>())); } } diff --git a/content/browser/renderer_host/image_transport_factory.cc b/content/browser/renderer_host/image_transport_factory.cc index 908a091..94103d7 100644 --- a/content/browser/renderer_host/image_transport_factory.cc +++ b/content/browser/renderer_host/image_transport_factory.cc @@ -296,9 +296,8 @@ class BrowserCompositorOutputSurface WebGraphicsContext3DCommandBufferImpl* context, int surface_id, BrowserCompositorOutputSurfaceProxy* output_surface_proxy) - : context3D_(context), + : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>(context)), surface_id_(surface_id), - client_(NULL), output_surface_proxy_(output_surface_proxy) { DetachFromThread(); } @@ -313,37 +312,14 @@ class BrowserCompositorOutputSurface virtual bool BindToClient( cc::OutputSurfaceClient* client) OVERRIDE { DCHECK(CalledOnValidThread()); - DCHECK(client); - DCHECK(!client_); - if (context3D_.get()) { - if (!context3D_->makeContextCurrent()) - return false; - } - client_ = client; + if (!OutputSurface::BindToClient(client)) + return false; + output_surface_proxy_->AddSurface(this, surface_id_); return true; } - virtual const struct Capabilities& Capabilities() const OVERRIDE { - DCHECK(CalledOnValidThread()); - return capabilities_; - } - - virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE { - DCHECK(CalledOnValidThread()); - return context3D_.get(); - } - - virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE { - DCHECK(CalledOnValidThread()); - return NULL; - } - - virtual void SendFrameToParentCompositor( - cc::CompositorFrame*) OVERRIDE { - } - void OnUpdateVSyncParameters( base::TimeTicks timebase, base::TimeDelta interval) { DCHECK(CalledOnValidThread()); @@ -352,10 +328,7 @@ class BrowserCompositorOutputSurface } private: - scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3D_; int surface_id_; - struct Capabilities capabilities_; - cc::OutputSurfaceClient* client_; scoped_refptr<BrowserCompositorOutputSurfaceProxy> output_surface_proxy_; }; diff --git a/content/renderer/gpu/compositor_output_surface.cc b/content/renderer/gpu/compositor_output_surface.cc index da7c3c1..e3aec12 100644 --- a/content/renderer/gpu/compositor_output_surface.cc +++ b/content/renderer/gpu/compositor_output_surface.cc @@ -47,12 +47,11 @@ CompositorOutputSurface::CompositorOutputSurface( int32 routing_id, WebGraphicsContext3D* context3D, cc::SoftwareOutputDevice* software_device) - : output_surface_filter_( + : OutputSurface(make_scoped_ptr(context3D), + make_scoped_ptr(software_device)), + output_surface_filter_( RenderThreadImpl::current()->compositor_output_surface_filter()), - client_(NULL), routing_id_(routing_id), - context3D_(context3D), - software_device_(software_device), prefers_smoothness_(false), main_thread_id_(base::PlatformThread::CurrentId()) { DCHECK(output_surface_filter_); @@ -65,26 +64,17 @@ CompositorOutputSurface::~CompositorOutputSurface() { if (!client_) return; UpdateSmoothnessTakesPriority(false); - output_surface_proxy_->ClearOutputSurface(); + if (output_surface_proxy_) + output_surface_proxy_->ClearOutputSurface(); output_surface_filter_->RemoveRoute(routing_id_); } -const struct cc::OutputSurface::Capabilities& - CompositorOutputSurface::Capabilities() const { - DCHECK(CalledOnValidThread()); - return capabilities_; -} - bool CompositorOutputSurface::BindToClient( cc::OutputSurfaceClient* client) { DCHECK(CalledOnValidThread()); - DCHECK(!client_); - if (context3D_.get()) { - if (!context3D_->makeContextCurrent()) - return false; - } - client_ = client; + if (!cc::OutputSurface::BindToClient(client)) + return false; output_surface_proxy_ = new CompositorOutputSurfaceProxy(this); output_surface_filter_->AddRoute( @@ -95,15 +85,6 @@ bool CompositorOutputSurface::BindToClient( return true; } -WebGraphicsContext3D* CompositorOutputSurface::Context3D() const { - DCHECK(CalledOnValidThread()); - return context3D_.get(); -} - -cc::SoftwareOutputDevice* CompositorOutputSurface::SoftwareDevice() const { - return software_device_.get(); -} - void CompositorOutputSurface::SendFrameToParentCompositor( cc::CompositorFrame* frame) { DCHECK(CalledOnValidThread()); diff --git a/content/renderer/gpu/compositor_output_surface.h b/content/renderer/gpu/compositor_output_surface.h index ffc6965..fa8e4c6 100644 --- a/content/renderer/gpu/compositor_output_surface.h +++ b/content/renderer/gpu/compositor_output_surface.h @@ -13,7 +13,6 @@ #include "base/threading/platform_thread.h" #include "base/time.h" #include "cc/output_surface.h" -#include "cc/software_output_device.h" namespace base { class TaskRunner; @@ -42,9 +41,6 @@ class CompositorOutputSurface // cc::OutputSurface implementation. virtual bool BindToClient(cc::OutputSurfaceClient* client) OVERRIDE; - virtual const struct Capabilities& Capabilities() const OVERRIDE; - virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE; - virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE; virtual void SendFrameToParentCompositor(cc::CompositorFrame*) OVERRIDE; // TODO(epenner): This seems out of place here and would be a better fit @@ -78,12 +74,8 @@ class CompositorOutputSurface bool Send(IPC::Message* message); scoped_refptr<IPC::ForwardingMessageFilter> output_surface_filter_; - cc::OutputSurfaceClient* client_; scoped_refptr<CompositorOutputSurfaceProxy> output_surface_proxy_; int routing_id_; - struct Capabilities capabilities_; - scoped_ptr<WebKit::WebGraphicsContext3D> context3D_; - scoped_ptr<cc::SoftwareOutputDevice> software_device_; bool prefers_smoothness_; base::PlatformThreadId main_thread_id_; }; diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc index 069afef..923d10d 100644 --- a/ui/compositor/compositor.cc +++ b/ui/compositor/compositor.cc @@ -52,46 +52,6 @@ ui::ContextFactory* g_context_factory = NULL; const int kCompositorLockTimeoutMs = 67; -// Adapts a pure WebGraphicsContext3D into a cc::OutputSurface. -class WebGraphicsContextToOutputSurfaceAdapter - : public cc::OutputSurface { - public: - explicit WebGraphicsContextToOutputSurfaceAdapter( - WebKit::WebGraphicsContext3D* context) - : context3D_(context), - client_(NULL) { - } - - virtual bool BindToClient( - cc::OutputSurfaceClient* client) OVERRIDE { - DCHECK(client); - if (!context3D_->makeContextCurrent()) - return false; - client_ = client; - return true; - } - - virtual const struct Capabilities& Capabilities() const OVERRIDE { - return capabilities_; - } - - virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE { - return context3D_.get(); - } - - virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE { - return NULL; - } - - virtual void SendFrameToParentCompositor(cc::CompositorFrame*) OVERRIDE { - } - - private: - scoped_ptr<WebKit::WebGraphicsContext3D> context3D_; - struct Capabilities capabilities_; - cc::OutputSurfaceClient* client_; -}; - class PendingSwap { public: PendingSwap(SwapType type, ui::PostedSwapQueue* posted_swaps); @@ -154,8 +114,8 @@ bool DefaultContextFactory::Initialize() { cc::OutputSurface* DefaultContextFactory::CreateOutputSurface( Compositor* compositor) { - return new WebGraphicsContextToOutputSurfaceAdapter( - CreateContextCommon(compositor, false)); + return new cc::OutputSurface( + make_scoped_ptr(CreateContextCommon(compositor, false))); } WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateOffscreenContext() { @@ -506,13 +466,13 @@ void Compositor::applyScrollAndScale(gfx::Vector2d scrollDelta, scoped_ptr<cc::OutputSurface> Compositor::createOutputSurface() { if (g_test_compositor_enabled) { - ui::TestWebGraphicsContext3D* test_context = - new ui::TestWebGraphicsContext3D(); - test_context->Initialize(); - return scoped_ptr<cc::OutputSurface>( - new WebGraphicsContextToOutputSurfaceAdapter(test_context)); + scoped_ptr<ui::TestWebGraphicsContext3D> context3d( + new ui::TestWebGraphicsContext3D); + context3d->Initialize(); + return make_scoped_ptr(new cc::OutputSurface( + context3d.PassAs<WebKit::WebGraphicsContext3D>())); } else { - return scoped_ptr<cc::OutputSurface>( + return make_scoped_ptr( ContextFactory::GetInstance()->CreateOutputSurface(this)); } } diff --git a/webkit/compositor_bindings/compositor_bindings.gyp b/webkit/compositor_bindings/compositor_bindings.gyp index b1d87b2..b115b67 100644 --- a/webkit/compositor_bindings/compositor_bindings.gyp +++ b/webkit/compositor_bindings/compositor_bindings.gyp @@ -11,8 +11,6 @@ 'web_animation_id_provider.h', 'web_animation_impl.cc', 'web_animation_impl.h', - 'web_compositor_support_output_surface.cc', - 'web_compositor_support_output_surface.h', 'web_compositor_support_software_output_device.cc', 'web_compositor_support_software_output_device.h', 'web_content_layer_impl.cc', diff --git a/webkit/compositor_bindings/web_compositor_support_impl.cc b/webkit/compositor_bindings/web_compositor_support_impl.cc index 705f74f..1f19bed2 100644 --- a/webkit/compositor_bindings/web_compositor_support_impl.cc +++ b/webkit/compositor_bindings/web_compositor_support_impl.cc @@ -6,10 +6,10 @@ #include "base/memory/scoped_ptr.h" #include "base/message_loop_proxy.h" +#include "cc/output_surface.h" #include "cc/thread_impl.h" #include "cc/transform_operations.h" #include "webkit/compositor_bindings/web_animation_impl.h" -#include "webkit/compositor_bindings/web_compositor_support_output_surface.h" #include "webkit/compositor_bindings/web_compositor_support_software_output_device.h" #include "webkit/compositor_bindings/web_content_layer_impl.h" #include "webkit/compositor_bindings/web_external_texture_layer_impl.h" @@ -84,16 +84,15 @@ WebKit::WebCompositorOutputSurface* WebCompositorSupportImpl::createOutputSurfaceFor3D( WebKit::WebGraphicsContext3D* context) { scoped_ptr<WebKit::WebGraphicsContext3D> context3d = make_scoped_ptr(context); - return WebCompositorSupportOutputSurface::Create3d( - context3d.Pass()).release(); + return new cc::OutputSurface(context3d.Pass()); } WebKit::WebCompositorOutputSurface* WebCompositorSupportImpl::createOutputSurfaceForSoftware() { scoped_ptr<WebCompositorSupportSoftwareOutputDevice> software_device = make_scoped_ptr(new WebCompositorSupportSoftwareOutputDevice); - return WebCompositorSupportOutputSurface::CreateSoftware( - software_device.PassAs<cc::SoftwareOutputDevice>()).release(); + return new cc::OutputSurface( + software_device.PassAs<cc::SoftwareOutputDevice>()); } WebLayer* WebCompositorSupportImpl::createLayer() { diff --git a/webkit/compositor_bindings/web_compositor_support_output_surface.cc b/webkit/compositor_bindings/web_compositor_support_output_surface.cc deleted file mode 100644 index 03d49f1..0000000 --- a/webkit/compositor_bindings/web_compositor_support_output_surface.cc +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 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 "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h" -#include "webkit/compositor_bindings/web_compositor_support_output_surface.h" - -namespace webkit { - -WebCompositorSupportOutputSurface::WebCompositorSupportOutputSurface( - scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { - context3d_ = context3d.Pass(); -} - -WebCompositorSupportOutputSurface::WebCompositorSupportOutputSurface( - scoped_ptr<cc::SoftwareOutputDevice> software_device) { - software_device_ = software_device.Pass(); -} - -WebCompositorSupportOutputSurface::~WebCompositorSupportOutputSurface() {} - -bool WebCompositorSupportOutputSurface::BindToClient( - cc::OutputSurfaceClient* client) { - if (!context3d_) - return true; - DCHECK(client); - return context3d_->makeContextCurrent(); -} - -const struct cc::OutputSurface::Capabilities& - WebCompositorSupportOutputSurface::Capabilities() const { - return capabilities_; -} - -WebKit::WebGraphicsContext3D* WebCompositorSupportOutputSurface::Context3D() const { - return context3d_.get(); -} - -cc::SoftwareOutputDevice* WebCompositorSupportOutputSurface::SoftwareDevice() const { - return software_device_.get(); -} - -void WebCompositorSupportOutputSurface::SendFrameToParentCompositor( - cc::CompositorFrame*) { - // No support for delegated renderers in DumpRenderTree. - NOTREACHED(); -} - -} // namespace webkit diff --git a/webkit/compositor_bindings/web_compositor_support_output_surface.h b/webkit/compositor_bindings/web_compositor_support_output_surface.h deleted file mode 100644 index c1bd598..0000000 --- a/webkit/compositor_bindings/web_compositor_support_output_surface.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 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 WEBKIT_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_OUTPUT_SURFACE -#define WEBKIT_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_OUTPUT_SURFACE - -#include "base/memory/scoped_ptr.h" -#include "cc/output_surface.h" -#include "webkit/compositor_bindings/web_compositor_support_software_output_device.h" -#include "webkit/compositor_bindings/webkit_compositor_bindings_export.h" - -namespace webkit { - -class WebCompositorSupportOutputSurface : public cc::OutputSurface { - public: - - static inline scoped_ptr<WebCompositorSupportOutputSurface> Create3d( - scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { - return make_scoped_ptr( - new WebCompositorSupportOutputSurface(context3d.Pass())); - } - - static inline scoped_ptr<WebCompositorSupportOutputSurface> CreateSoftware( - scoped_ptr<cc::SoftwareOutputDevice> software_device) { - return make_scoped_ptr( - new WebCompositorSupportOutputSurface(software_device.Pass())); - } - - virtual ~WebCompositorSupportOutputSurface(); - - virtual bool BindToClient(cc::OutputSurfaceClient*) OVERRIDE; - - virtual const struct Capabilities& Capabilities() const OVERRIDE; - - virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE; - virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE; - - virtual void SendFrameToParentCompositor(cc::CompositorFrame*) OVERRIDE; - -private: - WEBKIT_COMPOSITOR_BINDINGS_EXPORT explicit WebCompositorSupportOutputSurface( - scoped_ptr<WebKit::WebGraphicsContext3D> context3d); - WEBKIT_COMPOSITOR_BINDINGS_EXPORT explicit WebCompositorSupportOutputSurface( - scoped_ptr<cc::SoftwareOutputDevice> software_device); - - struct cc::OutputSurface::Capabilities capabilities_; - scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; - scoped_ptr<cc::SoftwareOutputDevice> software_device_; -}; - -} // namespace webkit - -#endif // WEBKIT_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_OUTPUT_SURFACE 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 index 0162afd..69caab9 100644 --- a/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc +++ b/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc @@ -10,6 +10,7 @@ #include "cc/input_handler.h" #include "cc/layer.h" #include "cc/layer_tree_host.h" +#include "cc/output_surface.h" #include "cc/switches.h" #include "cc/thread.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h" @@ -19,7 +20,6 @@ #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" @@ -158,8 +158,7 @@ scoped_ptr<cc::OutputSurface> WebLayerTreeViewImplForTesting::createOutputSurface() { scoped_ptr<WebGraphicsContext3D> context3d( new cc::FakeWebGraphicsContext3D); - return webkit::WebCompositorSupportOutputSurface::Create3d( - context3d.Pass()).PassAs<cc::OutputSurface>(); + return make_scoped_ptr(new cc::OutputSurface(context3d.Pass())); } void WebLayerTreeViewImplForTesting::didRecreateOutputSurface(bool success) { } |