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

Unified Diff: cc/surfaces/surface_factory.cc

Issue 2582823002: WIP: Surface Synchronization System
Patch Set: Only create ClientSurfaceEmbedder if window is visible. Trash it otherwise. Created 3 years, 11 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 f5746325790bd4b390dfe9b936c37d1f5775de5f..779bc5ad350acb40f43f11def0ae16a89d30fba5 100644
--- a/cc/surfaces/surface_factory.cc
+++ b/cc/surfaces/surface_factory.cc
@@ -64,14 +64,13 @@ void SurfaceFactory::SubmitCompositorFrame(const LocalFrameId& local_frame_id,
surface = std::move(current_surface_);
} else {
surface = Create(local_frame_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);
+
+ // Ask the surface manager to resolve the surface if it has a pending frame.
+ if (surface->GetPendingFrame().has_value())
+ manager_->RequestSurfaceResolution(surface.get());
+
if (!manager_->SurfaceModified(SurfaceId(frame_sink_id_, local_frame_id))) {
TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD);
surface->RunDrawCallbacks();
@@ -119,15 +118,38 @@ void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) {
holder_.UnrefResources(resources);
}
+void SurfaceFactory::OnSurfaceActivated(Surface* surface) {
+ gfx::Size frame_size;
+ // CompositorFrames may not be populated with a RenderPass in unit tests.
+ const CompositorFrame& frame = surface->GetEligibleFrame();
+ 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));
+ fprintf(stderr, ">>>SurfaceFactory::OnSurfaeActivated :%s\n",
+ surface->surface_id().ToString().c_str());
+ surface->RemoveObserver(this);
+}
+
+void SurfaceFactory::OnSurfaceChanged(
+ Surface* pending_surface,
+ const SurfaceDependencies& added_dependencies,
+ const SurfaceDependencies& removed_dependencies) {}
+
+void SurfaceFactory::OnSurfaceDiscarded(Surface* pending_surface) {}
+
std::unique_ptr<Surface> SurfaceFactory::Create(
const LocalFrameId& local_frame_id) {
auto surface = base::MakeUnique<Surface>(
SurfaceId(frame_sink_id_, local_frame_id), weak_factory_.GetWeakPtr());
manager_->RegisterSurface(surface.get());
+ 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