Index: components/exo/compositor_frame_sink_holder.h |
diff --git a/components/exo/compositor_frame_sink_holder.h b/components/exo/compositor_frame_sink_holder.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9c6cefd9d127dfae9732b2b187d9f98ba378e433 |
--- /dev/null |
+++ b/components/exo/compositor_frame_sink_holder.h |
@@ -0,0 +1,93 @@ |
+// 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. |
+ |
+#ifndef COMPONENTS_EXO_COMPOSITOR_FRAME_SINK_HOLDER_H_ |
+#define COMPONENTS_EXO_COMPOSITOR_FRAME_SINK_HOLDER_H_ |
+ |
+#include <list> |
+#include <map> |
+#include <memory> |
+ |
+#include "cc/ipc/mojo_compositor_frame_sink.mojom.h" |
+#include "cc/resources/single_release_callback.h" |
+#include "cc/resources/transferable_resource.h" |
+#include "cc/scheduler/begin_frame_source.h" |
+#include "components/exo/exo_compositor_frame_sink.h" |
+#include "mojo/public/cpp/bindings/binding.h" |
+ |
+namespace exo { |
+class Surface; |
+ |
+using FrameCallback = base::Callback<void(base::TimeTicks frame_time)>; |
+ |
+class CompositorFrameSinkHolder |
+ : public base::RefCounted<CompositorFrameSinkHolder>, |
+ public cc::mojom::MojoCompositorFrameSinkClient, |
+ public cc::ExternalBeginFrameSourceClient, |
+ public cc::BeginFrameObserver { |
+ public: |
+ CompositorFrameSinkHolder( |
+ std::unique_ptr<ExoCompositorFrameSink> compositor_frame_sink, |
+ base::WeakPtr<Surface> surface, |
+ cc::mojom::MojoCompositorFrameSinkClientRequest request); |
+ |
+ bool HasReleaseCallbacks(cc::ResourceId id); |
+ bool IsReleaseCallbacksEmpty(); |
+ void AddResourceReleaseCallback( |
+ cc::ResourceId id, |
+ std::unique_ptr<cc::SingleReleaseCallback> callback); |
+ |
+ void ActivateFrameCallbacks(std::list<FrameCallback>& frame_callbacks); |
+ void CancelFrameCallbacks(); |
+ |
+ void EvictFrame(); |
+ |
+ void SubmitCompositorFrame(const cc::LocalFrameId& local_frame_id, |
+ cc::CompositorFrame frame); |
+ void UpdateNeedsBeginFrame(); |
+ void SetNeedsBeginFrame(bool needs_begin_frame); |
+ |
+ // cc::mojom::MojoCompositorFrameSinkClient: |
+ void DidReceiveCompositorFrameAck() override; |
+ void OnBeginFrame(const cc::BeginFrameArgs& args) override; |
+ void ReclaimResources(const cc::ReturnedResourceArray& resources) override; |
+ void WillDrawSurface() override; |
+ |
+ const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; |
+ void OnBeginFrameSourcePausedChanged(bool paused) override; |
+ |
+ private: |
+ friend class base::RefCounted<CompositorFrameSinkHolder>; |
+ |
+ ~CompositorFrameSinkHolder() override; |
+ |
+ // cc::ExternalBeginFrameSouceClient: |
+ void OnNeedsBeginFrames(bool needs_begin_frames) override; |
+ |
+ using ResourceReleaseCallbacks = |
+ std::map<int, |
+ std::pair<scoped_refptr<CompositorFrameSinkHolder>, |
+ std::unique_ptr<cc::SingleReleaseCallback>>>; |
+ ResourceReleaseCallbacks release_callbacks_; |
+ |
+ std::unique_ptr<ExoCompositorFrameSink> compositor_frame_sink_; |
Fady Samuel
2016/11/30 16:41:57
Make this cc::mojom::MojoCompositorFrameSink
Alex Z.
2016/11/30 20:32:53
Done.
|
+ |
+ base::WeakPtr<Surface> surface_; |
+ |
+ std::list<FrameCallback> active_frame_callbacks_; |
+ |
+ std::unique_ptr<cc::ExternalBeginFrameSource> begin_frame_source_; |
+ |
+ bool needs_begin_frame_ = false; |
+ |
+ cc::BeginFrameArgs last_begin_frame_args_; |
+ |
+ mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient> binding_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkHolder); |
+}; |
+ |
+} // namespace exo |
+ |
+#endif // COMPONENTS_EXO_COMPOSITOR_FRAME_SINK_HOLDER_H_ |