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

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

Issue 2676373004: Implement service-side surface synchronization (Closed)
Patch Set: DisplayCompositorLockManager => SurfaceDependencyTracker. Added More Comments Created 3 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SURFACE_H_ 5 #ifndef CC_SURFACES_SURFACE_H_
6 #define CC_SURFACES_SURFACE_H_ 6 #define CC_SURFACES_SURFACE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <set> 13 #include <set>
14 #include <unordered_set> 14 #include <unordered_set>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/optional.h" 20 #include "base/optional.h"
21 #include "cc/output/copy_output_request.h" 21 #include "cc/output/copy_output_request.h"
22 #include "cc/surfaces/frame_sink_id.h" 22 #include "cc/surfaces/frame_sink_id.h"
23 #include "cc/surfaces/pending_frame_observer.h"
23 #include "cc/surfaces/surface_factory.h" 24 #include "cc/surfaces/surface_factory.h"
24 #include "cc/surfaces/surface_id.h" 25 #include "cc/surfaces/surface_id.h"
25 #include "cc/surfaces/surface_sequence.h" 26 #include "cc/surfaces/surface_sequence.h"
26 #include "cc/surfaces/surfaces_export.h" 27 #include "cc/surfaces/surfaces_export.h"
27 #include "ui/gfx/geometry/size.h" 28 #include "ui/gfx/geometry/size.h"
28 29
29 namespace ui { 30 namespace ui {
30 class LatencyInfo; 31 class LatencyInfo;
31 } 32 }
32 33
(...skipping 14 matching lines...) Expand all
47 const SurfaceId& surface_id() const { return surface_id_; } 48 const SurfaceId& surface_id() const { return surface_id_; }
48 const SurfaceId& previous_frame_surface_id() const { 49 const SurfaceId& previous_frame_surface_id() const {
49 return previous_frame_surface_id_; 50 return previous_frame_surface_id_;
50 } 51 }
51 52
52 void SetPreviousFrameSurface(Surface* surface); 53 void SetPreviousFrameSurface(Surface* surface);
53 54
54 void QueueFrame(CompositorFrame frame, const DrawCallback& draw_callback); 55 void QueueFrame(CompositorFrame frame, const DrawCallback& draw_callback);
55 void EvictFrame(); 56 void EvictFrame();
56 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request); 57 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request);
58
59 // Reports to the Surface that a blocking SurfaceId is now available.
60 void ReportSurfaceIdAvailable(const SurfaceId& surface_id);
vmpstr 2017/02/07 22:46:19 Notify?
Fady Samuel 2017/02/08 00:52:49 Done.
61
62 void AddObserver(PendingFrameObserver* observer);
63 void RemoveObserver(PendingFrameObserver* observer);
64
65 // Called if a deadline has been hit and this surface is not yet active but
66 // it's marked as respecting deadlines.
67 void ActivatePendingFrameForDeadline();
68
57 // Adds each CopyOutputRequest in the current frame to copy_requests. The 69 // Adds each CopyOutputRequest in the current frame to copy_requests. The
58 // caller takes ownership of them. |copy_requests| is keyed by RenderPass ids. 70 // caller takes ownership of them. |copy_requests| is keyed by RenderPass ids.
59 void TakeCopyOutputRequests( 71 void TakeCopyOutputRequests(
60 std::multimap<int, std::unique_ptr<CopyOutputRequest>>* copy_requests); 72 std::multimap<int, std::unique_ptr<CopyOutputRequest>>* copy_requests);
61 73
62 // Returns the most recent frame that is eligible to be rendered. 74 // Returns the most recent frame that is eligible to be rendered.
63 // You must check whether HasFrame() returns true before calling this method. 75 // You must check whether HasActiveFrame() returns true before calling this
64 const CompositorFrame& GetEligibleFrame() const; 76 // method.
77 const CompositorFrame& GetActiveFrame() const;
78
79 // Returns the currently pending frame.
vmpstr 2017/02/07 22:46:19 Can you add a similar comment here as above, "must
Fady Samuel 2017/02/08 00:52:49 Done.
80 const CompositorFrame& GetPendingFrame();
65 81
66 // Returns a number that increments by 1 every time a new frame is enqueued. 82 // Returns a number that increments by 1 every time a new frame is enqueued.
67 int frame_index() const { return frame_index_; } 83 int frame_index() const { return frame_index_; }
68 84
69 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info); 85 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info);
70 void RunDrawCallbacks(); 86 void RunDrawCallbacks();
71 87
72 base::WeakPtr<SurfaceFactory> factory() { return factory_; } 88 base::WeakPtr<SurfaceFactory> factory() { return factory_; }
73 89
74 // Add a SurfaceSequence that must be satisfied before the Surface is 90 // Add a SurfaceSequence that must be satisfied before the Surface is
75 // destroyed. 91 // destroyed.
76 void AddDestructionDependency(SurfaceSequence sequence); 92 void AddDestructionDependency(SurfaceSequence sequence);
77 93
78 // Satisfy all destruction dependencies that are contained in sequences, and 94 // Satisfy all destruction dependencies that are contained in sequences, and
79 // remove them from sequences. 95 // remove them from sequences.
80 void SatisfyDestructionDependencies( 96 void SatisfyDestructionDependencies(
81 std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences, 97 std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences,
82 std::unordered_set<FrameSinkId, FrameSinkIdHash>* valid_id_namespaces); 98 std::unordered_set<FrameSinkId, FrameSinkIdHash>* valid_id_namespaces);
83 size_t GetDestructionDependencyCount() const { 99 size_t GetDestructionDependencyCount() const {
84 return destruction_dependencies_.size(); 100 return destruction_dependencies_.size();
85 } 101 }
86 102
87 const std::vector<SurfaceId>& referenced_surfaces() const { 103 const std::vector<SurfaceId>& referenced_surfaces() const {
88 return referenced_surfaces_; 104 return referenced_surfaces_;
89 } 105 }
90 106
91 bool HasFrame() const { return current_frame_.has_value(); } 107 bool HasActiveFrame() const { return active_frame_.has_value(); }
108 bool HasPendingFrame() const { return pending_frame_.has_value(); }
92 109
93 bool destroyed() const { return destroyed_; } 110 bool destroyed() const { return destroyed_; }
94 void set_destroyed(bool destroyed) { destroyed_ = destroyed; } 111 void set_destroyed(bool destroyed) { destroyed_ = destroyed; }
95 112
96 private: 113 private:
114 void ActivatePendingFrame();
115 // Called when all of the surface's dependencies have been resolved.
116 void ActivateFrame(CompositorFrame frame);
117
97 void UnrefFrameResources(const CompositorFrame& frame_data); 118 void UnrefFrameResources(const CompositorFrame& frame_data);
98 void ClearCopyRequests(); 119 void ClearCopyRequests();
99 120
100 SurfaceId surface_id_; 121 SurfaceId surface_id_;
101 SurfaceId previous_frame_surface_id_; 122 SurfaceId previous_frame_surface_id_;
102 base::WeakPtr<SurfaceFactory> factory_; 123 base::WeakPtr<SurfaceFactory> factory_;
103 // TODO(jamesr): Support multiple frames in flight. 124 // TODO(jamesr): Support multiple frames in flight.
104 base::Optional<CompositorFrame> current_frame_; 125 base::Optional<CompositorFrame> pending_frame_;
126 base::Optional<CompositorFrame> active_frame_;
105 int frame_index_; 127 int frame_index_;
106 bool destroyed_; 128 bool destroyed_;
107 std::vector<SurfaceSequence> destruction_dependencies_; 129 std::vector<SurfaceSequence> destruction_dependencies_;
108 130
109 // This surface may have multiple BeginFrameSources if it is 131 // This surface may have multiple BeginFrameSources if it is
110 // on multiple Displays. 132 // on multiple Displays.
111 std::set<BeginFrameSource*> begin_frame_sources_; 133 std::set<BeginFrameSource*> begin_frame_sources_;
112 134
113 std::vector<SurfaceId> referenced_surfaces_; 135 std::vector<SurfaceId> referenced_surfaces_;
114 136
137 SurfaceDependencies blocked_on_surfaces_;
vmpstr 2017/02/07 22:46:19 nit: "blocking_surfaces_"?
Fady Samuel 2017/02/08 00:52:49 Done.
138 base::ObserverList<PendingFrameObserver, true> observers_;
139
115 DrawCallback draw_callback_; 140 DrawCallback draw_callback_;
116 141
117 DISALLOW_COPY_AND_ASSIGN(Surface); 142 DISALLOW_COPY_AND_ASSIGN(Surface);
118 }; 143 };
119 144
145 using PendingSurfaceSet = std::unordered_set<Surface*>;
vmpstr 2017/02/07 22:46:19 What's the expected size of these things? flat set
Fady Samuel 2017/02/08 00:52:49 Added a TODO.
146
120 } // namespace cc 147 } // namespace cc
121 148
122 #endif // CC_SURFACES_SURFACE_H_ 149 #endif // CC_SURFACES_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698