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

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

Issue 2868473002: Implement aura::Window::CreateCompositorFrameSink() (Closed)
Patch Set: Address review issues Created 3 years, 7 months 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_EXO_COMPOSITOR_FRAME_SINK_HOLDER_H_ 5 #ifndef COMPONENTS_EXO_COMPOSITOR_FRAME_SINK_HOLDER_H_
6 #define COMPONENTS_EXO_COMPOSITOR_FRAME_SINK_HOLDER_H_ 6 #define COMPONENTS_EXO_COMPOSITOR_FRAME_SINK_HOLDER_H_
7 7
8 #include <list>
9 #include <map>
10 #include <memory> 8 #include <memory>
11 9
12 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" 10 #include "base/containers/flat_map.h"
11 #include "cc/output/compositor_frame_sink_client.h"
13 #include "cc/resources/release_callback.h" 12 #include "cc/resources/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" 13 #include "components/exo/surface_observer.h"
18 #include "mojo/public/cpp/bindings/binding.h" 14
15 namespace cc {
16 class CompositorFrameSink;
17 }
19 18
20 namespace exo { 19 namespace exo {
21 class Surface; 20 class Surface;
22 21
23 // This class talks to MojoCompositorFrameSink and keeps track of references to 22 // This class talks to MojoCompositorFrameSink and keeps track of references to
24 // the contents of Buffers. It's keeped alive by references from 23 // the contents of Buffers. It's keeped alive by references from
25 // release_callbacks_. It's destroyed when its owning Surface is destroyed and 24 // release_callbacks_. It's destroyed when its owning Surface is destroyed and
26 // the last outstanding release callback is called. 25 // the last outstanding release callback is called.
27 class CompositorFrameSinkHolder 26 class CompositorFrameSinkHolder : public cc::CompositorFrameSinkClient,
28 : public base::RefCounted<CompositorFrameSinkHolder>, 27 public SurfaceObserver {
29 public cc::ExternalBeginFrameSourceClient,
30 public cc::mojom::MojoCompositorFrameSinkClient,
31 public SurfaceObserver {
32 public: 28 public:
33 CompositorFrameSinkHolder(Surface* surface, 29 CompositorFrameSinkHolder(
34 const cc::FrameSinkId& frame_sink_id, 30 Surface* surface,
35 cc::SurfaceManager* surface_manager); 31 std::unique_ptr<cc::CompositorFrameSink> frame_sink);
32 ~CompositorFrameSinkHolder() override;
36 33
37 bool HasReleaseCallbackForResource(cc::ResourceId id); 34 bool HasReleaseCallbackForResource(cc::ResourceId id);
38 void SetResourceReleaseCallback(cc::ResourceId id, 35 void SetResourceReleaseCallback(cc::ResourceId id,
39 const cc::ReleaseCallback& callback); 36 const cc::ReleaseCallback& callback);
40 37
41 CompositorFrameSink* GetCompositorFrameSink() { return frame_sink_.get(); } 38 cc::CompositorFrameSink* GetCompositorFrameSink() {
39 return frame_sink_.get();
40 }
42 41
43 base::WeakPtr<CompositorFrameSinkHolder> GetWeakPtr() { 42 base::WeakPtr<CompositorFrameSinkHolder> GetWeakPtr() {
44 return weak_factory_.GetWeakPtr(); 43 return weak_factory_.GetWeakPtr();
45 } 44 }
46 45
47 // Overridden from cc::mojom::MojoCompositorFrameSinkClient: 46 // Overridden from cc::CompositorFrameSinkClient:
48 void DidReceiveCompositorFrameAck( 47 void SetBeginFrameSource(cc::BeginFrameSource* source) override;
49 const cc::ReturnedResourceArray& resources) override;
50 void OnBeginFrame(const cc::BeginFrameArgs& args) override;
51 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; 48 void ReclaimResources(const cc::ReturnedResourceArray& resources) override;
52 49 void SetTreeActivationCallback(const base::Closure& callback) override {}
53 // Overridden from cc::ExternalBeginFrameSourceClient: 50 void DidReceiveCompositorFrameAck() override;
54 void OnNeedsBeginFrames(bool needs_begin_frames) override; 51 void DidLoseCompositorFrameSink() override {}
55 void OnDidFinishFrame(const cc::BeginFrameAck& ack) override; 52 void OnDraw(const gfx::Transform& transform,
53 const gfx::Rect& viewport,
54 bool resourceless_software_draw) override {}
55 void SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override {}
56 void SetExternalTilePriorityConstraints(
57 const gfx::Rect& viewport_rect,
58 const gfx::Transform& transform) override {}
56 59
57 // Overridden from SurfaceObserver: 60 // Overridden from SurfaceObserver:
58 void OnSurfaceDestroying(Surface* surface) override; 61 void OnSurfaceDestroying(Surface* surface) override;
59 62
60 private: 63 private:
61 friend class base::RefCounted<CompositorFrameSinkHolder>;
62
63 ~CompositorFrameSinkHolder() override;
64 64
65 // A collection of callbacks used to release resources. 65 // A collection of callbacks used to release resources.
66 using ResourceReleaseCallbackMap = std::map<int, cc::ReleaseCallback>; 66 using ResourceReleaseCallbackMap = base::flat_map<int, cc::ReleaseCallback>;
67 ResourceReleaseCallbackMap release_callbacks_; 67 ResourceReleaseCallbackMap release_callbacks_;
68 68
69 Surface* surface_; 69 Surface* surface_;
70 std::unique_ptr<CompositorFrameSink> frame_sink_; 70 std::unique_ptr<cc::CompositorFrameSink> frame_sink_;
71 std::unique_ptr<cc::ExternalBeginFrameSource> begin_frame_source_;
72 71
73 base::WeakPtrFactory<CompositorFrameSinkHolder> weak_factory_; 72 base::WeakPtrFactory<CompositorFrameSinkHolder> weak_factory_;
74 73
75 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkHolder); 74 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkHolder);
76 }; 75 };
77 76
78 } // namespace exo 77 } // namespace exo
79 78
80 #endif // COMPONENTS_EXO_COMPOSITOR_FRAME_SINK_HOLDER_H_ 79 #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