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

Unified Diff: components/exo/compositor_frame_sink_holder.cc

Issue 2493223002: Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: Moved CompositorFrameSink implementation details in to CompositorFrameSinkSupport; addressed commen… Created 4 years 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/compositor_frame_sink_holder.h ('k') | components/exo/gamepad_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/compositor_frame_sink_holder.cc
diff --git a/components/exo/compositor_frame_sink_holder.cc b/components/exo/compositor_frame_sink_holder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..741944239d35994405c0075dd4425983c58f01de
--- /dev/null
+++ b/components/exo/compositor_frame_sink_holder.cc
@@ -0,0 +1,132 @@
+// 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/compositor_frame_sink_holder.h"
+
+#include "cc/resources/returned_resource.h"
+#include "components/exo/surface.h"
+
+namespace exo {
+
+////////////////////////////////////////////////////////////////////////////////
+// CompositorFrameSinkHolder, public:
+CompositorFrameSinkHolder::CompositorFrameSinkHolder(
+ cc::mojom::MojoCompositorFrameSinkPtr compositor_frame_sink,
+ base::WeakPtr<Surface> surface,
+ cc::mojom::MojoCompositorFrameSinkClientRequest request)
+ : compositor_frame_sink_(std::move(compositor_frame_sink)),
+ surface_(surface),
+ begin_frame_source_(base::MakeUnique<cc::ExternalBeginFrameSource>(this)),
+ binding_(this, std::move(request)) {}
+
+bool CompositorFrameSinkHolder::HasReleaseCallbacks(cc::ResourceId id) {
+ return release_callbacks_.count(id);
+}
+
+bool CompositorFrameSinkHolder::IsReleaseCallbacksEmpty() {
+ return release_callbacks_.size() == 0;
+}
+
+void CompositorFrameSinkHolder::AddResourceReleaseCallback(
+ cc::ResourceId id,
+ std::unique_ptr<cc::SingleReleaseCallback> callback) {
+ release_callbacks_[id] = std::make_pair(this, std::move(callback));
+}
+
+void CompositorFrameSinkHolder::ActivateFrameCallbacks(
+ std::list<FrameCallback>& frame_callbacks) {
+ active_frame_callbacks_.splice(active_frame_callbacks_.end(),
+ frame_callbacks);
+}
+
+void CompositorFrameSinkHolder::CancelFrameCallbacks() {
+ // Call pending frame callbacks with a null frame time to indicate that they
+ // have been cancelled.
+ for (const auto& frame_callback : active_frame_callbacks_)
+ frame_callback.Run(base::TimeTicks());
+}
+
+void CompositorFrameSinkHolder::EvictFrame() {
Fady Samuel 2016/12/06 20:14:40 How about just providing an accessor to cc::mojom:
Alex Z. 2016/12/06 21:09:38 Done.
+ compositor_frame_sink_->EvictFrame();
+}
+
+void CompositorFrameSinkHolder::UpdateNeedsBeginFrame() {
+ if (!begin_frame_source_)
+ return;
+
+ bool needs_begin_frame = !active_frame_callbacks_.empty();
+ if (needs_begin_frame == needs_begin_frame_)
+ return;
+
+ needs_begin_frame_ = needs_begin_frame;
+ OnNeedsBeginFrames(needs_begin_frame_);
+}
+
+void CompositorFrameSinkHolder::SetNeedsBeginFrame(bool needs_begin_frame) {
+ needs_begin_frame_ = needs_begin_frame;
+ OnNeedsBeginFrames(needs_begin_frame);
+}
+
+void CompositorFrameSinkHolder::SubmitCompositorFrame(
+ const cc::LocalFrameId& local_frame_id,
+ cc::CompositorFrame frame) {
+ if (compositor_frame_sink_) {
+ compositor_frame_sink_->SubmitCompositorFrame(local_frame_id,
+ std::move(frame));
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// cc::mojom::MojoCompositorFrameSinkClient overrides:
+
+void CompositorFrameSinkHolder::DidReceiveCompositorFrameAck() {
+ // TODO(staraz): Implement this
+}
+
+void CompositorFrameSinkHolder::OnBeginFrame(const cc::BeginFrameArgs& args) {
+ while (!active_frame_callbacks_.empty()) {
+ active_frame_callbacks_.front().Run(args.frame_time);
+ active_frame_callbacks_.pop_front();
+ }
+ begin_frame_source_->OnBeginFrame(args);
+}
+
+void CompositorFrameSinkHolder::ReclaimResources(
+ const cc::ReturnedResourceArray& resources) {
+ scoped_refptr<CompositorFrameSinkHolder> holder(this);
+ 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);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// cc::BeginFrameObserver:
+const cc::BeginFrameArgs& CompositorFrameSinkHolder::LastUsedBeginFrameArgs()
+ const {
+ return last_begin_frame_args_;
+}
+
+void CompositorFrameSinkHolder::OnBeginFrameSourcePausedChanged(bool paused) {}
+
+////////////////////////////////////////////////////////////////////////////////
+// ExoComopositorFrameSink, private:
+
+CompositorFrameSinkHolder::~CompositorFrameSinkHolder() {}
+
+void CompositorFrameSinkHolder::WillDrawSurface() {
+ if (surface_)
+ surface_->WillDraw();
+
+ UpdateNeedsBeginFrame();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// cc::ExternalBeginFrameSouceClient:
+void CompositorFrameSinkHolder::OnNeedsBeginFrames(bool needs_begin_frames) {
+ compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames);
+}
+} // namespace exo
« no previous file with comments | « components/exo/compositor_frame_sink_holder.h ('k') | components/exo/gamepad_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698