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

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

Issue 2449853004: Getting rid of DelegatedFrameData (Closed)
Patch Set: nit 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
« no previous file with comments | « cc/surfaces/display_unittest.cc ('k') | cc/surfaces/surface.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 15 matching lines...) Expand all
45 ~Surface(); 46 ~Surface();
46 47
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);
56 void EvictFrame();
55 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request); 57 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request);
56 // Adds each CopyOutputRequest in the current frame to copy_requests. The 58 // Adds each CopyOutputRequest in the current frame to copy_requests. The
57 // caller takes ownership of them. 59 // caller takes ownership of them.
58 void TakeCopyOutputRequests( 60 void TakeCopyOutputRequests(
59 std::multimap<RenderPassId, std::unique_ptr<CopyOutputRequest>>* 61 std::multimap<RenderPassId, std::unique_ptr<CopyOutputRequest>>*
60 copy_requests); 62 copy_requests);
61 63
62 // Returns the most recent frame that is eligible to be rendered. 64 // Returns the most recent frame that is eligible to be rendered.
63 // If the CompositorFrame's DelegateFrameData is null then there is 65 // You must check whether HasFrame() returns true before calling this method.
64 // no eligible frame.
65 const CompositorFrame& GetEligibleFrame(); 66 const CompositorFrame& GetEligibleFrame();
66 67
67 // Returns a number that increments by 1 every time a new frame is enqueued. 68 // Returns a number that increments by 1 every time a new frame is enqueued.
68 int frame_index() const { return frame_index_; } 69 int frame_index() const { return frame_index_; }
69 70
70 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info); 71 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info);
71 void RunDrawCallbacks(); 72 void RunDrawCallbacks();
72 73
73 base::WeakPtr<SurfaceFactory> factory() { return factory_; } 74 base::WeakPtr<SurfaceFactory> factory() { return factory_; }
74 75
75 // Add a SurfaceSequence that must be satisfied before the Surface is 76 // Add a SurfaceSequence that must be satisfied before the Surface is
76 // destroyed. 77 // destroyed.
77 void AddDestructionDependency(SurfaceSequence sequence); 78 void AddDestructionDependency(SurfaceSequence sequence);
78 79
79 // Satisfy all destruction dependencies that are contained in sequences, and 80 // Satisfy all destruction dependencies that are contained in sequences, and
80 // remove them from sequences. 81 // remove them from sequences.
81 void SatisfyDestructionDependencies( 82 void SatisfyDestructionDependencies(
82 std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences, 83 std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences,
83 std::unordered_set<FrameSinkId, FrameSinkIdHash>* valid_id_namespaces); 84 std::unordered_set<FrameSinkId, FrameSinkIdHash>* valid_id_namespaces);
84 size_t GetDestructionDependencyCount() const { 85 size_t GetDestructionDependencyCount() const {
85 return destruction_dependencies_.size(); 86 return destruction_dependencies_.size();
86 } 87 }
87 88
88 const std::vector<SurfaceId>& referenced_surfaces() const { 89 const std::vector<SurfaceId>& referenced_surfaces() const {
89 return referenced_surfaces_; 90 return referenced_surfaces_;
90 } 91 }
91 92
93 bool HasFrame() const { return current_frame_.has_value(); }
94
92 bool destroyed() const { return destroyed_; } 95 bool destroyed() const { return destroyed_; }
93 void set_destroyed(bool destroyed) { destroyed_ = destroyed; } 96 void set_destroyed(bool destroyed) { destroyed_ = destroyed; }
94 97
95 private: 98 private:
96 void UnrefFrameResources(DelegatedFrameData* frame_data); 99 void UnrefFrameResources(const CompositorFrame& frame_data);
97 void ClearCopyRequests(); 100 void ClearCopyRequests();
98 101
99 SurfaceId surface_id_; 102 SurfaceId surface_id_;
100 SurfaceId previous_frame_surface_id_; 103 SurfaceId previous_frame_surface_id_;
101 base::WeakPtr<SurfaceFactory> factory_; 104 base::WeakPtr<SurfaceFactory> factory_;
102 // TODO(jamesr): Support multiple frames in flight. 105 // TODO(jamesr): Support multiple frames in flight.
103 CompositorFrame current_frame_; 106 base::Optional<CompositorFrame> current_frame_;
104 int frame_index_; 107 int frame_index_;
105 bool destroyed_; 108 bool destroyed_;
106 std::vector<SurfaceSequence> destruction_dependencies_; 109 std::vector<SurfaceSequence> destruction_dependencies_;
107 110
108 // This surface may have multiple BeginFrameSources if it is 111 // This surface may have multiple BeginFrameSources if it is
109 // on multiple Displays. 112 // on multiple Displays.
110 std::set<BeginFrameSource*> begin_frame_sources_; 113 std::set<BeginFrameSource*> begin_frame_sources_;
111 114
112 std::vector<SurfaceId> referenced_surfaces_; 115 std::vector<SurfaceId> referenced_surfaces_;
113 116
114 DrawCallback draw_callback_; 117 DrawCallback draw_callback_;
115 118
116 DISALLOW_COPY_AND_ASSIGN(Surface); 119 DISALLOW_COPY_AND_ASSIGN(Surface);
117 }; 120 };
118 121
119 } // namespace cc 122 } // namespace cc
120 123
121 #endif // CC_SURFACES_SURFACE_H_ 124 #endif // CC_SURFACES_SURFACE_H_
OLDNEW
« no previous file with comments | « cc/surfaces/display_unittest.cc ('k') | cc/surfaces/surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698