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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 222 |
223 WebGraphicsContext3DCommandBufferImpl::ShareGroup::~ShareGroup() { | 223 WebGraphicsContext3DCommandBufferImpl::ShareGroup::~ShareGroup() { |
224 DCHECK(contexts_.empty()); | 224 DCHECK(contexts_.empty()); |
225 } | 225 } |
226 | 226 |
227 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( | 227 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( |
228 int surface_id, | 228 int surface_id, |
229 const GURL& active_url, | 229 const GURL& active_url, |
230 GpuChannelHost* host, | 230 GpuChannelHost* host, |
231 const Attributes& attributes, | 231 const Attributes& attributes, |
| 232 #if !defined(OS_CHROMEOS) |
232 bool bind_generates_resources, | 233 bool bind_generates_resources, |
| 234 #endif |
233 bool lose_context_when_out_of_memory, | 235 bool lose_context_when_out_of_memory, |
234 const SharedMemoryLimits& limits, | 236 const SharedMemoryLimits& limits, |
235 WebGraphicsContext3DCommandBufferImpl* share_context) | 237 WebGraphicsContext3DCommandBufferImpl* share_context) |
236 : initialize_failed_(false), | 238 : initialize_failed_(false), |
237 visible_(false), | 239 visible_(false), |
238 host_(host), | 240 host_(host), |
239 surface_id_(surface_id), | 241 surface_id_(surface_id), |
240 active_url_(active_url), | 242 active_url_(active_url), |
241 context_lost_callback_(0), | 243 context_lost_callback_(0), |
242 context_lost_reason_(GL_NO_ERROR), | 244 context_lost_reason_(GL_NO_ERROR), |
243 error_message_callback_(0), | 245 error_message_callback_(0), |
244 attributes_(attributes), | 246 attributes_(attributes), |
245 gpu_preference_(attributes.preferDiscreteGPU ? gfx::PreferDiscreteGpu | 247 gpu_preference_(attributes.preferDiscreteGPU ? gfx::PreferDiscreteGpu |
246 : gfx::PreferIntegratedGpu), | 248 : gfx::PreferIntegratedGpu), |
247 weak_ptr_factory_(this), | 249 weak_ptr_factory_(this), |
248 initialized_(false), | 250 initialized_(false), |
249 gl_(NULL), | 251 gl_(NULL), |
| 252 #if !defined(OS_CHROMEOS) |
250 bind_generates_resources_(bind_generates_resources), | 253 bind_generates_resources_(bind_generates_resources), |
| 254 #endif |
251 lose_context_when_out_of_memory_(lose_context_when_out_of_memory), | 255 lose_context_when_out_of_memory_(lose_context_when_out_of_memory), |
252 mem_limits_(limits), | 256 mem_limits_(limits), |
253 flush_id_(0) { | 257 flush_id_(0) { |
254 if (share_context) { | 258 if (share_context) { |
255 DCHECK(!attributes_.shareResources); | 259 DCHECK(!attributes_.shareResources); |
256 share_group_ = share_context->share_group_; | 260 share_group_ = share_context->share_group_; |
257 } else { | 261 } else { |
258 share_group_ = attributes_.shareResources | 262 share_group_ = attributes_.shareResources |
259 ? GetDefaultShareGroupForHost(host) | 263 ? GetDefaultShareGroupForHost(host) |
260 : scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup>( | 264 : scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup>( |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 attribs.push_back(STENCIL_SIZE); | 351 attribs.push_back(STENCIL_SIZE); |
348 attribs.push_back(attributes_.stencil ? 8 : 0); | 352 attribs.push_back(attributes_.stencil ? 8 : 0); |
349 attribs.push_back(SAMPLES); | 353 attribs.push_back(SAMPLES); |
350 attribs.push_back(attributes_.antialias ? 4 : 0); | 354 attribs.push_back(attributes_.antialias ? 4 : 0); |
351 attribs.push_back(SAMPLE_BUFFERS); | 355 attribs.push_back(SAMPLE_BUFFERS); |
352 attribs.push_back(attributes_.antialias ? 1 : 0); | 356 attribs.push_back(attributes_.antialias ? 1 : 0); |
353 attribs.push_back(FAIL_IF_MAJOR_PERF_CAVEAT); | 357 attribs.push_back(FAIL_IF_MAJOR_PERF_CAVEAT); |
354 attribs.push_back(attributes_.failIfMajorPerformanceCaveat ? 1 : 0); | 358 attribs.push_back(attributes_.failIfMajorPerformanceCaveat ? 1 : 0); |
355 attribs.push_back(LOSE_CONTEXT_WHEN_OUT_OF_MEMORY); | 359 attribs.push_back(LOSE_CONTEXT_WHEN_OUT_OF_MEMORY); |
356 attribs.push_back(lose_context_when_out_of_memory_ ? 1 : 0); | 360 attribs.push_back(lose_context_when_out_of_memory_ ? 1 : 0); |
| 361 #if defined(OS_CHROMEOS) |
| 362 attribs.push_back(BIND_GENERATES_RESOURCES); |
| 363 attribs.push_back(0); |
| 364 #endif |
357 attribs.push_back(NONE); | 365 attribs.push_back(NONE); |
358 | 366 |
359 // Create a proxy to a command buffer in the GPU process. | 367 // Create a proxy to a command buffer in the GPU process. |
360 if (onscreen) { | 368 if (onscreen) { |
361 command_buffer_.reset(host_->CreateViewCommandBuffer( | 369 command_buffer_.reset(host_->CreateViewCommandBuffer( |
362 surface_id_, | 370 surface_id_, |
363 share_group_command_buffer, | 371 share_group_command_buffer, |
364 attribs, | 372 attribs, |
365 active_url_, | 373 active_url_, |
366 gpu_preference_)); | 374 gpu_preference_)); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 | 429 |
422 if (attributes_.noAutomaticFlushes) | 430 if (attributes_.noAutomaticFlushes) |
423 gles2_helper_->SetAutomaticFlushes(false); | 431 gles2_helper_->SetAutomaticFlushes(false); |
424 // Create a transfer buffer used to copy resources between the renderer | 432 // Create a transfer buffer used to copy resources between the renderer |
425 // process and the GPU process. | 433 // process and the GPU process. |
426 transfer_buffer_ .reset(new gpu::TransferBuffer(gles2_helper_.get())); | 434 transfer_buffer_ .reset(new gpu::TransferBuffer(gles2_helper_.get())); |
427 | 435 |
428 DCHECK(host_.get()); | 436 DCHECK(host_.get()); |
429 | 437 |
430 // Create the object exposing the OpenGL API. | 438 // Create the object exposing the OpenGL API. |
| 439 #if defined(OS_CHROMEOS) |
| 440 bool bind_generates_resources = false; |
| 441 #endif |
| 442 |
431 real_gl_.reset( | 443 real_gl_.reset( |
432 new gpu::gles2::GLES2Implementation(gles2_helper_.get(), | 444 new gpu::gles2::GLES2Implementation(gles2_helper_.get(), |
433 gles2_share_group, | 445 gles2_share_group, |
434 transfer_buffer_.get(), | 446 transfer_buffer_.get(), |
| 447 #if defined(OS_CHROMEOS) |
| 448 bind_generates_resources, |
| 449 #else |
435 bind_generates_resources_, | 450 bind_generates_resources_, |
| 451 #endif |
436 lose_context_when_out_of_memory_, | 452 lose_context_when_out_of_memory_, |
437 command_buffer_.get())); | 453 command_buffer_.get())); |
438 gl_ = real_gl_.get(); | 454 gl_ = real_gl_.get(); |
439 | 455 |
440 if (!real_gl_->Initialize( | 456 if (!real_gl_->Initialize( |
441 mem_limits_.start_transfer_buffer_size, | 457 mem_limits_.start_transfer_buffer_size, |
442 mem_limits_.min_transfer_buffer_size, | 458 mem_limits_.min_transfer_buffer_size, |
443 mem_limits_.max_transfer_buffer_size, | 459 mem_limits_.max_transfer_buffer_size, |
444 mem_limits_.mapped_memory_reclaim_limit)) { | 460 mem_limits_.mapped_memory_reclaim_limit)) { |
445 LOG(ERROR) << "Failed to initialize GLES2Implementation."; | 461 LOG(ERROR) << "Failed to initialize GLES2Implementation."; |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 const WebGraphicsContext3D::Attributes& attributes, | 1214 const WebGraphicsContext3D::Attributes& attributes, |
1199 bool lose_context_when_out_of_memory, | 1215 bool lose_context_when_out_of_memory, |
1200 const GURL& active_url, | 1216 const GURL& active_url, |
1201 const SharedMemoryLimits& limits, | 1217 const SharedMemoryLimits& limits, |
1202 WebGraphicsContext3DCommandBufferImpl* share_context) { | 1218 WebGraphicsContext3DCommandBufferImpl* share_context) { |
1203 if (!host) | 1219 if (!host) |
1204 return NULL; | 1220 return NULL; |
1205 | 1221 |
1206 if (share_context && share_context->IsCommandBufferContextLost()) | 1222 if (share_context && share_context->IsCommandBufferContextLost()) |
1207 return NULL; | 1223 return NULL; |
1208 | 1224 #if !defined(OS_CHROMEOS) |
1209 bool bind_generates_resources = false; | 1225 bool bind_generates_resources = false; |
| 1226 #endif |
1210 return new WebGraphicsContext3DCommandBufferImpl( | 1227 return new WebGraphicsContext3DCommandBufferImpl( |
1211 0, | 1228 0, |
1212 active_url, | 1229 active_url, |
1213 host, | 1230 host, |
1214 attributes, | 1231 attributes, |
| 1232 #if !defined(OS_CHROMEOS) |
1215 bind_generates_resources, | 1233 bind_generates_resources, |
| 1234 #endif |
1216 lose_context_when_out_of_memory, | 1235 lose_context_when_out_of_memory, |
1217 limits, | 1236 limits, |
1218 share_context); | 1237 share_context); |
1219 } | 1238 } |
1220 | 1239 |
1221 DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM, | 1240 DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM, |
1222 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Duint, WGC3Duint) | 1241 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Duint, WGC3Duint) |
1223 | 1242 |
1224 DELEGATE_TO_GL_5(texStorage2DEXT, TexStorage2DEXT, | 1243 DELEGATE_TO_GL_5(texStorage2DEXT, TexStorage2DEXT, |
1225 WGC3Denum, WGC3Dint, WGC3Duint, WGC3Dint, WGC3Dint) | 1244 WGC3Denum, WGC3Dint, WGC3Duint, WGC3Dint, WGC3Dint) |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 | 1419 |
1401 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( | 1420 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( |
1402 const std::string& message, int id) { | 1421 const std::string& message, int id) { |
1403 if (error_message_callback_) { | 1422 if (error_message_callback_) { |
1404 blink::WebString str = blink::WebString::fromUTF8(message.c_str()); | 1423 blink::WebString str = blink::WebString::fromUTF8(message.c_str()); |
1405 error_message_callback_->onErrorMessage(str, id); | 1424 error_message_callback_->onErrorMessage(str, id); |
1406 } | 1425 } |
1407 } | 1426 } |
1408 | 1427 |
1409 } // namespace content | 1428 } // namespace content |
OLD | NEW |