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

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

Issue 2807653003: Move Work From CompositorFrameSinkSupport() To Init() (Closed)
Patch Set: Add CompositorFrameSinkSupport::Create 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
« no previous file with comments | « ash/laser/laser_pointer_view.cc ('k') | cc/surfaces/compositor_frame_sink_support.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 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 10 matching lines...) Expand all
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 SurfaceFactoryClient,
29 public BeginFrameObserver { 29 public BeginFrameObserver {
30 public: 30 public:
31 CompositorFrameSinkSupport(CompositorFrameSinkSupportClient* client, 31 static std::unique_ptr<CompositorFrameSinkSupport> Create(
32 SurfaceManager* surface_manager, 32 CompositorFrameSinkSupportClient* client,
33 const FrameSinkId& frame_sink_id, 33 SurfaceManager* surface_manager,
34 bool is_root, 34 const FrameSinkId& frame_sink_id,
35 bool handles_frame_sink_id_invalidation, 35 bool is_root,
36 bool needs_sync_points); 36 bool handles_frame_sink_id_invalidation,
37 bool needs_sync_points);
37 38
38 ~CompositorFrameSinkSupport() override; 39 ~CompositorFrameSinkSupport() override;
39 40
40 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } 41 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; }
41 42
42 Surface* current_surface_for_testing() { 43 Surface* current_surface_for_testing() {
43 return surface_factory_.current_surface_for_testing(); 44 return surface_factory_->current_surface_for_testing();
44 } 45 }
45 46
46 const ReferencedSurfaceTracker& ReferenceTrackerForTesting() const { 47 const ReferencedSurfaceTracker& ReferenceTrackerForTesting() const {
47 return reference_tracker_; 48 return reference_tracker_;
48 } 49 }
49 50
50 // SurfaceFactoryClient implementation. 51 // SurfaceFactoryClient implementation.
51 void ReferencedSurfacesChanged( 52 void ReferencedSurfacesChanged(
52 const LocalSurfaceId& local_surface_id, 53 const LocalSurfaceId& local_surface_id,
53 const std::vector<SurfaceId>* active_referenced_surfaces, 54 const std::vector<SurfaceId>* active_referenced_surfaces,
54 const std::vector<SurfaceId>* pending_referenced_surfaces) override; 55 const std::vector<SurfaceId>* pending_referenced_surfaces) override;
55 void ReturnResources(const ReturnedResourceArray& resources) override; 56 void ReturnResources(const ReturnedResourceArray& resources) override;
56 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; 57 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override;
57 void WillDrawSurface(const LocalSurfaceId& local_surface_id, 58 void WillDrawSurface(const LocalSurfaceId& local_surface_id,
58 const gfx::Rect& damage_rect) override; 59 const gfx::Rect& damage_rect) override;
59 60
60 void EvictFrame(); 61 void EvictFrame();
61 void SetNeedsBeginFrame(bool needs_begin_frame); 62 void SetNeedsBeginFrame(bool needs_begin_frame);
62 void BeginFrameDidNotSwap(const BeginFrameAck& ack); 63 void BeginFrameDidNotSwap(const BeginFrameAck& ack);
63 void SubmitCompositorFrame(const LocalSurfaceId& local_surface_id, 64 void SubmitCompositorFrame(const LocalSurfaceId& local_surface_id,
64 CompositorFrame frame); 65 CompositorFrame frame);
65 void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> request); 66 void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> request);
66 void ForceReclaimResources(); 67 void ForceReclaimResources();
67 void ClaimTemporaryReference(const SurfaceId& surface_id); 68 void ClaimTemporaryReference(const SurfaceId& surface_id);
68 69
70 protected:
71 CompositorFrameSinkSupport(CompositorFrameSinkSupportClient* client,
72 const FrameSinkId& frame_sink_id,
73 bool is_root,
74 bool handles_frame_sink_id_invalidation);
75
76 void Init(SurfaceManager* surface_manager, bool needs_sync_points);
77
69 private: 78 private:
70 // Update surface references with SurfaceManager for current CompositorFrame 79 // Update surface references with SurfaceManager for current CompositorFrame
71 // that has |local_surface_id|. UpdateReferences() must be called on 80 // that has |local_surface_id|. UpdateReferences() must be called on
72 // |reference_tracker_| before calling this. Will add and remove top-level 81 // |reference_tracker_| before calling this. Will add and remove top-level
73 // root references if |display_| is not null. 82 // root references if |display_| is not null.
74 void UpdateSurfaceReferences(const SurfaceId& last_surface_id, 83 void UpdateSurfaceReferences(const SurfaceId& last_surface_id,
75 const LocalSurfaceId& local_surface_id); 84 const LocalSurfaceId& local_surface_id);
76 85
77 void AddTopLevelRootReference(const SurfaceId& surface_id); 86 void AddTopLevelRootReference(const SurfaceId& surface_id);
78 void RemoveTopLevelRootReference(const SurfaceId& surface_id); 87 void RemoveTopLevelRootReference(const SurfaceId& surface_id);
79 88
80 void DidReceiveCompositorFrameAck(); 89 void DidReceiveCompositorFrameAck();
81 90
82 // BeginFrameObserver implementation. 91 // BeginFrameObserver implementation.
83 void OnBeginFrame(const BeginFrameArgs& args) override; 92 void OnBeginFrame(const BeginFrameArgs& args) override;
84 const BeginFrameArgs& LastUsedBeginFrameArgs() const override; 93 const BeginFrameArgs& LastUsedBeginFrameArgs() const override;
85 void OnBeginFrameSourcePausedChanged(bool paused) override; 94 void OnBeginFrameSourcePausedChanged(bool paused) override;
86 95
87 void UpdateNeedsBeginFramesInternal(); 96 void UpdateNeedsBeginFramesInternal();
88 97
89 CompositorFrameSinkSupportClient* const client_; 98 CompositorFrameSinkSupportClient* const client_;
90 99
91 SurfaceManager* const surface_manager_; 100 SurfaceManager* surface_manager_ = nullptr;
92 101
93 const FrameSinkId frame_sink_id_; 102 const FrameSinkId frame_sink_id_;
94 103
95 SurfaceFactory surface_factory_; 104 std::unique_ptr<SurfaceFactory> surface_factory_;
96 // Counts the number of CompositorFrames that have been submitted and have not 105 // Counts the number of CompositorFrames that have been submitted and have not
97 // yet received an ACK. 106 // yet received an ACK.
98 int ack_pending_count_ = 0; 107 int ack_pending_count_ = 0;
99 ReturnedResourceArray surface_returned_resources_; 108 ReturnedResourceArray surface_returned_resources_;
100 109
101 // The begin frame source being observered. Null if none. 110 // The begin frame source being observered. Null if none.
102 BeginFrameSource* begin_frame_source_ = nullptr; 111 BeginFrameSource* begin_frame_source_ = nullptr;
103 112
104 // The last begin frame args generated by the begin frame source. 113 // The last begin frame args generated by the begin frame source.
105 BeginFrameArgs last_begin_frame_args_; 114 BeginFrameArgs last_begin_frame_args_;
(...skipping 23 matching lines...) Expand all
129 const bool handles_frame_sink_id_invalidation_; 138 const bool handles_frame_sink_id_invalidation_;
130 139
131 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_; 140 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_;
132 141
133 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport); 142 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport);
134 }; 143 };
135 144
136 } // namespace cc 145 } // namespace cc
137 146
138 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ 147 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_
OLDNEW
« no previous file with comments | « ash/laser/laser_pointer_view.cc ('k') | cc/surfaces/compositor_frame_sink_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698