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 cc::SurfaceManager* surface_manager); | |
45 | |
46 // To be cc::mojom::MojoCompositorFrameSink: | |
47 void SubmitCompositorFrame(cc::CompositorFrame frame, | |
48 const cc::LocalFrameId& local_frame_id); | |
Fady Samuel
2016/11/16 21:29:40
nit: local_frame_id first.
Alex Z.
2016/11/17 21:32:27
Done.
| |
49 | |
50 std::map<int, | |
51 std::pair<scoped_refptr<ExoCompositorFrameSink>, | |
Fady Samuel
2016/11/16 21:29:40
TODO to remove this. Also, this is a ginormous typ
Alex Z.
2016/11/23 14:25:04
Done.
| |
52 std::unique_ptr<cc::SingleReleaseCallback>>>* | |
53 release_callbacks() { | |
54 return &release_callbacks_; | |
55 } | |
56 | |
57 private: | |
58 friend class base::RefCounted<ExoCompositorFrameSink>; | |
59 | |
60 ~ExoCompositorFrameSink() override; | |
61 void UpdateNeedsBeginFrameInternal(); | |
62 void DidRecieveCompositorFrameAck(); | |
63 | |
64 // cc::SurfaceFactoryClient: | |
65 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | |
66 void WillDrawSurface(const cc::LocalFrameId& id, | |
67 const gfx::Rect& damage_rect) override; | |
68 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | |
69 | |
70 // cc::BeginFrameObserver: | |
71 void OnBeginFrame(const cc::BeginFrameArgs& args) override; | |
72 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; | |
73 void OnBeginFrameSourcePausedChanged(bool paused) override; | |
74 | |
75 std::map<int, | |
76 std::pair<scoped_refptr<ExoCompositorFrameSink>, | |
77 std::unique_ptr<cc::SingleReleaseCallback>>> | |
78 release_callbacks_; | |
79 const cc::FrameSinkId frame_sink_id_; | |
80 cc::LocalFrameId last_local_frame_id_; | |
81 | |
82 cc::SurfaceManager* surface_manager_; | |
83 cc::SurfaceFactory surface_factory_; | |
84 | |
85 int ack_pending_count_ = 0; | |
86 | |
87 cc::BeginFrameSource* begin_frame_source_ = nullptr; | |
88 | |
89 gfx::Size last_submitted_frame_size_; | |
90 | |
91 cc::BeginFrameArgs last_begin_frame_args_; | |
92 | |
93 bool needs_begin_frame_ = false; | |
94 bool added_frame_observer_ = false; | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(ExoCompositorFrameSink); | |
97 }; | |
98 | |
99 } // namespace exo | |
OLD | NEW |