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 |
11 #include "third_party/khronos/GLES2/gl2ext.h" | 11 #include "third_party/khronos/GLES2/gl2ext.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <set> | 14 #include <set> |
15 | 15 |
16 #include "base/bind.h" | 16 #include "base/bind.h" |
17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
18 #include "base/string_tokenizer.h" | 18 #include "base/string_tokenizer.h" |
19 #include "base/command_line.h" | 19 #include "base/command_line.h" |
20 #include "base/debug/trace_event.h" | 20 #include "base/debug/trace_event.h" |
21 #include "base/logging.h" | 21 #include "base/logging.h" |
22 #include "base/message_loop.h" | 22 #include "base/message_loop.h" |
| 23 #include "base/metrics/field_trial.h" |
23 #include "base/metrics/histogram.h" | 24 #include "base/metrics/histogram.h" |
24 #include "base/synchronization/lock.h" | 25 #include "base/synchronization/lock.h" |
25 #include "content/common/gpu/gpu_memory_allocation.h" | 26 #include "content/common/gpu/gpu_memory_allocation.h" |
26 #include "content/common/gpu/client/gpu_channel_host.h" | 27 #include "content/common/gpu/client/gpu_channel_host.h" |
27 #include "content/common/gpu/gpu_process_launch_causes.h" | 28 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 29 #include "content/public/common/content_constants.h" |
28 #include "content/public/common/content_switches.h" | 30 #include "content/public/common/content_switches.h" |
29 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 31 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
30 #include "gpu/command_buffer/client/gles2_implementation.h" | 32 #include "gpu/command_buffer/client/gles2_implementation.h" |
31 #include "gpu/command_buffer/client/gles2_lib.h" | 33 #include "gpu/command_buffer/client/gles2_lib.h" |
32 #include "gpu/command_buffer/client/transfer_buffer.h" | 34 #include "gpu/command_buffer/client/transfer_buffer.h" |
33 #include "gpu/command_buffer/common/constants.h" | 35 #include "gpu/command_buffer/common/constants.h" |
34 #include "gpu/ipc/command_buffer_proxy.h" | 36 #include "gpu/ipc/command_buffer_proxy.h" |
35 #include "webkit/glue/gl_bindings_skia_cmd_buffer.h" | 37 #include "webkit/glue/gl_bindings_skia_cmd_buffer.h" |
36 | 38 |
37 static base::LazyInstance<base::Lock>::Leaky | 39 static base::LazyInstance<base::Lock>::Leaky |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 // used by the compositor. | 517 // used by the compositor. |
516 if (ShouldUseSwapClient()) | 518 if (ShouldUseSwapClient()) |
517 swap_client_->OnViewContextSwapBuffersPosted(); | 519 swap_client_->OnViewContextSwapBuffersPosted(); |
518 | 520 |
519 if (command_buffer_->GetLastState().error == gpu::error::kNoError) | 521 if (command_buffer_->GetLastState().error == gpu::error::kNoError) |
520 gl_->SwapBuffers(); | 522 gl_->SwapBuffers(); |
521 | 523 |
522 bool use_echo_for_swap_ack = true; | 524 bool use_echo_for_swap_ack = true; |
523 #if defined(OS_MACOSX) || defined(OS_WIN) | 525 #if defined(OS_MACOSX) || defined(OS_WIN) |
524 // Get ViewMsg_SwapBuffers_ACK from browser for single-threaded path. | 526 // Get ViewMsg_SwapBuffers_ACK from browser for single-threaded path. |
525 use_echo_for_swap_ack = | 527 base::FieldTrial* trial = |
526 CommandLine::ForCurrentProcess()->HasSwitch( | 528 base::FieldTrialList::Find(content::kGpuCompositingFieldTrialName); |
527 switches::kEnableThreadedCompositing) && | 529 bool thread_trial = trial && trial->group_name() == |
528 !CommandLine::ForCurrentProcess()->HasSwitch( | 530 content::kGpuCompositingFieldTrialThreadEnabledName; |
529 switches::kDisableThreadedCompositing); | 531 use_echo_for_swap_ack = thread_trial || |
| 532 (CommandLine::ForCurrentProcess()->HasSwitch( |
| 533 switches::kEnableThreadedCompositing) && |
| 534 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 535 switches::kDisableThreadedCompositing)); |
530 #endif | 536 #endif |
531 if (use_echo_for_swap_ack) { | 537 if (use_echo_for_swap_ack) { |
532 command_buffer_->Echo(base::Bind( | 538 command_buffer_->Echo(base::Bind( |
533 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete, | 539 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete, |
534 weak_ptr_factory_.GetWeakPtr())); | 540 weak_ptr_factory_.GetWeakPtr())); |
535 } | 541 } |
536 #if defined(OS_MACOSX) | 542 #if defined(OS_MACOSX) |
537 // It appears that making the compositor's on-screen context current on | 543 // It appears that making the compositor's on-screen context current on |
538 // other platforms implies this flush. TODO(kbr): this means that the | 544 // other platforms implies this flush. TODO(kbr): this means that the |
539 // TOUCH build and, in the future, other platforms might need this. | 545 // TOUCH build and, in the future, other platforms might need this. |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 swap_client_->OnViewContextSwapBuffersAborted(); | 1566 swap_client_->OnViewContextSwapBuffersAborted(); |
1561 } | 1567 } |
1562 | 1568 |
1563 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( | 1569 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( |
1564 const std::string& message, int id) { | 1570 const std::string& message, int id) { |
1565 if (error_message_callback_) { | 1571 if (error_message_callback_) { |
1566 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); | 1572 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); |
1567 error_message_callback_->onErrorMessage(str, id); | 1573 error_message_callback_->onErrorMessage(str, id); |
1568 } | 1574 } |
1569 } | 1575 } |
OLD | NEW |