OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_EXO_EXO_COMPOSITOR_FRAME_SINK_H_ |
| 6 #define COMPONENTS_EXO_EXO_COMPOSITOR_FRAME_SINK_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <utility> |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 #include "cc/ipc/compositor_frame.mojom.h" |
| 15 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" |
| 16 #include "cc/resources/transferable_resource.h" |
| 17 #include "cc/scheduler/begin_frame_source.h" |
| 18 #include "cc/surfaces/surface_factory.h" |
| 19 #include "cc/surfaces/surface_factory_client.h" |
| 20 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 21 #include "ui/gfx/geometry/rect.h" |
| 22 |
| 23 namespace cc { |
| 24 class SurfaceFactory; |
| 25 } |
| 26 |
| 27 namespace exo { |
| 28 |
| 29 // This class owns the SurfaceFactory and keeps track of references to the |
| 30 // contents of Buffers. It's keeped alive by references from |
| 31 // release_callbacks_. It's destroyed when its owning Surface is destroyed and |
| 32 // the last outstanding release callback is called. |
| 33 class CompositorFrameSink : public cc::SurfaceFactoryClient, |
| 34 public cc::BeginFrameObserver, |
| 35 public cc::mojom::MojoCompositorFrameSink { |
| 36 public: |
| 37 static void Create(const cc::FrameSinkId& frame_sink_id, |
| 38 cc::SurfaceManager* surface_manager, |
| 39 cc::mojom::MojoCompositorFrameSinkClientPtr client, |
| 40 cc::mojom::MojoCompositorFrameSinkRequest request); |
| 41 |
| 42 CompositorFrameSink(const cc::FrameSinkId& frame_sink_id, |
| 43 cc::SurfaceManager* surface_manager, |
| 44 cc::mojom::MojoCompositorFrameSinkClientPtr client); |
| 45 |
| 46 ~CompositorFrameSink() override; |
| 47 |
| 48 // cc::mojom::MojoCompositorFrameSink: |
| 49 void SetNeedsBeginFrame(bool needs_begin_frame) override; |
| 50 void SubmitCompositorFrame(const cc::LocalFrameId& local_frame_id, |
| 51 cc::CompositorFrame frame) override; |
| 52 void EvictFrame() override; |
| 53 |
| 54 private: |
| 55 void UpdateNeedsBeginFrameInternal(); |
| 56 void DidReceiveCompositorFrameAck(); |
| 57 |
| 58 // cc::SurfaceFactoryClient: |
| 59 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 60 void WillDrawSurface(const cc::LocalFrameId& id, |
| 61 const gfx::Rect& damage_rect) override; |
| 62 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
| 63 |
| 64 // cc::BeginFrameObserver: |
| 65 void OnBeginFrame(const cc::BeginFrameArgs& args) override; |
| 66 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; |
| 67 void OnBeginFrameSourcePausedChanged(bool paused) override; |
| 68 |
| 69 const cc::FrameSinkId frame_sink_id_; |
| 70 |
| 71 cc::SurfaceManager* surface_manager_; |
| 72 cc::SurfaceFactory surface_factory_; |
| 73 |
| 74 cc::mojom::MojoCompositorFrameSinkClientPtr client_; |
| 75 |
| 76 int ack_pending_count_ = 0; |
| 77 cc::ReturnedResourceArray surface_returned_resources_; |
| 78 |
| 79 cc::BeginFrameSource* begin_frame_source_ = nullptr; |
| 80 |
| 81 gfx::Size last_submitted_frame_size_; |
| 82 |
| 83 cc::BeginFrameArgs last_begin_frame_args_; |
| 84 |
| 85 bool needs_begin_frame_ = false; |
| 86 bool added_frame_observer_ = false; |
| 87 |
| 88 mojo::StrongBindingPtr<cc::mojom::MojoCompositorFrameSink> binding_; |
| 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSink); |
| 91 }; |
| 92 |
| 93 } // namespace exo |
| 94 |
| 95 #endif // COMPONENTS_EXO_EXO_COMPOSITOR_FRAME_SINK_H_ |
OLD | NEW |