| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 5 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 6 | 6 |
| 7 #include "third_party/khronos/GLES2/gl2.h" | 7 #include "third_party/khronos/GLES2/gl2.h" |
| 8 #ifndef GL_GLEXT_PROTOTYPES | 8 #ifndef GL_GLEXT_PROTOTYPES |
| 9 #define GL_GLEXT_PROTOTYPES 1 | 9 #define GL_GLEXT_PROTOTYPES 1 |
| 10 #endif | 10 #endif |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool WebGraphicsContext3DCommandBufferImpl::Initialize( | 87 bool WebGraphicsContext3DCommandBufferImpl::Initialize( |
| 88 const WebGraphicsContext3D::Attributes& attributes) { | 88 const WebGraphicsContext3D::Attributes& attributes) { |
| 89 DCHECK(!context_); | 89 DCHECK(!context_); |
| 90 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::initialize"); | 90 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::initialize"); |
| 91 GpuChannelHostFactory* factory = GpuChannelHostFactory::instance(); | 91 GpuChannelHostFactory* factory = GpuChannelHostFactory::instance(); |
| 92 if (!factory) | 92 if (!factory) |
| 93 return false; | 93 return false; |
| 94 | 94 |
| 95 // The noExtensions and canRecoverFromContextLoss flags are | 95 if (attributes.preferDiscreteGPU) |
| 96 // currently used as hints that we are creating a context on | |
| 97 // behalf of WebGL or accelerated 2D canvas, respectively. | |
| 98 if (attributes.noExtensions || !attributes.canRecoverFromContextLoss) | |
| 99 gpu_preference_ = gfx::PreferDiscreteGpu; | 96 gpu_preference_ = gfx::PreferDiscreteGpu; |
| 100 | 97 |
| 101 bool retry = false; | 98 bool retry = false; |
| 102 | 99 |
| 103 // Note similar code in Pepper PlatformContext3DImpl::Init. | 100 // Note similar code in Pepper PlatformContext3DImpl::Init. |
| 104 do { | 101 do { |
| 105 host_ = factory->EstablishGpuChannelSync( | 102 host_ = factory->EstablishGpuChannelSync( |
| 106 content:: | 103 content:: |
| 107 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE); | 104 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE); |
| 108 if (!host_) | 105 if (!host_) |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 } | 1204 } |
| 1208 | 1205 |
| 1209 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( | 1206 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( |
| 1210 const std::string& message, int id) { | 1207 const std::string& message, int id) { |
| 1211 if (error_message_callback_) { | 1208 if (error_message_callback_) { |
| 1212 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); | 1209 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); |
| 1213 error_message_callback_->onErrorMessage(str, id); | 1210 error_message_callback_->onErrorMessage(str, id); |
| 1214 } | 1211 } |
| 1215 } | 1212 } |
| 1216 | 1213 |
| OLD | NEW |