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

Unified Diff: components/exo/exo_compositor_frame_sink.cc

Issue 2493223002: Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: rebase 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
« no previous file with comments | « components/exo/exo_compositor_frame_sink.h ('k') | components/exo/surface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a18908b0d13f71867b1452c5797a04f37290ff0d
--- /dev/null
+++ b/components/exo/exo_compositor_frame_sink.cc
@@ -0,0 +1,108 @@
+// 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)
+ : frame_sink_id_(frame_sink_id) {
+ id_allocator_.reset(new cc::SurfaceIdAllocator());
+}
+
+void ExoCompositorFrameSink::Init(cc::SurfaceManager* surface_manager) {
+ surface_factory_.reset(
+ new cc::SurfaceFactory(frame_sink_id_, surface_manager, this));
+}
+
+void ExoCompositorFrameSink::UnregisterSurface(
+ const cc::SurfaceId& surface_id) {
+ if (surface_id.local_frame_id().is_valid())
+ surface_factory_->Destroy(surface_id.local_frame_id());
+}
+
+const cc::SurfaceId& ExoCompositorFrameSink::CommitToNewSurface(
+ const cc::LocalFrameId& old_local_frame_id) {
+ cc::LocalFrameId local_frame_id = id_allocator_->GenerateId();
+ surface_factory_->Create(local_frame_id);
+
+ if (old_local_frame_id.is_valid()) {
+ surface_factory_->SetPreviousFrameSurface(local_frame_id,
+ old_local_frame_id);
+ surface_factory_->Destroy(old_local_frame_id);
+ }
+
+ return std::move(cc::SurfaceId(frame_sink_id_, local_frame_id));
Fady Samuel 2016/11/15 16:01:32 This isn't safe. You're returning a reference to a
Alex Z. 2016/11/15 22:27:30 Done.
+}
+////////////////////////////////////////////////////////////////////////////////
+// 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();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// 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_);
+}
+
+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);
+}
+
+} // namespace exo
« no previous file with comments | « components/exo/exo_compositor_frame_sink.h ('k') | components/exo/surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698