OLD | NEW |
---|---|
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 |
(...skipping 23 matching lines...) Expand all Loading... | |
34 namespace cc { | 34 namespace cc { |
35 | 35 |
36 class BeginFrameSource; | 36 class BeginFrameSource; |
37 class CompositorFrame; | 37 class CompositorFrame; |
38 class CopyOutputRequest; | 38 class CopyOutputRequest; |
39 class SurfaceFactory; | 39 class SurfaceFactory; |
40 | 40 |
41 class CC_SURFACES_EXPORT Surface { | 41 class CC_SURFACES_EXPORT Surface { |
42 public: | 42 public: |
43 using DrawCallback = SurfaceFactory::DrawCallback; | 43 using DrawCallback = SurfaceFactory::DrawCallback; |
44 using WillDrawCallback = SurfaceFactory::WillDrawCallback; | |
44 | 45 |
45 Surface(const SurfaceId& id, base::WeakPtr<SurfaceFactory> factory); | 46 Surface(const SurfaceId& id, base::WeakPtr<SurfaceFactory> factory); |
46 ~Surface(); | 47 ~Surface(); |
47 | 48 |
48 const SurfaceId& surface_id() const { return surface_id_; } | 49 const SurfaceId& surface_id() const { return surface_id_; } |
49 const SurfaceId& previous_frame_surface_id() const { | 50 const SurfaceId& previous_frame_surface_id() const { |
50 return previous_frame_surface_id_; | 51 return previous_frame_surface_id_; |
51 } | 52 } |
52 | 53 |
53 void SetPreviousFrameSurface(Surface* surface); | 54 void SetPreviousFrameSurface(Surface* surface); |
54 | 55 |
55 void QueueFrame(CompositorFrame frame, const DrawCallback& draw_callback); | 56 void QueueFrame(CompositorFrame frame, |
danakj
2017/04/20 17:56:45
Can you add a comment explaining what these 2 call
Alex Z.
2017/04/20 18:10:21
Done.
| |
57 const DrawCallback& draw_callback, | |
58 const WillDrawCallback& will_draw_callback); | |
56 void EvictFrame(); | 59 void EvictFrame(); |
57 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request); | 60 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request); |
58 | 61 |
59 // Notifies the Surface that a blocking SurfaceId now has an active frame. | 62 // Notifies the Surface that a blocking SurfaceId now has an active frame. |
60 void NotifySurfaceIdAvailable(const SurfaceId& surface_id); | 63 void NotifySurfaceIdAvailable(const SurfaceId& surface_id); |
61 | 64 |
62 void AddObserver(PendingFrameObserver* observer); | 65 void AddObserver(PendingFrameObserver* observer); |
63 void RemoveObserver(PendingFrameObserver* observer); | 66 void RemoveObserver(PendingFrameObserver* observer); |
64 | 67 |
65 // Called if a deadline has been hit and this surface is not yet active but | 68 // Called if a deadline has been hit and this surface is not yet active but |
(...skipping 11 matching lines...) Expand all Loading... | |
77 const CompositorFrame& GetActiveFrame() const; | 80 const CompositorFrame& GetActiveFrame() const; |
78 | 81 |
79 // Returns the currently pending frame. You must check where HasPendingFrame() | 82 // Returns the currently pending frame. You must check where HasPendingFrame() |
80 // returns true before calling this method. | 83 // returns true before calling this method. |
81 const CompositorFrame& GetPendingFrame(); | 84 const CompositorFrame& GetPendingFrame(); |
82 | 85 |
83 // Returns a number that increments by 1 every time a new frame is enqueued. | 86 // Returns a number that increments by 1 every time a new frame is enqueued. |
84 int frame_index() const { return frame_index_; } | 87 int frame_index() const { return frame_index_; } |
85 | 88 |
86 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info); | 89 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info); |
87 void RunDrawCallbacks(); | 90 void RunDrawCallback(); |
91 void RunWillDrawCallback(const gfx::Rect& damage_rect); | |
88 | 92 |
89 base::WeakPtr<SurfaceFactory> factory() { return factory_; } | 93 base::WeakPtr<SurfaceFactory> factory() { return factory_; } |
90 | 94 |
91 // Add a SurfaceSequence that must be satisfied before the Surface is | 95 // Add a SurfaceSequence that must be satisfied before the Surface is |
92 // destroyed. | 96 // destroyed. |
93 void AddDestructionDependency(SurfaceSequence sequence); | 97 void AddDestructionDependency(SurfaceSequence sequence); |
94 | 98 |
95 // Satisfy all destruction dependencies that are contained in sequences, and | 99 // Satisfy all destruction dependencies that are contained in sequences, and |
96 // remove them from sequences. | 100 // remove them from sequences. |
97 void SatisfyDestructionDependencies( | 101 void SatisfyDestructionDependencies( |
(...skipping 14 matching lines...) Expand all Loading... | |
112 } | 116 } |
113 | 117 |
114 bool HasActiveFrame() const { return active_frame_data_.has_value(); } | 118 bool HasActiveFrame() const { return active_frame_data_.has_value(); } |
115 bool HasPendingFrame() const { return pending_frame_data_.has_value(); } | 119 bool HasPendingFrame() const { return pending_frame_data_.has_value(); } |
116 | 120 |
117 bool destroyed() const { return destroyed_; } | 121 bool destroyed() const { return destroyed_; } |
118 void set_destroyed(bool destroyed) { destroyed_ = destroyed; } | 122 void set_destroyed(bool destroyed) { destroyed_ = destroyed; } |
119 | 123 |
120 private: | 124 private: |
121 struct FrameData { | 125 struct FrameData { |
122 FrameData(CompositorFrame&& frame, const DrawCallback& draw_callback); | 126 FrameData(CompositorFrame&& frame, |
127 const DrawCallback& draw_callback, | |
128 const WillDrawCallback& will_draw_callback); | |
123 FrameData(FrameData&& other); | 129 FrameData(FrameData&& other); |
124 ~FrameData(); | 130 ~FrameData(); |
125 FrameData& operator=(FrameData&& other); | 131 FrameData& operator=(FrameData&& other); |
126 CompositorFrame frame; | 132 CompositorFrame frame; |
127 DrawCallback draw_callback; | 133 DrawCallback draw_callback; |
134 WillDrawCallback will_draw_callback; | |
128 }; | 135 }; |
129 | 136 |
130 void ActivatePendingFrame(); | 137 void ActivatePendingFrame(); |
131 // Called when all of the surface's dependencies have been resolved. | 138 // Called when all of the surface's dependencies have been resolved. |
132 void ActivateFrame(FrameData frame_data); | 139 void ActivateFrame(FrameData frame_data); |
133 void UpdateBlockingSurfaces(bool has_previous_pending_frame, | 140 void UpdateBlockingSurfaces(bool has_previous_pending_frame, |
134 const CompositorFrame& current_frame); | 141 const CompositorFrame& current_frame); |
135 | 142 |
136 void UnrefFrameResourcesAndRunDrawCallback( | 143 void UnrefFrameResourcesAndRunDrawCallback( |
137 base::Optional<FrameData> frame_data); | 144 base::Optional<FrameData> frame_data); |
(...skipping 21 matching lines...) Expand all Loading... | |
159 | 166 |
160 SurfaceDependencies blocking_surfaces_; | 167 SurfaceDependencies blocking_surfaces_; |
161 base::ObserverList<PendingFrameObserver, true> observers_; | 168 base::ObserverList<PendingFrameObserver, true> observers_; |
162 | 169 |
163 DISALLOW_COPY_AND_ASSIGN(Surface); | 170 DISALLOW_COPY_AND_ASSIGN(Surface); |
164 }; | 171 }; |
165 | 172 |
166 } // namespace cc | 173 } // namespace cc |
167 | 174 |
168 #endif // CC_SURFACES_SURFACE_H_ | 175 #endif // CC_SURFACES_SURFACE_H_ |
OLD | NEW |