Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: content/gpu/gpu_child_thread.cc

Issue 2612623002: gpu: Use mus gpu interface in non-mus chrome. (Closed)
Patch Set: more cleanup Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/gpu/gpu_child_thread.h" 5 #include "content/gpu/gpu_child_thread.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 21 matching lines...) Expand all
32 #include "gpu/ipc/common/memory_stats.h" 32 #include "gpu/ipc/common/memory_stats.h"
33 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" 33 #include "gpu/ipc/service/gpu_memory_buffer_factory.h"
34 #include "gpu/ipc/service/gpu_watchdog_thread.h" 34 #include "gpu/ipc/service/gpu_watchdog_thread.h"
35 #include "ipc/ipc_channel_handle.h" 35 #include "ipc/ipc_channel_handle.h"
36 #include "ipc/ipc_sync_message_filter.h" 36 #include "ipc/ipc_sync_message_filter.h"
37 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h" 37 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h"
38 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" 38 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h"
39 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" 39 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h"
40 #include "media/gpu/ipc/service/media_gpu_channel_manager.h" 40 #include "media/gpu/ipc/service/media_gpu_channel_manager.h"
41 #include "services/service_manager/public/cpp/interface_registry.h" 41 #include "services/service_manager/public/cpp/interface_registry.h"
42 #include "services/ui/gpu/interfaces/gpu_service.mojom.h"
42 #include "ui/gl/gl_implementation.h" 43 #include "ui/gl/gl_implementation.h"
43 #include "ui/gl/gl_switches.h" 44 #include "ui/gl/gl_switches.h"
44 #include "ui/gl/gpu_switching_manager.h" 45 #include "ui/gl/gpu_switching_manager.h"
45 #include "ui/gl/init/gl_factory.h" 46 #include "ui/gl/init/gl_factory.h"
46 #include "url/gurl.h" 47 #include "url/gurl.h"
47 48
48 #if defined(USE_OZONE) 49 #if defined(USE_OZONE)
49 #include "ui/ozone/public/ozone_platform.h" 50 #include "ui/ozone/public/ozone_platform.h"
50 #endif 51 #endif
51 52
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } // namespace 144 } // namespace
144 145
145 GpuChildThread::GpuChildThread( 146 GpuChildThread::GpuChildThread(
146 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread, 147 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread,
147 bool dead_on_arrival, 148 bool dead_on_arrival,
148 const gpu::GPUInfo& gpu_info, 149 const gpu::GPUInfo& gpu_info,
149 const DeferredMessages& deferred_messages, 150 const DeferredMessages& deferred_messages,
150 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory) 151 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory)
151 : ChildThreadImpl(GetOptions(gpu_memory_buffer_factory)), 152 : ChildThreadImpl(GetOptions(gpu_memory_buffer_factory)),
152 dead_on_arrival_(dead_on_arrival), 153 dead_on_arrival_(dead_on_arrival),
153 watchdog_thread_(std::move(watchdog_thread)),
154 gpu_info_(gpu_info), 154 gpu_info_(gpu_info),
155 deferred_messages_(deferred_messages), 155 deferred_messages_(deferred_messages),
156 in_browser_process_(false), 156 in_browser_process_(false),
157 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { 157 gpu_service_(
158 new ui::GpuService(gpu_info,
159 std::move(watchdog_thread),
160 gpu_memory_buffer_factory,
161 ChildProcess::current()->io_task_runner())),
162 gpu_main_binding_(this) {
158 #if defined(OS_WIN) 163 #if defined(OS_WIN)
159 target_services_ = NULL; 164 target_services_ = NULL;
160 #endif 165 #endif
161 g_thread_safe_sender.Get() = thread_safe_sender(); 166 g_thread_safe_sender.Get() = thread_safe_sender();
162 } 167 }
163 168
164 GpuChildThread::GpuChildThread( 169 GpuChildThread::GpuChildThread(
165 const InProcessChildThreadParams& params, 170 const InProcessChildThreadParams& params,
166 const gpu::GPUInfo& gpu_info, 171 const gpu::GPUInfo& gpu_info,
167 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory) 172 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory)
168 : ChildThreadImpl(ChildThreadImpl::Options::Builder() 173 : ChildThreadImpl(ChildThreadImpl::Options::Builder()
169 .InBrowserProcess(params) 174 .InBrowserProcess(params)
170 .AddStartupFilter(new GpuMemoryBufferMessageFilter( 175 .AddStartupFilter(new GpuMemoryBufferMessageFilter(
171 gpu_memory_buffer_factory)) 176 gpu_memory_buffer_factory))
172 .ConnectToBrowser(true) 177 .ConnectToBrowser(true)
173 .Build()), 178 .Build()),
174 dead_on_arrival_(false), 179 dead_on_arrival_(false),
175 gpu_info_(gpu_info), 180 gpu_info_(gpu_info),
176 in_browser_process_(true), 181 in_browser_process_(true),
177 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { 182 gpu_service_(
183 new ui::GpuService(gpu_info,
184 nullptr /* watchdog thread */,
185 gpu_memory_buffer_factory,
186 ChildProcess::current()->io_task_runner())),
187 gpu_main_binding_(this) {
178 #if defined(OS_WIN) 188 #if defined(OS_WIN)
179 target_services_ = NULL; 189 target_services_ = NULL;
180 #endif 190 #endif
181 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 191 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
182 switches::kSingleProcess) || 192 switches::kSingleProcess) ||
183 base::CommandLine::ForCurrentProcess()->HasSwitch( 193 base::CommandLine::ForCurrentProcess()->HasSwitch(
184 switches::kInProcessGPU)); 194 switches::kInProcessGPU));
185 195
186 g_thread_safe_sender.Get() = thread_safe_sender(); 196 g_thread_safe_sender.Get() = thread_safe_sender();
187 } 197 }
(...skipping 14 matching lines...) Expand all
202 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun(). 212 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun().
203 if (!in_browser_process_) 213 if (!in_browser_process_)
204 media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid()); 214 media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid());
205 #endif 215 #endif
206 // We don't want to process any incoming interface requests until 216 // We don't want to process any incoming interface requests until
207 // OnInitialize() is invoked. 217 // OnInitialize() is invoked.
208 GetInterfaceRegistry()->PauseBinding(); 218 GetInterfaceRegistry()->PauseBinding();
209 219
210 if (GetContentClient()->gpu()) // NULL in tests. 220 if (GetContentClient()->gpu()) // NULL in tests.
211 GetContentClient()->gpu()->Initialize(this); 221 GetContentClient()->gpu()->Initialize(this);
212 channel()->AddAssociatedInterface(base::Bind( 222 AssociatedInterfaceRegistry* registry = &associated_interfaces_;
223 registry->AddInterface(base::Bind(
Ken Rockot(use gerrit already) 2017/01/23 18:29:53 nit: just use associated_interfaces_
sadrul 2017/01/23 19:57:49 I tried that at first, but it gives me a compile e
213 &GpuChildThread::CreateGpuMainService, base::Unretained(this))); 224 &GpuChildThread::CreateGpuMainService, base::Unretained(this)));
214 } 225 }
215 226
216 void GpuChildThread::OnFieldTrialGroupFinalized(const std::string& trial_name, 227 void GpuChildThread::OnFieldTrialGroupFinalized(const std::string& trial_name,
217 const std::string& group_name) { 228 const std::string& group_name) {
218 Send(new GpuHostMsg_FieldTrialActivated(trial_name)); 229 Send(new GpuHostMsg_FieldTrialActivated(trial_name));
219 } 230 }
220 231
221 void GpuChildThread::CreateGpuMainService( 232 void GpuChildThread::CreateGpuMainService(
222 ui::mojom::GpuMainAssociatedRequest request) { 233 ui::mojom::GpuMainAssociatedRequest request) {
223 // TODO(sad): Implement. 234 gpu_main_binding_.Bind(std::move(request));
224 } 235 }
225 236
226 bool GpuChildThread::Send(IPC::Message* msg) { 237 bool GpuChildThread::Send(IPC::Message* msg) {
227 // The GPU process must never send a synchronous IPC message to the browser 238 // The GPU process must never send a synchronous IPC message to the browser
228 // process. This could result in deadlock. 239 // process. This could result in deadlock.
229 DCHECK(!msg->is_sync()); 240 DCHECK(!msg->is_sync());
230 241
231 return ChildThreadImpl::Send(msg); 242 return ChildThreadImpl::Send(msg);
232 } 243 }
233 244
234 bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) { 245 bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) {
235 bool handled = true; 246 bool handled = true;
236 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg) 247 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg)
237 IPC_MESSAGE_HANDLER(GpuMsg_Initialize, OnInitialize)
238 IPC_MESSAGE_HANDLER(GpuMsg_Finalize, OnFinalize) 248 IPC_MESSAGE_HANDLER(GpuMsg_Finalize, OnFinalize)
239 IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo) 249 IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo)
240 IPC_MESSAGE_HANDLER(GpuMsg_GetVideoMemoryUsageStats, 250 IPC_MESSAGE_HANDLER(GpuMsg_GetVideoMemoryUsageStats,
241 OnGetVideoMemoryUsageStats) 251 OnGetVideoMemoryUsageStats)
242 IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean) 252 IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean)
243 IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash) 253 IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash)
244 IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang) 254 IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang)
245 IPC_MESSAGE_HANDLER(GpuMsg_GpuSwitched, OnGpuSwitched) 255 IPC_MESSAGE_HANDLER(GpuMsg_GpuSwitched, OnGpuSwitched)
246 IPC_MESSAGE_UNHANDLED(handled = false) 256 IPC_MESSAGE_UNHANDLED(handled = false)
247 IPC_END_MESSAGE_MAP() 257 IPC_END_MESSAGE_MAP()
(...skipping 17 matching lines...) Expand all
265 OnDestroyingVideoSurface); 275 OnDestroyingVideoSurface);
266 #endif 276 #endif
267 IPC_MESSAGE_UNHANDLED(handled = false) 277 IPC_MESSAGE_UNHANDLED(handled = false)
268 IPC_END_MESSAGE_MAP() 278 IPC_END_MESSAGE_MAP()
269 if (handled) 279 if (handled)
270 return true; 280 return true;
271 281
272 return false; 282 return false;
273 } 283 }
274 284
275 void GpuChildThread::SetActiveURL(const GURL& url) { 285 void GpuChildThread::OnAssociatedInterfaceRequest(
276 GetContentClient()->SetActiveURL(url); 286 const std::string& name,
287 mojo::ScopedInterfaceEndpointHandle handle) {
288 associated_interfaces_.BindRequest(name, std::move(handle));
277 } 289 }
278 290
279 void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) { 291 void GpuChildThread::CreateGpuService(
280 Send(new GpuHostMsg_DidCreateOffscreenContext(active_url)); 292 ui::mojom::GpuServiceRequest request,
281 } 293 ui::mojom::GpuHostPtr gpu_host,
294 const gpu::GpuPreferences& gpu_preferences) {
295 gpu_service_->Bind(std::move(request));
282 296
283 void GpuChildThread::DidDestroyChannel(int client_id) {
284 media_gpu_channel_manager_->RemoveChannel(client_id);
285 Send(new GpuHostMsg_DestroyChannel(client_id));
286 }
287
288 void GpuChildThread::DidDestroyOffscreenContext(const GURL& active_url) {
289 Send(new GpuHostMsg_DidDestroyOffscreenContext(active_url));
290 }
291
292 void GpuChildThread::DidLoseContext(bool offscreen,
293 gpu::error::ContextLostReason reason,
294 const GURL& active_url) {
295 Send(new GpuHostMsg_DidLoseContext(offscreen, reason, active_url));
296 }
297
298 #if defined(OS_WIN)
299 void GpuChildThread::SendAcceleratedSurfaceCreatedChildWindow(
300 gpu::SurfaceHandle parent_window,
301 gpu::SurfaceHandle child_window) {
302 Send(new GpuHostMsg_AcceleratedSurfaceCreatedChildWindow(parent_window,
303 child_window));
304 }
305 #endif
306
307 void GpuChildThread::StoreShaderToDisk(int32_t client_id,
308 const std::string& key,
309 const std::string& shader) {
310 Send(new GpuHostMsg_CacheShader(client_id, key, shader));
311 }
312
313 void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) {
314 gpu_info_.video_decode_accelerator_capabilities = 297 gpu_info_.video_decode_accelerator_capabilities =
315 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences); 298 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences);
316 gpu_info_.video_encode_accelerator_supported_profiles = 299 gpu_info_.video_encode_accelerator_supported_profiles =
317 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(gpu_preferences); 300 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(gpu_preferences);
318 gpu_info_.jpeg_decode_accelerator_supported = 301 gpu_info_.jpeg_decode_accelerator_supported =
319 media::GpuJpegDecodeAccelerator::IsSupported(); 302 media::GpuJpegDecodeAccelerator::IsSupported();
320 303
321 // Record initialization only after collecting the GPU info because that can 304 // Record initialization only after collecting the GPU info because that can
322 // take a significant amount of time. 305 // take a significant amount of time.
323 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; 306 gpu_info_.initialization_time = base::Time::Now() - process_start_time_;
(...skipping 12 matching lines...) Expand all
336 319
337 // We don't need to pipe log messages if we are running the GPU thread in 320 // We don't need to pipe log messages if we are running the GPU thread in
338 // the browser process. 321 // the browser process.
339 if (!in_browser_process_) 322 if (!in_browser_process_)
340 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); 323 logging::SetLogMessageHandler(GpuProcessLogMessageHandler);
341 324
342 gpu::SyncPointManager* sync_point_manager = nullptr; 325 gpu::SyncPointManager* sync_point_manager = nullptr;
343 // Note SyncPointManager from ContentGpuClient cannot be owned by this. 326 // Note SyncPointManager from ContentGpuClient cannot be owned by this.
344 if (GetContentClient()->gpu()) 327 if (GetContentClient()->gpu())
345 sync_point_manager = GetContentClient()->gpu()->GetSyncPointManager(); 328 sync_point_manager = GetContentClient()->gpu()->GetSyncPointManager();
346 if (!sync_point_manager) { 329 gpu_service_->InitializeWithHost(std::move(gpu_host), gpu_preferences,
347 if (!owned_sync_point_manager_) { 330 sync_point_manager,
348 owned_sync_point_manager_.reset(new gpu::SyncPointManager(false)); 331 ChildProcess::current()->GetShutDownEvent());
349 } 332 CHECK(gpu_service_->media_gpu_channel_manager());
350 sync_point_manager = owned_sync_point_manager_.get();
351 }
352
353 // Defer creation of the render thread. This is to prevent it from handling
354 // IPC messages before the sandbox has been enabled and all other necessary
355 // initialization has succeeded.
356 gpu_channel_manager_.reset(new gpu::GpuChannelManager(
357 gpu_preferences, this, watchdog_thread_.get(),
358 base::ThreadTaskRunnerHandle::Get().get(),
359 ChildProcess::current()->io_task_runner(),
360 ChildProcess::current()->GetShutDownEvent(), sync_point_manager,
361 gpu_memory_buffer_factory_));
362
363 media_gpu_channel_manager_.reset(
364 new media::MediaGpuChannelManager(gpu_channel_manager_.get()));
365 333
366 // Only set once per process instance. 334 // Only set once per process instance.
367 service_factory_.reset( 335 service_factory_.reset(new GpuServiceFactory(
368 new GpuServiceFactory(media_gpu_channel_manager_->AsWeakPtr())); 336 gpu_service_->media_gpu_channel_manager()->AsWeakPtr()));
369 337
370 GetInterfaceRegistry()->AddInterface(base::Bind( 338 GetInterfaceRegistry()->AddInterface(base::Bind(
371 &GpuChildThread::BindServiceFactoryRequest, base::Unretained(this))); 339 &GpuChildThread::BindServiceFactoryRequest, base::Unretained(this)));
372 340
373 if (GetContentClient()->gpu()) { // NULL in tests. 341 if (GetContentClient()->gpu()) { // NULL in tests.
374 GetContentClient()->gpu()->ExposeInterfacesToBrowser(GetInterfaceRegistry(), 342 GetContentClient()->gpu()->ExposeInterfacesToBrowser(GetInterfaceRegistry(),
375 gpu_preferences); 343 gpu_preferences);
376 GetContentClient()->gpu()->ConsumeInterfacesFromBrowser( 344 GetContentClient()->gpu()->ConsumeInterfacesFromBrowser(
377 GetRemoteInterfaces()); 345 GetRemoteInterfaces());
378 } 346 }
379 347
380 GetInterfaceRegistry()->ResumeBinding(); 348 GetInterfaceRegistry()->ResumeBinding();
381 } 349 }
382 350
351 void GpuChildThread::CreateDisplayCompositor(
352 cc::mojom::DisplayCompositorRequest request,
353 cc::mojom::DisplayCompositorClientPtr client) {
354 NOTREACHED();
355 }
356
383 void GpuChildThread::OnFinalize() { 357 void GpuChildThread::OnFinalize() {
384 // Quit the GPU process 358 // Quit the GPU process
385 base::MessageLoop::current()->QuitWhenIdle(); 359 base::MessageLoop::current()->QuitWhenIdle();
386 } 360 }
387 361
388 void GpuChildThread::OnCollectGraphicsInfo() { 362 void GpuChildThread::OnCollectGraphicsInfo() {
389 if (dead_on_arrival_) 363 if (dead_on_arrival_)
390 return; 364 return;
391 365
392 #if defined(OS_WIN) 366 #if defined(OS_WIN)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 #if defined(OS_WIN) 411 #if defined(OS_WIN)
438 if (!in_browser_process_) { 412 if (!in_browser_process_) {
439 // The unsandboxed GPU process fulfilled its duty. Rest in peace. 413 // The unsandboxed GPU process fulfilled its duty. Rest in peace.
440 base::MessageLoop::current()->QuitWhenIdle(); 414 base::MessageLoop::current()->QuitWhenIdle();
441 } 415 }
442 #endif // OS_WIN 416 #endif // OS_WIN
443 } 417 }
444 418
445 void GpuChildThread::OnGetVideoMemoryUsageStats() { 419 void GpuChildThread::OnGetVideoMemoryUsageStats() {
446 gpu::VideoMemoryUsageStats video_memory_usage_stats; 420 gpu::VideoMemoryUsageStats video_memory_usage_stats;
447 if (gpu_channel_manager_) { 421 if (gpu_channel_manager()) {
448 gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats( 422 gpu_channel_manager()->gpu_memory_manager()->GetVideoMemoryUsageStats(
449 &video_memory_usage_stats); 423 &video_memory_usage_stats);
450 } 424 }
451 Send(new GpuHostMsg_VideoMemoryUsageStats(video_memory_usage_stats)); 425 Send(new GpuHostMsg_VideoMemoryUsageStats(video_memory_usage_stats));
452 } 426 }
453 427
454 void GpuChildThread::OnClean() { 428 void GpuChildThread::OnClean() {
455 DVLOG(1) << "GPU: Removing all contexts"; 429 DVLOG(1) << "GPU: Removing all contexts";
456 if (gpu_channel_manager_) 430 if (gpu_channel_manager())
457 gpu_channel_manager_->DestroyAllChannels(); 431 gpu_channel_manager()->DestroyAllChannels();
458 } 432 }
459 433
460 void GpuChildThread::OnCrash() { 434 void GpuChildThread::OnCrash() {
461 DVLOG(1) << "GPU: Simulating GPU crash"; 435 DVLOG(1) << "GPU: Simulating GPU crash";
462 // Good bye, cruel world. 436 // Good bye, cruel world.
463 volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL; 437 volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL;
464 *it_s_the_end_of_the_world_as_we_know_it = 0xdead; 438 *it_s_the_end_of_the_world_as_we_know_it = 0xdead;
465 } 439 }
466 440
467 void GpuChildThread::OnHang() { 441 void GpuChildThread::OnHang() {
468 DVLOG(1) << "GPU: Simulating GPU hang"; 442 DVLOG(1) << "GPU: Simulating GPU hang";
469 for (;;) { 443 for (;;) {
470 // Do not sleep here. The GPU watchdog timer tracks the amount of user 444 // Do not sleep here. The GPU watchdog timer tracks the amount of user
471 // time this thread is using and it doesn't use much while calling Sleep. 445 // time this thread is using and it doesn't use much while calling Sleep.
472 } 446 }
473 } 447 }
474 448
475 void GpuChildThread::OnGpuSwitched() { 449 void GpuChildThread::OnGpuSwitched() {
476 DVLOG(1) << "GPU: GPU has switched"; 450 DVLOG(1) << "GPU: GPU has switched";
477 // Notify observers in the GPU process. 451 // Notify observers in the GPU process.
478 if (!in_browser_process_) 452 if (!in_browser_process_)
479 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); 453 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched();
480 } 454 }
481 455
482 void GpuChildThread::OnEstablishChannel(const EstablishChannelParams& params) { 456 void GpuChildThread::OnEstablishChannel(const EstablishChannelParams& params) {
483 if (!gpu_channel_manager_) 457 if (!gpu_channel_manager())
484 return; 458 return;
485 459
486 IPC::ChannelHandle channel_handle = gpu_channel_manager_->EstablishChannel( 460 IPC::ChannelHandle channel_handle = gpu_channel_manager()->EstablishChannel(
487 params.client_id, params.client_tracing_id, params.preempts, 461 params.client_id, params.client_tracing_id, params.preempts,
488 params.allow_view_command_buffers, params.allow_real_time_streams); 462 params.allow_view_command_buffers, params.allow_real_time_streams);
489 media_gpu_channel_manager_->AddChannel(params.client_id); 463 gpu_service_->media_gpu_channel_manager()->AddChannel(params.client_id);
490 Send(new GpuHostMsg_ChannelEstablished(channel_handle)); 464 Send(new GpuHostMsg_ChannelEstablished(channel_handle));
491 } 465 }
492 466
493 void GpuChildThread::OnCloseChannel(int32_t client_id) { 467 void GpuChildThread::OnCloseChannel(int32_t client_id) {
494 if (gpu_channel_manager_) 468 if (gpu_channel_manager())
495 gpu_channel_manager_->RemoveChannel(client_id); 469 gpu_channel_manager()->RemoveChannel(client_id);
496 } 470 }
497 471
498 void GpuChildThread::OnLoadedShader(const std::string& shader) { 472 void GpuChildThread::OnLoadedShader(const std::string& shader) {
499 if (gpu_channel_manager_) 473 if (gpu_channel_manager())
500 gpu_channel_manager_->PopulateShaderCache(shader); 474 gpu_channel_manager()->PopulateShaderCache(shader);
501 } 475 }
502 476
503 void GpuChildThread::OnDestroyGpuMemoryBuffer( 477 void GpuChildThread::OnDestroyGpuMemoryBuffer(
504 gfx::GpuMemoryBufferId id, 478 gfx::GpuMemoryBufferId id,
505 int client_id, 479 int client_id,
506 const gpu::SyncToken& sync_token) { 480 const gpu::SyncToken& sync_token) {
507 if (gpu_channel_manager_) 481 if (gpu_channel_manager())
508 gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token); 482 gpu_channel_manager()->DestroyGpuMemoryBuffer(id, client_id, sync_token);
509 } 483 }
510 484
511 #if defined(OS_ANDROID) 485 #if defined(OS_ANDROID)
512 void GpuChildThread::OnWakeUpGpu() { 486 void GpuChildThread::OnWakeUpGpu() {
513 if (gpu_channel_manager_) 487 if (gpu_channel_manager())
514 gpu_channel_manager_->WakeUpGpu(); 488 gpu_channel_manager()->WakeUpGpu();
515 } 489 }
516 490
517 void GpuChildThread::OnDestroyingVideoSurface(int surface_id) { 491 void GpuChildThread::OnDestroyingVideoSurface(int surface_id) {
518 media::AVDACodecAllocator::Instance()->OnSurfaceDestroyed(surface_id); 492 media::AVDACodecAllocator::Instance()->OnSurfaceDestroyed(surface_id);
519 Send(new GpuHostMsg_DestroyingVideoSurfaceAck(surface_id)); 493 Send(new GpuHostMsg_DestroyingVideoSurfaceAck(surface_id));
520 } 494 }
521 #endif 495 #endif
522 496
523 void GpuChildThread::OnLoseAllContexts() {
524 if (gpu_channel_manager_) {
525 gpu_channel_manager_->DestroyAllChannels();
526 media_gpu_channel_manager_->DestroyAllChannels();
527 }
528 }
529
530 void GpuChildThread::BindServiceFactoryRequest( 497 void GpuChildThread::BindServiceFactoryRequest(
531 service_manager::mojom::ServiceFactoryRequest request) { 498 service_manager::mojom::ServiceFactoryRequest request) {
532 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest"; 499 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest";
533 DCHECK(service_factory_); 500 DCHECK(service_factory_);
534 service_factory_bindings_.AddBinding(service_factory_.get(), 501 service_factory_bindings_.AddBinding(service_factory_.get(),
535 std::move(request)); 502 std::move(request));
536 } 503 }
537 504
538 } // namespace content 505 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698