Chromium Code Reviews| Index: content/common/gpu/gpu_command_buffer_stub.cc |
| diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc |
| index d0ed3d1c42908ca3b99bd7de42dc60870fad4c93..91cc5bfecff6497b4a4014466b5dd4d0d56bf27c 100644 |
| --- a/content/common/gpu/gpu_command_buffer_stub.cc |
| +++ b/content/common/gpu/gpu_command_buffer_stub.cc |
| @@ -164,8 +164,7 @@ gfx::GLSurface::Format GetSurfaceFormatFromAttribute( |
| const gpu::gles2::ContextCreationAttribHelper& attrib, |
| bool use_virtualized_gl_context) { |
| gfx::GLSurface::Format format = gfx::GLSurface::SURFACE_DEFAULT; // ARGB8888 |
| - if (!use_virtualized_gl_context && |
| - attrib.red_size <= 5 && |
| + if (attrib.red_size <= 5 && |
| attrib.green_size <= 6 && |
| attrib.blue_size <= 5 && |
| attrib.alpha_size == 0) { |
| @@ -561,39 +560,36 @@ void GpuCommandBufferStub::OnInitialize( |
| } |
| scoped_refptr<gfx::GLContext> context; |
| - if (use_virtualized_gl_context_ && channel_->share_group()) { |
| - context = channel_->share_group()->GetSharedContext(); |
| + gfx::GLShareGroup* share_group = channel_->share_group(); |
| + if (use_virtualized_gl_context_ && share_group) { |
|
no sievers
2016/02/17 00:56:26
Is it simpler to just treat |is_onscreen && is_low
Jinsuk Kim
2016/02/17 07:23:32
Good to know that virtualization can be done for s
|
| + context = share_group->GetSharedContext(); |
| if (!context.get()) { |
| - context = gfx::GLContext::CreateGLContext( |
| - channel_->share_group(), |
| - channel_->gpu_channel_manager()->GetDefaultOffscreenSurface(), |
| - gpu_preference_); |
| + share_group->UpdateActiveSharedContext(surface_.get(), gpu_preference_); |
| + context = share_group->GetSharedContext(); |
| if (!context.get()) { |
| - DLOG(ERROR) << "Failed to create shared context for virtualization."; |
| OnInitializeFailed(reply_message); |
| return; |
| } |
| - channel_->share_group()->SetSharedContext(context.get()); |
| } |
| // This should be a non-virtual GL context. |
| DCHECK(context->GetHandle()); |
| context = new gpu::GLContextVirtual( |
| - channel_->share_group(), context.get(), decoder_->AsWeakPtr()); |
| + share_group, context.get(), decoder_->AsWeakPtr()); |
| if (!context->Initialize(surface_.get(), gpu_preference_)) { |
| - // TODO(sievers): The real context created above for the default |
| - // offscreen surface might not be compatible with this surface. |
| - // Need to adjust at least GLX to be able to create the initial context |
| - // with a config that is compatible with onscreen and offscreen surfaces. |
| - context = NULL; |
| - |
| - DLOG(ERROR) << "Failed to initialize virtual GL context."; |
| - OnInitializeFailed(reply_message); |
| - return; |
| + // Context with incompatible configuration was attempted to be made |
| + // current. Update the shared context to a compatible one and init again. |
| + share_group->UpdateActiveSharedContext(surface_.get(), gpu_preference_); |
| + context->UpdateSharedContext(share_group->GetSharedContext()); |
| + if (!context->Initialize(surface_.get(), gpu_preference_)) { |
| + DLOG(ERROR) << "Failed to initialize virtual GL context."; |
| + OnInitializeFailed(reply_message); |
| + return; |
| + } |
| } |
| } |
| if (!context.get()) { |
| context = gfx::GLContext::CreateGLContext( |
| - channel_->share_group(), surface_.get(), gpu_preference_); |
| + share_group, surface_.get(), gpu_preference_); |
| } |
| if (!context.get()) { |
| DLOG(ERROR) << "Failed to create context."; |