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 "gpu/ipc/service/gpu_channel_manager.h" | 5 #include "gpu/ipc/service/gpu_channel_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/memory/ptr_util.h" |
13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
14 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
16 #include "gpu/command_buffer/common/sync_token.h" | 17 #include "gpu/command_buffer/common/sync_token.h" |
17 #include "gpu/command_buffer/common/value_state.h" | 18 #include "gpu/command_buffer/common/value_state.h" |
18 #include "gpu/command_buffer/service/feature_info.h" | 19 #include "gpu/command_buffer/service/feature_info.h" |
19 #include "gpu/command_buffer/service/mailbox_manager.h" | 20 #include "gpu/command_buffer/service/mailbox_manager.h" |
20 #include "gpu/command_buffer/service/memory_program_cache.h" | 21 #include "gpu/command_buffer/service/memory_program_cache.h" |
21 #include "gpu/command_buffer/service/shader_translator_cache.h" | 22 #include "gpu/command_buffer/service/shader_translator_cache.h" |
22 #include "gpu/command_buffer/service/sync_point_manager.h" | 23 #include "gpu/command_buffer/service/sync_point_manager.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 if (it != buffer_presented_callback_map_.end()) | 138 if (it != buffer_presented_callback_map_.end()) |
138 it->second.Run(surface_id, vsync_timebase, vsync_interval); | 139 it->second.Run(surface_id, vsync_timebase, vsync_interval); |
139 } | 140 } |
140 #endif | 141 #endif |
141 | 142 |
142 GpuChannel* GpuChannelManager::LookupChannel(int32_t client_id) const { | 143 GpuChannel* GpuChannelManager::LookupChannel(int32_t client_id) const { |
143 const auto& it = gpu_channels_.find(client_id); | 144 const auto& it = gpu_channels_.find(client_id); |
144 return it != gpu_channels_.end() ? it->second : nullptr; | 145 return it != gpu_channels_.end() ? it->second : nullptr; |
145 } | 146 } |
146 | 147 |
147 scoped_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel( | 148 std::unique_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel( |
148 int client_id, | 149 int client_id, |
149 uint64_t client_tracing_id, | 150 uint64_t client_tracing_id, |
150 bool preempts, | 151 bool preempts, |
151 bool allow_view_command_buffers, | 152 bool allow_view_command_buffers, |
152 bool allow_real_time_streams) { | 153 bool allow_real_time_streams) { |
153 return make_scoped_ptr( | 154 return base::WrapUnique( |
154 new GpuChannel(this, sync_point_manager(), watchdog_, share_group(), | 155 new GpuChannel(this, sync_point_manager(), watchdog_, share_group(), |
155 mailbox_manager(), preempts ? preemption_flag() : nullptr, | 156 mailbox_manager(), preempts ? preemption_flag() : nullptr, |
156 preempts ? nullptr : preemption_flag(), task_runner_.get(), | 157 preempts ? nullptr : preemption_flag(), task_runner_.get(), |
157 io_task_runner_.get(), client_id, client_tracing_id, | 158 io_task_runner_.get(), client_id, client_tracing_id, |
158 allow_view_command_buffers, allow_real_time_streams)); | 159 allow_view_command_buffers, allow_real_time_streams)); |
159 } | 160 } |
160 | 161 |
161 IPC::ChannelHandle GpuChannelManager::EstablishChannel( | 162 IPC::ChannelHandle GpuChannelManager::EstablishChannel( |
162 int client_id, | 163 int client_id, |
163 uint64_t client_tracing_id, | 164 uint64_t client_tracing_id, |
164 bool preempts, | 165 bool preempts, |
165 bool allow_view_command_buffers, | 166 bool allow_view_command_buffers, |
166 bool allow_real_time_streams) { | 167 bool allow_real_time_streams) { |
167 scoped_ptr<GpuChannel> channel( | 168 std::unique_ptr<GpuChannel> channel( |
168 CreateGpuChannel(client_id, client_tracing_id, preempts, | 169 CreateGpuChannel(client_id, client_tracing_id, preempts, |
169 allow_view_command_buffers, allow_real_time_streams)); | 170 allow_view_command_buffers, allow_real_time_streams)); |
170 IPC::ChannelHandle channel_handle = channel->Init(shutdown_event_); | 171 IPC::ChannelHandle channel_handle = channel->Init(shutdown_event_); |
171 gpu_channels_.set(client_id, std::move(channel)); | 172 gpu_channels_.set(client_id, std::move(channel)); |
172 return channel_handle; | 173 return channel_handle; |
173 } | 174 } |
174 | 175 |
175 void GpuChannelManager::InternalDestroyGpuMemoryBuffer( | 176 void GpuChannelManager::InternalDestroyGpuMemoryBuffer( |
176 gfx::GpuMemoryBufferId id, | 177 gfx::GpuMemoryBufferId id, |
177 int client_id) { | 178 int client_id) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 315 } |
315 } | 316 } |
316 if (!stub || !stub->decoder()->MakeCurrent()) | 317 if (!stub || !stub->decoder()->MakeCurrent()) |
317 return; | 318 return; |
318 glFinish(); | 319 glFinish(); |
319 DidAccessGpu(); | 320 DidAccessGpu(); |
320 } | 321 } |
321 #endif | 322 #endif |
322 | 323 |
323 } // namespace gpu | 324 } // namespace gpu |
OLD | NEW |