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 #include <list> |
| 6 #include <memory> |
| 7 #include <set> |
| 8 #include <utility> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/observer_list.h" |
| 15 #include "cc/ipc/compositor_frame.mojom.h" |
| 16 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" |
| 17 #include "cc/resources/transferable_resource.h" |
| 18 #include "cc/scheduler/begin_frame_source.h" |
| 19 #include "cc/surfaces/surface_factory.h" |
| 20 #include "cc/surfaces/surface_factory_client.h" |
| 21 #include "cc/surfaces/surface_id_allocator.h" |
| 22 #include "mojo/public/cpp/bindings/binding.h" |
| 23 #include "third_party/skia/include/core/SkRegion.h" |
| 24 #include "third_party/skia/include/core/SkXfermode.h" |
| 25 #include "ui/aura/window.h" |
| 26 #include "ui/aura/window_observer.h" |
| 27 #include "ui/gfx/geometry/rect.h" |
| 28 |
| 29 namespace cc { |
| 30 class SurfaceFactory; |
| 31 } |
| 32 |
| 33 namespace exo { |
| 34 |
| 35 // This class owns the SurfaceFactory and keeps track of references to the |
| 36 // contents of Buffers. It's keeped alive by references from |
| 37 // release_callbacks_. It's destroyed when its owning Surface is destroyed and |
| 38 // the last outstanding release callback is called. |
| 39 class ExoCompositorFrameSink : public base::RefCounted<ExoCompositorFrameSink>, |
| 40 public cc::SurfaceFactoryClient, |
| 41 public cc::BeginFrameObserver { |
| 42 public: |
| 43 ExoCompositorFrameSink(const cc::FrameSinkId& frame_sink_id); |
| 44 |
| 45 void Init(cc::SurfaceManager* surface_manager); |
| 46 void UnregisterSurface(const cc::SurfaceId& surface_id); |
| 47 const cc::SurfaceId& CommitToNewSurface( |
| 48 const cc::LocalFrameId& old_local_frame_id); |
| 49 |
| 50 // Overridden from cc::SurfaceFactoryClient: |
| 51 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 52 void WillDrawSurface(const cc::LocalFrameId& id, |
| 53 const gfx::Rect& damage_rect) override; |
| 54 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
| 55 |
| 56 // cc::BeginFrameObserver: |
| 57 void OnBeginFrame(const cc::BeginFrameArgs& args) override; |
| 58 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; |
| 59 void OnBeginFrameSourcePausedChanged(bool paused) override; |
| 60 |
| 61 const cc::FrameSinkId& frame_sink_id() { return frame_sink_id_; } |
| 62 |
| 63 private: |
| 64 friend class base::RefCounted<ExoCompositorFrameSink>; |
| 65 friend class Surface; |
| 66 |
| 67 ~ExoCompositorFrameSink() override; |
| 68 void UpdateNeedsBeginFrameInternal(); |
| 69 |
| 70 std::map<int, |
| 71 std::pair<scoped_refptr<ExoCompositorFrameSink>, |
| 72 std::unique_ptr<cc::SingleReleaseCallback>>> |
| 73 release_callbacks_; |
| 74 cc::FrameSinkId frame_sink_id_; |
| 75 std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_; |
| 76 std::unique_ptr<cc::SurfaceFactory> surface_factory_; |
| 77 |
| 78 cc::BeginFrameSource* begin_frame_source_ = nullptr; |
| 79 |
| 80 cc::BeginFrameArgs last_begin_frame_args_; |
| 81 |
| 82 bool needs_begin_frame_ = false; |
| 83 bool added_frame_observer_ = false; |
| 84 }; |
| 85 |
| 86 } // namespace exo |
OLD | NEW |