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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/exo/surface.h ('k') | components/exo/surface_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/surface.cc
diff --git a/components/exo/surface.cc b/components/exo/surface.cc
index be4b90ba2d34b2b99d34a99c847e10480a2183ca..bdcd746536ddccae9d57dc5d578742f4868d6c1b 100644
--- a/components/exo/surface.cc
+++ b/components/exo/surface.cc
@@ -432,6 +432,13 @@ void Surface::Commit() {
CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces();
CommitSurfaceHierarchy();
}
+
+ if (begin_frame_source_ && current_begin_frame_ack_.sequence_number !=
+ cc::BeginFrameArgs::kInvalidFrameNumber) {
+ begin_frame_source_->DidFinishFrame(this, current_begin_frame_ack_);
+ current_begin_frame_ack_.sequence_number =
+ cc::BeginFrameArgs::kInvalidFrameNumber;
+ }
}
void Surface::CommitSurfaceHierarchy() {
@@ -603,17 +610,42 @@ void Surface::WillDraw() {
frame_callbacks_);
swapping_presentation_callbacks_.splice(
swapping_presentation_callbacks_.end(), presentation_callbacks_);
+ UpdateNeedsBeginFrame();
+}
+
+void Surface::SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) {
+ if (needs_begin_frame_) {
+ DCHECK(begin_frame_source_);
+ begin_frame_source_->RemoveObserver(this);
+ needs_begin_frame_ = false;
+ }
+ begin_frame_source_ = begin_frame_source;
+ UpdateNeedsBeginFrame();
}
-bool Surface::NeedsBeginFrame() const {
- return !active_frame_callbacks_.empty();
+void Surface::UpdateNeedsBeginFrame() {
+ if (!begin_frame_source_)
+ return;
+
+ bool needs_begin_frame = !active_frame_callbacks_.empty();
+ if (needs_begin_frame == needs_begin_frame_)
+ return;
+
+ needs_begin_frame_ = needs_begin_frame;
+ if (needs_begin_frame_)
+ begin_frame_source_->AddObserver(this);
+ else
+ begin_frame_source_->RemoveObserver(this);
}
-void Surface::BeginFrame(base::TimeTicks frame_time) {
+bool Surface::OnBeginFrameDerivedImpl(const cc::BeginFrameArgs& args) {
+ current_begin_frame_ack_ = cc::BeginFrameAck(
+ args.source_id, args.sequence_number, args.sequence_number, 0, false);
while (!active_frame_callbacks_.empty()) {
- active_frame_callbacks_.front().Run(frame_time);
+ active_frame_callbacks_.front().Run(args.frame_time);
active_frame_callbacks_.pop_front();
}
+ return true;
}
void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() {
@@ -806,6 +838,9 @@ void Surface::UpdateSurface(bool full_damage) {
quad_state->opacity = state_.alpha;
cc::CompositorFrame frame;
+ current_begin_frame_ack_.has_damage = true;
+ frame.metadata.begin_frame_ack = current_begin_frame_ack_;
+
if (current_resource_.id) {
// Texture quad is only needed if buffer is not fully transparent.
if (state_.alpha) {
« 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