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

Side by Side Diff: content/renderer/android/synchronous_compositor_frame_sink.cc

Issue 2409923002: cc: Rename SwapBuffers on CompositorFrameSink to SubmitCompositorFrame (Closed)
Patch Set: swap-to-submit: 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/renderer/android/synchronous_compositor_frame_sink.h" 5 #include "content/renderer/android/synchronous_compositor_frame_sink.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 display_ = nullptr; 204 display_ = nullptr;
205 surface_factory_ = nullptr; 205 surface_factory_ = nullptr;
206 surface_id_allocator_ = nullptr; 206 surface_id_allocator_ = nullptr;
207 surface_manager_ = nullptr; 207 surface_manager_ = nullptr;
208 cc::CompositorFrameSink::DetachFromClient(); 208 cc::CompositorFrameSink::DetachFromClient();
209 CancelFallbackTick(); 209 CancelFallbackTick();
210 } 210 }
211 211
212 static void NoOpDrawCallback() {} 212 static void NoOpDrawCallback() {}
213 213
214 void SynchronousCompositorFrameSink::SwapBuffers(cc::CompositorFrame frame) { 214 void SynchronousCompositorFrameSink::SubmitCompositorFrame(
215 cc::CompositorFrame frame) {
215 DCHECK(CalledOnValidThread()); 216 DCHECK(CalledOnValidThread());
216 DCHECK(sync_client_); 217 DCHECK(sync_client_);
217 218
218 if (fallback_tick_running_) { 219 if (fallback_tick_running_) {
219 DCHECK(frame.delegated_frame_data->resource_list.empty()); 220 DCHECK(frame.delegated_frame_data->resource_list.empty());
220 cc::ReturnedResourceArray return_resources; 221 cc::ReturnedResourceArray return_resources;
221 ReturnResources(return_resources); 222 ReturnResources(return_resources);
222 did_swap_ = true; 223 did_submit_frame_ = true;
223 return; 224 return;
224 } 225 }
225 226
226 cc::CompositorFrame swap_frame; 227 cc::CompositorFrame submit_frame;
227 228
228 if (in_software_draw_) { 229 if (in_software_draw_) {
229 // The frame we send to the client is actually just the metadata. Preserve 230 // The frame we send to the client is actually just the metadata. Preserve
230 // the |frame| for the software path below. 231 // the |frame| for the software path below.
231 swap_frame.metadata = frame.metadata.Clone(); 232 submit_frame.metadata = frame.metadata.Clone();
232 233
233 if (root_local_frame_id_.is_null()) { 234 if (root_local_frame_id_.is_null()) {
234 root_local_frame_id_ = surface_id_allocator_->GenerateId(); 235 root_local_frame_id_ = surface_id_allocator_->GenerateId();
235 surface_factory_->Create(root_local_frame_id_); 236 surface_factory_->Create(root_local_frame_id_);
236 child_local_frame_id_ = surface_id_allocator_->GenerateId(); 237 child_local_frame_id_ = surface_id_allocator_->GenerateId();
237 surface_factory_->Create(child_local_frame_id_); 238 surface_factory_->Create(child_local_frame_id_);
238 } 239 }
239 240
240 display_->SetSurfaceId(cc::SurfaceId(kFrameSinkId, root_local_frame_id_), 241 display_->SetSurfaceId(cc::SurfaceId(kFrameSinkId, root_local_frame_id_),
241 frame.metadata.device_scale_factor); 242 frame.metadata.device_scale_factor);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 291
291 surface_factory_->SubmitCompositorFrame( 292 surface_factory_->SubmitCompositorFrame(
292 child_local_frame_id_, std::move(frame), base::Bind(&NoOpDrawCallback)); 293 child_local_frame_id_, std::move(frame), base::Bind(&NoOpDrawCallback));
293 surface_factory_->SubmitCompositorFrame(root_local_frame_id_, 294 surface_factory_->SubmitCompositorFrame(root_local_frame_id_,
294 std::move(embed_frame), 295 std::move(embed_frame),
295 base::Bind(&NoOpDrawCallback)); 296 base::Bind(&NoOpDrawCallback));
296 display_->DrawAndSwap(); 297 display_->DrawAndSwap();
297 } else { 298 } else {
298 // For hardware draws we send the whole frame to the client so it can draw 299 // For hardware draws we send the whole frame to the client so it can draw
299 // the content in it. 300 // the content in it.
300 swap_frame = std::move(frame); 301 submit_frame = std::move(frame);
301 } 302 }
302 303
303 sync_client_->SwapBuffers(compositor_frame_sink_id_, std::move(swap_frame)); 304 sync_client_->SubmitCompositorFrame(compositor_frame_sink_id_,
305 std::move(submit_frame));
304 DeliverMessages(); 306 DeliverMessages();
305 did_swap_ = true; 307 did_submit_frame_ = true;
306 } 308 }
307 309
308 void SynchronousCompositorFrameSink::CancelFallbackTick() { 310 void SynchronousCompositorFrameSink::CancelFallbackTick() {
309 fallback_tick_.Cancel(); 311 fallback_tick_.Cancel();
310 fallback_tick_pending_ = false; 312 fallback_tick_pending_ = false;
311 } 313 }
312 314
313 void SynchronousCompositorFrameSink::FallbackTickFired() { 315 void SynchronousCompositorFrameSink::FallbackTickFired() {
314 DCHECK(CalledOnValidThread()); 316 DCHECK(CalledOnValidThread());
315 TRACE_EVENT0("renderer", "SynchronousCompositorFrameSink::FallbackTickFired"); 317 TRACE_EVENT0("renderer", "SynchronousCompositorFrameSink::FallbackTickFired");
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 // save it for later. 373 // save it for later.
372 sw_viewport_for_current_draw_ = viewport; 374 sw_viewport_for_current_draw_ = viewport;
373 375
374 base::AutoReset<bool> set_in_software_draw(&in_software_draw_, true); 376 base::AutoReset<bool> set_in_software_draw(&in_software_draw_, true);
375 InvokeComposite(transform, viewport); 377 InvokeComposite(transform, viewport);
376 } 378 }
377 379
378 void SynchronousCompositorFrameSink::InvokeComposite( 380 void SynchronousCompositorFrameSink::InvokeComposite(
379 const gfx::Transform& transform, 381 const gfx::Transform& transform,
380 const gfx::Rect& viewport) { 382 const gfx::Rect& viewport) {
381 did_swap_ = false; 383 did_submit_frame_ = false;
382 // Adjust transform so that the layer compositor draws the |viewport| rect 384 // Adjust transform so that the layer compositor draws the |viewport| rect
383 // at its origin. The offset of the |viewport| we pass to the layer compositor 385 // at its origin. The offset of the |viewport| we pass to the layer compositor
384 // is ignored for drawing, so its okay to not match the transform. 386 // is ignored for drawing, so its okay to not match the transform.
385 // TODO(danakj): Why do we pass a viewport origin and then not really use it 387 // TODO(danakj): Why do we pass a viewport origin and then not really use it
386 // (only for comparing to the viewport passed in 388 // (only for comparing to the viewport passed in
387 // SetExternalTilePriorityConstraints), surely this could be more clear? 389 // SetExternalTilePriorityConstraints), surely this could be more clear?
388 gfx::Transform adjusted_transform = transform; 390 gfx::Transform adjusted_transform = transform;
389 adjusted_transform.matrix().postTranslate(-viewport.x(), -viewport.y(), 0); 391 adjusted_transform.matrix().postTranslate(-viewport.x(), -viewport.y(), 0);
390 client_->OnDraw(adjusted_transform, viewport, in_software_draw_); 392 client_->OnDraw(adjusted_transform, viewport, in_software_draw_);
391 393
392 if (did_swap_) { 394 if (did_submit_frame_) {
393 // This must happen after unwinding the stack and leaving the compositor. 395 // This must happen after unwinding the stack and leaving the compositor.
394 // Usually it is a separate task but we just defer it until OnDraw completes 396 // Usually it is a separate task but we just defer it until OnDraw completes
395 // instead. 397 // instead.
396 client_->DidSwapBuffersComplete(); 398 client_->DidReceiveCompositorFrameAck();
397 } 399 }
398 } 400 }
399 401
400 void SynchronousCompositorFrameSink::OnReclaimResources( 402 void SynchronousCompositorFrameSink::OnReclaimResources(
401 uint32_t compositor_frame_sink_id, 403 uint32_t compositor_frame_sink_id,
402 const cc::ReturnedResourceArray& resources) { 404 const cc::ReturnedResourceArray& resources) {
403 // Ignore message if it's a stale one coming from a different output surface 405 // Ignore message if it's a stale one coming from a different output surface
404 // (e.g. after a lost context). 406 // (e.g. after a lost context).
405 if (compositor_frame_sink_id != compositor_frame_sink_id_) 407 if (compositor_frame_sink_id != compositor_frame_sink_id_)
406 return; 408 return;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 client_->ReclaimResources(resources); 463 client_->ReclaimResources(resources);
462 } 464 }
463 465
464 void SynchronousCompositorFrameSink::SetBeginFrameSource( 466 void SynchronousCompositorFrameSink::SetBeginFrameSource(
465 cc::BeginFrameSource* begin_frame_source) { 467 cc::BeginFrameSource* begin_frame_source) {
466 // Software output is synchronous and doesn't use a BeginFrameSource. 468 // Software output is synchronous and doesn't use a BeginFrameSource.
467 NOTREACHED(); 469 NOTREACHED();
468 } 470 }
469 471
470 } // namespace content 472 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698