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

Side by Side Diff: content/test/mailbox_output_surface.cc

Issue 2096493002: Make cc::CompositorFrames movable [Part 1 of 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Dana's nits Created 4 years, 5 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
« no previous file with comments | « content/test/mailbox_output_surface.h ('k') | content/test/test_render_view_host.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 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/test/mailbox_output_surface.h" 5 #include "content/test/mailbox_output_surface.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/compositor_frame_ack.h" 9 #include "cc/output/compositor_frame_ack.h"
10 #include "cc/output/gl_frame_data.h" 10 #include "cc/output/gl_frame_data.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // If it does not return a mailbox, it discarded the frontbuffer which is 196 // If it does not return a mailbox, it discarded the frontbuffer which is
197 // the oldest texture we sent. 197 // the oldest texture we sent.
198 uint32_t texture_id = pending_textures_.front().texture_id; 198 uint32_t texture_id = pending_textures_.front().texture_id;
199 if (texture_id) 199 if (texture_id)
200 context_provider_->ContextGL()->DeleteTextures(1, &texture_id); 200 context_provider_->ContextGL()->DeleteTextures(1, &texture_id);
201 pending_textures_.pop_front(); 201 pending_textures_.pop_front();
202 } 202 }
203 203
204 ReclaimResources(&ack); 204 ReclaimResources(&ack);
205 client_->DidSwapBuffersComplete(); 205 client_->DidSwapBuffersComplete();
206 }
207
208 void MailboxOutputSurface::ShortcutSwapAck(
209 uint32_t output_surface_id,
210 std::unique_ptr<cc::GLFrameData> gl_frame_data) {
211 if (!previous_frame_ack_) {
212 previous_frame_ack_.reset(new cc::CompositorFrameAck);
213 previous_frame_ack_->gl_frame_data.reset(new cc::GLFrameData);
214 } 206 }
215 207
216 OnSwapAck(output_surface_id, *previous_frame_ack_); 208 void MailboxOutputSurface::ShortcutSwapAck(
209 uint32_t output_surface_id,
210 std::unique_ptr<cc::GLFrameData> gl_frame_data) {
211 if (!previous_frame_ack_) {
212 previous_frame_ack_.reset(new cc::CompositorFrameAck);
213 previous_frame_ack_->gl_frame_data.reset(new cc::GLFrameData);
214 }
217 215
218 previous_frame_ack_->gl_frame_data = std::move(gl_frame_data); 216 OnSwapAck(output_surface_id, *previous_frame_ack_);
219 }
220 217
221 void MailboxOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { 218 previous_frame_ack_->gl_frame_data = std::move(gl_frame_data);
222 // This class is here to support layout tests that are currently 219 }
223 // doing a readback in the renderer instead of the browser. So they
224 // are using deprecated code paths in the renderer and don't need to
225 // actually swap anything to the browser. We shortcut the swap to the
226 // browser here and just ack directly within the renderer process.
227 // Once crbug.com/311404 is fixed, this can be removed.
228 220
229 // This would indicate that crbug.com/311404 is being fixed, and this 221 void MailboxOutputSurface::SwapBuffers(cc::CompositorFrame frame) {
230 // block needs to be removed. 222 // This class is here to support layout tests that are currently
231 DCHECK(!frame->delegated_frame_data); 223 // doing a readback in the renderer instead of the browser. So they
224 // are using deprecated code paths in the renderer and don't need to
225 // actually swap anything to the browser. We shortcut the swap to the
226 // browser here and just ack directly within the renderer process.
227 // Once crbug.com/311404 is fixed, this can be removed.
232 228
233 DCHECK(frame->gl_frame_data); 229 // This would indicate that crbug.com/311404 is being fixed, and this
234 DCHECK(!surface_size_.IsEmpty()); 230 // block needs to be removed.
235 DCHECK(surface_size_ == current_backing_.size); 231 DCHECK(!frame.delegated_frame_data);
236 DCHECK(frame->gl_frame_data->size == current_backing_.size);
237 DCHECK(!current_backing_.mailbox.IsZero() ||
238 context_provider_->ContextGL()->GetGraphicsResetStatusKHR() !=
239 GL_NO_ERROR);
240 232
241 frame->gl_frame_data->mailbox = current_backing_.mailbox; 233 DCHECK(frame.gl_frame_data);
234 DCHECK(!surface_size_.IsEmpty());
235 DCHECK(surface_size_ == current_backing_.size);
236 DCHECK(frame.gl_frame_data->size == current_backing_.size);
237 DCHECK(!current_backing_.mailbox.IsZero() ||
238 context_provider_->ContextGL()->GetGraphicsResetStatusKHR() !=
239 GL_NO_ERROR);
242 240
243 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); 241 frame.gl_frame_data->mailbox = current_backing_.mailbox;
244 242
245 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); 243 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
246 gl->Flush();
247 gl->GenSyncTokenCHROMIUM(fence_sync,
248 frame->gl_frame_data->sync_token.GetData());
249 244
250 // Copy the |sync_token| out of the GLFrameData before moving it into the 245 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM();
251 // closure. 246 gl->Flush();
252 gpu::SyncToken sync_token = frame->gl_frame_data->sync_token; 247 gl->GenSyncTokenCHROMIUM(fence_sync,
253 context_provider()->ContextSupport()->SignalSyncToken( 248 frame.gl_frame_data->sync_token.GetData());
254 sync_token, base::Bind(&MailboxOutputSurface::ShortcutSwapAck,
255 weak_ptrs_.GetWeakPtr(), output_surface_id_,
256 base::Passed(&frame->gl_frame_data)));
257 249
258 pending_textures_.push_back(current_backing_); 250 // Copy the |sync_token| out of the GLFrameData before moving it into the
259 current_backing_ = TransferableFrame(); 251 // closure.
252 gpu::SyncToken sync_token = frame.gl_frame_data->sync_token;
253 context_provider()->ContextSupport()->SignalSyncToken(
254 sync_token, base::Bind(&MailboxOutputSurface::ShortcutSwapAck,
255 weak_ptrs_.GetWeakPtr(), output_surface_id_,
256 base::Passed(&frame.gl_frame_data)));
260 257
261 client_->DidSwapBuffers(); 258 pending_textures_.push_back(current_backing_);
259 current_backing_ = TransferableFrame();
260
261 client_->DidSwapBuffers();
262 } 262 }
263 263
264 MailboxOutputSurface::TransferableFrame::TransferableFrame() : texture_id(0) {} 264 MailboxOutputSurface::TransferableFrame::TransferableFrame() : texture_id(0) {}
265 265
266 MailboxOutputSurface::TransferableFrame::TransferableFrame( 266 MailboxOutputSurface::TransferableFrame::TransferableFrame(
267 uint32_t texture_id, 267 uint32_t texture_id,
268 const gpu::Mailbox& mailbox, 268 const gpu::Mailbox& mailbox,
269 const gfx::Size size) 269 const gfx::Size size)
270 : texture_id(texture_id), mailbox(mailbox), size(size) {} 270 : texture_id(texture_id), mailbox(mailbox), size(size) {}
271 271
272 } // namespace content 272 } // namespace content
OLDNEW
« no previous file with comments | « content/test/mailbox_output_surface.h ('k') | content/test/test_render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698