Chromium Code Reviews| Index: webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc |
| diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc |
| index c4ad5ac59b8155be365036cf1c50b165a77aa3cc..d7e53fa54098547a41000a8d6e74611d2f9700e6 100644 |
| --- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc |
| +++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc |
| @@ -31,8 +31,9 @@ |
| #include "gpu/command_buffer/common/constants.h" |
| #include "gpu/command_buffer/service/command_buffer_service.h" |
| #include "gpu/command_buffer/service/context_group.h" |
| -#include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| +#include "gpu/command_buffer/service/gl_context_virtual.h" |
| #include "gpu/command_buffer/service/gpu_scheduler.h" |
| +#include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| #include "ui/gl/gl_context.h" |
| #include "ui/gl/gl_share_group.h" |
| #include "ui/gl/gl_surface.h" |
| @@ -99,7 +100,8 @@ class GLInProcessContext { |
| bool share_resources, |
| const char* allowed_extensions, |
| const int32* attrib_list, |
| - gfx::GpuPreference gpu_preference); |
| + gfx::GpuPreference gpu_preference, |
| + bool use_virtualized_gl_context); |
| // For an offscreen frame buffer GLInProcessContext, return the texture ID |
| // with respect to the parent GLInProcessContext. Returns zero if |
| @@ -150,7 +152,8 @@ class GLInProcessContext { |
| const gfx::Size& size, |
| const char* allowed_extensions, |
| const int32* attrib_list, |
| - gfx::GpuPreference gpu_preference); |
| + gfx::GpuPreference gpu_preference, |
| + bool use_virtualized_gl_context); |
| void Destroy(); |
| void OnContextLost(); |
| @@ -214,7 +217,8 @@ GLInProcessContext* GLInProcessContext::CreateContext( |
| bool share_resources, |
| const char* allowed_extensions, |
| const int32* attrib_list, |
| - gfx::GpuPreference gpu_preference) { |
| + gfx::GpuPreference gpu_preference, |
| + bool use_virtualized_gl_context) { |
| scoped_ptr<GLInProcessContext> context( |
| new GLInProcessContext(share_resources)); |
| if (!context->Initialize( |
| @@ -223,7 +227,8 @@ GLInProcessContext* GLInProcessContext::CreateContext( |
| size, |
| allowed_extensions, |
| attrib_list, |
| - gpu_preference)) |
| + gpu_preference, |
| + use_virtualized_gl_context)) |
| return NULL; |
| return context.release(); |
| @@ -394,7 +399,8 @@ bool GLInProcessContext::Initialize( |
| const gfx::Size& size, |
| const char* allowed_extensions, |
| const int32* attrib_list, |
| - gfx::GpuPreference gpu_preference) { |
| + gfx::GpuPreference gpu_preference, |
| + bool use_virtualized_gl_context) { |
| // Use one share group for all contexts. |
| CR_DEFINE_STATIC_LOCAL(scoped_refptr<gfx::GLShareGroup>, share_group, |
| (new gfx::GLShareGroup)); |
| @@ -478,9 +484,29 @@ bool GLInProcessContext::Initialize( |
| return false; |
| } |
| - context_ = gfx::GLContext::CreateGLContext(share_group.get(), |
| - surface_.get(), |
| - gpu_preference); |
| + if (use_virtualized_gl_context) { |
| + context_ = share_group->GetSharedContext(); |
| + if (!context_) { |
| + context_ = gfx::GLContext::CreateGLContext(share_group.get(), |
| + surface_.get(), |
| + gpu_preference); |
| + share_group->SetSharedContext(context_); |
| + } |
| + |
| + // This should be a non-virtual GL context. |
| + DCHECK(context_->GetHandle()); |
|
no sievers
2013/04/19 18:38:40
Won't this DCHECK() fail for WebView (where we nev
|
| + context_ = new ::gpu::GLContextVirtual(share_group.get(), |
| + context_, |
| + decoder_->AsWeakPtr()); |
| + if (context_->Initialize(surface_, gpu_preference)) { |
|
no sievers
2013/04/19 18:39:45
Oh, and you could fall back to the else-path in he
|
| + LOG(INFO) << "Created virtual GL context."; |
| + } |
| + } else { |
| + context_ = gfx::GLContext::CreateGLContext(share_group.get(), |
| + surface_.get(), |
| + gpu_preference); |
| + } |
| + |
| if (!context_.get()) { |
| LOG(ERROR) << "Could not create GLContext."; |
| Destroy(); |
| @@ -588,9 +614,10 @@ void GLInProcessContext::OnContextLost() { |
| WebGraphicsContext3DInProcessCommandBufferImpl* |
| WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( |
| const WebKit::WebGraphicsContext3D::Attributes& attributes, |
| - gfx::AcceleratedWidget window) { |
| + gfx::AcceleratedWidget window, |
| + bool use_virtualized_gl_context) { |
| return new WebGraphicsContext3DInProcessCommandBufferImpl( |
| - attributes, false, window); |
| + attributes, false, window, use_virtualized_gl_context); |
| } |
| // static |
| @@ -598,16 +625,18 @@ WebGraphicsContext3DInProcessCommandBufferImpl* |
| WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( |
| const WebKit::WebGraphicsContext3D::Attributes& attributes) { |
| return new WebGraphicsContext3DInProcessCommandBufferImpl( |
| - attributes, true, gfx::kNullAcceleratedWidget); |
| + attributes, true, gfx::kNullAcceleratedWidget, false); |
| } |
| WebGraphicsContext3DInProcessCommandBufferImpl:: |
| WebGraphicsContext3DInProcessCommandBufferImpl( |
| const WebKit::WebGraphicsContext3D::Attributes& attributes, |
| bool is_offscreen, |
| - gfx::AcceleratedWidget window) |
| + gfx::AcceleratedWidget window, |
| + bool use_virtualized_gl_context) |
| : is_offscreen_(is_offscreen), |
| window_(window), |
| + use_virtualized_gl_context_(use_virtualized_gl_context), |
| initialized_(false), |
| initialize_failed_(false), |
| context_(NULL), |
| @@ -663,7 +692,8 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() { |
| attributes_.shareResources, |
| preferred_extensions, |
| attribs, |
| - gpu_preference); |
| + gpu_preference, |
| + use_virtualized_gl_context_); |
| if (!context_) { |
| initialize_failed_ = true; |