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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 attribs.push_back(DEPTH_SIZE); | 343 attribs.push_back(DEPTH_SIZE); |
344 attribs.push_back(attributes_.depth ? 24 : 0); | 344 attribs.push_back(attributes_.depth ? 24 : 0); |
345 attribs.push_back(STENCIL_SIZE); | 345 attribs.push_back(STENCIL_SIZE); |
346 attribs.push_back(attributes_.stencil ? 8 : 0); | 346 attribs.push_back(attributes_.stencil ? 8 : 0); |
347 attribs.push_back(SAMPLES); | 347 attribs.push_back(SAMPLES); |
348 attribs.push_back(attributes_.antialias ? 4 : 0); | 348 attribs.push_back(attributes_.antialias ? 4 : 0); |
349 attribs.push_back(SAMPLE_BUFFERS); | 349 attribs.push_back(SAMPLE_BUFFERS); |
350 attribs.push_back(attributes_.antialias ? 1 : 0); | 350 attribs.push_back(attributes_.antialias ? 1 : 0); |
351 attribs.push_back(FAIL_IF_MAJOR_PERF_CAVEAT); | 351 attribs.push_back(FAIL_IF_MAJOR_PERF_CAVEAT); |
352 attribs.push_back(attributes_.failIfMajorPerformanceCaveat ? 1 : 0); | 352 attribs.push_back(attributes_.failIfMajorPerformanceCaveat ? 1 : 0); |
| 353 attribs.push_back(LOSE_CONTEXT_WHEN_OUT_OF_MEMORY); |
| 354 attribs.push_back(attributes_.loseContextWhenOutOfMemory ? 1 : 0); |
353 attribs.push_back(NONE); | 355 attribs.push_back(NONE); |
354 | 356 |
355 // Create a proxy to a command buffer in the GPU process. | 357 // Create a proxy to a command buffer in the GPU process. |
356 if (onscreen) { | 358 if (onscreen) { |
357 command_buffer_.reset(host_->CreateViewCommandBuffer( | 359 command_buffer_.reset(host_->CreateViewCommandBuffer( |
358 surface_id_, | 360 surface_id_, |
359 share_group_command_buffer, | 361 share_group_command_buffer, |
360 attribs, | 362 attribs, |
361 active_url_, | 363 active_url_, |
362 gpu_preference_)); | 364 gpu_preference_)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 transfer_buffer_ .reset(new gpu::TransferBuffer(gles2_helper_.get())); | 424 transfer_buffer_ .reset(new gpu::TransferBuffer(gles2_helper_.get())); |
423 | 425 |
424 DCHECK(host_.get()); | 426 DCHECK(host_.get()); |
425 | 427 |
426 // Create the object exposing the OpenGL API. | 428 // Create the object exposing the OpenGL API. |
427 real_gl_.reset(new gpu::gles2::GLES2Implementation( | 429 real_gl_.reset(new gpu::gles2::GLES2Implementation( |
428 gles2_helper_.get(), | 430 gles2_helper_.get(), |
429 gles2_share_group, | 431 gles2_share_group, |
430 transfer_buffer_.get(), | 432 transfer_buffer_.get(), |
431 bind_generates_resources_, | 433 bind_generates_resources_, |
| 434 attributes_.loseContextWhenOutOfMemory, |
432 command_buffer_.get())); | 435 command_buffer_.get())); |
433 gl_ = real_gl_.get(); | 436 gl_ = real_gl_.get(); |
434 | 437 |
435 if (!real_gl_->Initialize( | 438 if (!real_gl_->Initialize( |
436 mem_limits_.start_transfer_buffer_size, | 439 mem_limits_.start_transfer_buffer_size, |
437 mem_limits_.min_transfer_buffer_size, | 440 mem_limits_.min_transfer_buffer_size, |
438 mem_limits_.max_transfer_buffer_size, | 441 mem_limits_.max_transfer_buffer_size, |
439 mem_limits_.mapped_memory_reclaim_limit)) { | 442 mem_limits_.mapped_memory_reclaim_limit)) { |
440 LOG(ERROR) << "Failed to initialize GLES2Implementation."; | 443 LOG(ERROR) << "Failed to initialize GLES2Implementation."; |
441 return false; | 444 return false; |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 | 1394 |
1392 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( | 1395 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( |
1393 const std::string& message, int id) { | 1396 const std::string& message, int id) { |
1394 if (error_message_callback_) { | 1397 if (error_message_callback_) { |
1395 blink::WebString str = blink::WebString::fromUTF8(message.c_str()); | 1398 blink::WebString str = blink::WebString::fromUTF8(message.c_str()); |
1396 error_message_callback_->onErrorMessage(str, id); | 1399 error_message_callback_->onErrorMessage(str, id); |
1397 } | 1400 } |
1398 } | 1401 } |
1399 | 1402 |
1400 } // namespace content | 1403 } // namespace content |
OLD | NEW |