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

Side by Side Diff: components/exo/surface.cc

Issue 2724953007: [exo] Clean up BeginFrame distribution & add acks in Surface. (Closed)
Patch Set: rename instance var. Created 3 years, 9 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 | « components/exo/surface.h ('k') | components/exo/surface_unittest.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/exo/surface.h" 5 #include "components/exo/surface.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 has_pending_layer_changes_ = true; 425 has_pending_layer_changes_ = true;
426 } 426 }
427 } 427 }
428 428
429 if (delegate_) { 429 if (delegate_) {
430 delegate_->OnSurfaceCommit(); 430 delegate_->OnSurfaceCommit();
431 } else { 431 } else {
432 CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); 432 CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces();
433 CommitSurfaceHierarchy(); 433 CommitSurfaceHierarchy();
434 } 434 }
435
436 if (begin_frame_source_ && current_begin_frame_ack_.sequence_number !=
437 cc::BeginFrameArgs::kInvalidFrameNumber) {
438 begin_frame_source_->DidFinishFrame(this, current_begin_frame_ack_);
439 current_begin_frame_ack_.sequence_number =
440 cc::BeginFrameArgs::kInvalidFrameNumber;
441 }
435 } 442 }
436 443
437 void Surface::CommitSurfaceHierarchy() { 444 void Surface::CommitSurfaceHierarchy() {
438 DCHECK(needs_commit_surface_hierarchy_); 445 DCHECK(needs_commit_surface_hierarchy_);
439 needs_commit_surface_hierarchy_ = false; 446 needs_commit_surface_hierarchy_ = false;
440 has_pending_layer_changes_ = false; 447 has_pending_layer_changes_ = false;
441 448
442 state_ = pending_state_; 449 state_ = pending_state_;
443 pending_state_.only_visible_on_secure_output = false; 450 pending_state_.only_visible_on_secure_output = false;
444 451
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 new base::trace_event::TracedValue()); 603 new base::trace_event::TracedValue());
597 value->SetString("name", window_->layer()->name()); 604 value->SetString("name", window_->layer()->name());
598 return value; 605 return value;
599 } 606 }
600 607
601 void Surface::WillDraw() { 608 void Surface::WillDraw() {
602 active_frame_callbacks_.splice(active_frame_callbacks_.end(), 609 active_frame_callbacks_.splice(active_frame_callbacks_.end(),
603 frame_callbacks_); 610 frame_callbacks_);
604 swapping_presentation_callbacks_.splice( 611 swapping_presentation_callbacks_.splice(
605 swapping_presentation_callbacks_.end(), presentation_callbacks_); 612 swapping_presentation_callbacks_.end(), presentation_callbacks_);
613 UpdateNeedsBeginFrame();
606 } 614 }
607 615
608 bool Surface::NeedsBeginFrame() const { 616 void Surface::SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) {
609 return !active_frame_callbacks_.empty(); 617 if (needs_begin_frame_) {
618 DCHECK(begin_frame_source_);
619 begin_frame_source_->RemoveObserver(this);
620 needs_begin_frame_ = false;
621 }
622 begin_frame_source_ = begin_frame_source;
623 UpdateNeedsBeginFrame();
610 } 624 }
611 625
612 void Surface::BeginFrame(base::TimeTicks frame_time) { 626 void Surface::UpdateNeedsBeginFrame() {
627 if (!begin_frame_source_)
628 return;
629
630 bool needs_begin_frame = !active_frame_callbacks_.empty();
631 if (needs_begin_frame == needs_begin_frame_)
632 return;
633
634 needs_begin_frame_ = needs_begin_frame;
635 if (needs_begin_frame_)
636 begin_frame_source_->AddObserver(this);
637 else
638 begin_frame_source_->RemoveObserver(this);
639 }
640
641 bool Surface::OnBeginFrameDerivedImpl(const cc::BeginFrameArgs& args) {
642 current_begin_frame_ack_ = cc::BeginFrameAck(
643 args.source_id, args.sequence_number, args.sequence_number, 0, false);
613 while (!active_frame_callbacks_.empty()) { 644 while (!active_frame_callbacks_.empty()) {
614 active_frame_callbacks_.front().Run(frame_time); 645 active_frame_callbacks_.front().Run(args.frame_time);
615 active_frame_callbacks_.pop_front(); 646 active_frame_callbacks_.pop_front();
616 } 647 }
648 return true;
617 } 649 }
618 650
619 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() { 651 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() {
620 if (HasLayerHierarchyChanged()) 652 if (HasLayerHierarchyChanged())
621 SetSurfaceHierarchyNeedsCommitToNewSurfaces(); 653 SetSurfaceHierarchyNeedsCommitToNewSurfaces();
622 } 654 }
623 655
624 //////////////////////////////////////////////////////////////////////////////// 656 ////////////////////////////////////////////////////////////////////////////////
625 // ui::ContextFactoryObserver overrides: 657 // ui::ContextFactoryObserver overrides:
626 658
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 gfx::Transform()); 831 gfx::Transform());
800 832
801 gfx::Rect quad_rect = output_rect; 833 gfx::Rect quad_rect = output_rect;
802 cc::SharedQuadState* quad_state = 834 cc::SharedQuadState* quad_state =
803 render_pass->CreateAndAppendSharedQuadState(); 835 render_pass->CreateAndAppendSharedQuadState();
804 quad_state->quad_layer_bounds = contents_surface_size; 836 quad_state->quad_layer_bounds = contents_surface_size;
805 quad_state->visible_quad_layer_rect = quad_rect; 837 quad_state->visible_quad_layer_rect = quad_rect;
806 quad_state->opacity = state_.alpha; 838 quad_state->opacity = state_.alpha;
807 839
808 cc::CompositorFrame frame; 840 cc::CompositorFrame frame;
841 current_begin_frame_ack_.has_damage = true;
842 frame.metadata.begin_frame_ack = current_begin_frame_ack_;
843
809 if (current_resource_.id) { 844 if (current_resource_.id) {
810 // Texture quad is only needed if buffer is not fully transparent. 845 // Texture quad is only needed if buffer is not fully transparent.
811 if (state_.alpha) { 846 if (state_.alpha) {
812 cc::TextureDrawQuad* texture_quad = 847 cc::TextureDrawQuad* texture_quad =
813 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); 848 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
814 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0}; 849 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0};
815 gfx::Rect opaque_rect; 850 gfx::Rect opaque_rect;
816 if (!current_resource_has_alpha_ || 851 if (!current_resource_has_alpha_ ||
817 state_.blend_mode == SkBlendMode::kSrc || 852 state_.blend_mode == SkBlendMode::kSrc ||
818 state_.opaque_region.contains(gfx::RectToSkIRect(quad_rect))) { 853 state_.opaque_region.contains(gfx::RectToSkIRect(quad_rect))) {
(...skipping 15 matching lines...) Expand all
834 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); 869 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
835 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); 870 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false);
836 } 871 }
837 872
838 frame.render_pass_list.push_back(std::move(render_pass)); 873 frame.render_pass_list.push_back(std::move(render_pass));
839 compositor_frame_sink_holder_->GetCompositorFrameSink() 874 compositor_frame_sink_holder_->GetCompositorFrameSink()
840 ->SubmitCompositorFrame(local_surface_id_, std::move(frame)); 875 ->SubmitCompositorFrame(local_surface_id_, std::move(frame));
841 } 876 }
842 877
843 } // namespace exo 878 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/surface.h ('k') | components/exo/surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698