Commit 09b06cad authored by staraz's avatar staraz Committed by Commit bot

[exo]CompositorFrameSinkHolder calls WillDraw in DidReceiveCompositorFrameAck

CommitSurfaceHierarchy() moves pending_frame_callbacks_ into
frame_callbacks_ before calling UpdateSurface() so that the ack doesn't
arrive too early.

exo::Surface is the only class which needs
MojoCompositorFrameSinkClient::WillDrawSurface(). With this change, we
can remove WillDrawSurface from the mojo interface and reduce IPC overhead.

BUG=671202, 709076

Review-Url: https://codereview.chromium.org/2786643002
Cr-Commit-Position: refs/heads/master@{#462678}
parent 58f84757
......@@ -41,7 +41,8 @@ void CompositorFrameSinkHolder::SetResourceReleaseCallback(
// cc::mojom::MojoCompositorFrameSinkClient overrides:
void CompositorFrameSinkHolder::DidReceiveCompositorFrameAck() {
// TODO(staraz): Implement this
if (surface_)
surface_->DidReceiveCompositorFrameAck();
}
void CompositorFrameSinkHolder::OnBeginFrame(const cc::BeginFrameArgs& args) {
......@@ -62,10 +63,7 @@ void CompositorFrameSinkHolder::ReclaimResources(
void CompositorFrameSinkHolder::WillDrawSurface(
const cc::LocalSurfaceId& local_surface_id,
const gfx::Rect& damage_rect) {
if (surface_)
surface_->WillDraw();
}
const gfx::Rect& damage_rect) {}
////////////////////////////////////////////////////////////////////////////////
// cc::ExternalBeginFrameSourceClient overrides:
......
......@@ -464,6 +464,13 @@ void Surface::CommitSurfaceHierarchy() {
local_surface_id_ = id_allocator_.GenerateId();
}
// Move pending frame callbacks to the end of frame_callbacks_.
frame_callbacks_.splice(frame_callbacks_.end(), pending_frame_callbacks_);
// Move pending presentation callbacks to the end of presentation_callbacks_.
presentation_callbacks_.splice(presentation_callbacks_.end(),
pending_presentation_callbacks_);
UpdateSurface(false);
if (old_local_surface_id != local_surface_id_) {
......@@ -492,13 +499,6 @@ void Surface::CommitSurfaceHierarchy() {
compositor_frame_sink_holder_->HasReleaseCallbackForResource(
current_resource_.id));
// Move pending frame callbacks to the end of frame_callbacks_.
frame_callbacks_.splice(frame_callbacks_.end(), pending_frame_callbacks_);
// Move pending presentation callbacks to the end of presentation_callbacks_.
presentation_callbacks_.splice(presentation_callbacks_.end(),
pending_presentation_callbacks_);
// Synchronize window hierarchy. This will position and update the stacking
// order of all sub-surfaces after committing all pending state of sub-surface
// descendants.
......@@ -605,7 +605,7 @@ std::unique_ptr<base::trace_event::TracedValue> Surface::AsTracedValue() const {
return value;
}
void Surface::WillDraw() {
void Surface::DidReceiveCompositorFrameAck() {
active_frame_callbacks_.splice(active_frame_callbacks_.end(),
frame_callbacks_);
swapping_presentation_callbacks_.splice(
......
......@@ -191,8 +191,9 @@ class Surface : public ui::ContextFactoryObserver,
// Returns a trace value representing the state of the surface.
std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const;
// Call this to indicate that surface is being scheduled for a draw.
void WillDraw();
// Call this to indicate that the previous CompositorFrame is processed and
// the surface is being scheduled for a draw.
void DidReceiveCompositorFrameAck();
// Called when the begin frame source has changed.
void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source);
......
......@@ -329,8 +329,9 @@ TEST_F(SurfaceTest, SendsBeginFrameAcks) {
surface->Commit(); // Move callback from pending callbacks to current ones.
RunAllPendingInMessageLoop();
// Surface should add itself as observer during WillDraw().
surface->WillDraw();
// Surface should add itself as observer during
// DidReceiveCompositorFrameAck().
surface->DidReceiveCompositorFrameAck();
EXPECT_EQ(1u, source.num_observers());
cc::BeginFrameArgs args(source.CreateBeginFrameArgs(BEGINFRAME_FROM_HERE));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment