OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "gpu/command_buffer/service/in_process_command_buffer.h" | 5 #include "gpu/command_buffer/service/in_process_command_buffer.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 cond_var_.Wait(); | 173 cond_var_.Wait(); |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 base::LazyInstance<SyncPointManager> g_sync_point_manager = | 177 base::LazyInstance<SyncPointManager> g_sync_point_manager = |
178 LAZY_INSTANCE_INITIALIZER; | 178 LAZY_INSTANCE_INITIALIZER; |
179 | 179 |
180 bool WaitSyncPoint(uint32 sync_point) { | 180 bool WaitSyncPoint(uint32 sync_point) { |
181 g_sync_point_manager.Get().WaitSyncPoint(sync_point); | 181 g_sync_point_manager.Get().WaitSyncPoint(sync_point); |
182 return true; | 182 return true; |
183 } | 183 } |
piman
2014/10/21 23:28:51
nit: you don't need this trivial wrapper any more,
no sievers
2014/10/22 15:59:22
Done.
| |
184 | 184 |
185 } // anonyous namespace | 185 } // anonyous namespace |
186 | 186 |
187 InProcessCommandBuffer::Service::Service() {} | 187 InProcessCommandBuffer::Service::Service() {} |
188 | 188 |
189 InProcessCommandBuffer::Service::~Service() {} | 189 InProcessCommandBuffer::Service::~Service() {} |
190 | 190 |
191 scoped_refptr<gles2::MailboxManager> | 191 scoped_refptr<gles2::MailboxManager> |
192 InProcessCommandBuffer::Service::mailbox_manager() { | 192 InProcessCommandBuffer::Service::mailbox_manager() { |
193 if (!mailbox_manager_.get()) | 193 if (!mailbox_manager_.get()) |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 LOG(ERROR) << "Could not initialize decoder."; | 415 LOG(ERROR) << "Could not initialize decoder."; |
416 DestroyOnGpuThread(); | 416 DestroyOnGpuThread(); |
417 return false; | 417 return false; |
418 } | 418 } |
419 *params.capabilities = decoder_->GetCapabilities(); | 419 *params.capabilities = decoder_->GetCapabilities(); |
420 | 420 |
421 if (!params.is_offscreen) { | 421 if (!params.is_offscreen) { |
422 decoder_->SetResizeCallback(base::Bind( | 422 decoder_->SetResizeCallback(base::Bind( |
423 &InProcessCommandBuffer::OnResizeView, gpu_thread_weak_ptr_)); | 423 &InProcessCommandBuffer::OnResizeView, gpu_thread_weak_ptr_)); |
424 } | 424 } |
425 decoder_->SetWaitSyncPointCallback(base::Bind(&WaitSyncPoint)); | 425 decoder_->SetWaitSyncPointCallback( |
426 base::Bind(&InProcessCommandBuffer::WaitSyncPointOnGpuThread, | |
427 base::Unretained(this))); | |
426 | 428 |
427 return true; | 429 return true; |
428 } | 430 } |
429 | 431 |
430 void InProcessCommandBuffer::Destroy() { | 432 void InProcessCommandBuffer::Destroy() { |
431 CheckSequencedThread(); | 433 CheckSequencedThread(); |
432 | 434 |
433 base::WaitableEvent completion(true, false); | 435 base::WaitableEvent completion(true, false); |
434 bool result = false; | 436 bool result = false; |
435 base::Callback<bool(void)> destroy_task = base::Bind( | 437 base::Callback<bool(void)> destroy_task = base::Bind( |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 void InProcessCommandBuffer::RetireSyncPointOnGpuThread(uint32 sync_point) { | 653 void InProcessCommandBuffer::RetireSyncPointOnGpuThread(uint32 sync_point) { |
652 gles2::MailboxManager* mailbox_manager = | 654 gles2::MailboxManager* mailbox_manager = |
653 decoder_->GetContextGroup()->mailbox_manager(); | 655 decoder_->GetContextGroup()->mailbox_manager(); |
654 if (mailbox_manager->UsesSync()) { | 656 if (mailbox_manager->UsesSync()) { |
655 bool make_current_success = false; | 657 bool make_current_success = false; |
656 { | 658 { |
657 base::AutoLock lock(command_buffer_lock_); | 659 base::AutoLock lock(command_buffer_lock_); |
658 make_current_success = MakeCurrent(); | 660 make_current_success = MakeCurrent(); |
659 } | 661 } |
660 if (make_current_success) | 662 if (make_current_success) |
661 mailbox_manager->PushTextureUpdates(); | 663 mailbox_manager->PushTextureUpdates(sync_point); |
662 } | 664 } |
663 g_sync_point_manager.Get().RetireSyncPoint(sync_point); | 665 g_sync_point_manager.Get().RetireSyncPoint(sync_point); |
664 } | 666 } |
665 | 667 |
666 void InProcessCommandBuffer::SignalSyncPoint(unsigned sync_point, | 668 void InProcessCommandBuffer::SignalSyncPoint(unsigned sync_point, |
667 const base::Closure& callback) { | 669 const base::Closure& callback) { |
668 CheckSequencedThread(); | 670 CheckSequencedThread(); |
669 QueueTask(base::Bind(&InProcessCommandBuffer::SignalSyncPointOnGpuThread, | 671 QueueTask(base::Bind(&InProcessCommandBuffer::SignalSyncPointOnGpuThread, |
670 base::Unretained(this), | 672 base::Unretained(this), |
671 sync_point, | 673 sync_point, |
672 WrapCallback(callback))); | 674 WrapCallback(callback))); |
673 } | 675 } |
674 | 676 |
677 bool InProcessCommandBuffer::WaitSyncPointOnGpuThread(unsigned sync_point) { | |
678 WaitSyncPoint(sync_point); | |
679 gles2::MailboxManager* mailbox_manager = | |
680 decoder_->GetContextGroup()->mailbox_manager(); | |
681 mailbox_manager->PullTextureUpdates(sync_point); | |
682 return true; | |
683 } | |
684 | |
675 void InProcessCommandBuffer::SignalSyncPointOnGpuThread( | 685 void InProcessCommandBuffer::SignalSyncPointOnGpuThread( |
676 unsigned sync_point, | 686 unsigned sync_point, |
677 const base::Closure& callback) { | 687 const base::Closure& callback) { |
678 if (g_sync_point_manager.Get().IsSyncPointPassed(sync_point)) { | 688 if (g_sync_point_manager.Get().IsSyncPointPassed(sync_point)) { |
679 callback.Run(); | 689 callback.Run(); |
680 } else { | 690 } else { |
681 service_->ScheduleIdleWork( | 691 service_->ScheduleIdleWork( |
682 base::Bind(&InProcessCommandBuffer::SignalSyncPointOnGpuThread, | 692 base::Bind(&InProcessCommandBuffer::SignalSyncPointOnGpuThread, |
683 gpu_thread_weak_ptr_, | 693 gpu_thread_weak_ptr_, |
684 sync_point, | 694 sync_point, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
778 | 788 |
779 #if defined(OS_ANDROID) | 789 #if defined(OS_ANDROID) |
780 scoped_refptr<gfx::SurfaceTexture> | 790 scoped_refptr<gfx::SurfaceTexture> |
781 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { | 791 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { |
782 DCHECK(stream_texture_manager_); | 792 DCHECK(stream_texture_manager_); |
783 return stream_texture_manager_->GetSurfaceTexture(stream_id); | 793 return stream_texture_manager_->GetSurfaceTexture(stream_id); |
784 } | 794 } |
785 #endif | 795 #endif |
786 | 796 |
787 } // namespace gpu | 797 } // namespace gpu |
OLD | NEW |