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

Unified Diff: cc/surfaces/surface_factory.cc

Issue 2676373004: Implement service-side surface synchronization (Closed)
Patch Set: Better unit test name Created 3 years, 10 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
Index: cc/surfaces/surface_factory.cc
diff --git a/cc/surfaces/surface_factory.cc b/cc/surfaces/surface_factory.cc
index 63f9b570b4f96bebf712302e1ed94f4c01bc0772..907a59fefe5dfd5a4c15a03360cfe2b794895a87 100644
--- a/cc/surfaces/surface_factory.cc
+++ b/cc/surfaces/surface_factory.cc
@@ -65,14 +65,9 @@ void SurfaceFactory::SubmitCompositorFrame(
surface = std::move(current_surface_);
} else {
surface = Create(local_surface_id);
- gfx::Size frame_size;
- // CompositorFrames may not be populated with a RenderPass in unit tests.
- if (!frame.render_pass_list.empty())
- frame_size = frame.render_pass_list.back()->output_rect.size();
- manager_->SurfaceCreated(SurfaceInfo(
- surface->surface_id(), frame.metadata.device_scale_factor, frame_size));
}
surface->QueueFrame(std::move(frame), callback);
+
if (!manager_->SurfaceModified(SurfaceId(frame_sink_id_, local_surface_id))) {
TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD);
surface->RunDrawCallbacks();
@@ -120,15 +115,41 @@ void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) {
holder_.UnrefResources(resources);
}
+void SurfaceFactory::OnSurfaceActivated(Surface* surface) {
+ DCHECK(surface->HasActiveFrame());
+ const CompositorFrame& frame = surface->GetActiveFrame();
+ // CompositorFrames might not be populated with a RenderPass in unit tests.
+ gfx::Size frame_size;
+ if (!frame.render_pass_list.empty())
+ frame_size = frame.render_pass_list.back()->output_rect.size();
+
+ // SurfaceCreated only applies for the first Surface activation. Thus,
+ // SurfaceFactory stops observing new activations after the first one.
+ manager_->SurfaceCreated(SurfaceInfo(
+ surface->surface_id(), frame.metadata.device_scale_factor, frame_size));
+ surface->RemoveObserver(this);
+}
+
+void SurfaceFactory::OnSurfaceDependenciesChanged(
+ Surface* pending_surface,
+ const SurfaceDependencies& added_dependencies,
+ const SurfaceDependencies& removed_dependencies) {}
+
+void SurfaceFactory::OnSurfaceDiscarded(Surface* pending_surface) {}
+
std::unique_ptr<Surface> SurfaceFactory::Create(
const LocalSurfaceId& local_surface_id) {
auto surface = base::MakeUnique<Surface>(
SurfaceId(frame_sink_id_, local_surface_id), weak_factory_.GetWeakPtr());
manager_->RegisterSurface(surface.get());
+ // Observe a Surface from the time it's created until it's activated for the
+ // first time.
+ surface->AddObserver(this);
return surface;
}
void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) {
+ surface->RemoveObserver(this);
if (manager_)
manager_->Destroy(std::move(surface));
}

Powered by Google App Engine
This is Rietveld 408576698