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

Side by Side Diff: gpu/ipc/service/image_transport_surface_overlay_mac.mm

Issue 2440853002: Mac: Add command line flag to disable AVFoundation layers (Closed)
Patch Set: Fix formatting Created 4 years, 1 month 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
« no previous file with comments | « content/browser/gpu/gpu_process_host.cc ('k') | ui/base/ui_base_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/image_transport_surface_overlay_mac.h" 5 #include "gpu/ipc/service/image_transport_surface_overlay_mac.h"
6 6
7 #include <CoreGraphics/CoreGraphics.h> 7 #include <CoreGraphics/CoreGraphics.h>
8 #include <IOSurface/IOSurface.h> 8 #include <IOSurface/IOSurface.h>
9 #include <OpenGL/CGLRenderers.h> 9 #include <OpenGL/CGLRenderers.h>
10 #include <OpenGL/CGLTypes.h> 10 #include <OpenGL/CGLTypes.h>
11 #include <OpenGL/gl.h> 11 #include <OpenGL/gl.h>
12 #include <stddef.h> 12 #include <stddef.h>
13 13
14 #include <algorithm> 14 #include <algorithm>
15 15
16 // This type consistently causes problem on Mac, and needs to be dealt with 16 // This type consistently causes problem on Mac, and needs to be dealt with
17 // in a systemic way. 17 // in a systemic way.
18 // http://crbug.com/517208 18 // http://crbug.com/517208
19 #ifndef GL_OES_EGL_image 19 #ifndef GL_OES_EGL_image
20 typedef void* GLeglImageOES; 20 typedef void* GLeglImageOES;
21 #endif 21 #endif
22 22
23 #include "base/bind.h" 23 #include "base/bind.h"
24 #include "base/bind_helpers.h" 24 #include "base/bind_helpers.h"
25 #include "base/command_line.h"
25 #include "base/metrics/histogram_macros.h" 26 #include "base/metrics/histogram_macros.h"
26 #include "base/threading/thread_task_runner_handle.h" 27 #include "base/threading/thread_task_runner_handle.h"
27 #include "base/trace_event/trace_event.h" 28 #include "base/trace_event/trace_event.h"
28 #include "gpu/ipc/common/gpu_messages.h" 29 #include "gpu/ipc/common/gpu_messages.h"
29 #include "gpu/ipc/service/gpu_channel_manager.h" 30 #include "gpu/ipc/service/gpu_channel_manager.h"
30 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" 31 #include "gpu/ipc/service/gpu_channel_manager_delegate.h"
31 #include "ui/accelerated_widget_mac/ca_layer_tree_coordinator.h" 32 #include "ui/accelerated_widget_mac/ca_layer_tree_coordinator.h"
32 #include "ui/accelerated_widget_mac/io_surface_context.h" 33 #include "ui/accelerated_widget_mac/io_surface_context.h"
33 #include "ui/base/cocoa/animation_utils.h" 34 #include "ui/base/cocoa/animation_utils.h"
34 #include "ui/base/cocoa/remote_layer_api.h" 35 #include "ui/base/cocoa/remote_layer_api.h"
36 #include "ui/base/ui_base_switches.h"
35 #include "ui/gfx/geometry/rect_conversions.h" 37 #include "ui/gfx/geometry/rect_conversions.h"
36 #include "ui/gfx/swap_result.h" 38 #include "ui/gfx/swap_result.h"
37 #include "ui/gfx/transform.h" 39 #include "ui/gfx/transform.h"
38 #include "ui/gl/ca_renderer_layer_params.h" 40 #include "ui/gl/ca_renderer_layer_params.h"
39 #include "ui/gl/gl_context.h" 41 #include "ui/gl/gl_context.h"
40 #include "ui/gl/gl_fence.h" 42 #include "ui/gl/gl_fence.h"
41 #include "ui/gl/gl_image_io_surface.h" 43 #include "ui/gl/gl_image_io_surface.h"
42 #include "ui/gl/gpu_switching_manager.h" 44 #include "ui/gl/gpu_switching_manager.h"
43 #include "ui/gl/scoped_api.h" 45 #include "ui/gl/scoped_api.h"
44 #include "ui/gl/scoped_cgl.h" 46 #include "ui/gl/scoped_cgl.h"
(...skipping 15 matching lines...) Expand all
60 namespace gpu { 62 namespace gpu {
61 63
62 ImageTransportSurfaceOverlayMac::ImageTransportSurfaceOverlayMac( 64 ImageTransportSurfaceOverlayMac::ImageTransportSurfaceOverlayMac(
63 GpuCommandBufferStub* stub) 65 GpuCommandBufferStub* stub)
64 : stub_(stub->AsWeakPtr()), 66 : stub_(stub->AsWeakPtr()),
65 use_remote_layer_api_(ui::RemoteLayerAPISupported()), 67 use_remote_layer_api_(ui::RemoteLayerAPISupported()),
66 scale_factor_(1), 68 scale_factor_(1),
67 gl_renderer_id_(0) { 69 gl_renderer_id_(0) {
68 ui::GpuSwitchingManager::GetInstance()->AddObserver(this); 70 ui::GpuSwitchingManager::GetInstance()->AddObserver(this);
69 71
70 bool disable_av_sample_buffer_display_layer = 72 static bool av_disabled_at_command_line =
71 stub_->GetFeatureInfo() 73 base::CommandLine::ForCurrentProcess()->HasSwitch(
72 ->workarounds() 74 switches::kDisableAVFoundationOverlays);
73 .disable_av_sample_buffer_display_layer; 75
76 bool allow_av_sample_buffer_display_layer =
77 !av_disabled_at_command_line &&
78 !stub_->GetFeatureInfo()
79 ->workarounds()
80 .disable_av_sample_buffer_display_layer;
74 81
75 ca_layer_tree_coordinator_.reset(new ui::CALayerTreeCoordinator( 82 ca_layer_tree_coordinator_.reset(new ui::CALayerTreeCoordinator(
76 use_remote_layer_api_, !disable_av_sample_buffer_display_layer)); 83 use_remote_layer_api_, allow_av_sample_buffer_display_layer));
77 } 84 }
78 85
79 ImageTransportSurfaceOverlayMac::~ImageTransportSurfaceOverlayMac() { 86 ImageTransportSurfaceOverlayMac::~ImageTransportSurfaceOverlayMac() {
80 ui::GpuSwitchingManager::GetInstance()->RemoveObserver(this); 87 ui::GpuSwitchingManager::GetInstance()->RemoveObserver(this);
81 if (stub_.get()) { 88 if (stub_.get()) {
82 stub_->SetLatencyInfoCallback( 89 stub_->SetLatencyInfoCallback(
83 base::Callback<void(const std::vector<ui::LatencyInfo>&)>()); 90 base::Callback<void(const std::vector<ui::LatencyInfo>&)>());
84 } 91 }
85 Destroy(); 92 Destroy();
86 } 93 }
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; 392 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask;
386 393
387 // Post a task holding a reference to the new GL context. The reason for 394 // Post a task holding a reference to the new GL context. The reason for
388 // this is to avoid creating-then-destroying the context for every image 395 // this is to avoid creating-then-destroying the context for every image
389 // transport surface that is observing the GPU switch. 396 // transport surface that is observing the GPU switch.
390 base::ThreadTaskRunnerHandle::Get()->PostTask( 397 base::ThreadTaskRunnerHandle::Get()->PostTask(
391 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); 398 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu));
392 } 399 }
393 400
394 } // namespace gpu 401 } // namespace gpu
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_process_host.cc ('k') | ui/base/ui_base_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698