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/gpu_command_buffer_stub.h" | 5 #include "content/common/gpu/gpu_command_buffer_stub.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 }; | 149 }; |
150 | 150 |
151 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 151 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
152 DevToolsChannelData::CreateForChannel(GpuChannel* channel) { | 152 DevToolsChannelData::CreateForChannel(GpuChannel* channel) { |
153 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); | 153 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); |
154 res->SetInteger("renderer_pid", channel->GetClientPID()); | 154 res->SetInteger("renderer_pid", channel->GetClientPID()); |
155 res->SetDouble("used_bytes", channel->GetMemoryUsage()); | 155 res->SetDouble("used_bytes", channel->GetMemoryUsage()); |
156 return new DevToolsChannelData(res.release()); | 156 return new DevToolsChannelData(res.release()); |
157 } | 157 } |
158 | 158 |
159 uint64_t GetCommandBufferID(int channel_id, int32_t route_id) { | 159 gpu::CommandBufferId GetCommandBufferID(int channel_id, int32_t route_id) { |
160 return (static_cast<uint64_t>(channel_id) << 32) | route_id; | 160 return gpu::CommandBufferId::FromUnsafeValue( |
| 161 (static_cast<uint64_t>(channel_id) << 32) | route_id); |
161 } | 162 } |
162 | 163 |
163 gfx::GLSurface::Format GetSurfaceFormatFromAttribute( | 164 gfx::GLSurface::Format GetSurfaceFormatFromAttribute( |
164 const gpu::gles2::ContextCreationAttribHelper& attrib, | 165 const gpu::gles2::ContextCreationAttribHelper& attrib, |
165 bool use_virtualized_gl_context) { | 166 bool use_virtualized_gl_context) { |
166 gfx::GLSurface::Format format = gfx::GLSurface::SURFACE_DEFAULT; // ARGB8888 | 167 gfx::GLSurface::Format format = gfx::GLSurface::SURFACE_DEFAULT; // ARGB8888 |
167 if (!use_virtualized_gl_context && | 168 if (!use_virtualized_gl_context && |
168 attrib.red_size <= 5 && | 169 attrib.red_size <= 5 && |
169 attrib.green_size <= 6 && | 170 attrib.green_size <= 6 && |
170 attrib.blue_size <= 5 && | 171 attrib.blue_size <= 5 && |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 221 |
221 gpu::gles2::ContextCreationAttribHelper attrib_parser; | 222 gpu::gles2::ContextCreationAttribHelper attrib_parser; |
222 attrib_parser.Parse(requested_attribs_); | 223 attrib_parser.Parse(requested_attribs_); |
223 | 224 |
224 if (share_group) { | 225 if (share_group) { |
225 context_group_ = share_group->context_group_; | 226 context_group_ = share_group->context_group_; |
226 DCHECK(context_group_->bind_generates_resource() == | 227 DCHECK(context_group_->bind_generates_resource() == |
227 attrib_parser.bind_generates_resource); | 228 attrib_parser.bind_generates_resource); |
228 } else { | 229 } else { |
229 context_group_ = new gpu::gles2::ContextGroup( | 230 context_group_ = new gpu::gles2::ContextGroup( |
230 mailbox_manager, | 231 mailbox_manager, new GpuCommandBufferMemoryTracker( |
231 new GpuCommandBufferMemoryTracker(channel, command_buffer_id_), | 232 channel, command_buffer_id_.GetUnsafeValue()), |
232 channel_->gpu_channel_manager()->shader_translator_cache(), | 233 channel_->gpu_channel_manager()->shader_translator_cache(), |
233 channel_->gpu_channel_manager()->framebuffer_completeness_cache(), NULL, | 234 channel_->gpu_channel_manager()->framebuffer_completeness_cache(), NULL, |
234 subscription_ref_set, pending_valuebuffer_state, | 235 subscription_ref_set, pending_valuebuffer_state, |
235 attrib_parser.bind_generates_resource); | 236 attrib_parser.bind_generates_resource); |
236 } | 237 } |
237 | 238 |
238 // Virtualize PreferIntegratedGpu contexts by default on OS X to prevent | 239 // Virtualize PreferIntegratedGpu contexts by default on OS X to prevent |
239 // performance regressions when enabling FCM. | 240 // performance regressions when enabling FCM. |
240 // http://crbug.com/180463 | 241 // http://crbug.com/180463 |
241 #if defined(OS_MACOSX) | 242 #if defined(OS_MACOSX) |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 input_visible_size, | 908 input_visible_size, |
908 output_profile, | 909 output_profile, |
909 initial_bitrate, | 910 initial_bitrate, |
910 reply_message); | 911 reply_message); |
911 // encoder is registered as a DestructionObserver of this stub and will | 912 // encoder is registered as a DestructionObserver of this stub and will |
912 // self-delete during destruction of this stub. | 913 // self-delete during destruction of this stub. |
913 } | 914 } |
914 | 915 |
915 void GpuCommandBufferStub::PullTextureUpdates( | 916 void GpuCommandBufferStub::PullTextureUpdates( |
916 gpu::CommandBufferNamespace namespace_id, | 917 gpu::CommandBufferNamespace namespace_id, |
917 uint64_t command_buffer_id, | 918 gpu::CommandBufferId command_buffer_id, |
918 uint32_t release) { | 919 uint32_t release) { |
919 gpu::gles2::MailboxManager* mailbox_manager = | 920 gpu::gles2::MailboxManager* mailbox_manager = |
920 context_group_->mailbox_manager(); | 921 context_group_->mailbox_manager(); |
921 if (mailbox_manager->UsesSync() && MakeCurrent()) { | 922 if (mailbox_manager->UsesSync() && MakeCurrent()) { |
922 gpu::SyncToken sync_token(namespace_id, 0, command_buffer_id, release); | 923 gpu::SyncToken sync_token(namespace_id, 0, command_buffer_id, release); |
923 mailbox_manager->PullTextureUpdates(sync_token); | 924 mailbox_manager->PullTextureUpdates(sync_token); |
924 } | 925 } |
925 } | 926 } |
926 | 927 |
927 void GpuCommandBufferStub::OnSignalSyncToken(const gpu::SyncToken& sync_token, | 928 void GpuCommandBufferStub::OnSignalSyncToken(const gpu::SyncToken& sync_token, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, | 975 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, |
975 command_buffer_id_, release); | 976 command_buffer_id_, release); |
976 mailbox_manager->PushTextureUpdates(sync_token); | 977 mailbox_manager->PushTextureUpdates(sync_token); |
977 } | 978 } |
978 | 979 |
979 sync_point_client_->ReleaseFenceSync(release); | 980 sync_point_client_->ReleaseFenceSync(release); |
980 } | 981 } |
981 | 982 |
982 bool GpuCommandBufferStub::OnWaitFenceSync( | 983 bool GpuCommandBufferStub::OnWaitFenceSync( |
983 gpu::CommandBufferNamespace namespace_id, | 984 gpu::CommandBufferNamespace namespace_id, |
984 uint64_t command_buffer_id, | 985 gpu::CommandBufferId command_buffer_id, |
985 uint64_t release) { | 986 uint64_t release) { |
986 DCHECK(!waiting_for_sync_point_); | 987 DCHECK(!waiting_for_sync_point_); |
987 DCHECK(scheduler_->scheduled()); | 988 DCHECK(scheduler_->scheduled()); |
988 | 989 |
989 scoped_refptr<gpu::SyncPointClientState> release_state = | 990 scoped_refptr<gpu::SyncPointClientState> release_state = |
990 sync_point_manager_->GetSyncPointClientState(namespace_id, | 991 sync_point_manager_->GetSyncPointClientState(namespace_id, |
991 command_buffer_id); | 992 command_buffer_id); |
992 | 993 |
993 if (!release_state) | 994 if (!release_state) |
994 return true; | 995 return true; |
(...skipping 13 matching lines...) Expand all Loading... |
1008 | 1009 |
1009 if (!waiting_for_sync_point_) | 1010 if (!waiting_for_sync_point_) |
1010 return true; | 1011 return true; |
1011 | 1012 |
1012 scheduler_->SetScheduled(false); | 1013 scheduler_->SetScheduled(false); |
1013 return false; | 1014 return false; |
1014 } | 1015 } |
1015 | 1016 |
1016 void GpuCommandBufferStub::OnWaitFenceSyncCompleted( | 1017 void GpuCommandBufferStub::OnWaitFenceSyncCompleted( |
1017 gpu::CommandBufferNamespace namespace_id, | 1018 gpu::CommandBufferNamespace namespace_id, |
1018 uint64_t command_buffer_id, | 1019 gpu::CommandBufferId command_buffer_id, |
1019 uint64_t release) { | 1020 uint64_t release) { |
1020 DCHECK(waiting_for_sync_point_); | 1021 DCHECK(waiting_for_sync_point_); |
1021 TRACE_EVENT_ASYNC_END1("gpu", "WaitFenceSync", this, "GpuCommandBufferStub", | 1022 TRACE_EVENT_ASYNC_END1("gpu", "WaitFenceSync", this, "GpuCommandBufferStub", |
1022 this); | 1023 this); |
1023 PullTextureUpdates(namespace_id, command_buffer_id, release); | 1024 PullTextureUpdates(namespace_id, command_buffer_id, release); |
1024 waiting_for_sync_point_ = false; | 1025 waiting_for_sync_point_ = false; |
1025 scheduler_->SetScheduled(true); | 1026 scheduler_->SetScheduled(true); |
1026 } | 1027 } |
1027 | 1028 |
1028 void GpuCommandBufferStub::OnCreateImage( | 1029 void GpuCommandBufferStub::OnCreateImage( |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 result)); | 1179 result)); |
1179 } | 1180 } |
1180 | 1181 |
1181 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1182 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
1182 base::TimeDelta interval) { | 1183 base::TimeDelta interval) { |
1183 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1184 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
1184 interval)); | 1185 interval)); |
1185 } | 1186 } |
1186 | 1187 |
1187 } // namespace content | 1188 } // namespace content |
OLD | NEW |