OLD | NEW |
---|---|
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 CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ | 5 #ifndef CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ |
6 #define CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ | 6 #define CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <unordered_set> | 9 #include <unordered_set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 25 matching lines...) Expand all Loading... | |
36 SurfaceManager* surface_manager, | 36 SurfaceManager* surface_manager, |
37 const FrameSinkId& frame_sink_id, | 37 const FrameSinkId& frame_sink_id, |
38 bool is_root, | 38 bool is_root, |
39 bool handles_frame_sink_id_invalidation, | 39 bool handles_frame_sink_id_invalidation, |
40 bool needs_sync_points); | 40 bool needs_sync_points); |
41 | 41 |
42 ~CompositorFrameSinkSupport() override; | 42 ~CompositorFrameSinkSupport() override; |
43 | 43 |
44 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } | 44 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } |
45 | 45 |
46 Surface* current_surface_for_testing() { return current_surface_.get(); } | |
47 SurfaceManager* surface_manager() { return surface_manager_; } | 46 SurfaceManager* surface_manager() { return surface_manager_; } |
48 bool needs_sync_points() { return needs_sync_points_; } | 47 bool needs_sync_points() { return needs_sync_points_; } |
49 | 48 |
50 // SurfaceResourceHolderClient implementation. | 49 // SurfaceResourceHolderClient implementation. |
51 void ReturnResources(const ReturnedResourceArray& resources) override; | 50 void ReturnResources(const ReturnedResourceArray& resources) override; |
52 | 51 |
53 // FrameSinkManagerClient implementation. | 52 // FrameSinkManagerClient implementation. |
54 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; | 53 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; |
55 | 54 |
56 void EvictCurrentSurface(); | 55 void EvictCurrentSurface(); |
57 void SetNeedsBeginFrame(bool needs_begin_frame); | 56 void SetNeedsBeginFrame(bool needs_begin_frame); |
58 void DidNotProduceFrame(const BeginFrameAck& ack); | 57 void DidNotProduceFrame(const BeginFrameAck& ack); |
59 bool SubmitCompositorFrame(const LocalSurfaceId& local_surface_id, | 58 bool SubmitCompositorFrame(const LocalSurfaceId& local_surface_id, |
60 CompositorFrame frame); | 59 CompositorFrame frame); |
61 void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> request); | 60 void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> request); |
62 void ClaimTemporaryReference(const SurfaceId& surface_id); | 61 void ClaimTemporaryReference(const SurfaceId& surface_id); |
63 | 62 |
64 // TODO(staraz): Move the following 3 methods to private. | 63 // TODO(staraz): Move the following 3 methods to private. |
65 void ReceiveFromChild(const TransferableResourceArray& resources); | 64 void ReceiveFromChild(const TransferableResourceArray& resources); |
66 void RefResources(const TransferableResourceArray& resources); | 65 void RefResources(const TransferableResourceArray& resources); |
67 void UnrefResources(const ReturnedResourceArray& resources); | 66 void UnrefResources(const ReturnedResourceArray& resources); |
68 | 67 |
69 void OnSurfaceActivated(Surface* surface); | 68 void OnSurfaceActivated(Surface* surface); |
70 | 69 |
70 Surface* GetCurrentSurface(); | |
danakj
2017/06/21 21:24:09
We don't want users of this to go using the Surfac
Saman Sami
2017/06/26 20:44:05
I added a ForTesting suffix.
| |
71 | |
71 protected: | 72 protected: |
72 CompositorFrameSinkSupport(CompositorFrameSinkSupportClient* client, | 73 CompositorFrameSinkSupport(CompositorFrameSinkSupportClient* client, |
73 const FrameSinkId& frame_sink_id, | 74 const FrameSinkId& frame_sink_id, |
74 bool is_root, | 75 bool is_root, |
75 bool handles_frame_sink_id_invalidation, | 76 bool handles_frame_sink_id_invalidation, |
76 bool needs_sync_points); | 77 bool needs_sync_points); |
77 | 78 |
78 void Init(SurfaceManager* surface_manager); | 79 void Init(SurfaceManager* surface_manager); |
79 | 80 |
80 private: | 81 private: |
(...skipping 11 matching lines...) Expand all Loading... | |
92 void DidReceiveCompositorFrameAck(); | 93 void DidReceiveCompositorFrameAck(); |
93 void WillDrawSurface(const LocalSurfaceId& local_surface_id, | 94 void WillDrawSurface(const LocalSurfaceId& local_surface_id, |
94 const gfx::Rect& damage_rect); | 95 const gfx::Rect& damage_rect); |
95 | 96 |
96 // BeginFrameObserver implementation. | 97 // BeginFrameObserver implementation. |
97 void OnBeginFrame(const BeginFrameArgs& args) override; | 98 void OnBeginFrame(const BeginFrameArgs& args) override; |
98 const BeginFrameArgs& LastUsedBeginFrameArgs() const override; | 99 const BeginFrameArgs& LastUsedBeginFrameArgs() const override; |
99 void OnBeginFrameSourcePausedChanged(bool paused) override; | 100 void OnBeginFrameSourcePausedChanged(bool paused) override; |
100 | 101 |
101 void UpdateNeedsBeginFramesInternal(); | 102 void UpdateNeedsBeginFramesInternal(); |
102 std::unique_ptr<Surface> CreateSurface(const SurfaceInfo& surface_info); | 103 Surface* CreateSurface(const SurfaceInfo& surface_info); |
103 void DestroyCurrentSurface(); | |
104 | 104 |
105 CompositorFrameSinkSupportClient* const client_; | 105 CompositorFrameSinkSupportClient* const client_; |
106 | 106 |
107 SurfaceManager* surface_manager_ = nullptr; | 107 SurfaceManager* surface_manager_ = nullptr; |
108 | 108 |
109 const FrameSinkId frame_sink_id_; | 109 const FrameSinkId frame_sink_id_; |
110 LocalSurfaceId current_local_surface_id_; | |
110 | 111 |
111 // If this contains a value then a surface reference from the top-level root | 112 // If this contains a value then a surface reference from the top-level root |
112 // to SurfaceId(frame_sink_id_, referenced_local_surface_id_.value()) was | 113 // to SurfaceId(frame_sink_id_, referenced_local_surface_id_.value()) was |
113 // added. This will not contain a value if |is_root_| is false. | 114 // added. This will not contain a value if |is_root_| is false. |
114 base::Optional<LocalSurfaceId> referenced_local_surface_id_; | 115 base::Optional<LocalSurfaceId> referenced_local_surface_id_; |
115 | 116 |
116 SurfaceResourceHolder surface_resource_holder_; | 117 SurfaceResourceHolder surface_resource_holder_; |
117 | 118 |
118 std::unique_ptr<Surface> current_surface_; | |
119 // Counts the number of CompositorFrames that have been submitted and have not | 119 // Counts the number of CompositorFrames that have been submitted and have not |
120 // yet received an ACK. | 120 // yet received an ACK. |
121 int ack_pending_count_ = 0; | 121 int ack_pending_count_ = 0; |
122 ReturnedResourceArray surface_returned_resources_; | 122 ReturnedResourceArray surface_returned_resources_; |
123 | 123 |
124 // The begin frame source being observered. Null if none. | 124 // The begin frame source being observered. Null if none. |
125 BeginFrameSource* begin_frame_source_ = nullptr; | 125 BeginFrameSource* begin_frame_source_ = nullptr; |
126 | 126 |
127 // The last begin frame args generated by the begin frame source. | 127 // The last begin frame args generated by the begin frame source. |
128 BeginFrameArgs last_begin_frame_args_; | 128 BeginFrameArgs last_begin_frame_args_; |
(...skipping 21 matching lines...) Expand all Loading... | |
150 const bool handles_frame_sink_id_invalidation_; | 150 const bool handles_frame_sink_id_invalidation_; |
151 | 151 |
152 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_; | 152 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_; |
153 | 153 |
154 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport); | 154 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport); |
155 }; | 155 }; |
156 | 156 |
157 } // namespace cc | 157 } // namespace cc |
158 | 158 |
159 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ | 159 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ |
OLD | NEW |