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

Unified Diff: cc/surfaces/direct_compositor_frame_sink.cc

Issue 2612083002: DirectCompositorFrameSink Uses CompositorFrameSinkSupport (Closed)
Patch Set: 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/direct_compositor_frame_sink.cc
diff --git a/cc/surfaces/direct_compositor_frame_sink.cc b/cc/surfaces/direct_compositor_frame_sink.cc
index 01239ee9f822df7c1f589bf8691e0857cf804881..e0f5fa4a225870eb3de44d2cfb6ab56db2e98f14 100644
--- a/cc/surfaces/direct_compositor_frame_sink.cc
+++ b/cc/surfaces/direct_compositor_frame_sink.cc
@@ -27,16 +27,17 @@ DirectCompositorFrameSink::DirectCompositorFrameSink(
std::move(worker_context_provider),
gpu_memory_buffer_manager,
shared_bitmap_manager),
- frame_sink_id_(frame_sink_id),
- surface_manager_(surface_manager),
- display_(display),
- factory_(frame_sink_id, surface_manager, this) {
+ support_(this,
+ surface_manager,
+ frame_sink_id,
+ std::move(display),
+ nullptr) {
DCHECK(thread_checker_.CalledOnValidThread());
capabilities_.can_force_reclaim_resources = true;
// Display and DirectCompositorFrameSink share a GL context, so sync
// points aren't needed when passing resources between them.
capabilities_.delegated_sync_points_required = false;
- factory_.set_needs_sync_points(false);
+ support_.SetFactoryNeedsSyncPoints(false);
}
DirectCompositorFrameSink::DirectCompositorFrameSink(
@@ -45,10 +46,11 @@ DirectCompositorFrameSink::DirectCompositorFrameSink(
Display* display,
scoped_refptr<VulkanContextProvider> vulkan_context_provider)
: CompositorFrameSink(std::move(vulkan_context_provider)),
- frame_sink_id_(frame_sink_id),
- surface_manager_(surface_manager),
- display_(display),
- factory_(frame_sink_id_, surface_manager, this) {
+ support_(this,
+ surface_manager,
+ frame_sink_id,
+ std::move(display),
+ nullptr) {
DCHECK(thread_checker_.CalledOnValidThread());
capabilities_.can_force_reclaim_resources = true;
}
@@ -64,8 +66,7 @@ bool DirectCompositorFrameSink::BindToClient(
if (!CompositorFrameSink::BindToClient(client))
return false;
- surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this);
-
+ support_.BindToClient();
Fady Samuel 2017/01/04 20:59:25 Create support_ here instead. Use a unique_ptr.
// We want the Display's output surface to hear about lost context, and since
// this shares a context with it, we should not be listening for lost context
// callbacks on the context here.
@@ -74,16 +75,11 @@ bool DirectCompositorFrameSink::BindToClient(
// Avoid initializing GL context here, as this should be sharing the
// Display's context.
- display_->Initialize(this, surface_manager_);
return true;
}
void DirectCompositorFrameSink::DetachFromClient() {
- // Unregister the SurfaceFactoryClient here instead of the dtor so that only
- // one client is alive for this namespace at any given time.
- surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
- factory_.EvictSurface();
-
+ support_.DetachFromClient();
Fady Samuel 2017/01/04 20:59:25 support_.reset() support_ is a unique_ptr.
CompositorFrameSink::DetachFromClient();
}
@@ -93,30 +89,11 @@ void DirectCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) {
delegated_local_frame_id_ = surface_id_allocator_.GenerateId();
last_swap_frame_size_ = frame_size;
}
- display_->SetLocalFrameId(delegated_local_frame_id_,
- frame.metadata.device_scale_factor);
-
- factory_.SubmitCompositorFrame(
- delegated_local_frame_id_, std::move(frame),
- base::Bind(&DirectCompositorFrameSink::DidDrawCallback,
- base::Unretained(this)));
+ support_.SubmitCompositorFrame(delegated_local_frame_id_, std::move(frame));
}
void DirectCompositorFrameSink::ForceReclaimResources() {
- if (delegated_local_frame_id_.is_valid())
- factory_.ClearSurface();
-}
-
-void DirectCompositorFrameSink::ReturnResources(
- const ReturnedResourceArray& resources) {
- if (client_)
- client_->ReclaimResources(resources);
-}
-
-void DirectCompositorFrameSink::SetBeginFrameSource(
- BeginFrameSource* begin_frame_source) {
- DCHECK(client_);
- client_->SetBeginFrameSource(begin_frame_source);
+ support_.ForceReclaimResources();
}
void DirectCompositorFrameSink::DisplayOutputSurfaceLost() {
@@ -136,6 +113,26 @@ void DirectCompositorFrameSink::DisplayDidDrawAndSwap() {
// be drawn.
}
+void DirectCompositorFrameSink::DidReceiveCompositorFrameAck() {
+ if (client_)
+ client_->DidReceiveCompositorFrameAck();
+}
+
+void DirectCompositorFrameSink::OnBeginFrame(const BeginFrameArgs& args) {
+ // TODO(staraz): Implement this.
+ NOTIMPLEMENTED();
+}
+
+void DirectCompositorFrameSink::ReclaimResources(
+ const ReturnedResourceArray& resources) {
+ if (client_)
+ client_->ReclaimResources(resources);
+}
+
+void DirectCompositorFrameSink::WillDrawSurface() {
+ // TODO(staraz): Implement this.
+}
+
void DirectCompositorFrameSink::DidDrawCallback() {
client_->DidReceiveCompositorFrameAck();
}

Powered by Google App Engine
This is Rietveld 408576698