Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: components/exo/compositor_frame_sink_holder.h

Issue 2493223002: Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: Override DesktopMediaListAshTest::TearDown() to reset list_ Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/exo/compositor_frame_sink.cc ('k') | components/exo/compositor_frame_sink_holder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_COMPOSITOR_FRAME_SINK_HOLDER_H_
6 #define COMPONENTS_EXO_COMPOSITOR_FRAME_SINK_HOLDER_H_
7
8 #include <list>
9 #include <map>
10 #include <memory>
11
12 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h"
13 #include "cc/resources/single_release_callback.h"
14 #include "cc/resources/transferable_resource.h"
15 #include "cc/scheduler/begin_frame_source.h"
16 #include "components/exo/compositor_frame_sink.h"
17 #include "components/exo/surface_observer.h"
18 #include "mojo/public/cpp/bindings/binding.h"
19
20 namespace exo {
21 class Surface;
22
23 // This class talks to MojoCompositorFrameSink and keeps track of references to
24 // the contents of Buffers. It's keeped alive by references from
25 // release_callbacks_. It's destroyed when its owning Surface is destroyed and
26 // the last outstanding release callback is called.
27 class CompositorFrameSinkHolder
28 : public base::RefCounted<CompositorFrameSinkHolder>,
29 public cc::ExternalBeginFrameSourceClient,
30 public cc::mojom::MojoCompositorFrameSinkClient,
31 public cc::BeginFrameObserver,
32 public SurfaceObserver {
33 public:
34 CompositorFrameSinkHolder(
35 Surface* surface,
36 std::unique_ptr<CompositorFrameSink> frame_sink,
37 cc::mojom::MojoCompositorFrameSinkClientRequest request);
38
39 bool HasReleaseCallbackForResource(cc::ResourceId id);
40 void AddResourceReleaseCallback(
41 cc::ResourceId id,
42 std::unique_ptr<cc::SingleReleaseCallback> callback);
43
44 CompositorFrameSink* GetCompositorFrameSink() { return frame_sink_.get(); }
45
46 base::WeakPtr<CompositorFrameSinkHolder> GetWeakPtr() {
47 return weak_factory_.GetWeakPtr();
48 }
49
50 using FrameCallback = base::Callback<void(base::TimeTicks frame_time)>;
51 void ActivateFrameCallbacks(std::list<FrameCallback>* frame_callbacks);
52 void CancelFrameCallbacks();
53
54 void SetNeedsBeginFrame(bool needs_begin_frame);
55
56 void Satisfy(const cc::SurfaceSequence& sequence);
57 void Require(const cc::SurfaceId& id, const cc::SurfaceSequence& sequence);
58
59 // Overridden from cc::mojom::MojoCompositorFrameSinkClient:
60 void DidReceiveCompositorFrameAck() override;
61 void OnBeginFrame(const cc::BeginFrameArgs& args) override;
62 void ReclaimResources(const cc::ReturnedResourceArray& resources) override;
63 void WillDrawSurface() override;
64
65 // Overridden from cc::BeginFrameObserver:
66 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override;
67 void OnBeginFrameSourcePausedChanged(bool paused) override;
68
69 // Overridden from cc::ExternalBeginFrameSouceClient:
70 void OnNeedsBeginFrames(bool needs_begin_frames) override;
71
72 // Overridden from SurfaceObserver:
73 void OnSurfaceDestroying(Surface* surface) override;
74
75 private:
76 friend class base::RefCounted<CompositorFrameSinkHolder>;
77
78 ~CompositorFrameSinkHolder() override;
79
80 void UpdateNeedsBeginFrame();
81
82 // Each release callback holds a reference to the CompositorFrameSinkHolder
83 // itself to keep it alive. Running and erasing the callbacks might result in
84 // the instance being destroyed. Therefore, we should not access any member
85 // variables after running and erasing the callbacks.
86 using ResourceReleaseCallbackMap =
87 std::map<int,
88 std::pair<scoped_refptr<CompositorFrameSinkHolder>,
89 std::unique_ptr<cc::SingleReleaseCallback>>>;
90 ResourceReleaseCallbackMap release_callbacks_;
91
92 Surface* surface_;
93 std::unique_ptr<CompositorFrameSink> frame_sink_;
94
95 std::list<FrameCallback> active_frame_callbacks_;
96 std::unique_ptr<cc::ExternalBeginFrameSource> begin_frame_source_;
97 bool needs_begin_frame_ = false;
98 cc::BeginFrameArgs last_begin_frame_args_;
99 mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient> binding_;
100
101 base::WeakPtrFactory<CompositorFrameSinkHolder> weak_factory_;
102
103 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkHolder);
104 };
105
106 } // namespace exo
107
108 #endif // COMPONENTS_EXO_COMPOSITOR_FRAME_SINK_HOLDER_H_
OLDNEW
« no previous file with comments | « components/exo/compositor_frame_sink.cc ('k') | components/exo/compositor_frame_sink_holder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698