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

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

Issue 2449853004: Getting rid of DelegatedFrameData (Closed)
Patch Set: Dana's comment rebase Created 4 years, 1 month 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 "cc/output/copy_output_request.h" 21 #include "cc/output/copy_output_request.h"
21 #include "cc/quads/render_pass_id.h" 22 #include "cc/quads/render_pass_id.h"
22 #include "cc/surfaces/frame_sink_id.h" 23 #include "cc/surfaces/frame_sink_id.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 {
(...skipping 23 matching lines...) Expand all
53 54
54 void QueueFrame(CompositorFrame frame, const DrawCallback& draw_callback); 55 void QueueFrame(CompositorFrame frame, const DrawCallback& draw_callback);
55 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request); 56 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request);
56 // Adds each CopyOutputRequest in the current frame to copy_requests. The 57 // Adds each CopyOutputRequest in the current frame to copy_requests. The
57 // caller takes ownership of them. 58 // caller takes ownership of them.
58 void TakeCopyOutputRequests( 59 void TakeCopyOutputRequests(
59 std::multimap<RenderPassId, std::unique_ptr<CopyOutputRequest>>* 60 std::multimap<RenderPassId, std::unique_ptr<CopyOutputRequest>>*
60 copy_requests); 61 copy_requests);
61 62
62 // Returns the most recent frame that is eligible to be rendered. 63 // Returns the most recent frame that is eligible to be rendered.
63 // If the CompositorFrame's DelegateFrameData is null then there is 64 // You must check whether HasFrame() returns true before calling this method.
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
92 bool destroyed() const { return destroyed_; } 94 bool destroyed() const { return destroyed_; }
93 void set_destroyed(bool destroyed) { destroyed_ = destroyed; } 95 void set_destroyed(bool destroyed) { destroyed_ = destroyed; }
94 96
95 private: 97 private:
96 void UnrefFrameResources(DelegatedFrameData* frame_data); 98 void UnrefFrameResources(const CompositorFrame& frame_data);
97 void ClearCopyRequests(); 99 void ClearCopyRequests();
98 100
99 SurfaceId surface_id_; 101 SurfaceId surface_id_;
100 SurfaceId previous_frame_surface_id_; 102 SurfaceId previous_frame_surface_id_;
101 base::WeakPtr<SurfaceFactory> factory_; 103 base::WeakPtr<SurfaceFactory> factory_;
102 // TODO(jamesr): Support multiple frames in flight. 104 // TODO(jamesr): Support multiple frames in flight.
103 CompositorFrame current_frame_; 105 base::Optional<CompositorFrame> current_frame_;
104 int frame_index_; 106 int frame_index_;
105 bool destroyed_; 107 bool destroyed_;
106 std::vector<SurfaceSequence> destruction_dependencies_; 108 std::vector<SurfaceSequence> destruction_dependencies_;
107 109
108 // This surface may have multiple BeginFrameSources if it is 110 // This surface may have multiple BeginFrameSources if it is
109 // on multiple Displays. 111 // on multiple Displays.
110 std::set<BeginFrameSource*> begin_frame_sources_; 112 std::set<BeginFrameSource*> begin_frame_sources_;
111 113
112 std::vector<SurfaceId> referenced_surfaces_; 114 std::vector<SurfaceId> referenced_surfaces_;
113 115
114 DrawCallback draw_callback_; 116 DrawCallback draw_callback_;
115 117
116 DISALLOW_COPY_AND_ASSIGN(Surface); 118 DISALLOW_COPY_AND_ASSIGN(Surface);
117 }; 119 };
118 120
119 } // namespace cc 121 } // namespace cc
120 122
121 #endif // CC_SURFACES_SURFACE_H_ 123 #endif // CC_SURFACES_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698