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

Unified Diff: cc/surfaces/surface.cc

Issue 2834553002: Replace CompositorFrameSinkSupport::WillDrawSurface With RepeatingCallback (Closed)
Patch Set: Address Comments On Documentation Created 3 years, 8 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 | « cc/surfaces/surface.h ('k') | cc/surfaces/surface_aggregator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/surface.cc
diff --git a/cc/surfaces/surface.cc b/cc/surfaces/surface.cc
index 80d5a7ab32587d9b62b8c34e0e91c51ba4d1c394..be2332bf73d85d7396e4ae4660474fbcb371d449 100644
--- a/cc/surfaces/surface.cc
+++ b/cc/surfaces/surface.cc
@@ -50,7 +50,9 @@ void Surface::SetPreviousFrameSurface(Surface* surface) {
surface->TakeLatencyInfoFromPendingFrame(&frame.metadata.latency_info);
}
-void Surface::QueueFrame(CompositorFrame frame, const DrawCallback& callback) {
+void Surface::QueueFrame(CompositorFrame frame,
+ const DrawCallback& callback,
+ const WillDrawCallback& will_draw_callback) {
TakeLatencyInfoFromPendingFrame(&frame.metadata.latency_info);
base::Optional<FrameData> previous_pending_frame_data =
@@ -66,13 +68,14 @@ void Surface::QueueFrame(CompositorFrame frame, const DrawCallback& callback) {
bool is_pending_frame = !blocking_surfaces_.empty();
if (is_pending_frame) {
- pending_frame_data_ = FrameData(std::move(frame), callback);
+ pending_frame_data_ =
+ FrameData(std::move(frame), callback, will_draw_callback);
// Ask the surface manager to inform |this| when its dependencies are
// resolved.
factory_->manager()->RequestSurfaceResolution(this);
} else {
// If there are no blockers, then immediately activate the frame.
- ActivateFrame(FrameData(std::move(frame), callback));
+ ActivateFrame(FrameData(std::move(frame), callback, will_draw_callback));
}
// Returns resources for the previous pending frame.
@@ -80,7 +83,7 @@ void Surface::QueueFrame(CompositorFrame frame, const DrawCallback& callback) {
}
void Surface::EvictFrame() {
- QueueFrame(CompositorFrame(), DrawCallback());
+ QueueFrame(CompositorFrame(), DrawCallback(), WillDrawCallback());
active_frame_data_.reset();
}
@@ -143,8 +146,11 @@ void Surface::ActivatePendingFrameForDeadline() {
}
Surface::FrameData::FrameData(CompositorFrame&& frame,
- const DrawCallback& draw_callback)
- : frame(std::move(frame)), draw_callback(draw_callback) {}
+ const DrawCallback& draw_callback,
+ const WillDrawCallback& will_draw_callback)
+ : frame(std::move(frame)),
+ draw_callback(draw_callback),
+ will_draw_callback(will_draw_callback) {}
Surface::FrameData::FrameData(FrameData&& other) = default;
@@ -274,7 +280,7 @@ void Surface::TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info) {
TakeLatencyInfoFromFrame(&active_frame_data_->frame, latency_info);
}
-void Surface::RunDrawCallbacks() {
+void Surface::RunDrawCallback() {
if (active_frame_data_ && !active_frame_data_->draw_callback.is_null()) {
DrawCallback callback = active_frame_data_->draw_callback;
active_frame_data_->draw_callback = DrawCallback();
@@ -282,6 +288,14 @@ void Surface::RunDrawCallbacks() {
}
}
+void Surface::RunWillDrawCallback(const gfx::Rect& damage_rect) {
+ if (!active_frame_data_ || active_frame_data_->will_draw_callback.is_null())
+ return;
+
+ active_frame_data_->will_draw_callback.Run(surface_id_.local_surface_id(),
+ damage_rect);
+}
+
void Surface::AddDestructionDependency(SurfaceSequence sequence) {
destruction_dependencies_.push_back(sequence);
}
« no previous file with comments | « cc/surfaces/surface.h ('k') | cc/surfaces/surface_aggregator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698