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

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

Issue 2365583004: Mac: Clean up plumbing of accelerated widgets (Closed)
Patch Set: Add explicit Created 4 years, 3 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 "cc/output/compositor_frame.h" 7 #include "cc/output/compositor_frame.h"
8 #include "components/display_compositor/compositor_overlay_candidate_validator.h " 8 #include "components/display_compositor/compositor_overlay_candidate_validator.h "
9 #include "content/browser/gpu/gpu_surface_tracker.h" 9 #include "content/browser/gpu/gpu_surface_tracker.h"
10 #include "content/common/gpu/client/context_provider_command_buffer.h" 10 #include "content/common/gpu/client/context_provider_command_buffer.h"
11 #include "gpu/GLES2/gl2extchromium.h" 11 #include "gpu/GLES2/gl2extchromium.h"
12 #include "gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.h" 12 #include "gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.h"
13 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" 13 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
14 #include "ui/base/cocoa/remote_layer_api.h" 14 #include "ui/base/cocoa/remote_layer_api.h"
15 #include "ui/compositor/compositor.h"
15 #include "ui/display/types/display_snapshot.h" 16 #include "ui/display/types/display_snapshot.h"
16 #include "ui/gfx/mac/io_surface.h" 17 #include "ui/gfx/mac/io_surface.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 struct GpuOutputSurfaceMac::RemoteLayers { 21 struct GpuOutputSurfaceMac::RemoteLayers {
21 void UpdateLayers(CAContextID content_ca_context_id, 22 void UpdateLayers(CAContextID content_ca_context_id,
22 CAContextID fullscreen_low_power_ca_context_id) { 23 CAContextID fullscreen_low_power_ca_context_id) {
23 if (content_ca_context_id) { 24 if (content_ca_context_id) {
24 if ([content_layer contextId] != content_ca_context_id) { 25 if ([content_layer contextId] != content_ca_context_id) {
(...skipping 16 matching lines...) Expand all
41 } else { 42 } else {
42 fullscreen_low_power_layer.reset(); 43 fullscreen_low_power_layer.reset();
43 } 44 }
44 } 45 }
45 46
46 base::scoped_nsobject<CALayerHost> content_layer; 47 base::scoped_nsobject<CALayerHost> content_layer;
47 base::scoped_nsobject<CALayerHost> fullscreen_low_power_layer; 48 base::scoped_nsobject<CALayerHost> fullscreen_low_power_layer;
48 }; 49 };
49 50
50 GpuOutputSurfaceMac::GpuOutputSurfaceMac( 51 GpuOutputSurfaceMac::GpuOutputSurfaceMac(
52 gfx::AcceleratedWidget widget,
51 scoped_refptr<ContextProviderCommandBuffer> context, 53 scoped_refptr<ContextProviderCommandBuffer> context,
52 gpu::SurfaceHandle surface_handle, 54 gpu::SurfaceHandle surface_handle,
53 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, 55 scoped_refptr<ui::CompositorVSyncManager> vsync_manager,
54 cc::SyntheticBeginFrameSource* begin_frame_source, 56 cc::SyntheticBeginFrameSource* begin_frame_source,
55 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> 57 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator>
56 overlay_candidate_validator, 58 overlay_candidate_validator,
57 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) 59 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager)
58 : GpuSurfacelessBrowserCompositorOutputSurface( 60 : GpuSurfacelessBrowserCompositorOutputSurface(
59 std::move(context), 61 std::move(context),
60 surface_handle, 62 surface_handle,
61 std::move(vsync_manager), 63 std::move(vsync_manager),
62 begin_frame_source, 64 begin_frame_source,
63 std::move(overlay_candidate_validator), 65 std::move(overlay_candidate_validator),
64 GL_TEXTURE_RECTANGLE_ARB, 66 GL_TEXTURE_RECTANGLE_ARB,
65 GL_RGBA, 67 GL_RGBA,
66 gfx::BufferFormat::RGBA_8888, 68 gfx::BufferFormat::RGBA_8888,
67 gpu_memory_buffer_manager), 69 gpu_memory_buffer_manager),
70 widget_(widget),
68 remote_layers_(new RemoteLayers) {} 71 remote_layers_(new RemoteLayers) {}
69 72
70 GpuOutputSurfaceMac::~GpuOutputSurfaceMac() {} 73 GpuOutputSurfaceMac::~GpuOutputSurfaceMac() {}
71 74
72 void GpuOutputSurfaceMac::SwapBuffers(cc::CompositorFrame frame) { 75 void GpuOutputSurfaceMac::SwapBuffers(cc::CompositorFrame frame) {
73 GpuSurfacelessBrowserCompositorOutputSurface::SwapBuffers(std::move(frame)); 76 GpuSurfacelessBrowserCompositorOutputSurface::SwapBuffers(std::move(frame));
74 77
75 if (should_show_frames_state_ == 78 if (should_show_frames_state_ ==
76 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED) { 79 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED) {
77 should_show_frames_state_ = SHOULD_SHOW_FRAMES; 80 should_show_frames_state_ = SHOULD_SHOW_FRAMES;
78 } 81 }
79 } 82 }
80 83
81 void GpuOutputSurfaceMac::OnGpuSwapBuffersCompleted( 84 void GpuOutputSurfaceMac::OnGpuSwapBuffersCompleted(
82 const std::vector<ui::LatencyInfo>& latency_info, 85 const std::vector<ui::LatencyInfo>& latency_info,
83 gfx::SwapResult result, 86 gfx::SwapResult result,
84 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { 87 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) {
85 remote_layers_->UpdateLayers(params_mac->ca_context_id, 88 remote_layers_->UpdateLayers(params_mac->ca_context_id,
86 params_mac->fullscreen_low_power_ca_context_id); 89 params_mac->fullscreen_low_power_ca_context_id);
87 if (should_show_frames_state_ == SHOULD_SHOW_FRAMES) { 90 if (should_show_frames_state_ == SHOULD_SHOW_FRAMES) {
88 ui::AcceleratedWidgetMac* widget = ui::AcceleratedWidgetMac::Get( 91 ui::AcceleratedWidgetMac* widget = ui::AcceleratedWidgetMac::Get(widget_);
89 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(
90 params_mac->surface_handle));
91 if (widget) { 92 if (widget) {
92 if (remote_layers_->content_layer) { 93 if (remote_layers_->content_layer) {
93 widget->GotCALayerFrame( 94 widget->GotCALayerFrame(
94 base::scoped_nsobject<CALayer>(remote_layers_->content_layer.get(), 95 base::scoped_nsobject<CALayer>(remote_layers_->content_layer.get(),
95 base::scoped_policy::RETAIN), 96 base::scoped_policy::RETAIN),
96 params_mac->fullscreen_low_power_ca_context_valid, 97 params_mac->fullscreen_low_power_ca_context_valid,
97 base::scoped_nsobject<CALayer>( 98 base::scoped_nsobject<CALayer>(
98 remote_layers_->fullscreen_low_power_layer.get(), 99 remote_layers_->fullscreen_low_power_layer.get(),
99 base::scoped_policy::RETAIN), 100 base::scoped_policy::RETAIN),
100 params_mac->pixel_size, params_mac->scale_factor); 101 params_mac->pixel_size, params_mac->scale_factor);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED; 133 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED;
133 } 134 }
134 } 135 }
135 } 136 }
136 137
137 bool GpuOutputSurfaceMac::SurfaceIsSuspendForRecycle() const { 138 bool GpuOutputSurfaceMac::SurfaceIsSuspendForRecycle() const {
138 return should_show_frames_state_ == SHOULD_NOT_SHOW_FRAMES_SUSPENDED; 139 return should_show_frames_state_ == SHOULD_NOT_SHOW_FRAMES_SUSPENDED;
139 } 140 }
140 141
141 } // namespace content 142 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698