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> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "cc/output/compositor_frame.h" | 14 #include "cc/output/compositor_frame.h" |
15 #include "cc/scheduler/begin_frame_source.h" | 15 #include "cc/scheduler/begin_frame_source.h" |
| 16 #include "cc/surfaces/framesink_manager_client.h" |
16 #include "cc/surfaces/referenced_surface_tracker.h" | 17 #include "cc/surfaces/referenced_surface_tracker.h" |
17 #include "cc/surfaces/surface_factory.h" | 18 #include "cc/surfaces/surface_factory.h" |
18 #include "cc/surfaces/surface_factory_client.h" | 19 #include "cc/surfaces/surface_factory_client.h" |
19 #include "cc/surfaces/surface_id.h" | 20 #include "cc/surfaces/surface_id.h" |
| 21 #include "cc/surfaces/surface_resource_holder_client.h" |
20 #include "cc/surfaces/surfaces_export.h" | 22 #include "cc/surfaces/surfaces_export.h" |
21 | 23 |
22 namespace cc { | 24 namespace cc { |
23 | 25 |
24 class CompositorFrameSinkSupportClient; | 26 class CompositorFrameSinkSupportClient; |
25 class SurfaceManager; | 27 class SurfaceManager; |
26 | 28 |
27 class CC_SURFACES_EXPORT CompositorFrameSinkSupport | 29 class CC_SURFACES_EXPORT CompositorFrameSinkSupport |
28 : public SurfaceFactoryClient, | 30 : public SurfaceFactoryClient, |
29 public BeginFrameObserver { | 31 public BeginFrameObserver, |
| 32 public SurfaceResourceHolderClient, |
| 33 public FrameSinkManagerClient { |
30 public: | 34 public: |
31 static std::unique_ptr<CompositorFrameSinkSupport> Create( | 35 static std::unique_ptr<CompositorFrameSinkSupport> Create( |
32 CompositorFrameSinkSupportClient* client, | 36 CompositorFrameSinkSupportClient* client, |
33 SurfaceManager* surface_manager, | 37 SurfaceManager* surface_manager, |
34 const FrameSinkId& frame_sink_id, | 38 const FrameSinkId& frame_sink_id, |
35 bool is_root, | 39 bool is_root, |
36 bool handles_frame_sink_id_invalidation, | 40 bool handles_frame_sink_id_invalidation, |
37 bool needs_sync_points); | 41 bool needs_sync_points); |
38 | 42 |
39 ~CompositorFrameSinkSupport() override; | 43 ~CompositorFrameSinkSupport() override; |
40 | 44 |
41 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } | 45 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } |
42 | 46 |
43 Surface* current_surface_for_testing() { | 47 Surface* current_surface_for_testing() { |
44 return surface_factory_->current_surface_for_testing(); | 48 return surface_factory_->current_surface_for_testing(); |
45 } | 49 } |
46 | 50 |
47 const ReferencedSurfaceTracker& ReferenceTrackerForTesting() const { | 51 const ReferencedSurfaceTracker& ReferenceTrackerForTesting() const { |
48 return reference_tracker_; | 52 return reference_tracker_; |
49 } | 53 } |
50 | 54 |
51 // SurfaceFactoryClient implementation. | 55 // SurfaceFactoryClient implementation. |
52 void ReferencedSurfacesChanged( | 56 void ReferencedSurfacesChanged( |
53 const LocalSurfaceId& local_surface_id, | 57 const LocalSurfaceId& local_surface_id, |
54 const std::vector<SurfaceId>* active_referenced_surfaces) override; | 58 const std::vector<SurfaceId>* active_referenced_surfaces) override; |
| 59 |
| 60 // SurfaceResourceHolderClient implementation. |
55 void ReturnResources(const ReturnedResourceArray& resources) override; | 61 void ReturnResources(const ReturnedResourceArray& resources) override; |
| 62 |
| 63 // FrameSinkManagerClient implementation. |
56 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; | 64 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; |
57 void WillDrawSurface(const LocalSurfaceId& local_surface_id, | |
58 const gfx::Rect& damage_rect) override; | |
59 | 65 |
60 void EvictFrame(); | 66 void EvictFrame(); |
61 void SetNeedsBeginFrame(bool needs_begin_frame); | 67 void SetNeedsBeginFrame(bool needs_begin_frame); |
62 void BeginFrameDidNotSwap(const BeginFrameAck& ack); | 68 void BeginFrameDidNotSwap(const BeginFrameAck& ack); |
63 void SubmitCompositorFrame(const LocalSurfaceId& local_surface_id, | 69 void SubmitCompositorFrame(const LocalSurfaceId& local_surface_id, |
64 CompositorFrame frame); | 70 CompositorFrame frame); |
65 void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> request); | 71 void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> request); |
66 void ForceReclaimResources(); | 72 void ForceReclaimResources(); |
67 void ClaimTemporaryReference(const SurfaceId& surface_id); | 73 void ClaimTemporaryReference(const SurfaceId& surface_id); |
68 | 74 |
(...skipping 10 matching lines...) Expand all Loading... |
79 // that has |local_surface_id|. UpdateReferences() must be called on | 85 // that has |local_surface_id|. UpdateReferences() must be called on |
80 // |reference_tracker_| before calling this. Will add and remove top-level | 86 // |reference_tracker_| before calling this. Will add and remove top-level |
81 // root references if |display_| is not null. | 87 // root references if |display_| is not null. |
82 void UpdateSurfaceReferences(const SurfaceId& last_surface_id, | 88 void UpdateSurfaceReferences(const SurfaceId& last_surface_id, |
83 const LocalSurfaceId& local_surface_id); | 89 const LocalSurfaceId& local_surface_id); |
84 | 90 |
85 void AddTopLevelRootReference(const SurfaceId& surface_id); | 91 void AddTopLevelRootReference(const SurfaceId& surface_id); |
86 void RemoveTopLevelRootReference(const SurfaceId& surface_id); | 92 void RemoveTopLevelRootReference(const SurfaceId& surface_id); |
87 | 93 |
88 void DidReceiveCompositorFrameAck(); | 94 void DidReceiveCompositorFrameAck(); |
| 95 void WillDrawSurface(const LocalSurfaceId& local_surface_id, |
| 96 const gfx::Rect& damage_rect); |
89 | 97 |
90 // BeginFrameObserver implementation. | 98 // BeginFrameObserver implementation. |
91 void OnBeginFrame(const BeginFrameArgs& args) override; | 99 void OnBeginFrame(const BeginFrameArgs& args) override; |
92 const BeginFrameArgs& LastUsedBeginFrameArgs() const override; | 100 const BeginFrameArgs& LastUsedBeginFrameArgs() const override; |
93 void OnBeginFrameSourcePausedChanged(bool paused) override; | 101 void OnBeginFrameSourcePausedChanged(bool paused) override; |
94 | 102 |
95 void UpdateNeedsBeginFramesInternal(); | 103 void UpdateNeedsBeginFramesInternal(); |
96 | 104 |
97 CompositorFrameSinkSupportClient* const client_; | 105 CompositorFrameSinkSupportClient* const client_; |
98 | 106 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 const bool handles_frame_sink_id_invalidation_; | 145 const bool handles_frame_sink_id_invalidation_; |
138 | 146 |
139 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_; | 147 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_; |
140 | 148 |
141 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport); | 149 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport); |
142 }; | 150 }; |
143 | 151 |
144 } // namespace cc | 152 } // namespace cc |
145 | 153 |
146 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ | 154 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ |
OLD | NEW |