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

Side by Side Diff: cc/surfaces/compositor_frame_sink_support.h

Issue 2802023002: Remove SurfaceFactory And SurfaceFactoryClient (Closed)
Patch Set: Rebase Created 3 years, 8 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
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 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/pending_frame_observer.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_client.h"
19 #include "cc/surfaces/surface_id.h" 18 #include "cc/surfaces/surface_id.h"
19 #include "cc/surfaces/surface_resource_holder.h"
20 #include "cc/surfaces/surfaces_export.h" 20 #include "cc/surfaces/surfaces_export.h"
21 21
22 namespace cc { 22 namespace cc {
23 23
24 class CompositorFrameSinkSupportClient; 24 class CompositorFrameSinkSupportClient;
25 class SurfaceManager; 25 class SurfaceManager;
26 26
27 class CC_SURFACES_EXPORT CompositorFrameSinkSupport 27 class CC_SURFACES_EXPORT CompositorFrameSinkSupport
28 : public SurfaceFactoryClient, 28 : public BeginFrameObserver,
29 public BeginFrameObserver { 29 public PendingFrameObserver {
30 public: 30 public:
31 CompositorFrameSinkSupport(CompositorFrameSinkSupportClient* client, 31 CompositorFrameSinkSupport(CompositorFrameSinkSupportClient* client,
32 SurfaceManager* surface_manager, 32 SurfaceManager* surface_manager,
33 const FrameSinkId& frame_sink_id, 33 const FrameSinkId& frame_sink_id,
34 bool is_root, 34 bool is_root,
35 bool handles_frame_sink_id_invalidation, 35 bool handles_frame_sink_id_invalidation,
36 bool needs_sync_points); 36 bool needs_sync_points);
37 37
38 ~CompositorFrameSinkSupport() override; 38 ~CompositorFrameSinkSupport() override;
39 39
40 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } 40 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; }
41 41
42 Surface* current_surface_for_testing() { 42 Surface* current_surface_for_testing() { return current_surface_.get(); }
43 return surface_factory_.current_surface_for_testing(); 43 SurfaceManager* surface_manager() { return surface_manager_; }
44 } 44 bool needs_sync_points() { return needs_sync_points_; }
45 45
46 const ReferencedSurfaceTracker& ReferenceTrackerForTesting() const { 46 const ReferencedSurfaceTracker& ReferenceTrackerForTesting() const {
47 return reference_tracker_; 47 return reference_tracker_;
48 } 48 }
49 49
50 void EvictFrame(); 50 void EvictFrame();
51 void SetNeedsBeginFrame(bool needs_begin_frame); 51 void SetNeedsBeginFrame(bool needs_begin_frame);
52 void BeginFrameDidNotSwap(const BeginFrameAck& ack); 52 void BeginFrameDidNotSwap(const BeginFrameAck& ack);
53 void SubmitCompositorFrame(const LocalSurfaceId& local_surface_id, 53 void SubmitCompositorFrame(const LocalSurfaceId& local_surface_id,
54 CompositorFrame frame); 54 CompositorFrame frame);
55 void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> request); 55 void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> request);
56 void ForceReclaimResources(); 56 void ForceReclaimResources();
57 void ClaimTemporaryReference(const SurfaceId& surface_id); 57 void ClaimTemporaryReference(const SurfaceId& surface_id);
58 void ReceiveFromChild(const TransferableResourceArray& resources);
Fady Samuel 2017/04/06 21:53:23 Make these private?
Alex Z. 2017/04/13 17:15:30 I'm leaving them public following our discussion o
59 void RefResources(const TransferableResourceArray& resources);
60 void UnrefResources(const ReturnedResourceArray& resources);
58 61
59 BeginFrameSource* BeginFrameSourceForTesting() const; 62 BeginFrameSource* BeginFrameSourceForTesting() const;
60 63
61 private: 64 private:
65 friend class SurfaceResourceHolder;
66 friend class FrameSinkManager;
67 friend class SurfaceAggregator;
68
62 // Update surface references with SurfaceManager for current CompositorFrame 69 // Update surface references with SurfaceManager for current CompositorFrame
63 // that has |local_surface_id|. UpdateReferences() must be called on 70 // that has |local_surface_id|. UpdateReferences() must be called on
64 // |reference_tracker_| before calling this. Will add and remove top-level 71 // |reference_tracker_| before calling this. Will add and remove top-level
65 // root references if |display_| is not null. 72 // root references if |display_| is not null.
66 void UpdateSurfaceReferences(const SurfaceId& last_surface_id, 73 void UpdateSurfaceReferences(const SurfaceId& last_surface_id,
67 const LocalSurfaceId& local_surface_id); 74 const LocalSurfaceId& local_surface_id);
68 75
69 void AddTopLevelRootReference(const SurfaceId& surface_id); 76 void AddTopLevelRootReference(const SurfaceId& surface_id);
70 void RemoveTopLevelRootReference(const SurfaceId& surface_id); 77 void RemoveTopLevelRootReference(const SurfaceId& surface_id);
71 78
72 void DidReceiveCompositorFrameAck(); 79 void DidReceiveCompositorFrameAck();
73 80
74 // SurfaceFactoryClient implementation. 81 void ReturnResources(const ReturnedResourceArray& resources);
75 void ReferencedSurfacesChanged( 82 void SetBeginFrameSource(BeginFrameSource* begin_frame_source);
76 const LocalSurfaceId& local_surface_id,
77 const std::vector<SurfaceId>* active_referenced_surfaces,
78 const std::vector<SurfaceId>* pending_referenced_surfaces) override;
79 void ReturnResources(const ReturnedResourceArray& resources) override;
80 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override;
81 void WillDrawSurface(const LocalSurfaceId& local_surface_id, 83 void WillDrawSurface(const LocalSurfaceId& local_surface_id,
82 const gfx::Rect& damage_rect) override; 84 const gfx::Rect& damage_rect);
83 85
84 // BeginFrameObserver implementation. 86 // BeginFrameObserver implementation.
85 void OnBeginFrame(const BeginFrameArgs& args) override; 87 void OnBeginFrame(const BeginFrameArgs& args) override;
86 const BeginFrameArgs& LastUsedBeginFrameArgs() const override; 88 const BeginFrameArgs& LastUsedBeginFrameArgs() const override;
87 void OnBeginFrameSourcePausedChanged(bool paused) override; 89 void OnBeginFrameSourcePausedChanged(bool paused) override;
88 90
91 // PendingFrameObserver implementation.
92 void OnReferencedSurfacesChanged(
93 Surface* surface,
94 const std::vector<SurfaceId>* active_referenced_surfaces,
95 const std::vector<SurfaceId>* pending_referenced_surfaces) override;
96 void OnSurfaceActivated(Surface* surface) override;
97 void OnSurfaceDependenciesChanged(
98 Surface* surface,
99 const SurfaceDependencies& added_dependencies,
100 const SurfaceDependencies& removed_dependencies) override;
101 void OnSurfaceDiscarded(Surface* surface) override;
102
89 void UpdateNeedsBeginFramesInternal(); 103 void UpdateNeedsBeginFramesInternal();
104 std::unique_ptr<Surface> CreateSurface(
105 const LocalSurfaceId& local_surface_id);
106 void DestroyCurrentSurface();
90 107
91 CompositorFrameSinkSupportClient* const client_; 108 CompositorFrameSinkSupportClient* const client_;
92 109
93 SurfaceManager* const surface_manager_; 110 SurfaceManager* const surface_manager_;
111 SurfaceResourceHolder surface_resource_holder_;
94 112
95 const FrameSinkId frame_sink_id_; 113 const FrameSinkId frame_sink_id_;
96 114
97 SurfaceFactory surface_factory_; 115 std::unique_ptr<Surface> current_surface_;
98 // Counts the number of CompositorFrames that have been submitted and have not 116 // Counts the number of CompositorFrames that have been submitted and have not
99 // yet received an ACK. 117 // yet received an ACK.
100 int ack_pending_count_ = 0; 118 int ack_pending_count_ = 0;
101 ReturnedResourceArray surface_returned_resources_; 119 ReturnedResourceArray surface_returned_resources_;
102 120
103 // The begin frame source being observered. Null if none. 121 // The begin frame source being observered. Null if none.
104 BeginFrameSource* begin_frame_source_ = nullptr; 122 BeginFrameSource* begin_frame_source_ = nullptr;
105 123
106 // The last begin frame args generated by the begin frame source. 124 // The last begin frame args generated by the begin frame source.
107 BeginFrameArgs last_begin_frame_args_; 125 BeginFrameArgs last_begin_frame_args_;
108 126
109 // Whether a request for begin frames has been issued. 127 // Whether a request for begin frames has been issued.
110 bool needs_begin_frame_ = false; 128 bool needs_begin_frame_ = false;
111 129
112 // Whether or not a frame observer has been added. 130 // Whether or not a frame observer has been added.
113 bool added_frame_observer_ = false; 131 bool added_frame_observer_ = false;
114 132
115 // Track the surface references for the surface corresponding to this 133 // Track the surface references for the surface corresponding to this
116 // compositor frame sink. 134 // compositor frame sink.
117 ReferencedSurfaceTracker reference_tracker_; 135 ReferencedSurfaceTracker reference_tracker_;
118 136
119 const bool is_root_; 137 const bool is_root_;
138 bool needs_sync_points_;
139 bool seen_first_frame_activation_ = false;
120 140
121 // TODO(staraz): Remove this flag once ui::Compositor no longer needs to call 141 // TODO(staraz): Remove this flag once ui::Compositor no longer needs to call
122 // RegisterFrameSinkId(). 142 // RegisterFrameSinkId().
123 // A surfaceSequence's validity is bound to the lifetime of the parent 143 // A surfaceSequence's validity is bound to the lifetime of the parent
124 // FrameSink that created it. We track the lifetime of FrameSinks through 144 // FrameSink that created it. We track the lifetime of FrameSinks through
125 // RegisterFrameSinkId and InvalidateFrameSinkId. During startup and GPU 145 // RegisterFrameSinkId and InvalidateFrameSinkId. During startup and GPU
126 // restart, a SurfaceSequence created by the top most layer compositor may be 146 // restart, a SurfaceSequence created by the top most layer compositor may be
127 // used prior to the creation of the associated CompositorFrameSinkSupport. 147 // used prior to the creation of the associated CompositorFrameSinkSupport.
128 // CompositorFrameSinkSupport is created asynchronously when a new GPU channel 148 // CompositorFrameSinkSupport is created asynchronously when a new GPU channel
129 // is established. Once we switch to SurfaceReferences, this ordering concern 149 // is established. Once we switch to SurfaceReferences, this ordering concern
130 // goes away and we can remove this bool. 150 // goes away and we can remove this bool.
131 const bool handles_frame_sink_id_invalidation_; 151 const bool handles_frame_sink_id_invalidation_;
132 152
133 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_; 153 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_;
134 154
135 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport); 155 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport);
136 }; 156 };
137 157
138 } // namespace cc 158 } // namespace cc
139 159
140 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ 160 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698