diff options
-rw-r--r-- | cc/test/layer_tree_pixel_test.cc | 2 | ||||
-rw-r--r-- | cc/test/pixel_test.cc | 8 | ||||
-rw-r--r-- | webkit/gpu/context_provider_in_process.cc | 3 | ||||
-rw-r--r-- | webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc | 71 | ||||
-rw-r--r-- | webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h | 20 | ||||
-rw-r--r-- | webkit/support/test_webkit_platform_support.cc | 3 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_webkit_init.cc | 3 |
7 files changed, 81 insertions, 29 deletions
diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc index b213217..34a0f8d 100644 --- a/cc/test/layer_tree_pixel_test.cc +++ b/cc/test/layer_tree_pixel_test.cc @@ -25,7 +25,7 @@ scoped_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface() { using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( - new WebGraphicsContext3DInProcessCommandBufferImpl( + WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( WebKit::WebGraphicsContext3D::Attributes())); return make_scoped_ptr( new OutputSurface(context3d.PassAs<WebKit::WebGraphicsContext3D>())); diff --git a/cc/test/pixel_test.cc b/cc/test/pixel_test.cc index 8d0e64e..8563440 100644 --- a/cc/test/pixel_test.cc +++ b/cc/test/pixel_test.cc @@ -57,10 +57,10 @@ PixelTest::~PixelTest() {} void PixelTest::SetUp() { CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL)); - scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl> - context3d( - new webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl( - WebKit::WebGraphicsContext3D::Attributes())); + using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; + scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( + WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( + WebKit::WebGraphicsContext3D::Attributes())); output_surface_.reset(new OutputSurface( context3d.PassAs<WebKit::WebGraphicsContext3D>())); resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); diff --git a/webkit/gpu/context_provider_in_process.cc b/webkit/gpu/context_provider_in_process.cc index 8fa3fa2..a8855ab 100644 --- a/webkit/gpu/context_provider_in_process.cc +++ b/webkit/gpu/context_provider_in_process.cc @@ -59,8 +59,9 @@ bool ContextProviderInProcess::InitializeOnMainThread() { attributes.shareResources = true; attributes.noAutomaticFlushes = true; + using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; context3d_.reset( - new webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl( + WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( attributes)); return context3d_; diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc index 689ee34..c4ad5ac 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc +++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc @@ -89,15 +89,12 @@ class GLInProcessContext { void PumpCommands(); bool GetBufferChanged(int32 transfer_buffer_id); - // Create a GLInProcessContext that renders to an offscreen frame buffer. If - // parent is not NULL, that GLInProcessContext can access a copy of the - // created GLInProcessContext's frame buffer that is updated every time - // SwapBuffers is called. It is not as general as shared GLInProcessContexts - // in other implementations of OpenGL. If parent is not NULL, it must be used - // on the same thread as the parent. A child GLInProcessContext may not - // outlive its parent. attrib_list must be NULL or a NONE-terminated list of - // attribute/value pairs. - static GLInProcessContext* CreateOffscreenContext( + // Create a GLInProcessContext, if |is_offscreen| is true, renders to an + // offscreen context. |attrib_list| must be NULL or a NONE-terminated list + // of attribute/value pairs. + static GLInProcessContext* CreateContext( + bool is_offscreen, + gfx::AcceleratedWidget window, const gfx::Size& size, bool share_resources, const char* allowed_extensions, @@ -148,7 +145,9 @@ class GLInProcessContext { private: explicit GLInProcessContext(bool share_resources); - bool Initialize(const gfx::Size& size, + bool Initialize(bool is_offscreen, + gfx::AcceleratedWidget window, + const gfx::Size& size, const char* allowed_extensions, const int32* attrib_list, gfx::GpuPreference gpu_preference); @@ -208,7 +207,9 @@ GLInProcessContext::~GLInProcessContext() { Destroy(); } -GLInProcessContext* GLInProcessContext::CreateOffscreenContext( +GLInProcessContext* GLInProcessContext::CreateContext( + bool is_offscreen, + gfx::AcceleratedWidget window, const gfx::Size& size, bool share_resources, const char* allowed_extensions, @@ -217,6 +218,8 @@ GLInProcessContext* GLInProcessContext::CreateOffscreenContext( scoped_ptr<GLInProcessContext> context( new GLInProcessContext(share_resources)); if (!context->Initialize( + is_offscreen, + window, size, allowed_extensions, attrib_list, @@ -385,10 +388,13 @@ GLInProcessContext::GLInProcessContext(bool share_resources) context_lost_(false) { } -bool GLInProcessContext::Initialize(const gfx::Size& size, - const char* allowed_extensions, - const int32* attrib_list, - gfx::GpuPreference gpu_preference) { +bool GLInProcessContext::Initialize( + bool is_offscreen, + gfx::AcceleratedWidget window, + const gfx::Size& size, + const char* allowed_extensions, + const int32* attrib_list, + gfx::GpuPreference gpu_preference) { // Use one share group for all contexts. CR_DEFINE_STATIC_LOCAL(scoped_refptr<gfx::GLShareGroup>, share_group, (new gfx::GLShareGroup)); @@ -461,7 +467,10 @@ bool GLInProcessContext::Initialize(const gfx::Size& size, decoder_->set_engine(gpu_scheduler_.get()); - surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1)); + if (is_offscreen) + surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, size); + else + surface_ = gfx::GLSurface::CreateViewGLSurface(false, window); if (!surface_.get()) { LOG(ERROR) << "Could not create GLSurface."; @@ -574,10 +583,32 @@ void GLInProcessContext::OnContextLost() { context_lost_callback_.Run(); } + +// static +WebGraphicsContext3DInProcessCommandBufferImpl* +WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( + const WebKit::WebGraphicsContext3D::Attributes& attributes, + gfx::AcceleratedWidget window) { + return new WebGraphicsContext3DInProcessCommandBufferImpl( + attributes, false, window); +} + +// static +WebGraphicsContext3DInProcessCommandBufferImpl* +WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( + const WebKit::WebGraphicsContext3D::Attributes& attributes) { + return new WebGraphicsContext3DInProcessCommandBufferImpl( + attributes, true, gfx::kNullAcceleratedWidget); +} + WebGraphicsContext3DInProcessCommandBufferImpl:: WebGraphicsContext3DInProcessCommandBufferImpl( - const WebKit::WebGraphicsContext3D::Attributes& attributes) - : initialized_(false), + const WebKit::WebGraphicsContext3D::Attributes& attributes, + bool is_offscreen, + gfx::AcceleratedWidget window) + : is_offscreen_(is_offscreen), + window_(window), + initialized_(false), initialize_failed_(false), context_(NULL), gl_(NULL), @@ -625,7 +656,9 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() { // discrete GPU is created, or the last one is destroyed. gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; - context_ = GLInProcessContext::CreateOffscreenContext( + context_ = GLInProcessContext::CreateContext( + is_offscreen_, + window_, gfx::Size(1, 1), attributes_.shareResources, preferred_extensions, diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h index 22cd3b3..0d5c177 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h +++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h @@ -45,9 +45,15 @@ class GLInProcessContext; class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl : public NON_EXPORTED_BASE(WebKit::WebGraphicsContext3D) { public: + static WebGraphicsContext3DInProcessCommandBufferImpl* + CreateViewContext( + const WebKit::WebGraphicsContext3D::Attributes& attributes, + gfx::AcceleratedWidget window); + + static WebGraphicsContext3DInProcessCommandBufferImpl* + CreateOffscreenContext( + const WebKit::WebGraphicsContext3D::Attributes& attributes); - explicit WebGraphicsContext3DInProcessCommandBufferImpl( - const WebKit::WebGraphicsContext3D::Attributes& attributes); virtual ~WebGraphicsContext3DInProcessCommandBufferImpl(); //---------------------------------------------------------------------- @@ -526,6 +532,11 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl virtual GrGLInterface* onCreateGrGLInterface(); private: + WebGraphicsContext3DInProcessCommandBufferImpl( + const WebKit::WebGraphicsContext3D::Attributes& attributes, + bool is_offscreen, + gfx::AcceleratedWidget window); + // SwapBuffers callback. void OnSwapBuffersComplete(); virtual void OnContextLost(); @@ -536,6 +547,11 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl // instead of going through WebGraphicsContext3D. void ClearContext(); + + bool is_offscreen_; + // Only used when not offscreen. + gfx::AcceleratedWidget window_; + bool initialized_; bool initialize_failed_; diff --git a/webkit/support/test_webkit_platform_support.cc b/webkit/support/test_webkit_platform_support.cc index a12bd6a..c615405 100644 --- a/webkit/support/test_webkit_platform_support.cc +++ b/webkit/support/test_webkit_platform_support.cc @@ -371,7 +371,8 @@ WebKit::WebGraphicsContext3D* TestWebKitPlatformSupport::createOffscreenGraphicsContext3D( const WebKit::WebGraphicsContext3D::Attributes& attributes) { using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; - return new WebGraphicsContext3DInProcessCommandBufferImpl(attributes); + return WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( + attributes); } WebKit::WebGraphicsContext3D* diff --git a/webkit/tools/test_shell/test_shell_webkit_init.cc b/webkit/tools/test_shell/test_shell_webkit_init.cc index f09e117..2dcbb6c 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.cc +++ b/webkit/tools/test_shell/test_shell_webkit_init.cc @@ -266,7 +266,8 @@ WebKit::WebIDBFactory* TestShellWebKitInit::idbFactory() { WebKit::WebGraphicsContext3D* TestShellWebKitInit::createOffscreenGraphicsContext3D( const WebKit::WebGraphicsContext3D::Attributes& attributes) { - return new webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl( + using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; + return WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( attributes); } |