| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); | 136 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); |
| 137 res->SetInteger("renderer_pid", channel->renderer_pid()); | 137 res->SetInteger("renderer_pid", channel->renderer_pid()); |
| 138 res->SetDouble("used_bytes", channel->GetMemoryUsage()); | 138 res->SetDouble("used_bytes", channel->GetMemoryUsage()); |
| 139 res->SetDouble("limit_bytes", | 139 res->SetDouble("limit_bytes", |
| 140 channel->gpu_channel_manager() | 140 channel->gpu_channel_manager() |
| 141 ->gpu_memory_manager() | 141 ->gpu_memory_manager() |
| 142 ->GetMaximumClientAllocation()); | 142 ->GetMaximumClientAllocation()); |
| 143 return new DevToolsChannelData(res.release()); | 143 return new DevToolsChannelData(res.release()); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void RunOnThread(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 147 const base::Closure& callback) { |
| 148 if (task_runner->BelongsToCurrentThread()) { |
| 149 callback.Run(); |
| 150 } else { |
| 151 task_runner->PostTask(FROM_HERE, callback); |
| 152 } |
| 153 } |
| 154 |
| 146 } // namespace | 155 } // namespace |
| 147 | 156 |
| 148 GpuCommandBufferStub::GpuCommandBufferStub( | 157 GpuCommandBufferStub::GpuCommandBufferStub( |
| 149 GpuChannel* channel, | 158 GpuChannel* channel, |
| 150 GpuCommandBufferStub* share_group, | 159 GpuCommandBufferStub* share_group, |
| 151 const gfx::GLSurfaceHandle& handle, | 160 const gfx::GLSurfaceHandle& handle, |
| 152 gpu::gles2::MailboxManager* mailbox_manager, | 161 gpu::gles2::MailboxManager* mailbox_manager, |
| 153 gpu::gles2::SubscriptionRefSet* subscription_ref_set, | 162 gpu::gles2::SubscriptionRefSet* subscription_ref_set, |
| 154 gpu::ValueStateMap* pending_valuebuffer_state, | 163 gpu::ValueStateMap* pending_valuebuffer_state, |
| 155 const gfx::Size& size, | 164 const gfx::Size& size, |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 return true; | 898 return true; |
| 890 } | 899 } |
| 891 | 900 |
| 892 if (sync_point_wait_count_ == 0) { | 901 if (sync_point_wait_count_ == 0) { |
| 893 TRACE_EVENT_ASYNC_BEGIN1("gpu", "WaitSyncPoint", this, | 902 TRACE_EVENT_ASYNC_BEGIN1("gpu", "WaitSyncPoint", this, |
| 894 "GpuCommandBufferStub", this); | 903 "GpuCommandBufferStub", this); |
| 895 } | 904 } |
| 896 scheduler_->SetScheduled(false); | 905 scheduler_->SetScheduled(false); |
| 897 ++sync_point_wait_count_; | 906 ++sync_point_wait_count_; |
| 898 manager->sync_point_manager()->AddSyncPointCallback( | 907 manager->sync_point_manager()->AddSyncPointCallback( |
| 899 sync_point, base::Bind(&GpuCommandBufferStub::OnWaitSyncPointCompleted, | 908 sync_point, |
| 900 this->AsWeakPtr(), sync_point)); | 909 base::Bind(&RunOnThread, base::ThreadTaskRunnerHandle::Get(), |
| 910 base::Bind(&GpuCommandBufferStub::OnWaitSyncPointCompleted, |
| 911 this->AsWeakPtr(), sync_point))); |
| 901 return scheduler_->IsScheduled(); | 912 return scheduler_->IsScheduled(); |
| 902 } | 913 } |
| 903 | 914 |
| 904 void GpuCommandBufferStub::OnWaitSyncPointCompleted(uint32 sync_point) { | 915 void GpuCommandBufferStub::OnWaitSyncPointCompleted(uint32 sync_point) { |
| 905 PullTextureUpdates(sync_point); | 916 PullTextureUpdates(sync_point); |
| 906 --sync_point_wait_count_; | 917 --sync_point_wait_count_; |
| 907 if (sync_point_wait_count_ == 0) { | 918 if (sync_point_wait_count_ == 0) { |
| 908 TRACE_EVENT_ASYNC_END1("gpu", "WaitSyncPoint", this, | 919 TRACE_EVENT_ASYNC_END1("gpu", "WaitSyncPoint", this, |
| 909 "GpuCommandBufferStub", this); | 920 "GpuCommandBufferStub", this); |
| 910 } | 921 } |
| 911 scheduler_->SetScheduled(true); | 922 scheduler_->SetScheduled(true); |
| 912 } | 923 } |
| 913 | 924 |
| 914 void GpuCommandBufferStub::PullTextureUpdates(uint32 sync_point) { | 925 void GpuCommandBufferStub::PullTextureUpdates(uint32 sync_point) { |
| 915 gpu::gles2::MailboxManager* mailbox_manager = | 926 gpu::gles2::MailboxManager* mailbox_manager = |
| 916 context_group_->mailbox_manager(); | 927 context_group_->mailbox_manager(); |
| 917 if (mailbox_manager->UsesSync() && MakeCurrent()) | 928 if (mailbox_manager->UsesSync() && MakeCurrent()) |
| 918 mailbox_manager->PullTextureUpdates(sync_point); | 929 mailbox_manager->PullTextureUpdates(sync_point); |
| 919 } | 930 } |
| 920 | 931 |
| 921 void GpuCommandBufferStub::OnSignalSyncPoint(uint32 sync_point, uint32 id) { | 932 void GpuCommandBufferStub::OnSignalSyncPoint(uint32 sync_point, uint32 id) { |
| 922 GpuChannelManager* manager = channel_->gpu_channel_manager(); | 933 GpuChannelManager* manager = channel_->gpu_channel_manager(); |
| 923 manager->sync_point_manager()->AddSyncPointCallback( | 934 manager->sync_point_manager()->AddSyncPointCallback( |
| 924 sync_point, | 935 sync_point, |
| 925 base::Bind(&GpuCommandBufferStub::OnSignalSyncPointAck, | 936 base::Bind(&RunOnThread, base::ThreadTaskRunnerHandle::Get(), |
| 926 this->AsWeakPtr(), | 937 base::Bind(&GpuCommandBufferStub::OnSignalSyncPointAck, |
| 927 id)); | 938 this->AsWeakPtr(), id))); |
| 928 } | 939 } |
| 929 | 940 |
| 930 void GpuCommandBufferStub::OnSignalSyncPointAck(uint32 id) { | 941 void GpuCommandBufferStub::OnSignalSyncPointAck(uint32 id) { |
| 931 Send(new GpuCommandBufferMsg_SignalSyncPointAck(route_id_, id)); | 942 Send(new GpuCommandBufferMsg_SignalSyncPointAck(route_id_, id)); |
| 932 } | 943 } |
| 933 | 944 |
| 934 void GpuCommandBufferStub::OnSignalQuery(uint32 query_id, uint32 id) { | 945 void GpuCommandBufferStub::OnSignalQuery(uint32 query_id, uint32 id) { |
| 935 if (decoder_) { | 946 if (decoder_) { |
| 936 gpu::gles2::QueryManager* query_manager = decoder_->GetQueryManager(); | 947 gpu::gles2::QueryManager* query_manager = decoder_->GetQueryManager(); |
| 937 if (query_manager) { | 948 if (query_manager) { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 result)); | 1160 result)); |
| 1150 } | 1161 } |
| 1151 | 1162 |
| 1152 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1163 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
| 1153 base::TimeDelta interval) { | 1164 base::TimeDelta interval) { |
| 1154 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1165 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
| 1155 interval)); | 1166 interval)); |
| 1156 } | 1167 } |
| 1157 | 1168 |
| 1158 } // namespace content | 1169 } // namespace content |
| OLD | NEW |