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

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

Issue 2018603002: Mac: Clean up ifdefs in output surface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #elif defined(USE_OZONE) 65 #elif defined(USE_OZONE)
66 #include "components/display_compositor/compositor_overlay_candidate_validator_o zone.h" 66 #include "components/display_compositor/compositor_overlay_candidate_validator_o zone.h"
67 #include "content/browser/compositor/software_output_device_ozone.h" 67 #include "content/browser/compositor/software_output_device_ozone.h"
68 #include "ui/ozone/public/overlay_candidates_ozone.h" 68 #include "ui/ozone/public/overlay_candidates_ozone.h"
69 #include "ui/ozone/public/overlay_manager_ozone.h" 69 #include "ui/ozone/public/overlay_manager_ozone.h"
70 #include "ui/ozone/public/ozone_platform.h" 70 #include "ui/ozone/public/ozone_platform.h"
71 #include "ui/ozone/public/ozone_switches.h" 71 #include "ui/ozone/public/ozone_switches.h"
72 #elif defined(USE_X11) 72 #elif defined(USE_X11)
73 #include "content/browser/compositor/software_output_device_x11.h" 73 #include "content/browser/compositor/software_output_device_x11.h"
74 #elif defined(OS_MACOSX) 74 #elif defined(OS_MACOSX)
75 #include "components/display_compositor/compositor_overlay_candidate_validator_m ac.h" 75 #include "content/browser/compositor/gpu_browser_compositor_output_surface_mac.h "
76 #include "content/browser/compositor/software_output_device_mac.h" 76 #include "content/browser/compositor/software_output_device_mac.h"
77 #include "gpu/config/gpu_driver_bug_workaround_type.h"
78 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" 77 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
79 #include "ui/base/cocoa/remote_layer_api.h"
80 #include "ui/base/ui_base_switches.h"
81 #elif defined(OS_ANDROID) 78 #elif defined(OS_ANDROID)
82 #include "components/display_compositor/compositor_overlay_candidate_validator_a ndroid.h" 79 #include "components/display_compositor/compositor_overlay_candidate_validator_a ndroid.h"
83 #endif 80 #endif
84 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW) 81 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW)
85 #include "content/browser/gpu/gpu_surface_tracker.h" 82 #include "content/browser/gpu/gpu_surface_tracker.h"
86 #endif 83 #endif
87 84
88 #if defined(ENABLE_VULKAN) 85 #if defined(ENABLE_VULKAN)
89 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h" 86 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h"
90 #endif 87 #endif
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 constexpr bool automatic_flushes = false; 127 constexpr bool automatic_flushes = false;
131 128
132 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); 129 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon");
133 return make_scoped_refptr(new content::ContextProviderCommandBuffer( 130 return make_scoped_refptr(new content::ContextProviderCommandBuffer(
134 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, 131 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT,
135 gpu::GpuStreamPriority::NORMAL, surface_handle, url, 132 gpu::GpuStreamPriority::NORMAL, surface_handle, url,
136 gfx::PreferIntegratedGpu, automatic_flushes, support_locking, 133 gfx::PreferIntegratedGpu, automatic_flushes, support_locking,
137 gpu::SharedMemoryLimits(), attributes, shared_context_provider, type)); 134 gpu::SharedMemoryLimits(), attributes, shared_context_provider, type));
138 } 135 }
139 136
140 #if defined(OS_MACOSX)
141 bool IsCALayersDisabledFromCommandLine() {
142 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
143 return command_line->HasSwitch(switches::kDisableMacOverlays);
144 }
145 #endif
146
147 } // namespace 137 } // namespace
148 138
149 namespace content { 139 namespace content {
150 140
151 struct GpuProcessTransportFactory::PerCompositorData { 141 struct GpuProcessTransportFactory::PerCompositorData {
152 gpu::SurfaceHandle surface_handle; 142 gpu::SurfaceHandle surface_handle;
153 BrowserCompositorOutputSurface* surface; 143 BrowserCompositorOutputSurface* surface;
154 ReflectorImpl* reflector; 144 ReflectorImpl* reflector;
155 std::unique_ptr<cc::OnscreenDisplayClient> display_client; 145 std::unique_ptr<cc::OnscreenDisplayClient> display_client;
156 bool output_is_secure = false; 146 bool output_is_secure = false;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 ->GetOverlayManager() 212 ->GetOverlayManager()
223 ->CreateOverlayCandidates(widget); 213 ->CreateOverlayCandidates(widget);
224 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 214 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
225 if (overlay_candidates && 215 if (overlay_candidates &&
226 (command_line->HasSwitch(switches::kEnableHardwareOverlays) || 216 (command_line->HasSwitch(switches::kEnableHardwareOverlays) ||
227 command_line->HasSwitch(switches::kOzoneTestSingleOverlaySupport))) { 217 command_line->HasSwitch(switches::kOzoneTestSingleOverlaySupport))) {
228 validator.reset( 218 validator.reset(
229 new display_compositor::CompositorOverlayCandidateValidatorOzone( 219 new display_compositor::CompositorOverlayCandidateValidatorOzone(
230 std::move(overlay_candidates))); 220 std::move(overlay_candidates)));
231 } 221 }
232 #elif defined(OS_MACOSX)
233 // Overlays are only supported through the remote layer API.
234 if (ui::RemoteLayerAPISupported()) {
235 static bool overlays_disabled_at_command_line =
236 IsCALayersDisabledFromCommandLine();
237 const bool ca_layers_disabled =
238 overlays_disabled_at_command_line ||
239 GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive(
240 gpu::DISABLE_OVERLAY_CA_LAYERS);
241 validator.reset(
242 new display_compositor::CompositorOverlayCandidateValidatorMac(
243 ca_layers_disabled));
244 }
245 #elif defined(OS_ANDROID) 222 #elif defined(OS_ANDROID)
246 validator.reset( 223 validator.reset(
247 new display_compositor::CompositorOverlayCandidateValidatorAndroid()); 224 new display_compositor::CompositorOverlayCandidateValidatorAndroid());
248 #endif 225 #endif
249 226
250 return validator; 227 return validator;
251 } 228 }
252 229
253 static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) { 230 static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) {
254 #if defined(MOJO_RUNNER_CLIENT) 231 #if defined(MOJO_RUNNER_CLIENT)
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 } else { 423 } else {
447 DCHECK(context_provider); 424 DCHECK(context_provider);
448 const auto& capabilities = context_provider->ContextCapabilities(); 425 const auto& capabilities = context_provider->ContextCapabilities();
449 if (data->surface_handle == gpu::kNullSurfaceHandle) { 426 if (data->surface_handle == gpu::kNullSurfaceHandle) {
450 surface = base::WrapUnique(new OffscreenBrowserCompositorOutputSurface( 427 surface = base::WrapUnique(new OffscreenBrowserCompositorOutputSurface(
451 context_provider, compositor->vsync_manager(), 428 context_provider, compositor->vsync_manager(),
452 compositor->task_runner().get(), 429 compositor->task_runner().get(),
453 std::unique_ptr< 430 std::unique_ptr<
454 display_compositor::CompositorOverlayCandidateValidator>())); 431 display_compositor::CompositorOverlayCandidateValidator>()));
455 } else if (capabilities.surfaceless) { 432 } else if (capabilities.surfaceless) {
456 GLenum target = GL_TEXTURE_2D;
457 GLenum format = GL_RGB;
458 #if defined(OS_MACOSX) 433 #if defined(OS_MACOSX)
459 target = GL_TEXTURE_RECTANGLE_ARB; 434 surface = base::WrapUnique(new GpuBrowserCompositorOutputSurfaceMac(
460 format = GL_RGBA; 435 context_provider, data->surface_handle, compositor->vsync_manager(),
461 #endif 436 compositor->task_runner().get(),
437 BrowserGpuMemoryBufferManager::current()));
438 #else
462 surface = 439 surface =
463 base::WrapUnique(new GpuSurfacelessBrowserCompositorOutputSurface( 440 base::WrapUnique(new GpuSurfacelessBrowserCompositorOutputSurface(
464 context_provider, data->surface_handle, 441 context_provider, data->surface_handle,
465 compositor->vsync_manager(), compositor->task_runner().get(), 442 compositor->vsync_manager(), compositor->task_runner().get(),
466 CreateOverlayCandidateValidator(compositor->widget()), target, 443 CreateOverlayCandidateValidator(compositor->widget()),
467 format, BrowserGpuMemoryBufferManager::current())); 444 GL_TEXTURE_2D, GL_RGB,
445 BrowserGpuMemoryBufferManager::current()));
446 #endif
468 } else { 447 } else {
469 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> 448 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator>
470 validator; 449 validator;
471 #if !defined(OS_MACOSX)
472 // Overlays are only supported on surfaceless output surfaces on Mac.
473 validator = CreateOverlayCandidateValidator(compositor->widget());
474 #endif
475 surface = base::WrapUnique(new GpuBrowserCompositorOutputSurface( 450 surface = base::WrapUnique(new GpuBrowserCompositorOutputSurface(
476 context_provider, compositor->vsync_manager(), 451 context_provider, compositor->vsync_manager(),
477 compositor->task_runner().get(), std::move(validator))); 452 compositor->task_runner().get(), std::move(validator)));
danakj 2016/05/26 21:33:51 nullptr for the validator?
ccameron 2016/05/26 22:46:16 Oh no ... I didn't realize that was !defined(OS_MA
478 } 453 }
479 } 454 }
480 } 455 }
481 456
482 data->surface = surface.get(); 457 data->surface = surface.get();
483 if (data->reflector) 458 if (data->reflector)
484 data->reflector->OnSourceSurfaceReady(data->surface); 459 data->reflector->OnSourceSurfaceReady(data->surface);
485 460
486 #if defined(OS_WIN) 461 #if defined(OS_WIN)
487 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild( 462 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild(
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 shared_vulkan_context_provider_ = 756 shared_vulkan_context_provider_ =
782 cc::VulkanInProcessContextProvider::Create(); 757 cc::VulkanInProcessContextProvider::Create();
783 } 758 }
784 759
785 shared_vulkan_context_provider_initialized_ = true; 760 shared_vulkan_context_provider_initialized_ = true;
786 } 761 }
787 return shared_vulkan_context_provider_; 762 return shared_vulkan_context_provider_;
788 } 763 }
789 764
790 } // namespace content 765 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698