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

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

Issue 2352963002: cc: Make most of cc::OutputSurface abstract. (Closed)
Patch Set: outputsurface-cleanup: rebase Created 4 years, 2 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_browser_compositor_output_surface.h" 5 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
11 #include "cc/output/output_surface_client.h" 11 #include "cc/output/output_surface_client.h"
12 #include "components/display_compositor/compositor_overlay_candidate_validator.h " 12 #include "components/display_compositor/compositor_overlay_candidate_validator.h "
13 #include "content/browser/compositor/reflector_impl.h" 13 #include "content/browser/compositor/reflector_impl.h"
14 #include "content/browser/compositor/reflector_texture.h" 14 #include "content/browser/compositor/reflector_texture.h"
15 #include "content/browser/renderer_host/render_widget_host_impl.h" 15 #include "content/browser/renderer_host/render_widget_host_impl.h"
16 #include "content/common/gpu/client/context_provider_command_buffer.h" 16 #include "content/common/gpu/client/context_provider_command_buffer.h"
17 #include "gpu/command_buffer/client/context_support.h" 17 #include "gpu/command_buffer/client/context_support.h"
18 #include "gpu/command_buffer/client/gles2_interface.h"
18 #include "gpu/ipc/client/command_buffer_proxy_impl.h" 19 #include "gpu/ipc/client/command_buffer_proxy_impl.h"
19 20
20 namespace content { 21 namespace content {
21 22
22 GpuBrowserCompositorOutputSurface::GpuBrowserCompositorOutputSurface( 23 GpuBrowserCompositorOutputSurface::GpuBrowserCompositorOutputSurface(
23 scoped_refptr<ContextProviderCommandBuffer> context, 24 scoped_refptr<ContextProviderCommandBuffer> context,
24 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, 25 scoped_refptr<ui::CompositorVSyncManager> vsync_manager,
25 cc::SyntheticBeginFrameSource* begin_frame_source, 26 cc::SyntheticBeginFrameSource* begin_frame_source,
26 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> 27 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator>
27 overlay_candidate_validator) 28 overlay_candidate_validator)
(...skipping 14 matching lines...) Expand all
42 GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() { 43 GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() {
43 ContextProviderCommandBuffer* provider_command_buffer = 44 ContextProviderCommandBuffer* provider_command_buffer =
44 static_cast<content::ContextProviderCommandBuffer*>( 45 static_cast<content::ContextProviderCommandBuffer*>(
45 context_provider_.get()); 46 context_provider_.get());
46 gpu::CommandBufferProxyImpl* command_buffer_proxy = 47 gpu::CommandBufferProxyImpl* command_buffer_proxy =
47 provider_command_buffer->GetCommandBufferProxy(); 48 provider_command_buffer->GetCommandBufferProxy();
48 DCHECK(command_buffer_proxy); 49 DCHECK(command_buffer_proxy);
49 return command_buffer_proxy; 50 return command_buffer_proxy;
50 } 51 }
51 52
53 void GpuBrowserCompositorOutputSurface::OnReflectorChanged() {
54 if (!reflector_) {
55 reflector_texture_.reset();
56 } else {
57 reflector_texture_.reset(new ReflectorTexture(context_provider()));
58 reflector_->OnSourceTextureMailboxUpdated(reflector_texture_->mailbox());
59 }
60 }
61
52 bool GpuBrowserCompositorOutputSurface::BindToClient( 62 bool GpuBrowserCompositorOutputSurface::BindToClient(
53 cc::OutputSurfaceClient* client) { 63 cc::OutputSurfaceClient* client) {
54 if (!BrowserCompositorOutputSurface::BindToClient(client)) 64 if (!BrowserCompositorOutputSurface::BindToClient(client))
55 return false; 65 return false;
56 66
57 GetCommandBufferProxy()->SetSwapBuffersCompletionCallback( 67 GetCommandBufferProxy()->SetSwapBuffersCompletionCallback(
58 swap_buffers_completion_callback_.callback()); 68 swap_buffers_completion_callback_.callback());
59 GetCommandBufferProxy()->SetUpdateVSyncParametersCallback( 69 GetCommandBufferProxy()->SetUpdateVSyncParametersCallback(
60 update_vsync_parameters_callback_.callback()); 70 update_vsync_parameters_callback_.callback());
61 if (capabilities_.uses_default_gl_framebuffer) { 71 if (capabilities_.uses_default_gl_framebuffer) {
62 capabilities_.flipped_output_surface = 72 capabilities_.flipped_output_surface =
63 context_provider()->ContextCapabilities().flips_vertically; 73 context_provider()->ContextCapabilities().flips_vertically;
64 } 74 }
65 return true; 75 return true;
66 } 76 }
67 77
68 uint32_t GpuBrowserCompositorOutputSurface::GetFramebufferCopyTextureFormat() { 78 void GpuBrowserCompositorOutputSurface::EnsureBackbuffer() {}
69 auto* gl = static_cast<ContextProviderCommandBuffer*>(context_provider()); 79
70 return gl->GetCopyTextureInternalFormat(); 80 void GpuBrowserCompositorOutputSurface::DiscardBackbuffer() {
81 context_provider()->ContextGL()->DiscardBackbufferCHROMIUM();
71 } 82 }
72 83
73 void GpuBrowserCompositorOutputSurface::OnReflectorChanged() { 84 void GpuBrowserCompositorOutputSurface::BindFramebuffer() {
74 if (!reflector_) { 85 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0);
75 reflector_texture_.reset();
76 } else {
77 reflector_texture_.reset(new ReflectorTexture(context_provider()));
78 reflector_->OnSourceTextureMailboxUpdated(reflector_texture_->mailbox());
79 }
80 } 86 }
81 87
82 void GpuBrowserCompositorOutputSurface::SwapBuffers(cc::CompositorFrame frame) { 88 void GpuBrowserCompositorOutputSurface::SwapBuffers(cc::CompositorFrame frame) {
83 DCHECK(frame.gl_frame_data); 89 DCHECK(frame.gl_frame_data);
84 90
85 GetCommandBufferProxy()->SetLatencyInfo(frame.metadata.latency_info); 91 GetCommandBufferProxy()->SetLatencyInfo(frame.metadata.latency_info);
86 92
87 if (reflector_) { 93 if (reflector_) {
88 if (frame.gl_frame_data->sub_buffer_rect == 94 if (frame.gl_frame_data->sub_buffer_rect ==
89 gfx::Rect(frame.gl_frame_data->size)) { 95 gfx::Rect(frame.gl_frame_data->size)) {
90 reflector_texture_->CopyTextureFullImage(SurfaceSize()); 96 reflector_texture_->CopyTextureFullImage(SurfaceSize());
91 reflector_->OnSourceSwapBuffers(); 97 reflector_->OnSourceSwapBuffers();
92 } else { 98 } else {
93 const gfx::Rect& rect = frame.gl_frame_data->sub_buffer_rect; 99 const gfx::Rect& rect = frame.gl_frame_data->sub_buffer_rect;
94 reflector_texture_->CopyTextureSubImage(rect); 100 reflector_texture_->CopyTextureSubImage(rect);
95 reflector_->OnSourcePostSubBuffer(rect); 101 reflector_->OnSourcePostSubBuffer(rect);
96 } 102 }
97 } 103 }
98 104
99 if (frame.gl_frame_data->sub_buffer_rect == 105 if (frame.gl_frame_data->sub_buffer_rect ==
100 gfx::Rect(frame.gl_frame_data->size)) { 106 gfx::Rect(frame.gl_frame_data->size)) {
101 context_provider_->ContextSupport()->Swap(); 107 context_provider_->ContextSupport()->Swap();
102 } else { 108 } else {
103 context_provider_->ContextSupport()->PartialSwapBuffers( 109 context_provider_->ContextSupport()->PartialSwapBuffers(
104 frame.gl_frame_data->sub_buffer_rect); 110 frame.gl_frame_data->sub_buffer_rect);
105 } 111 }
106 } 112 }
107 113
114 uint32_t GpuBrowserCompositorOutputSurface::GetFramebufferCopyTextureFormat() {
115 auto* gl = static_cast<ContextProviderCommandBuffer*>(context_provider());
116 return gl->GetCopyTextureInternalFormat();
117 }
118
119 bool GpuBrowserCompositorOutputSurface::IsDisplayedAsOverlayPlane() const {
120 return false;
121 }
122
123 unsigned GpuBrowserCompositorOutputSurface::GetOverlayTextureId() const {
124 return 0;
125 }
126
127 bool GpuBrowserCompositorOutputSurface::SurfaceIsSuspendForRecycle() const {
128 return false;
129 }
130
108 void GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( 131 void GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted(
109 const std::vector<ui::LatencyInfo>& latency_info, 132 const std::vector<ui::LatencyInfo>& latency_info,
110 gfx::SwapResult result, 133 gfx::SwapResult result,
111 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { 134 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) {
112 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); 135 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info);
113 OnSwapBuffersComplete(); 136 client_->DidSwapBuffersComplete();
114 } 137 }
115 138
116 #if defined(OS_MACOSX) 139 #if defined(OS_MACOSX)
117 void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle( 140 void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle(
118 bool suspended) {} 141 bool suspended) {}
119 #endif 142 #endif
120 143
121 } // namespace content 144 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698