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

Side by Side Diff: services/ui/surfaces/direct_output_surface_ozone.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 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 "services/ui/surfaces/direct_output_surface_ozone.h" 5 #include "services/ui/surfaces/direct_output_surface_ozone.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 context_provider->SetSwapBuffersCompletionCallback( 55 context_provider->SetSwapBuffersCompletionCallback(
56 base::Bind(&DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted, 56 base::Bind(&DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted,
57 base::Unretained(this))); 57 base::Unretained(this)));
58 } 58 }
59 59
60 DirectOutputSurfaceOzone::~DirectOutputSurfaceOzone() { 60 DirectOutputSurfaceOzone::~DirectOutputSurfaceOzone() {
61 // TODO(rjkroege): Support cleanup. 61 // TODO(rjkroege): Support cleanup.
62 } 62 }
63 63
64 bool DirectOutputSurfaceOzone::IsDisplayedAsOverlayPlane() const { 64 bool DirectOutputSurfaceOzone::BindToClient(cc::OutputSurfaceClient* client) {
65 // TODO(rjkroege): implement remaining overlay functionality. 65 if (!cc::OutputSurface::BindToClient(client))
66 return false;
67
68 if (capabilities_.uses_default_gl_framebuffer) {
69 capabilities_.flipped_output_surface =
70 context_provider()->ContextCapabilities().flips_vertically;
71 }
66 return true; 72 return true;
67 } 73 }
68 74
69 unsigned DirectOutputSurfaceOzone::GetOverlayTextureId() const { 75 void DirectOutputSurfaceOzone::EnsureBackbuffer() {}
76
77 void DirectOutputSurfaceOzone::DiscardBackbuffer() {
78 context_provider()->ContextGL()->DiscardBackbufferCHROMIUM();
79 }
80
81 void DirectOutputSurfaceOzone::BindFramebuffer() {
70 DCHECK(buffer_queue_); 82 DCHECK(buffer_queue_);
71 return buffer_queue_->current_texture_id(); 83 buffer_queue_->BindFramebuffer();
72 } 84 }
73 85
74 void DirectOutputSurfaceOzone::SwapBuffers(cc::CompositorFrame frame) { 86 void DirectOutputSurfaceOzone::SwapBuffers(cc::CompositorFrame frame) {
75 DCHECK(buffer_queue_); 87 DCHECK(buffer_queue_);
76 DCHECK(frame.gl_frame_data); 88 DCHECK(frame.gl_frame_data);
77 89
78 buffer_queue_->SwapBuffers(frame.gl_frame_data->sub_buffer_rect); 90 buffer_queue_->SwapBuffers(frame.gl_frame_data->sub_buffer_rect);
79 91
80 // Code combining GpuBrowserCompositorOutputSurface + DirectOutputSurface 92 // Code combining GpuBrowserCompositorOutputSurface + DirectOutputSurface
81 if (frame.gl_frame_data->sub_buffer_rect == 93 if (frame.gl_frame_data->sub_buffer_rect ==
82 gfx::Rect(frame.gl_frame_data->size)) { 94 gfx::Rect(frame.gl_frame_data->size)) {
83 context_provider_->ContextSupport()->Swap(); 95 context_provider_->ContextSupport()->Swap();
84 } else { 96 } else {
85 context_provider_->ContextSupport()->PartialSwapBuffers( 97 context_provider_->ContextSupport()->PartialSwapBuffers(
86 frame.gl_frame_data->sub_buffer_rect); 98 frame.gl_frame_data->sub_buffer_rect);
87 } 99 }
88 100
89 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); 101 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
90 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); 102 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM();
91 gl->ShallowFlushCHROMIUM(); 103 gl->ShallowFlushCHROMIUM();
92 104
93 gpu::SyncToken sync_token; 105 gpu::SyncToken sync_token;
94 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); 106 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
95 } 107 }
96 108
97 bool DirectOutputSurfaceOzone::BindToClient(cc::OutputSurfaceClient* client) { 109 uint32_t DirectOutputSurfaceOzone::GetFramebufferCopyTextureFormat() {
98 if (!cc::OutputSurface::BindToClient(client)) 110 return buffer_queue_->internal_format();
99 return false; 111 }
100 112
101 if (capabilities_.uses_default_gl_framebuffer) { 113 // We call this on every frame but changing the size once we've allocated
102 capabilities_.flipped_output_surface = 114 // backing NativePixmapOzone instances will cause a DCHECK because
103 context_provider()->ContextCapabilities().flips_vertically; 115 // Chrome never Reshape(s) after the first one from (0,0). NB: this implies
104 } 116 // that screen size changes need to be plumbed differently. In particular, we
117 // must create the native window in the size that the hardware reports.
118 void DirectOutputSurfaceOzone::Reshape(const gfx::Size& size,
119 float scale_factor,
120 const gfx::ColorSpace& color_space,
121 bool alpha) {
122 OutputSurface::Reshape(size, scale_factor, color_space, alpha);
123 DCHECK(buffer_queue_);
124 buffer_queue_->Reshape(SurfaceSize(), scale_factor, color_space);
125 }
126
127 cc::OverlayCandidateValidator*
128 DirectOutputSurfaceOzone::GetOverlayCandidateValidator() const {
129 return nullptr;
130 }
131
132 bool DirectOutputSurfaceOzone::IsDisplayedAsOverlayPlane() const {
133 // TODO(rjkroege): implement remaining overlay functionality.
105 return true; 134 return true;
106 } 135 }
107 136
137 unsigned DirectOutputSurfaceOzone::GetOverlayTextureId() const {
138 DCHECK(buffer_queue_);
139 return buffer_queue_->current_texture_id();
140 }
141
142 bool DirectOutputSurfaceOzone::SurfaceIsSuspendForRecycle() const {
143 return false;
144 }
145
146 bool DirectOutputSurfaceOzone::HasExternalStencilTest() const {
147 return false;
148 }
149
150 void DirectOutputSurfaceOzone::ApplyExternalStencil() {}
151
108 void DirectOutputSurfaceOzone::OnUpdateVSyncParametersFromGpu( 152 void DirectOutputSurfaceOzone::OnUpdateVSyncParametersFromGpu(
109 base::TimeTicks timebase, 153 base::TimeTicks timebase,
110 base::TimeDelta interval) { 154 base::TimeDelta interval) {
111 DCHECK(HasClient()); 155 DCHECK(client_);
112 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); 156 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval);
113 } 157 }
114 158
115 void DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted( 159 void DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted(
116 gfx::SwapResult result) { 160 gfx::SwapResult result) {
117 DCHECK(buffer_queue_); 161 DCHECK(buffer_queue_);
118 bool force_swap = false; 162 bool force_swap = false;
119 if (result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) { 163 if (result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) {
120 // Even through the swap failed, this is a fixable error so we can pretend 164 // Even through the swap failed, this is a fixable error so we can pretend
121 // it succeeded to the rest of the system. 165 // it succeeded to the rest of the system.
122 result = gfx::SwapResult::SWAP_ACK; 166 result = gfx::SwapResult::SWAP_ACK;
123 buffer_queue_->RecreateBuffers(); 167 buffer_queue_->RecreateBuffers();
124 force_swap = true; 168 force_swap = true;
125 } 169 }
126 170
127 buffer_queue_->PageFlipComplete(); 171 buffer_queue_->PageFlipComplete();
128 OnSwapBuffersComplete(); 172 client_->DidSwapBuffersComplete();
129 173
130 if (force_swap) 174 if (force_swap)
131 client_->SetNeedsRedrawRect(gfx::Rect(SurfaceSize())); 175 client_->SetNeedsRedrawRect(gfx::Rect(SurfaceSize()));
132 } 176 }
133 177
134 void DirectOutputSurfaceOzone::BindFramebuffer() {
135 DCHECK(buffer_queue_);
136 buffer_queue_->BindFramebuffer();
137 }
138
139 uint32_t DirectOutputSurfaceOzone::GetFramebufferCopyTextureFormat() {
140 return buffer_queue_->internal_format();
141 }
142
143 // We call this on every frame but changing the size once we've allocated
144 // backing NativePixmapOzone instances will cause a DCHECK because
145 // Chrome never Reshape(s) after the first one from (0,0). NB: this implies
146 // that screen size changes need to be plumbed differently. In particular, we
147 // must create the native window in the size that the hardware reports.
148 void DirectOutputSurfaceOzone::Reshape(const gfx::Size& size,
149 float scale_factor,
150 const gfx::ColorSpace& color_space,
151 bool alpha) {
152 OutputSurface::Reshape(size, scale_factor, color_space, alpha);
153 DCHECK(buffer_queue_);
154 buffer_queue_->Reshape(SurfaceSize(), scale_factor, color_space);
155 }
156
157 } // namespace ui 178 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/surfaces/direct_output_surface_ozone.h ('k') | ui/compositor/test/in_process_context_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698