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

Side by Side Diff: content/browser/frame_host/render_widget_host_view_child_frame.cc

Issue 2527283003: cc: Introduce BeginFrame sequence numbers and acknowledgements.
Patch Set: Address Brian's comments. Created 4 years 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/frame_host/render_widget_host_view_child_frame.h" 5 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 current_surface_size_ = frame_size; 397 current_surface_size_ = frame_size;
398 current_surface_scale_factor_ = scale_factor; 398 current_surface_scale_factor_ = scale_factor;
399 } 399 }
400 400
401 bool allocated_new_local_frame_id = false; 401 bool allocated_new_local_frame_id = false;
402 if (!local_frame_id_.is_valid()) { 402 if (!local_frame_id_.is_valid()) {
403 local_frame_id_ = id_allocator_->GenerateId(); 403 local_frame_id_ = id_allocator_->GenerateId();
404 allocated_new_local_frame_id = true; 404 allocated_new_local_frame_id = true;
405 } 405 }
406 406
407 uint64_t begin_frame_source_id = frame.metadata.begin_frame_source_id;
408 uint64_t begin_frame_number = frame.metadata.begin_frame_number;
409 uint64_t latest_confirmed_frame = frame.metadata.latest_confirmed_frame;
410
407 cc::SurfaceFactory::DrawCallback ack_callback = 411 cc::SurfaceFactory::DrawCallback ack_callback =
408 base::Bind(&RenderWidgetHostViewChildFrame::SurfaceDrawn, AsWeakPtr(), 412 base::Bind(&RenderWidgetHostViewChildFrame::SurfaceDrawn, AsWeakPtr(),
409 compositor_frame_sink_id); 413 compositor_frame_sink_id);
410 ack_pending_count_++; 414 ack_pending_count_++;
411 // If this value grows very large, something is going wrong. 415 // If this value grows very large, something is going wrong.
412 DCHECK_LT(ack_pending_count_, 1000U); 416 DCHECK_LT(ack_pending_count_, 1000U);
413 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame), 417 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame),
414 ack_callback); 418 ack_callback);
415 419
416 if (allocated_new_local_frame_id) { 420 if (allocated_new_local_frame_id) {
417 cc::SurfaceSequence sequence = 421 cc::SurfaceSequence sequence =
418 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++); 422 cc::SurfaceSequence(frame_sink_id_, next_surface_sequence_++);
419 // The renderer process will satisfy this dependency when it creates a 423 // The renderer process will satisfy this dependency when it creates a
420 // SurfaceLayer. 424 // SurfaceLayer.
421 cc::SurfaceManager* manager = GetSurfaceManager(); 425 cc::SurfaceManager* manager = GetSurfaceManager();
422 manager->GetSurfaceForId(cc::SurfaceId(frame_sink_id_, local_frame_id_)) 426 manager->GetSurfaceForId(cc::SurfaceId(frame_sink_id_, local_frame_id_))
423 ->AddDestructionDependency(sequence); 427 ->AddDestructionDependency(sequence);
424 frame_connector_->SetChildFrameSurface( 428 frame_connector_->SetChildFrameSurface(
425 cc::SurfaceId(frame_sink_id_, local_frame_id_), frame_size, 429 cc::SurfaceId(frame_sink_id_, local_frame_id_), frame_size,
426 scale_factor, sequence); 430 scale_factor, sequence);
427 } 431 }
428 ProcessFrameSwappedCallbacks(); 432 ProcessFrameSwappedCallbacks();
433 DidSwapFrame(begin_frame_source_id, begin_frame_number,
434 latest_confirmed_frame);
435 }
436
437 void RenderWidgetHostViewChildFrame::OnBeginFrameDidNotDraw(
438 const cc::BeginFrameAck& ack) {
439 if (begin_frame_source_)
440 begin_frame_source_->DidFinishFrame(this, ack);
429 } 441 }
430 442
431 void RenderWidgetHostViewChildFrame::ProcessFrameSwappedCallbacks() { 443 void RenderWidgetHostViewChildFrame::ProcessFrameSwappedCallbacks() {
432 // We only use callbacks once, therefore we make a new list for registration 444 // We only use callbacks once, therefore we make a new list for registration
433 // before we start, and discard the old list entries when we are done. 445 // before we start, and discard the old list entries when we are done.
434 FrameSwappedCallbackList process_callbacks; 446 FrameSwappedCallbackList process_callbacks;
435 process_callbacks.swap(frame_swapped_callbacks_); 447 process_callbacks.swap(frame_swapped_callbacks_);
436 for (std::unique_ptr<base::Closure>& callback : process_callbacks) 448 for (std::unique_ptr<base::Closure>& callback : process_callbacks)
437 callback->Run(); 449 callback->Run();
438 } 450 }
439 451
452 void RenderWidgetHostViewChildFrame::DidSwapFrame(
453 uint64_t source_id,
454 uint64_t sequence_number,
455 uint64_t latest_confirmed_frame) {
456 cc::BeginFrameAck ack(source_id, sequence_number, latest_confirmed_frame,
457 0, true);
458 if (begin_frame_source_)
459 begin_frame_source_->DidFinishFrame(this, ack);
460 }
461
440 gfx::Rect RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() { 462 gfx::Rect RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() {
441 gfx::Rect rect; 463 gfx::Rect rect;
442 if (frame_connector_) { 464 if (frame_connector_) {
443 RenderWidgetHostViewBase* root_view = 465 RenderWidgetHostViewBase* root_view =
444 frame_connector_->GetRootRenderWidgetHostView(); 466 frame_connector_->GetRootRenderWidgetHostView();
445 467
446 // The root_view can be null in tests when using a TestWebContents. 468 // The root_view can be null in tests when using a TestWebContents.
447 if (root_view) 469 if (root_view)
448 rect = root_view->GetBoundsInRootWindow(); 470 rect = root_view->GetBoundsInRootWindow();
449 } 471 }
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 754
733 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { 755 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const {
734 return true; 756 return true;
735 } 757 }
736 758
737 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { 759 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const {
738 return cc::SurfaceId(frame_sink_id_, local_frame_id_); 760 return cc::SurfaceId(frame_sink_id_, local_frame_id_);
739 }; 761 };
740 762
741 } // namespace content 763 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698