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

Side by Side Diff: content/browser/compositor/gpu_output_surface_mac.mm

Issue 2018793002: Mac: Move remote layer use to GpuOutputSurfaceMac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clean_up_mac
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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_output_surface_mac.h" 5 #include "content/browser/compositor/gpu_output_surface_mac.h"
6 6
7 #include "components/display_compositor/compositor_overlay_candidate_validator.h " 7 #include "components/display_compositor/compositor_overlay_candidate_validator.h "
8 #include "content/browser/gpu/gpu_surface_tracker.h" 8 #include "content/browser/gpu/gpu_surface_tracker.h"
9 #include "content/common/gpu/client/context_provider_command_buffer.h" 9 #include "content/common/gpu/client/context_provider_command_buffer.h"
10 #include "gpu/GLES2/gl2extchromium.h" 10 #include "gpu/GLES2/gl2extchromium.h"
11 #include "gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.h" 11 #include "gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.h"
12 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" 12 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
13 #include "ui/base/cocoa/remote_layer_api.h" 13 #include "ui/base/cocoa/remote_layer_api.h"
14 #include "ui/gfx/mac/io_surface.h" 14 #include "ui/gfx/mac/io_surface.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 class GpuOutputSurfaceMac::GpuOutputSurfaceMac::RemoteLayers {
tapted 2016/05/27 00:33:19 I think one of the GpuOutputSurfaceMac:: isn't nee
ccameron 2016/06/03 02:43:01 I'm amazed that compiles. Fixed.
19 public:
20 void UpdateLayers(CAContextID content_ca_context_id,
21 CAContextID fullscreen_low_power_ca_context_id) {
22 if (content_ca_context_id) {
23 if ([content_layer contextId] != content_ca_context_id) {
24 content_layer.reset([[CALayerHost alloc] init]);
25 [content_layer setContextId:content_ca_context_id];
26 [content_layer
27 setAutoresizingMask:kCALayerMaxXMargin | kCALayerMaxYMargin];
28 }
29 } else {
30 content_layer.reset();
31 }
32
33 if (fullscreen_low_power_ca_context_id) {
34 if ([fullscreen_low_power_layer contextId] !=
35 fullscreen_low_power_ca_context_id) {
36 fullscreen_low_power_layer.reset([[CALayerHost alloc] init]);
37 [fullscreen_low_power_layer
38 setContextId:fullscreen_low_power_ca_context_id];
39 }
40 } else {
41 fullscreen_low_power_layer.reset();
42 }
43 }
44 base::scoped_nsobject<CALayerHost> content_layer;
tapted 2016/05/27 00:33:19 nit: blank line before
ccameron 2016/06/03 02:43:01 Done.
45 base::scoped_nsobject<CALayerHost> fullscreen_low_power_layer;
46 };
47
18 GpuOutputSurfaceMac::GpuOutputSurfaceMac( 48 GpuOutputSurfaceMac::GpuOutputSurfaceMac(
19 scoped_refptr<ContextProviderCommandBuffer> context, 49 scoped_refptr<ContextProviderCommandBuffer> context,
20 gpu::SurfaceHandle surface_handle, 50 gpu::SurfaceHandle surface_handle,
21 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, 51 scoped_refptr<ui::CompositorVSyncManager> vsync_manager,
22 base::SingleThreadTaskRunner* task_runner, 52 base::SingleThreadTaskRunner* task_runner,
23 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> 53 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator>
24 overlay_candidate_validator, 54 overlay_candidate_validator,
25 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) 55 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager)
26 : GpuSurfacelessBrowserCompositorOutputSurface( 56 : GpuSurfacelessBrowserCompositorOutputSurface(
27 context, 57 context,
28 surface_handle, 58 surface_handle,
29 vsync_manager, 59 vsync_manager,
30 task_runner, 60 task_runner,
31 std::move(overlay_candidate_validator), 61 std::move(overlay_candidate_validator),
32 GL_TEXTURE_RECTANGLE_ARB, 62 GL_TEXTURE_RECTANGLE_ARB,
33 GL_RGBA, 63 GL_RGBA,
34 gpu_memory_buffer_manager) {} 64 gpu_memory_buffer_manager),
65 remote_layers_(new RemoteLayers) {}
35 66
36 GpuOutputSurfaceMac::~GpuOutputSurfaceMac() {} 67 GpuOutputSurfaceMac::~GpuOutputSurfaceMac() {}
37 68
38 void GpuOutputSurfaceMac::SwapBuffers(cc::CompositorFrame* frame) { 69 void GpuOutputSurfaceMac::SwapBuffers(cc::CompositorFrame* frame) {
39 GpuSurfacelessBrowserCompositorOutputSurface::SwapBuffers(frame); 70 GpuSurfacelessBrowserCompositorOutputSurface::SwapBuffers(frame);
40 71
41 if (should_show_frames_state_ == 72 if (should_show_frames_state_ ==
42 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED) { 73 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED) {
43 should_show_frames_state_ = SHOULD_SHOW_FRAMES; 74 should_show_frames_state_ = SHOULD_SHOW_FRAMES;
44 } 75 }
45 } 76 }
46 77
47 void GpuOutputSurfaceMac::OnGpuSwapBuffersCompleted( 78 void GpuOutputSurfaceMac::OnGpuSwapBuffersCompleted(
48 const std::vector<ui::LatencyInfo>& latency_info, 79 const std::vector<ui::LatencyInfo>& latency_info,
49 gfx::SwapResult result, 80 gfx::SwapResult result,
50 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { 81 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) {
82 remote_layers_->UpdateLayers(params_mac->ca_context_id,
83 params_mac->fullscreen_low_power_ca_context_id);
51 if (should_show_frames_state_ == SHOULD_SHOW_FRAMES) { 84 if (should_show_frames_state_ == SHOULD_SHOW_FRAMES) {
52 gfx::AcceleratedWidget native_widget = 85 ui::AcceleratedWidgetMac* widget = ui::AcceleratedWidgetMac::Get(
53 content::GpuSurfaceTracker::Get()->AcquireNativeWidget( 86 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(
54 params_mac->surface_handle); 87 params_mac->surface_handle));
55 ui::AcceleratedWidgetMacGotFrame( 88 if (widget) {
56 native_widget, params_mac->ca_context_id, 89 if (remote_layers_->content_layer) {
57 params_mac->fullscreen_low_power_ca_context_valid, 90 widget->GotCALayerFrame(
58 params_mac->fullscreen_low_power_ca_context_id, params_mac->io_surface, 91 remote_layers_->content_layer,
59 params_mac->pixel_size, params_mac->scale_factor, nullptr, nullptr); 92 params_mac->fullscreen_low_power_ca_context_valid,
93 remote_layers_->fullscreen_low_power_layer, params_mac->pixel_size,
94 params_mac->scale_factor);
95 } else {
96 widget->GotIOSurfaceFrame(params_mac->io_surface,
97 params_mac->pixel_size,
98 params_mac->scale_factor);
99 }
100 }
60 } 101 }
61 GpuSurfacelessBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( 102 GpuSurfacelessBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted(
62 latency_info, result, params_mac); 103 latency_info, result, params_mac);
63 } 104 }
64 105
65 void GpuOutputSurfaceMac::SetSurfaceSuspendedForRecycle(bool suspended) { 106 void GpuOutputSurfaceMac::SetSurfaceSuspendedForRecycle(bool suspended) {
66 if (suspended) { 107 if (suspended) {
67 // It may be that there are frames in-flight from the GPU process back to 108 // It may be that there are frames in-flight from the GPU process back to
68 // the browser. Make sure that these frames are not displayed by ignoring 109 // the browser. Make sure that these frames are not displayed by ignoring
69 // them in GpuProcessHostUIShim, until the browser issues a SwapBuffers for 110 // them in GpuProcessHostUIShim, until the browser issues a SwapBuffers for
(...skipping 14 matching lines...) Expand all
84 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED; 125 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED;
85 } 126 }
86 } 127 }
87 } 128 }
88 129
89 bool GpuOutputSurfaceMac::SurfaceIsSuspendForRecycle() const { 130 bool GpuOutputSurfaceMac::SurfaceIsSuspendForRecycle() const {
90 return should_show_frames_state_ == SHOULD_NOT_SHOW_FRAMES_SUSPENDED; 131 return should_show_frames_state_ == SHOULD_NOT_SHOW_FRAMES_SUSPENDED;
91 } 132 }
92 133
93 } // namespace content 134 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698