Chromium Code Reviews| 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 |
| 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 Loading... | |
| 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 // Notifies the Surface that a blocking SurfaceId now has an active frame. | |
| 60 void NotifySurfaceIdAvailable(const SurfaceId& surface_id); | |
| 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. You must check where HasPendingFrame() | |
| 80 // returns true before calling this method. | |
| 81 const CompositorFrame& GetPendingFrame(); | |
| 65 | 82 |
| 66 // Returns a number that increments by 1 every time a new frame is enqueued. | 83 // Returns a number that increments by 1 every time a new frame is enqueued. |
| 67 int frame_index() const { return frame_index_; } | 84 int frame_index() const { return frame_index_; } |
| 68 | 85 |
| 69 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info); | 86 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info); |
| 70 void RunDrawCallbacks(); | 87 void RunDrawCallbacks(); |
| 71 | 88 |
| 72 base::WeakPtr<SurfaceFactory> factory() { return factory_; } | 89 base::WeakPtr<SurfaceFactory> factory() { return factory_; } |
| 73 | 90 |
| 74 // Add a SurfaceSequence that must be satisfied before the Surface is | 91 // Add a SurfaceSequence that must be satisfied before the Surface is |
| 75 // destroyed. | 92 // destroyed. |
| 76 void AddDestructionDependency(SurfaceSequence sequence); | 93 void AddDestructionDependency(SurfaceSequence sequence); |
| 77 | 94 |
| 78 // Satisfy all destruction dependencies that are contained in sequences, and | 95 // Satisfy all destruction dependencies that are contained in sequences, and |
| 79 // remove them from sequences. | 96 // remove them from sequences. |
| 80 void SatisfyDestructionDependencies( | 97 void SatisfyDestructionDependencies( |
| 81 std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences, | 98 std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences, |
| 82 std::unordered_set<FrameSinkId, FrameSinkIdHash>* valid_id_namespaces); | 99 std::unordered_set<FrameSinkId, FrameSinkIdHash>* valid_id_namespaces); |
| 83 size_t GetDestructionDependencyCount() const { | 100 size_t GetDestructionDependencyCount() const { |
| 84 return destruction_dependencies_.size(); | 101 return destruction_dependencies_.size(); |
| 85 } | 102 } |
| 86 | 103 |
| 87 const std::vector<SurfaceId>& referenced_surfaces() const { | 104 const std::vector<SurfaceId>& referenced_surfaces() const { |
| 88 return referenced_surfaces_; | 105 return referenced_surfaces_; |
| 89 } | 106 } |
| 90 | 107 |
| 91 bool HasFrame() const { return current_frame_.has_value(); } | 108 bool HasActiveFrame() const { return active_frame_.has_value(); } |
| 109 bool HasPendingFrame() const { return pending_frame_.has_value(); } | |
| 92 | 110 |
| 93 bool destroyed() const { return destroyed_; } | 111 bool destroyed() const { return destroyed_; } |
| 94 void set_destroyed(bool destroyed) { destroyed_ = destroyed; } | 112 void set_destroyed(bool destroyed) { destroyed_ = destroyed; } |
| 95 | 113 |
| 96 private: | 114 private: |
| 115 void ActivatePendingFrame(); | |
|
kylechar
2017/02/09 15:50:31
What does ActivePendingFrame() do exactly? Can you
| |
| 116 // Called when all of the surface's dependencies have been resolved. | |
| 117 void ActivateFrame(CompositorFrame frame); | |
| 118 void UpdateBlockingSurfaces( | |
| 119 const base::Optional<CompositorFrame>& previous_pending_frame, | |
| 120 const CompositorFrame& current_frame); | |
| 121 | |
| 97 void UnrefFrameResources(const CompositorFrame& frame_data); | 122 void UnrefFrameResources(const CompositorFrame& frame_data); |
| 98 void ClearCopyRequests(); | 123 void ClearCopyRequests(); |
| 99 | 124 |
| 100 SurfaceId surface_id_; | 125 SurfaceId surface_id_; |
| 101 SurfaceId previous_frame_surface_id_; | 126 SurfaceId previous_frame_surface_id_; |
| 102 base::WeakPtr<SurfaceFactory> factory_; | 127 base::WeakPtr<SurfaceFactory> factory_; |
| 103 // TODO(jamesr): Support multiple frames in flight. | 128 // TODO(jamesr): Support multiple frames in flight. |
| 104 base::Optional<CompositorFrame> current_frame_; | 129 base::Optional<CompositorFrame> pending_frame_; |
| 130 base::Optional<CompositorFrame> active_frame_; | |
| 105 int frame_index_; | 131 int frame_index_; |
| 106 bool destroyed_; | 132 bool destroyed_; |
| 107 std::vector<SurfaceSequence> destruction_dependencies_; | 133 std::vector<SurfaceSequence> destruction_dependencies_; |
| 108 | 134 |
| 109 // This surface may have multiple BeginFrameSources if it is | 135 // This surface may have multiple BeginFrameSources if it is |
| 110 // on multiple Displays. | 136 // on multiple Displays. |
| 111 std::set<BeginFrameSource*> begin_frame_sources_; | 137 std::set<BeginFrameSource*> begin_frame_sources_; |
| 112 | 138 |
| 113 std::vector<SurfaceId> referenced_surfaces_; | 139 std::vector<SurfaceId> referenced_surfaces_; |
| 114 | 140 |
| 141 SurfaceDependencies blocking_surfaces_; | |
| 142 base::ObserverList<PendingFrameObserver, true> observers_; | |
| 143 | |
| 115 DrawCallback draw_callback_; | 144 DrawCallback draw_callback_; |
| 116 | 145 |
| 117 DISALLOW_COPY_AND_ASSIGN(Surface); | 146 DISALLOW_COPY_AND_ASSIGN(Surface); |
| 118 }; | 147 }; |
| 119 | 148 |
| 149 using PendingSurfaceSet = base::flat_set<Surface*>; | |
| 150 | |
| 120 } // namespace cc | 151 } // namespace cc |
| 121 | 152 |
| 122 #endif // CC_SURFACES_SURFACE_H_ | 153 #endif // CC_SURFACES_SURFACE_H_ |
| OLD | NEW |