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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 bound_fbo_(0), | 144 bound_fbo_(0), |
145 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 145 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
146 initialized_(false), | 146 initialized_(false), |
147 parent_(NULL), | 147 parent_(NULL), |
148 parent_texture_id_(0), | 148 parent_texture_id_(0), |
149 command_buffer_(NULL), | 149 command_buffer_(NULL), |
150 gles2_helper_(NULL), | 150 gles2_helper_(NULL), |
151 transfer_buffer_(NULL), | 151 transfer_buffer_(NULL), |
152 gl_(NULL), | 152 gl_(NULL), |
153 frame_number_(0), | 153 frame_number_(0), |
154 bind_generates_resources_(false) { | 154 bind_generates_resources_(false), |
155 use_echo_for_swap_ack_(true) { | |
156 #if defined(OS_MACOSX) || defined(OS_WIN) | |
157 // Get ViewMsg_SwapBuffers_ACK from browser for single-threaded path. | |
darin (slow to review)
2012/08/03 21:16:06
this is exactly the same logic as in render_view_i
| |
158 base::FieldTrial* trial = | |
159 base::FieldTrialList::Find(content::kGpuCompositingFieldTrialName); | |
160 bool thread_trial = trial && trial->group_name() == | |
161 content::kGpuCompositingFieldTrialThreadEnabledName; | |
162 use_echo_for_swap_ack_ = thread_trial || | |
163 (CommandLine::ForCurrentProcess()->HasSwitch( | |
164 switches::kEnableThreadedCompositing) && | |
165 !CommandLine::ForCurrentProcess()->HasSwitch( | |
166 switches::kDisableThreadedCompositing)); | |
167 #endif | |
155 } | 168 } |
156 | 169 |
157 WebGraphicsContext3DCommandBufferImpl:: | 170 WebGraphicsContext3DCommandBufferImpl:: |
158 ~WebGraphicsContext3DCommandBufferImpl() { | 171 ~WebGraphicsContext3DCommandBufferImpl() { |
159 if (gl_) { | 172 if (gl_) { |
160 gl_->SetErrorMessageCallback(NULL); | 173 gl_->SetErrorMessageCallback(NULL); |
161 } | 174 } |
162 | 175 |
163 { | 176 { |
164 base::AutoLock lock(g_all_shared_contexts_lock.Get()); | 177 base::AutoLock lock(g_all_shared_contexts_lock.Get()); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 "frame", frame_number_); | 527 "frame", frame_number_); |
515 frame_number_++; | 528 frame_number_++; |
516 // Copies the contents of the off-screen render target into the texture | 529 // Copies the contents of the off-screen render target into the texture |
517 // used by the compositor. | 530 // used by the compositor. |
518 if (ShouldUseSwapClient()) | 531 if (ShouldUseSwapClient()) |
519 swap_client_->OnViewContextSwapBuffersPosted(); | 532 swap_client_->OnViewContextSwapBuffersPosted(); |
520 | 533 |
521 if (command_buffer_->GetLastState().error == gpu::error::kNoError) | 534 if (command_buffer_->GetLastState().error == gpu::error::kNoError) |
522 gl_->SwapBuffers(); | 535 gl_->SwapBuffers(); |
523 | 536 |
524 bool use_echo_for_swap_ack = true; | 537 if (use_echo_for_swap_ack_) { |
525 #if defined(OS_MACOSX) || defined(OS_WIN) | |
526 // Get ViewMsg_SwapBuffers_ACK from browser for single-threaded path. | |
527 base::FieldTrial* trial = | |
528 base::FieldTrialList::Find(content::kGpuCompositingFieldTrialName); | |
529 bool thread_trial = trial && trial->group_name() == | |
530 content::kGpuCompositingFieldTrialThreadEnabledName; | |
531 use_echo_for_swap_ack = thread_trial || | |
532 (CommandLine::ForCurrentProcess()->HasSwitch( | |
533 switches::kEnableThreadedCompositing) && | |
534 !CommandLine::ForCurrentProcess()->HasSwitch( | |
535 switches::kDisableThreadedCompositing)); | |
536 #endif | |
537 if (use_echo_for_swap_ack) { | |
538 command_buffer_->Echo(base::Bind( | 538 command_buffer_->Echo(base::Bind( |
539 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete, | 539 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete, |
540 weak_ptr_factory_.GetWeakPtr())); | 540 weak_ptr_factory_.GetWeakPtr())); |
541 } | 541 } |
542 #if defined(OS_MACOSX) | 542 #if defined(OS_MACOSX) |
543 // 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 |
544 // other platforms implies this flush. TODO(kbr): this means that the | 544 // other platforms implies this flush. TODO(kbr): this means that the |
545 // TOUCH build and, in the future, other platforms might need this. | 545 // TOUCH build and, in the future, other platforms might need this. |
546 gl_->Flush(); | 546 gl_->Flush(); |
547 #endif | 547 #endif |
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1570 swap_client_->OnViewContextSwapBuffersAborted(); | 1570 swap_client_->OnViewContextSwapBuffersAborted(); |
1571 } | 1571 } |
1572 | 1572 |
1573 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( | 1573 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( |
1574 const std::string& message, int id) { | 1574 const std::string& message, int id) { |
1575 if (error_message_callback_) { | 1575 if (error_message_callback_) { |
1576 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); | 1576 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); |
1577 error_message_callback_->onErrorMessage(str, id); | 1577 error_message_callback_->onErrorMessage(str, id); |
1578 } | 1578 } |
1579 } | 1579 } |
OLD | NEW |