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 <list> |
| 9 #include <memory> |
| 10 #include <set> |
| 11 #include <utility> |
| 12 |
| 13 #include "base/callback.h" |
| 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" |
| 18 #include "cc/ipc/compositor_frame.mojom.h" |
| 19 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" |
| 20 #include "cc/resources/transferable_resource.h" |
| 21 #include "cc/scheduler/begin_frame_source.h" |
| 22 #include "cc/surfaces/surface_factory.h" |
| 23 #include "cc/surfaces/surface_factory_client.h" |
| 24 #include "cc/surfaces/surface_id_allocator.h" |
| 25 #include "mojo/public/cpp/bindings/binding.h" |
| 26 #include "third_party/skia/include/core/SkRegion.h" |
| 27 #include "third_party/skia/include/core/SkXfermode.h" |
| 28 #include "ui/aura/window.h" |
| 29 #include "ui/aura/window_observer.h" |
| 30 #include "ui/gfx/geometry/rect.h" |
| 31 |
| 32 namespace cc { |
| 33 class SurfaceFactory; |
| 34 } |
| 35 |
| 36 namespace exo { |
| 37 class CompositorFrameSinkHolder; |
| 38 |
| 39 // This class owns the SurfaceFactory and keeps track of references to the |
| 40 // contents of Buffers. It's keeped alive by references from |
| 41 // release_callbacks_. It's destroyed when its owning Surface is destroyed and |
| 42 // the last outstanding release callback is called. |
| 43 class ExoCompositorFrameSink : public base::RefCounted<ExoCompositorFrameSink>, |
| 44 public cc::SurfaceFactoryClient, |
| 45 public cc::BeginFrameObserver { |
| 46 public: |
| 47 ExoCompositorFrameSink(const cc::FrameSinkId& frame_sink_id, |
| 48 cc::SurfaceManager* surface_manager, |
| 49 cc::mojom::MojoCompositorFrameSinkClientPtr client); |
| 50 |
| 51 // To be cc::mojom::MojoCompositorFrameSink: |
| 52 void SubmitCompositorFrame(const cc::LocalFrameId& local_frame_id, |
| 53 cc::CompositorFrame frame); |
| 54 |
| 55 private: |
| 56 friend class base::RefCounted<ExoCompositorFrameSink>; |
| 57 |
| 58 ~ExoCompositorFrameSink() override; |
| 59 void UpdateNeedsBeginFrameInternal(); |
| 60 void DidReceiveCompositorFrameAck(); |
| 61 |
| 62 // cc::SurfaceFactoryClient: |
| 63 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 64 void WillDrawSurface(const cc::LocalFrameId& id, |
| 65 const gfx::Rect& damage_rect) override; |
| 66 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
| 67 |
| 68 // cc::BeginFrameObserver: |
| 69 void OnBeginFrame(const cc::BeginFrameArgs& args) override; |
| 70 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; |
| 71 void OnBeginFrameSourcePausedChanged(bool paused) override; |
| 72 |
| 73 const cc::FrameSinkId frame_sink_id_; |
| 74 cc::LocalFrameId last_local_frame_id_; |
| 75 |
| 76 cc::SurfaceManager* surface_manager_; |
| 77 cc::SurfaceFactory surface_factory_; |
| 78 |
| 79 // TODO(staraz): This should be cc::mojom::MojoCompositorFrameSinkClientPtr |
| 80 cc::mojom::MojoCompositorFrameSinkClientPtr client_; |
| 81 |
| 82 int ack_pending_count_ = 0; |
| 83 cc::ReturnedResourceArray surface_returned_resources_; |
| 84 |
| 85 cc::BeginFrameSource* begin_frame_source_ = nullptr; |
| 86 |
| 87 gfx::Size last_submitted_frame_size_; |
| 88 |
| 89 cc::BeginFrameArgs last_begin_frame_args_; |
| 90 |
| 91 bool needs_begin_frame_ = false; |
| 92 bool added_frame_observer_ = false; |
| 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(ExoCompositorFrameSink); |
| 95 }; |
| 96 |
| 97 } // namespace exo |
| 98 |
| 99 #endif // COMPONENTS_EXO_EXO_COMPOSITOR_FRAME_SINK_H_ |
OLD | NEW |