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

Side by Side Diff: content/browser/compositor/gpu_process_transport_factory.cc

Issue 2096843002: mus+ash: Enable Chrome HW rendering in mus+ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a compile error Created 4 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/compositor/gpu_process_transport_factory.h" 5 #include "content/browser/compositor/gpu_process_transport_factory.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "gpu/command_buffer/common/mailbox.h" 53 #include "gpu/command_buffer/common/mailbox.h"
54 #include "gpu/ipc/client/gpu_channel_host.h" 54 #include "gpu/ipc/client/gpu_channel_host.h"
55 #include "third_party/khronos/GLES2/gl2.h" 55 #include "third_party/khronos/GLES2/gl2.h"
56 #include "ui/compositor/compositor.h" 56 #include "ui/compositor/compositor.h"
57 #include "ui/compositor/compositor_constants.h" 57 #include "ui/compositor/compositor_constants.h"
58 #include "ui/compositor/compositor_switches.h" 58 #include "ui/compositor/compositor_switches.h"
59 #include "ui/compositor/layer.h" 59 #include "ui/compositor/layer.h"
60 #include "ui/gfx/geometry/size.h" 60 #include "ui/gfx/geometry/size.h"
61 61
62 #if defined(MOJO_RUNNER_CLIENT) 62 #if defined(MOJO_RUNNER_CLIENT)
63 #include "content/browser/compositor/mus_browser_compositor_output_surface.h"
64 #include "content/public/common/mojo_shell_connection.h"
63 #include "services/shell/runner/common/client_util.h" 65 #include "services/shell/runner/common/client_util.h"
66 #include "services/ui/common/gpu_service.h"
64 #endif 67 #endif
65 68
66 #if defined(OS_WIN) 69 #if defined(OS_WIN)
67 #include "content/browser/compositor/software_output_device_win.h" 70 #include "content/browser/compositor/software_output_device_win.h"
68 #include "ui/gfx/win/rendering_window_manager.h" 71 #include "ui/gfx/win/rendering_window_manager.h"
69 #elif defined(USE_OZONE) 72 #elif defined(USE_OZONE)
70 #include "components/display_compositor/compositor_overlay_candidate_validator_o zone.h" 73 #include "components/display_compositor/compositor_overlay_candidate_validator_o zone.h"
71 #include "content/browser/compositor/software_output_device_ozone.h" 74 #include "content/browser/compositor/software_output_device_ozone.h"
72 #include "ui/ozone/public/overlay_candidates_ozone.h" 75 #include "ui/ozone/public/overlay_candidates_ozone.h"
73 #include "ui/ozone/public/overlay_manager_ozone.h" 76 #include "ui/ozone/public/overlay_manager_ozone.h"
(...skipping 20 matching lines...) Expand all
94 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h" 97 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h"
95 #endif 98 #endif
96 99
97 using cc::ContextProvider; 100 using cc::ContextProvider;
98 using gpu::gles2::GLES2Interface; 101 using gpu::gles2::GLES2Interface;
99 102
100 namespace { 103 namespace {
101 104
102 const int kNumRetriesBeforeSoftwareFallback = 4; 105 const int kNumRetriesBeforeSoftwareFallback = 4;
103 106
107 bool IsUsingMus() {
108 #if defined(MOJO_RUNNER_CLIENT)
109 return shell::ShellIsRemote();
110 #else
111 return false;
112 #endif
113 }
114
104 scoped_refptr<content::ContextProviderCommandBuffer> CreateContextCommon( 115 scoped_refptr<content::ContextProviderCommandBuffer> CreateContextCommon(
105 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, 116 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
106 gpu::SurfaceHandle surface_handle, 117 gpu::SurfaceHandle surface_handle,
107 bool support_locking, 118 bool support_locking,
108 content::ContextProviderCommandBuffer* shared_context_provider, 119 content::ContextProviderCommandBuffer* shared_context_provider,
109 content::command_buffer_metrics::ContextType type) { 120 content::command_buffer_metrics::ContextType type) {
110 DCHECK( 121 DCHECK(
111 content::GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()); 122 content::GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor());
112 DCHECK(gpu_channel_host); 123 DCHECK(gpu_channel_host);
113 124
114 // This is called from a few places to create different contexts: 125 // This is called from a few places to create different contexts:
115 // - The shared main thread context (offscreen). 126 // - The shared main thread context (offscreen).
116 // - The compositor context, which is used by the browser compositor 127 // - The compositor context, which is used by the browser compositor
117 // (offscreen) for synchronization mostly, and by the display compositor 128 // (offscreen) for synchronization mostly, and by the display compositor
118 // (onscreen) for actual GL drawing. 129 // (onscreen) for actual GL drawing.
119 // - The compositor worker context (offscreen) used for GPU raster. 130 // - The compositor worker context (offscreen) used for GPU raster.
120 // So ask for capabilities needed by any of these cases (we can optimize by 131 // So ask for capabilities needed by any of these cases (we can optimize by
121 // branching on |surface_handle| being null if these needs diverge). 132 // branching on |surface_handle| being null if these needs diverge).
122 // 133 //
123 // The default framebuffer for an offscreen context is not used, so it does 134 // The default framebuffer for an offscreen context is not used, so it does
124 // not need alpha, stencil, depth, antialiasing. The display compositor does 135 // not need alpha, stencil, depth, antialiasing. The display compositor does
125 // not use these things either, so we can request nothing here. 136 // not use these things either, so we can request nothing here.
126 gpu::gles2::ContextCreationAttribHelper attributes; 137 gpu::gles2::ContextCreationAttribHelper attributes;
127 attributes.alpha_size = -1; 138 // For mus, we need the alpha channel for "onscreen" context.
danakj 2016/07/07 20:16:41 For mus the context is not onscreen anymore, so th
Peng 2016/07/07 21:33:37 Done.
139 attributes.alpha_size = (IsUsingMus() && surface_handle) ? 8 : -1;
128 attributes.depth_size = 0; 140 attributes.depth_size = 0;
129 attributes.stencil_size = 0; 141 attributes.stencil_size = 0;
130 attributes.samples = 0; 142 attributes.samples = 0;
131 attributes.sample_buffers = 0; 143 attributes.sample_buffers = 0;
132 attributes.bind_generates_resource = false; 144 attributes.bind_generates_resource = false;
133 attributes.lose_context_when_out_of_memory = true; 145 attributes.lose_context_when_out_of_memory = true;
134 146
135 constexpr bool automatic_flushes = false; 147 constexpr bool automatic_flushes = false;
136 148
149 // For mus, we create offscreen context.
danakj 2016/07/07 20:16:41 "an offscreen context"
Peng 2016/07/07 21:33:36 Done.
150 surface_handle = IsUsingMus() ? gpu::kNullSurfaceHandle : surface_handle;
danakj 2016/07/07 20:16:41 As the comment above says, this code is used for c
Peng 2016/07/07 21:33:37 Done.
151
137 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); 152 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon");
138 return make_scoped_refptr(new content::ContextProviderCommandBuffer( 153 return make_scoped_refptr(new content::ContextProviderCommandBuffer(
139 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, 154 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT,
140 gpu::GpuStreamPriority::NORMAL, surface_handle, url, automatic_flushes, 155 gpu::GpuStreamPriority::NORMAL, surface_handle, url, automatic_flushes,
141 support_locking, gpu::SharedMemoryLimits(), attributes, 156 support_locking, gpu::SharedMemoryLimits(), attributes,
142 shared_context_provider, type)); 157 shared_context_provider, type));
143 } 158 }
144 159
145 #if defined(OS_MACOSX) 160 #if defined(OS_MACOSX)
146 bool IsCALayersDisabledFromCommandLine() { 161 bool IsCALayersDisabledFromCommandLine() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 #elif defined(OS_ANDROID) 262 #elif defined(OS_ANDROID)
248 validator.reset( 263 validator.reset(
249 new display_compositor::CompositorOverlayCandidateValidatorAndroid()); 264 new display_compositor::CompositorOverlayCandidateValidatorAndroid());
250 #endif 265 #endif
251 266
252 return validator; 267 return validator;
253 } 268 }
254 269
255 static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) { 270 static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) {
256 #if defined(MOJO_RUNNER_CLIENT) 271 #if defined(MOJO_RUNNER_CLIENT)
257 // Chrome running as a mojo app currently can only use software compositing. 272 // Chrome running as a mojo app currently can only use software compositing.
danakj 2016/07/07 20:16:41 This comment is wrong now?
Peng 2016/07/07 21:33:36 Done.
258 // TODO(rjkroege): http://crbug.com/548451 273 // TODO(rjkroege): http://crbug.com/548451
259 if (shell::ShellIsRemote()) { 274 if (shell::ShellIsRemote() && !ui::GpuService::UseChromeGpuCommandBuffer())
260 return false; 275 return false;
261 }
262 #endif 276 #endif
263 277
264 #if defined(OS_CHROMEOS) 278 #if defined(OS_CHROMEOS)
265 // Software fallback does not happen on Chrome OS. 279 // Software fallback does not happen on Chrome OS.
266 return true; 280 return true;
267 #endif 281 #endif
268 282
269 #if defined(OS_WIN) 283 #if defined(OS_WIN)
270 if (::GetProp(compositor->widget(), kForceSoftwareCompositor) && 284 if (::GetProp(compositor->widget(), kForceSoftwareCompositor) &&
271 ::RemoveProp(compositor->widget(), kForceSoftwareCompositor)) 285 ::RemoveProp(compositor->widget(), kForceSoftwareCompositor))
(...skipping 15 matching lines...) Expand all
287 data->display_output_surface = nullptr; 301 data->display_output_surface = nullptr;
288 data->begin_frame_source = nullptr; 302 data->begin_frame_source = nullptr;
289 } 303 }
290 304
291 #if defined(OS_WIN) 305 #if defined(OS_WIN)
292 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( 306 gfx::RenderingWindowManager::GetInstance()->UnregisterParent(
293 compositor->widget()); 307 compositor->widget());
294 #endif 308 #endif
295 309
296 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider()); 310 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider());
297 311 const bool use_mus = IsUsingMus();
298 const bool create_gpu_output_surface = 312 const bool create_gpu_output_surface =
299 ShouldCreateGpuOutputSurface(compositor.get()); 313 ShouldCreateGpuOutputSurface(compositor.get());
300 if (create_gpu_output_surface && !use_vulkan) { 314 if (create_gpu_output_surface && !use_vulkan) {
301 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( 315 base::Closure callback(
302 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT,
303 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, 316 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel,
304 callback_factory_.GetWeakPtr(), compositor, 317 callback_factory_.GetWeakPtr(), compositor,
305 create_gpu_output_surface, 0)); 318 create_gpu_output_surface, 0));
319 if (!use_mus) {
320 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(
321 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, callback);
322 #if defined(MOJO_RUNNER_CLIENT)
323 } else {
piman 2016/07/07 21:02:20 nit: I would prefer to avoid mixing compile-time #
Peng 2016/07/07 21:33:37 Done.
324 ui::GpuService::GetInstance()->EstablishGpuChannel(callback);
325 #endif
326 }
306 } else { 327 } else {
307 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0); 328 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0);
308 } 329 }
309 } 330 }
310 331
311 void GpuProcessTransportFactory::EstablishedGpuChannel( 332 void GpuProcessTransportFactory::EstablishedGpuChannel(
312 base::WeakPtr<ui::Compositor> compositor, 333 base::WeakPtr<ui::Compositor> compositor,
313 bool create_gpu_output_surface, 334 bool create_gpu_output_surface,
314 int num_attempts) { 335 int num_attempts) {
315 if (!compositor) 336 if (!compositor)
(...skipping 16 matching lines...) Expand all
332 create_gpu_output_surface = false; 353 create_gpu_output_surface = false;
333 } 354 }
334 355
335 #if defined(OS_WIN) 356 #if defined(OS_WIN)
336 gfx::RenderingWindowManager::GetInstance()->RegisterParent( 357 gfx::RenderingWindowManager::GetInstance()->RegisterParent(
337 compositor->widget()); 358 compositor->widget());
338 #endif 359 #endif
339 360
340 scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider = 361 scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider =
341 SharedVulkanContextProvider(); 362 SharedVulkanContextProvider();
342 363 const bool use_mus = IsUsingMus();
343 scoped_refptr<ContextProviderCommandBuffer> context_provider; 364 scoped_refptr<ContextProviderCommandBuffer> context_provider;
344 if (create_gpu_output_surface && !vulkan_context_provider) { 365 if (create_gpu_output_surface && !vulkan_context_provider) {
345 // Try to reuse existing worker context provider. 366 // Try to reuse existing worker context provider.
346 if (shared_worker_context_provider_) { 367 if (shared_worker_context_provider_) {
347 bool lost; 368 bool lost;
348 { 369 {
349 // Note: If context is lost, we delete reference after releasing the 370 // Note: If context is lost, we delete reference after releasing the
350 // lock. 371 // lock.
351 base::AutoLock lock(*shared_worker_context_provider_->GetLock()); 372 base::AutoLock lock(*shared_worker_context_provider_->GetLock());
352 lost = shared_worker_context_provider_->ContextGL() 373 lost = shared_worker_context_provider_->ContextGL()
353 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR; 374 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR;
354 } 375 }
355 if (lost) 376 if (lost)
356 shared_worker_context_provider_ = nullptr; 377 shared_worker_context_provider_ = nullptr;
357 } 378 }
358 379
359 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; 380 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host;
360 if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { 381 if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) {
361 // We attempted to do EstablishGpuChannel already, so we just use 382 // We attempted to do EstablishGpuChannel already, so we just use
362 // GetGpuChannel() instead of EstablishGpuChannelSync(). 383 // GetGpuChannel() instead of EstablishGpuChannelSync().
363 gpu_channel_host = 384 if (!use_mus) {
364 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); 385 gpu_channel_host =
386 BrowserGpuChannelHostFactory::instance()->GetGpuChannel();
387 #if defined(MOJO_RUNNER_CLIENT)
388 } else {
piman 2016/07/07 21:02:20 nit: ditto
Peng 2016/07/07 21:33:37 Done.
389 gpu_channel_host = ui::GpuService::GetInstance()->GetGpuChannel();
390 #endif
391 }
365 } 392 }
366 393
367 if (!gpu_channel_host) { 394 if (!gpu_channel_host) {
368 shared_worker_context_provider_ = nullptr; 395 shared_worker_context_provider_ = nullptr;
369 } else { 396 } else {
370 if (!shared_worker_context_provider_) { 397 if (!shared_worker_context_provider_) {
371 const bool support_locking = true; 398 const bool support_locking = true;
372 shared_worker_context_provider_ = CreateContextCommon( 399 shared_worker_context_provider_ = CreateContextCommon(
373 gpu_channel_host, gpu::kNullSurfaceHandle, support_locking, nullptr, 400 gpu_channel_host, gpu::kNullSurfaceHandle, support_locking, nullptr,
374 command_buffer_metrics::BROWSER_WORKER_CONTEXT); 401 command_buffer_metrics::BROWSER_WORKER_CONTEXT);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } 438 }
412 439
413 bool created_gpu_browser_compositor = 440 bool created_gpu_browser_compositor =
414 !!context_provider && !!shared_worker_context_provider_; 441 !!context_provider && !!shared_worker_context_provider_;
415 442
416 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", 443 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor",
417 created_gpu_browser_compositor); 444 created_gpu_browser_compositor);
418 445
419 if (!created_gpu_browser_compositor) { 446 if (!created_gpu_browser_compositor) {
420 // Try again. 447 // Try again.
421 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( 448 base::Closure callback(
422 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT,
423 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, 449 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel,
424 callback_factory_.GetWeakPtr(), compositor, 450 callback_factory_.GetWeakPtr(), compositor,
425 create_gpu_output_surface, num_attempts + 1)); 451 create_gpu_output_surface, num_attempts + 1));
452 if (!use_mus) {
453 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(
454 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, callback);
455 #if defined(MOJO_RUNNER_CLIENT)
456 } else {
piman 2016/07/07 21:02:20 nit: ditto
Peng 2016/07/07 21:33:37 Done.
457 ui::GpuService::GetInstance()->EstablishGpuChannel(callback);
458 #endif
459 }
426 return; 460 return;
427 } 461 }
428 } 462 }
429 463
430 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; 464 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source;
431 if (!compositor->GetRendererSettings().disable_display_vsync) { 465 if (!compositor->GetRendererSettings().disable_display_vsync) {
432 begin_frame_source.reset(new cc::DelayBasedBeginFrameSource( 466 begin_frame_source.reset(new cc::DelayBasedBeginFrameSource(
433 base::MakeUnique<cc::DelayBasedTimeSource>( 467 base::MakeUnique<cc::DelayBasedTimeSource>(
434 compositor->task_runner().get()))); 468 compositor->task_runner().get())));
435 } else { 469 } else {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 compositor->vsync_manager(), begin_frame_source.get(), 518 compositor->vsync_manager(), begin_frame_source.get(),
485 CreateOverlayCandidateValidator(compositor->widget()), 519 CreateOverlayCandidateValidator(compositor->widget()),
486 GL_TEXTURE_2D, GL_RGB, 520 GL_TEXTURE_2D, GL_RGB,
487 BrowserGpuMemoryBufferManager::current())); 521 BrowserGpuMemoryBufferManager::current()));
488 #endif 522 #endif
489 } else { 523 } else {
490 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> 524 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator>
491 validator; 525 validator;
492 #if !defined(OS_MACOSX) 526 #if !defined(OS_MACOSX)
493 // Overlays are only supported on surfaceless output surfaces on Mac. 527 // Overlays are only supported on surfaceless output surfaces on Mac.
494 validator = CreateOverlayCandidateValidator(compositor->widget()); 528 if (!use_mus)
529 validator = CreateOverlayCandidateValidator(compositor->widget());
495 #endif 530 #endif
496 display_output_surface = 531 if (!use_mus) {
497 base::WrapUnique(new GpuBrowserCompositorOutputSurface( 532 display_output_surface =
498 context_provider, compositor->vsync_manager(), 533 base::WrapUnique(new GpuBrowserCompositorOutputSurface(
499 begin_frame_source.get(), std::move(validator))); 534 context_provider, compositor->vsync_manager(),
535 begin_frame_source.get(), std::move(validator)));
536 #if defined(MOJO_RUNNER_CLIENT)
danakj 2016/07/07 20:16:41 Why are things inside #if defined, but the source
Peng 2016/07/07 21:33:37 I think the MOJO_RUNNER_CLIENT is only defined wit
537 } else {
538 display_output_surface =
539 base::WrapUnique(new MusBrowserCompositorOutputSurface(
540 data->surface_handle, context_provider,
541 compositor->vsync_manager(), begin_frame_source.get(),
542 std::move(validator)));
543 #endif
544 }
500 } 545 }
501 } 546 }
502 } 547 }
503 548
504 data->display_output_surface = display_output_surface.get(); 549 data->display_output_surface = display_output_surface.get();
505 data->begin_frame_source = begin_frame_source.get(); 550 data->begin_frame_source = begin_frame_source.get();
506 if (data->reflector) 551 if (data->reflector)
507 data->reflector->OnSourceSurfaceReady(data->display_output_surface); 552 data->reflector->OnSourceSurfaceReady(data->display_output_surface);
508 553
509 #if defined(OS_WIN) 554 #if defined(OS_WIN)
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 } 770 }
726 #endif 771 #endif
727 772
728 scoped_refptr<cc::ContextProvider> 773 scoped_refptr<cc::ContextProvider>
729 GpuProcessTransportFactory::SharedMainThreadContextProvider() { 774 GpuProcessTransportFactory::SharedMainThreadContextProvider() {
730 if (shared_main_thread_contexts_) 775 if (shared_main_thread_contexts_)
731 return shared_main_thread_contexts_; 776 return shared_main_thread_contexts_;
732 777
733 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) 778 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor())
734 return nullptr; 779 return nullptr;
735 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( 780
736 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync( 781 const bool use_mus = IsUsingMus();
737 CAUSE_FOR_GPU_LAUNCH_BROWSER_SHARED_MAIN_THREAD_CONTEXT)); 782 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host;
783 if (!use_mus) {
784 gpu_channel_host =
785 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(
786 CAUSE_FOR_GPU_LAUNCH_BROWSER_SHARED_MAIN_THREAD_CONTEXT);
787 #if defined(MOJO_RUNNER_CLIENT)
788 } else {
piman 2016/07/07 21:02:20 nit: ditto
Peng 2016/07/07 21:33:37 Done.
789 gpu_channel_host = ui::GpuService::GetInstance()->EstablishGpuChannelSync();
790 #endif
791 }
792
738 if (!gpu_channel_host) 793 if (!gpu_channel_host)
739 return nullptr; 794 return nullptr;
740 795
741 // We need a separate context from the compositor's so that skia and gl_helper 796 // We need a separate context from the compositor's so that skia and gl_helper
742 // don't step on each other. 797 // don't step on each other.
743 bool support_locking = false; 798 bool support_locking = false;
744 shared_main_thread_contexts_ = CreateContextCommon( 799 shared_main_thread_contexts_ = CreateContextCommon(
745 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, support_locking, 800 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, support_locking,
746 nullptr, command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); 801 nullptr, command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT);
747 shared_main_thread_contexts_->SetLostContextCallback(base::Bind( 802 shared_main_thread_contexts_->SetLostContextCallback(base::Bind(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 shared_vulkan_context_provider_ = 874 shared_vulkan_context_provider_ =
820 cc::VulkanInProcessContextProvider::Create(); 875 cc::VulkanInProcessContextProvider::Create();
821 } 876 }
822 877
823 shared_vulkan_context_provider_initialized_ = true; 878 shared_vulkan_context_provider_initialized_ = true;
824 } 879 }
825 return shared_vulkan_context_provider_; 880 return shared_vulkan_context_provider_;
826 } 881 }
827 882
828 } // namespace content 883 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698