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

Unified Diff: components/exo/exo_compositor_frame_sink.cc

Issue 2493223002: Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: Added ExoCompositorFrameSink::SubmitCompositorFrame(). Created 4 years, 1 month 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: components/exo/exo_compositor_frame_sink.cc
diff --git a/components/exo/exo_compositor_frame_sink.cc b/components/exo/exo_compositor_frame_sink.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ae690fef08e9a662199660fd75ee69bb98cadf1d
--- /dev/null
+++ b/components/exo/exo_compositor_frame_sink.cc
@@ -0,0 +1,114 @@
+// Copyright 2016 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 "components/exo/exo_compositor_frame_sink.h"
+
+#include "cc/surfaces/surface_manager.h"
+#include "ui/aura/env.h"
+
+namespace exo {
+
+////////////////////////////////////////////////////////////////////////////////
+// ExoComopositorFrameSink, public:
+
+ExoCompositorFrameSink::ExoCompositorFrameSink(
+ const cc::FrameSinkId& frame_sink_id,
+ cc::SurfaceManager* surface_manager)
+ : frame_sink_id_(frame_sink_id),
+ surface_manager_(surface_manager),
+ surface_factory_(frame_sink_id, surface_manager, this) {
+ surface_manager_->RegisterFrameSinkId(frame_sink_id_);
+ surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// cc::SurfaceFactoryClient overrides:
+
+void ExoCompositorFrameSink::ReturnResources(
+ const cc::ReturnedResourceArray& resources) {
+ for (auto& resource : resources) {
+ auto it = release_callbacks_.find(resource.id);
+ DCHECK(it != release_callbacks_.end());
+ it->second.second->Run(resource.sync_token, resource.lost);
+ release_callbacks_.erase(it);
+ }
+}
+
+void ExoCompositorFrameSink::WillDrawSurface(const cc::LocalFrameId& id,
+ const gfx::Rect& damage_rect) {}
+
+void ExoCompositorFrameSink::SetBeginFrameSource(
+ cc::BeginFrameSource* begin_frame_source) {
+ if (begin_frame_source_ && added_frame_observer_) {
+ begin_frame_source_->RemoveObserver(this);
+ added_frame_observer_ = false;
+ }
+ begin_frame_source_ = begin_frame_source;
+ UpdateNeedsBeginFrameInternal();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// To be cc::mojom::MojoCompositorFrameSink overrides:
+
+void ExoCompositorFrameSink::SubmitCompositorFrame(cc::CompositorFrame frame) {
+ cc::LocalFrameId old_local_frame_id = local_frame_id_;
+ if (!local_frame_id_.is_valid() /* || needs_commit_to_new_surface_*/) {
Fady Samuel 2016/11/15 23:19:46 Remove commented out code.
Alex Z. 2016/12/07 21:13:43 Done.
+ local_frame_id_ = id_allocator_.GenerateId();
+ surface_factory_.Create(local_frame_id_);
+ }
+ // UpdateSurface(true); // surface_factory.SubmitCompositorFrame happens here
Fady Samuel 2016/11/15 23:19:46 Remove commented out code
Alex Z. 2016/12/07 21:13:43 Done.
+ surface_factory_.SubmitCompositorFrame(local_frame_id_, std::move(frame),
+ cc::SurfaceFactory::DrawCallback());
+ if (old_local_frame_id.is_valid() && old_local_frame_id != local_frame_id_) {
+ surface_factory_.SetPreviousFrameSurface(local_frame_id_,
+ old_local_frame_id);
+ surface_factory_.Destroy(old_local_frame_id);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// cc::BeginFrameObserver overrides:
+
+void ExoCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) {
+ UpdateNeedsBeginFrameInternal();
+ last_begin_frame_args_ = args;
+}
+
+const cc::BeginFrameArgs& ExoCompositorFrameSink::LastUsedBeginFrameArgs()
+ const {
+ return last_begin_frame_args_;
+}
+
+void ExoCompositorFrameSink::OnBeginFrameSourcePausedChanged(bool paused) {}
+
+////////////////////////////////////////////////////////////////////////////////
+// ExoComopositorFrameSink, private:
+
+ExoCompositorFrameSink::~ExoCompositorFrameSink() {
+ if (surface_factory_.manager())
+ surface_factory_.manager()->InvalidateFrameSinkId(frame_sink_id_);
+
+ surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id());
+}
+
+void ExoCompositorFrameSink::UpdateNeedsBeginFrameInternal() {
+ if (!begin_frame_source_)
+ return;
+
+ if (needs_begin_frame_ == added_frame_observer_)
+ return;
+
+ added_frame_observer_ = needs_begin_frame_;
+ if (needs_begin_frame_)
+ begin_frame_source_->AddObserver(this);
+ else
+ begin_frame_source_->RemoveObserver(this);
+}
+
+void ExoCompositorFrameSink::DidRecieveCompositorFrameAck() {
+ // TODO(staraz): Clean up resources
+ ack_pending_count_--;
+}
+
+} // namespace exo

Powered by Google App Engine
This is Rietveld 408576698