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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/hash.h" | 8 #include "base/hash.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 requested_attribs_(attribs), | 191 requested_attribs_(attribs), |
192 gpu_preference_(gpu_preference), | 192 gpu_preference_(gpu_preference), |
193 use_virtualized_gl_context_(use_virtualized_gl_context), | 193 use_virtualized_gl_context_(use_virtualized_gl_context), |
194 stream_id_(stream_id), | 194 stream_id_(stream_id), |
195 route_id_(route_id), | 195 route_id_(route_id), |
196 surface_id_(surface_id), | 196 surface_id_(surface_id), |
197 software_(software), | 197 software_(software), |
198 last_flush_count_(0), | 198 last_flush_count_(0), |
199 last_memory_allocation_valid_(false), | 199 last_memory_allocation_valid_(false), |
200 watchdog_(watchdog), | 200 watchdog_(watchdog), |
201 sync_point_wait_count_(0), | 201 waiting_for_sync_point_(false), |
202 delayed_work_scheduled_(false), | 202 delayed_work_scheduled_(false), |
203 previous_processed_num_(0), | 203 previous_processed_num_(0), |
204 active_url_(active_url), | 204 active_url_(active_url), |
205 total_gpu_memory_(0) { | 205 total_gpu_memory_(0) { |
206 active_url_hash_ = base::Hash(active_url.possibly_invalid_spec()); | 206 active_url_hash_ = base::Hash(active_url.possibly_invalid_spec()); |
207 FastSetActiveURL(active_url_, active_url_hash_); | 207 FastSetActiveURL(active_url_, active_url_hash_); |
208 | 208 |
209 gpu::gles2::ContextCreationAttribHelper attrib_parser; | 209 gpu::gles2::ContextCreationAttribHelper attrib_parser; |
210 attrib_parser.Parse(requested_attribs_); | 210 attrib_parser.Parse(requested_attribs_); |
211 | 211 |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
613 base::Bind(&GpuCommandBufferStub::OnWaitSyncPoint, | 613 base::Bind(&GpuCommandBufferStub::OnWaitSyncPoint, |
614 base::Unretained(this))); | 614 base::Unretained(this))); |
615 | 615 |
616 command_buffer_->SetPutOffsetChangeCallback( | 616 command_buffer_->SetPutOffsetChangeCallback( |
617 base::Bind(&GpuCommandBufferStub::PutChanged, base::Unretained(this))); | 617 base::Bind(&GpuCommandBufferStub::PutChanged, base::Unretained(this))); |
618 command_buffer_->SetGetBufferChangeCallback( | 618 command_buffer_->SetGetBufferChangeCallback( |
619 base::Bind(&gpu::GpuScheduler::SetGetBuffer, | 619 base::Bind(&gpu::GpuScheduler::SetGetBuffer, |
620 base::Unretained(scheduler_.get()))); | 620 base::Unretained(scheduler_.get()))); |
621 command_buffer_->SetParseErrorCallback( | 621 command_buffer_->SetParseErrorCallback( |
622 base::Bind(&GpuCommandBufferStub::OnParseError, base::Unretained(this))); | 622 base::Bind(&GpuCommandBufferStub::OnParseError, base::Unretained(this))); |
623 scheduler_->SetSchedulingChangedCallback( | 623 scheduler_->SetSchedulingChangedCallback(base::Bind( |
624 base::Bind(&GpuChannel::StubSchedulingChanged, | 624 &GpuCommandBufferStub::OnSchedulingChanged, base::Unretained(this))); |
625 base::Unretained(channel_))); | |
626 | 625 |
627 if (watchdog_) { | 626 if (watchdog_) { |
628 scheduler_->SetCommandProcessedCallback( | 627 scheduler_->SetCommandProcessedCallback( |
629 base::Bind(&GpuCommandBufferStub::OnCommandProcessed, | 628 base::Bind(&GpuCommandBufferStub::OnCommandProcessed, |
630 base::Unretained(this))); | 629 base::Unretained(this))); |
631 } | 630 } |
632 | 631 |
633 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); | 632 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); |
634 if (!shared_state_shm->Map(kSharedStateSize)) { | 633 if (!shared_state_shm->Map(kSharedStateSize)) { |
635 DLOG(ERROR) << "Failed to map shared state buffer."; | 634 DLOG(ERROR) << "Failed to map shared state buffer."; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
711 // Tell the browser about this context loss as well, so it can | 710 // Tell the browser about this context loss as well, so it can |
712 // determine whether client APIs like WebGL need to be immediately | 711 // determine whether client APIs like WebGL need to be immediately |
713 // blocked from automatically running. | 712 // blocked from automatically running. |
714 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 713 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
715 gpu_channel_manager->Send(new GpuHostMsg_DidLoseContext( | 714 gpu_channel_manager->Send(new GpuHostMsg_DidLoseContext( |
716 handle_.is_null(), state.context_lost_reason, active_url_)); | 715 handle_.is_null(), state.context_lost_reason, active_url_)); |
717 | 716 |
718 CheckContextLost(); | 717 CheckContextLost(); |
719 } | 718 } |
720 | 719 |
720 void GpuCommandBufferStub::OnSchedulingChanged(bool scheduled) { | |
721 TRACE_EVENT1("gpu", "GpuCommandBufferStub::OnSchedulingChanged", "scheduled", | |
722 scheduled); | |
723 channel_->OnStubSchedulingChanged(this, scheduled); | |
724 } | |
725 | |
721 void GpuCommandBufferStub::OnWaitForTokenInRange(int32 start, | 726 void GpuCommandBufferStub::OnWaitForTokenInRange(int32 start, |
722 int32 end, | 727 int32 end, |
723 IPC::Message* reply_message) { | 728 IPC::Message* reply_message) { |
724 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnWaitForTokenInRange"); | 729 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnWaitForTokenInRange"); |
725 DCHECK(command_buffer_.get()); | 730 DCHECK(command_buffer_.get()); |
726 CheckContextLost(); | 731 CheckContextLost(); |
727 if (wait_for_token_) | 732 if (wait_for_token_) |
728 LOG(ERROR) << "Got WaitForToken command while currently waiting for token."; | 733 LOG(ERROR) << "Got WaitForToken command while currently waiting for token."; |
729 wait_for_token_ = | 734 wait_for_token_ = |
730 make_scoped_ptr(new WaitForCommandState(start, end, reply_message)); | 735 make_scoped_ptr(new WaitForCommandState(start, end, reply_message)); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
901 | 906 |
902 bool GpuCommandBufferStub::OnWaitSyncPoint(uint32 sync_point) { | 907 bool GpuCommandBufferStub::OnWaitSyncPoint(uint32 sync_point) { |
903 if (!sync_point) | 908 if (!sync_point) |
904 return true; | 909 return true; |
905 GpuChannelManager* manager = channel_->gpu_channel_manager(); | 910 GpuChannelManager* manager = channel_->gpu_channel_manager(); |
906 if (manager->sync_point_manager()->IsSyncPointRetired(sync_point)) { | 911 if (manager->sync_point_manager()->IsSyncPointRetired(sync_point)) { |
907 PullTextureUpdates(sync_point); | 912 PullTextureUpdates(sync_point); |
908 return true; | 913 return true; |
909 } | 914 } |
910 | 915 |
911 if (sync_point_wait_count_ == 0) { | 916 TRACE_EVENT_ASYNC_BEGIN1("gpu", "WaitSyncPoint", this, "GpuCommandBufferStub", |
912 TRACE_EVENT_ASYNC_BEGIN1("gpu", "WaitSyncPoint", this, | 917 this); |
913 "GpuCommandBufferStub", this); | 918 |
914 } | |
915 scheduler_->SetScheduled(false); | 919 scheduler_->SetScheduled(false); |
jbauman
2015/09/16 21:31:26
DCHECK(!waiting_for_sync_point_);
sunnyps
2015/09/16 23:08:31
Done.
| |
916 ++sync_point_wait_count_; | 920 waiting_for_sync_point_ = true; |
917 manager->sync_point_manager()->AddSyncPointCallback( | 921 manager->sync_point_manager()->AddSyncPointCallback( |
918 sync_point, | 922 sync_point, |
919 base::Bind(&RunOnThread, task_runner_, | 923 base::Bind(&RunOnThread, task_runner_, |
920 base::Bind(&GpuCommandBufferStub::OnWaitSyncPointCompleted, | 924 base::Bind(&GpuCommandBufferStub::OnWaitSyncPointCompleted, |
921 this->AsWeakPtr(), sync_point))); | 925 this->AsWeakPtr(), sync_point))); |
922 return scheduler_->IsScheduled(); | 926 return false; |
piman
2015/09/16 21:46:29
AddSyncPointCallback may call the callback synchro
sunnyps
2015/09/16 23:08:31
Done.
| |
923 } | 927 } |
924 | 928 |
925 void GpuCommandBufferStub::OnWaitSyncPointCompleted(uint32 sync_point) { | 929 void GpuCommandBufferStub::OnWaitSyncPointCompleted(uint32 sync_point) { |
930 DCHECK(waiting_for_sync_point_); | |
931 TRACE_EVENT_ASYNC_END1("gpu", "WaitSyncPoint", this, "GpuCommandBufferStub", | |
932 this); | |
926 PullTextureUpdates(sync_point); | 933 PullTextureUpdates(sync_point); |
927 --sync_point_wait_count_; | 934 waiting_for_sync_point_ = false; |
928 if (sync_point_wait_count_ == 0) { | |
929 TRACE_EVENT_ASYNC_END1("gpu", "WaitSyncPoint", this, | |
930 "GpuCommandBufferStub", this); | |
931 } | |
932 scheduler_->SetScheduled(true); | 935 scheduler_->SetScheduled(true); |
933 } | 936 } |
934 | 937 |
935 void GpuCommandBufferStub::PullTextureUpdates(uint32 sync_point) { | 938 void GpuCommandBufferStub::PullTextureUpdates(uint32 sync_point) { |
936 gpu::gles2::MailboxManager* mailbox_manager = | 939 gpu::gles2::MailboxManager* mailbox_manager = |
937 context_group_->mailbox_manager(); | 940 context_group_->mailbox_manager(); |
938 if (mailbox_manager->UsesSync() && MakeCurrent()) | 941 if (mailbox_manager->UsesSync() && MakeCurrent()) |
939 mailbox_manager->PullTextureUpdates(sync_point); | 942 mailbox_manager->PullTextureUpdates(sync_point); |
940 } | 943 } |
941 | 944 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1174 result)); | 1177 result)); |
1175 } | 1178 } |
1176 | 1179 |
1177 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1180 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
1178 base::TimeDelta interval) { | 1181 base::TimeDelta interval) { |
1179 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1182 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
1180 interval)); | 1183 interval)); |
1181 } | 1184 } |
1182 | 1185 |
1183 } // namespace content | 1186 } // namespace content |
OLD | NEW |