Chromium Code Reviews| Index: webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc |
| diff --git a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc |
| index 57767ec07397880cdeb510260e92cfad9e699d22..0eda8789960b3cd41c6ef9469dfb9a43f5d80e8b 100644 |
| --- a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc |
| +++ b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc |
| @@ -73,7 +73,7 @@ WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( |
| scoped_ptr<WebKit::WebGraphicsContext3D> context; |
| if (gfx::GLSurface::InitializeOneOff()) { |
| context.reset(new WebGraphicsContext3DInProcessCommandBufferImpl( |
| - attributes, false, window)); |
| + scoped_ptr< ::gpu::GLInProcessContext>(), attributes, false, window)); |
| } |
| return context.Pass(); |
| } |
| @@ -83,12 +83,28 @@ scoped_ptr<WebKit::WebGraphicsContext3D> |
| WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( |
| const WebKit::WebGraphicsContext3D::Attributes& attributes) { |
| return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl( |
| - attributes, true, gfx::kNullAcceleratedWidget)) |
| + scoped_ptr< ::gpu::GLInProcessContext>(), |
| + attributes, |
| + true, |
| + gfx::kNullAcceleratedWidget)) |
| + .PassAs<WebKit::WebGraphicsContext3D>(); |
| +} |
| + |
| +scoped_ptr<WebKit::WebGraphicsContext3D> |
| +WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( |
| + scoped_ptr< ::gpu::GLInProcessContext> context, |
| + const WebKit::WebGraphicsContext3D::Attributes& attributes) { |
| + return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl( |
| + context.Pass(), |
|
joth
2013/08/04 00:45:16
nit: make indent consistent with line 86 (I think
boliu
2013/08/05 16:58:24
clang-formatted both. Not exactly as you suggested
|
| + attributes, |
| + true /* is_offscreen. Not used. */, |
| + gfx::kNullAcceleratedWidget /* window. Not used. */)) |
| .PassAs<WebKit::WebGraphicsContext3D>(); |
| } |
| WebGraphicsContext3DInProcessCommandBufferImpl:: |
| WebGraphicsContext3DInProcessCommandBufferImpl( |
| + scoped_ptr< ::gpu::GLInProcessContext> context, |
| const WebKit::WebGraphicsContext3D::Attributes& attributes, |
| bool is_offscreen, |
| gfx::AcceleratedWidget window) |
| @@ -96,6 +112,7 @@ WebGraphicsContext3DInProcessCommandBufferImpl:: |
| window_(window), |
| initialized_(false), |
| initialize_failed_(false), |
| + context_(context.Pass()), |
| gl_(NULL), |
| context_lost_callback_(NULL), |
| context_lost_reason_(GL_NO_ERROR), |
| @@ -118,46 +135,48 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() { |
| // Ensure the gles2 library is initialized first in a thread safe way. |
| g_gles2_initializer.Get(); |
| - // Convert WebGL context creation attributes into GLInProcessContext / EGL |
| - // size requests. |
| - const int alpha_size = attributes_.alpha ? 8 : 0; |
| - const int depth_size = attributes_.depth ? 24 : 0; |
| - const int stencil_size = attributes_.stencil ? 8 : 0; |
| - const int samples = attributes_.antialias ? 4 : 0; |
| - const int sample_buffers = attributes_.antialias ? 1 : 0; |
| - const int32 attribs[] = { |
| - GLInProcessContext::ALPHA_SIZE, alpha_size, |
| - GLInProcessContext::DEPTH_SIZE, depth_size, |
| - GLInProcessContext::STENCIL_SIZE, stencil_size, |
| - GLInProcessContext::SAMPLES, samples, |
| - GLInProcessContext::SAMPLE_BUFFERS, sample_buffers, |
| - GLInProcessContext::NONE, |
| - }; |
| - |
| - const char* preferred_extensions = "*"; |
| - |
| - // TODO(kbr): More work will be needed in this implementation to |
| - // properly support GPU switching. Like in the out-of-process |
| - // command buffer implementation, all previously created contexts |
| - // will need to be lost either when the first context requesting the |
| - // discrete GPU is created, or the last one is destroyed. |
| - gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| - |
| - base::Closure context_lost_callback = |
| - base::Bind(&WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost, |
| - base::Unretained(this)); |
| - |
| - context_.reset(GLInProcessContext::CreateContext( |
| - is_offscreen_, |
| - window_, |
| - gfx::Size(1, 1), |
| - attributes_.shareResources, |
| - preferred_extensions, |
| - attribs, |
| - gpu_preference, |
| - context_lost_callback)); |
| - |
| if (!context_) { |
| + // Convert WebGL context creation attributes into GLInProcessContext / EGL |
| + // size requests. |
|
joth
2013/08/04 00:45:16
ah ha, here's where it was copied from. I have no
boliu
2013/08/04 00:53:32
Oh I tried static method. But didn't figure out a
joth
2013/08/04 01:15:50
yeah it's mucky if you want to carry the size info
|
| + const int alpha_size = attributes_.alpha ? 8 : 0; |
| + const int depth_size = attributes_.depth ? 24 : 0; |
| + const int stencil_size = attributes_.stencil ? 8 : 0; |
| + const int samples = attributes_.antialias ? 4 : 0; |
| + const int sample_buffers = attributes_.antialias ? 1 : 0; |
| + const int32 attribs[] = { |
| + GLInProcessContext::ALPHA_SIZE, alpha_size, |
| + GLInProcessContext::DEPTH_SIZE, depth_size, |
| + GLInProcessContext::STENCIL_SIZE, stencil_size, |
| + GLInProcessContext::SAMPLES, samples, |
| + GLInProcessContext::SAMPLE_BUFFERS, sample_buffers, |
| + GLInProcessContext::NONE, |
| + }; |
| + |
| + const char* preferred_extensions = "*"; |
| + |
| + // TODO(kbr): More work will be needed in this implementation to |
| + // properly support GPU switching. Like in the out-of-process |
| + // command buffer implementation, all previously created contexts |
| + // will need to be lost either when the first context requesting the |
| + // discrete GPU is created, or the last one is destroyed. |
| + gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| + |
| + context_.reset(GLInProcessContext::CreateContext( |
| + is_offscreen_, |
| + window_, |
| + gfx::Size(1, 1), |
| + attributes_.shareResources, |
| + preferred_extensions, |
| + attribs, |
| + gpu_preference)); |
| + } |
| + |
| + if (context_) { |
| + base::Closure context_lost_callback = base::Bind( |
| + &WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost, |
| + base::Unretained(this)); |
| + context_->SetContextLostCallback(context_lost_callback); |
| + } else { |
| initialize_failed_ = true; |
| return false; |
| } |