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

Unified Diff: services/ui/ws/display_client_compositor_frame_sink.cc

Issue 2738923002: Add DisplayClientCompositorFrameSink (Closed)
Patch Set: addressed nits Created 3 years, 9 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 | « services/ui/ws/display_client_compositor_frame_sink.h ('k') | services/ui/ws/frame_generator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/display_client_compositor_frame_sink.cc
diff --git a/services/ui/ws/display_client_compositor_frame_sink.cc b/services/ui/ws/display_client_compositor_frame_sink.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5d719fa1dab4290c2bcdd7c33ffca4ff8adfccf4
--- /dev/null
+++ b/services/ui/ws/display_client_compositor_frame_sink.cc
@@ -0,0 +1,106 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "services/ui/ws/display_client_compositor_frame_sink.h"
+
+#include "base/threading/thread_checker.h"
+#include "cc/output/compositor_frame_sink_client.h"
+
+namespace ui {
+namespace ws {
+
+DisplayClientCompositorFrameSink::DisplayClientCompositorFrameSink(
+ const cc::FrameSinkId& frame_sink_id,
+ cc::mojom::MojoCompositorFrameSinkAssociatedPtr compositor_frame_sink,
+ cc::mojom::DisplayPrivateAssociatedPtr display_private,
+ cc::mojom::MojoCompositorFrameSinkClientRequest client_request)
+ : cc::CompositorFrameSink(nullptr, nullptr, nullptr, nullptr),
+ compositor_frame_sink_(std::move(compositor_frame_sink)),
+ client_binding_(this, std::move(client_request)),
+ display_private_(std::move(display_private)),
+ frame_sink_id_(frame_sink_id) {}
+
+DisplayClientCompositorFrameSink::~DisplayClientCompositorFrameSink() {}
+
+bool DisplayClientCompositorFrameSink::BindToClient(
+ cc::CompositorFrameSinkClient* client) {
+ if (!cc::CompositorFrameSink::BindToClient(client))
+ return false;
+ DCHECK(!thread_checker_);
+ thread_checker_ = base::MakeUnique<base::ThreadChecker>();
+
+ begin_frame_source_ = base::MakeUnique<cc::ExternalBeginFrameSource>(this);
+
+ client->SetBeginFrameSource(begin_frame_source_.get());
+ return true;
+}
+
+void DisplayClientCompositorFrameSink::DetachFromClient() {
+ client_->SetBeginFrameSource(nullptr);
+ begin_frame_source_.reset();
+ cc::CompositorFrameSink::DetachFromClient();
+}
+
+void DisplayClientCompositorFrameSink::SubmitCompositorFrame(
+ cc::CompositorFrame frame) {
+ DCHECK(thread_checker_->CalledOnValidThread());
+ if (!compositor_frame_sink_)
+ return;
+
+ gfx::Size frame_size = last_submitted_frame_size_;
+ if (!frame.render_pass_list.empty())
+ frame_size = frame.render_pass_list.back()->output_rect.size();
+
+ if (!local_surface_id_.is_valid() ||
+ frame_size != last_submitted_frame_size_) {
+ local_surface_id_ = id_allocator_.GenerateId();
+ display_private_->ResizeDisplay(frame_size);
+ }
+ display_private_->SetLocalSurfaceId(local_surface_id_,
+ frame.metadata.device_scale_factor);
+ compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_,
+ std::move(frame));
+ last_submitted_frame_size_ = frame_size;
+}
+
+void DisplayClientCompositorFrameSink::DidReceiveCompositorFrameAck() {
+ DCHECK(thread_checker_->CalledOnValidThread());
+ if (!client_)
+ return;
+ client_->DidReceiveCompositorFrameAck();
+}
+
+void DisplayClientCompositorFrameSink::OnBeginFrame(
+ const cc::BeginFrameArgs& begin_frame_args) {
+ DCHECK(thread_checker_->CalledOnValidThread());
+ begin_frame_source_->OnBeginFrame(begin_frame_args);
+}
+
+void DisplayClientCompositorFrameSink::ReclaimResources(
+ const cc::ReturnedResourceArray& resources) {
+ DCHECK(thread_checker_->CalledOnValidThread());
+ if (!client_)
+ return;
+ client_->ReclaimResources(resources);
+}
+
+void DisplayClientCompositorFrameSink::WillDrawSurface(
+ const cc::LocalSurfaceId& local_surface_id,
+ const gfx::Rect& damage_rect) {
+ // TODO(fsamuel, staraz): Implement this.
+}
+
+void DisplayClientCompositorFrameSink::OnNeedsBeginFrames(
+ bool needs_begin_frames) {
+ DCHECK(thread_checker_->CalledOnValidThread());
+ compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames);
+}
+
+void DisplayClientCompositorFrameSink::OnDidFinishFrame(
+ const cc::BeginFrameAck& ack) {
+ // TODO(eseckler): Pass on the ack to compositor_frame_sink_.
+}
+
+} // namespace ws
+} // namespace ui
« no previous file with comments | « services/ui/ws/display_client_compositor_frame_sink.h ('k') | services/ui/ws/frame_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698