| 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" | |
| 21 #include "cc/output/copy_output_request.h" | 20 #include "cc/output/copy_output_request.h" |
| 22 #include "cc/quads/render_pass_id.h" | 21 #include "cc/quads/render_pass_id.h" |
| 23 #include "cc/surfaces/frame_sink_id.h" | 22 #include "cc/surfaces/frame_sink_id.h" |
| 24 #include "cc/surfaces/surface_factory.h" | 23 #include "cc/surfaces/surface_factory.h" |
| 25 #include "cc/surfaces/surface_id.h" | 24 #include "cc/surfaces/surface_id.h" |
| 26 #include "cc/surfaces/surface_sequence.h" | 25 #include "cc/surfaces/surface_sequence.h" |
| 27 #include "cc/surfaces/surfaces_export.h" | 26 #include "cc/surfaces/surfaces_export.h" |
| 28 #include "ui/gfx/geometry/size.h" | 27 #include "ui/gfx/geometry/size.h" |
| 29 | 28 |
| 30 namespace ui { | 29 namespace ui { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 54 | 53 |
| 55 void QueueFrame(CompositorFrame frame, const DrawCallback& draw_callback); | 54 void QueueFrame(CompositorFrame frame, const DrawCallback& draw_callback); |
| 56 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request); | 55 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request); |
| 57 // Adds each CopyOutputRequest in the current frame to copy_requests. The | 56 // Adds each CopyOutputRequest in the current frame to copy_requests. The |
| 58 // caller takes ownership of them. | 57 // caller takes ownership of them. |
| 59 void TakeCopyOutputRequests( | 58 void TakeCopyOutputRequests( |
| 60 std::multimap<RenderPassId, std::unique_ptr<CopyOutputRequest>>* | 59 std::multimap<RenderPassId, std::unique_ptr<CopyOutputRequest>>* |
| 61 copy_requests); | 60 copy_requests); |
| 62 | 61 |
| 63 // Returns the most recent frame that is eligible to be rendered. | 62 // Returns the most recent frame that is eligible to be rendered. |
| 64 // You must check whether HasFrame() returns true before calling this method. | 63 // If the CompositorFrame's DelegateFrameData is null then there is |
| 64 // no eligible frame. |
| 65 const CompositorFrame& GetEligibleFrame(); | 65 const CompositorFrame& GetEligibleFrame(); |
| 66 | 66 |
| 67 // Returns a number that increments by 1 every time a new frame is enqueued. | 67 // Returns a number that increments by 1 every time a new frame is enqueued. |
| 68 int frame_index() const { return frame_index_; } | 68 int frame_index() const { return frame_index_; } |
| 69 | 69 |
| 70 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info); | 70 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info); |
| 71 void RunDrawCallbacks(); | 71 void RunDrawCallbacks(); |
| 72 | 72 |
| 73 base::WeakPtr<SurfaceFactory> factory() { return factory_; } | 73 base::WeakPtr<SurfaceFactory> factory() { return factory_; } |
| 74 | 74 |
| 75 // Add a SurfaceSequence that must be satisfied before the Surface is | 75 // Add a SurfaceSequence that must be satisfied before the Surface is |
| 76 // destroyed. | 76 // destroyed. |
| 77 void AddDestructionDependency(SurfaceSequence sequence); | 77 void AddDestructionDependency(SurfaceSequence sequence); |
| 78 | 78 |
| 79 // Satisfy all destruction dependencies that are contained in sequences, and | 79 // Satisfy all destruction dependencies that are contained in sequences, and |
| 80 // remove them from sequences. | 80 // remove them from sequences. |
| 81 void SatisfyDestructionDependencies( | 81 void SatisfyDestructionDependencies( |
| 82 std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences, | 82 std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences, |
| 83 std::unordered_set<FrameSinkId, FrameSinkIdHash>* valid_id_namespaces); | 83 std::unordered_set<FrameSinkId, FrameSinkIdHash>* valid_id_namespaces); |
| 84 size_t GetDestructionDependencyCount() const { | 84 size_t GetDestructionDependencyCount() const { |
| 85 return destruction_dependencies_.size(); | 85 return destruction_dependencies_.size(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 const std::vector<SurfaceId>& referenced_surfaces() const { | 88 const std::vector<SurfaceId>& referenced_surfaces() const { |
| 89 return referenced_surfaces_; | 89 return referenced_surfaces_; |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool HasFrame() const { return current_frame_.has_value(); } | |
| 93 | |
| 94 bool destroyed() const { return destroyed_; } | 92 bool destroyed() const { return destroyed_; } |
| 95 void set_destroyed(bool destroyed) { destroyed_ = destroyed; } | 93 void set_destroyed(bool destroyed) { destroyed_ = destroyed; } |
| 96 | 94 |
| 97 private: | 95 private: |
| 98 void UnrefFrameResources(const CompositorFrame& frame_data); | 96 void UnrefFrameResources(DelegatedFrameData* frame_data); |
| 99 void ClearCopyRequests(); | 97 void ClearCopyRequests(); |
| 100 | 98 |
| 101 SurfaceId surface_id_; | 99 SurfaceId surface_id_; |
| 102 SurfaceId previous_frame_surface_id_; | 100 SurfaceId previous_frame_surface_id_; |
| 103 base::WeakPtr<SurfaceFactory> factory_; | 101 base::WeakPtr<SurfaceFactory> factory_; |
| 104 // TODO(jamesr): Support multiple frames in flight. | 102 // TODO(jamesr): Support multiple frames in flight. |
| 105 base::Optional<CompositorFrame> current_frame_; | 103 CompositorFrame current_frame_; |
| 106 int frame_index_; | 104 int frame_index_; |
| 107 bool destroyed_; | 105 bool destroyed_; |
| 108 std::vector<SurfaceSequence> destruction_dependencies_; | 106 std::vector<SurfaceSequence> destruction_dependencies_; |
| 109 | 107 |
| 110 // This surface may have multiple BeginFrameSources if it is | 108 // This surface may have multiple BeginFrameSources if it is |
| 111 // on multiple Displays. | 109 // on multiple Displays. |
| 112 std::set<BeginFrameSource*> begin_frame_sources_; | 110 std::set<BeginFrameSource*> begin_frame_sources_; |
| 113 | 111 |
| 114 std::vector<SurfaceId> referenced_surfaces_; | 112 std::vector<SurfaceId> referenced_surfaces_; |
| 115 | 113 |
| 116 DrawCallback draw_callback_; | 114 DrawCallback draw_callback_; |
| 117 | 115 |
| 118 DISALLOW_COPY_AND_ASSIGN(Surface); | 116 DISALLOW_COPY_AND_ASSIGN(Surface); |
| 119 }; | 117 }; |
| 120 | 118 |
| 121 } // namespace cc | 119 } // namespace cc |
| 122 | 120 |
| 123 #endif // CC_SURFACES_SURFACE_H_ | 121 #endif // CC_SURFACES_SURFACE_H_ |
| OLD | NEW |