| 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..6e1fce96b2ca19a85793c6b66f83abe28dd65bd6 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,29 @@ 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(),
|
| + 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 +113,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 +136,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.
|
| + 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;
|
| }
|
|
|