OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 UI_ACCELERATED_WIDGET_MAC_CA_RENDERER_LAYER_TREE_H_ | 5 #ifndef UI_ACCELERATED_WIDGET_MAC_CA_RENDERER_LAYER_TREE_H_ |
6 #define UI_ACCELERATED_WIDGET_MAC_CA_RENDERER_LAYER_TREE_H_ | 6 #define UI_ACCELERATED_WIDGET_MAC_CA_RENDERER_LAYER_TREE_H_ |
7 | 7 |
8 #include <IOSurface/IOSurface.h> | 8 #include <IOSurface/IOSurface.h> |
9 #include <QuartzCore/QuartzCore.h> | 9 #include <QuartzCore/QuartzCore.h> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 namespace ui { | 25 namespace ui { |
26 | 26 |
27 struct CARendererLayerParams; | 27 struct CARendererLayerParams; |
28 | 28 |
29 // The CARendererLayerTree will construct a hierarchy of CALayers from a linear | 29 // The CARendererLayerTree will construct a hierarchy of CALayers from a linear |
30 // list provided by the CoreAnimation renderer using the algorithm and structure | 30 // list provided by the CoreAnimation renderer using the algorithm and structure |
31 // referenced described in | 31 // referenced described in |
32 // https://docs.google.com/document/d/1DtSN9zzvCF44_FQPM7ie01UxGHagQ66zfF5L9Hnig
QY/edit?usp=sharing | 32 // https://docs.google.com/document/d/1DtSN9zzvCF44_FQPM7ie01UxGHagQ66zfF5L9Hnig
QY/edit?usp=sharing |
33 class ACCELERATED_WIDGET_MAC_EXPORT CARendererLayerTree { | 33 class ACCELERATED_WIDGET_MAC_EXPORT CARendererLayerTree { |
34 public: | 34 public: |
35 CARendererLayerTree(); | 35 CARendererLayerTree(bool allow_av_sample_buffer_display_layer); |
36 | 36 |
37 // This will remove all CALayers from this tree from their superlayer. | 37 // This will remove all CALayers from this tree from their superlayer. |
38 ~CARendererLayerTree(); | 38 ~CARendererLayerTree(); |
39 | 39 |
40 // Append the description of a new CALayer to the tree. This will not | 40 // Append the description of a new CALayer to the tree. This will not |
41 // create any new CALayers until CommitScheduledCALayers is called. This | 41 // create any new CALayers until CommitScheduledCALayers is called. This |
42 // cannot be called anymore after CommitScheduledCALayers has been called. | 42 // cannot be called anymore after CommitScheduledCALayers has been called. |
43 bool ScheduleCALayer(const CARendererLayerParams& params); | 43 bool ScheduleCALayer(const CARendererLayerParams& params); |
44 | 44 |
45 // Create a CALayer tree for the scheduled layers, and set |superlayer| to | 45 // Create a CALayer tree for the scheduled layers, and set |superlayer| to |
(...skipping 10 matching lines...) Expand all Loading... |
56 // to draw this content and return true. Otherwise return false. This is to | 56 // to draw this content and return true. Otherwise return false. This is to |
57 // be called after committing scheduled CALayers. | 57 // be called after committing scheduled CALayers. |
58 bool CommitFullscreenLowPowerLayer( | 58 bool CommitFullscreenLowPowerLayer( |
59 AVSampleBufferDisplayLayer* fullscreen_low_power_layer); | 59 AVSampleBufferDisplayLayer* fullscreen_low_power_layer); |
60 | 60 |
61 private: | 61 private: |
62 struct RootLayer; | 62 struct RootLayer; |
63 struct ClipAndSortingLayer; | 63 struct ClipAndSortingLayer; |
64 struct TransformLayer; | 64 struct TransformLayer; |
65 struct ContentLayer; | 65 struct ContentLayer; |
| 66 friend struct ContentLayer; |
66 | 67 |
67 struct RootLayer { | 68 struct RootLayer { |
68 RootLayer(); | 69 RootLayer(); |
69 | 70 |
70 // This will remove |ca_layer| from its superlayer, if |ca_layer| is | 71 // This will remove |ca_layer| from its superlayer, if |ca_layer| is |
71 // non-nil. | 72 // non-nil. |
72 ~RootLayer(); | 73 ~RootLayer(); |
73 | 74 |
74 // Append a new content layer, without modifying the actual CALayer | 75 // Append a new content layer, without modifying the actual CALayer |
75 // structure. | 76 // structure. |
76 bool AddContentLayer(const CARendererLayerParams& params); | 77 bool AddContentLayer(CARendererLayerTree* tree, |
| 78 const CARendererLayerParams& params); |
77 | 79 |
78 // Allocate CALayers for this layer and its children, and set their | 80 // Allocate CALayers for this layer and its children, and set their |
79 // properties appropriately. Re-use the CALayers from |old_layer| if | 81 // properties appropriately. Re-use the CALayers from |old_layer| if |
80 // possible. If re-using a CALayer from |old_layer|, reset its |ca_layer| | 82 // possible. If re-using a CALayer from |old_layer|, reset its |ca_layer| |
81 // to nil, so that its destructor will not remove an active CALayer. | 83 // to nil, so that its destructor will not remove an active CALayer. |
82 void CommitToCA(CALayer* superlayer, | 84 void CommitToCA(CALayer* superlayer, |
83 RootLayer* old_layer, | 85 RootLayer* old_layer, |
84 float scale_factor); | 86 float scale_factor); |
85 | 87 |
86 std::vector<ClipAndSortingLayer> clip_and_sorting_layers; | 88 std::vector<ClipAndSortingLayer> clip_and_sorting_layers; |
87 base::scoped_nsobject<CALayer> ca_layer; | 89 base::scoped_nsobject<CALayer> ca_layer; |
88 | 90 |
89 private: | 91 private: |
90 DISALLOW_COPY_AND_ASSIGN(RootLayer); | 92 DISALLOW_COPY_AND_ASSIGN(RootLayer); |
91 }; | 93 }; |
92 struct ClipAndSortingLayer { | 94 struct ClipAndSortingLayer { |
93 ClipAndSortingLayer(bool is_clipped, | 95 ClipAndSortingLayer(bool is_clipped, |
94 gfx::Rect clip_rect, | 96 gfx::Rect clip_rect, |
95 unsigned sorting_context_id, | 97 unsigned sorting_context_id, |
96 bool is_singleton_sorting_context); | 98 bool is_singleton_sorting_context); |
97 ClipAndSortingLayer(ClipAndSortingLayer&& layer); | 99 ClipAndSortingLayer(ClipAndSortingLayer&& layer); |
98 | 100 |
99 // See the behavior of RootLayer for the effects of these functions on the | 101 // See the behavior of RootLayer for the effects of these functions on the |
100 // |ca_layer| member and |old_layer| argument. | 102 // |ca_layer| member and |old_layer| argument. |
101 ~ClipAndSortingLayer(); | 103 ~ClipAndSortingLayer(); |
102 void AddContentLayer(const CARendererLayerParams& params); | 104 void AddContentLayer(CARendererLayerTree* tree, |
| 105 const CARendererLayerParams& params); |
103 void CommitToCA(CALayer* superlayer, | 106 void CommitToCA(CALayer* superlayer, |
104 ClipAndSortingLayer* old_layer, | 107 ClipAndSortingLayer* old_layer, |
105 float scale_factor); | 108 float scale_factor); |
106 | 109 |
107 std::vector<TransformLayer> transform_layers; | 110 std::vector<TransformLayer> transform_layers; |
108 bool is_clipped = false; | 111 bool is_clipped = false; |
109 gfx::Rect clip_rect; | 112 gfx::Rect clip_rect; |
110 unsigned sorting_context_id = 0; | 113 unsigned sorting_context_id = 0; |
111 bool is_singleton_sorting_context = false; | 114 bool is_singleton_sorting_context = false; |
112 base::scoped_nsobject<CALayer> ca_layer; | 115 base::scoped_nsobject<CALayer> ca_layer; |
113 | 116 |
114 private: | 117 private: |
115 DISALLOW_COPY_AND_ASSIGN(ClipAndSortingLayer); | 118 DISALLOW_COPY_AND_ASSIGN(ClipAndSortingLayer); |
116 }; | 119 }; |
117 struct TransformLayer { | 120 struct TransformLayer { |
118 TransformLayer(const gfx::Transform& transform); | 121 TransformLayer(const gfx::Transform& transform); |
119 TransformLayer(TransformLayer&& layer); | 122 TransformLayer(TransformLayer&& layer); |
120 | 123 |
121 // See the behavior of RootLayer for the effects of these functions on the | 124 // See the behavior of RootLayer for the effects of these functions on the |
122 // |ca_layer| member and |old_layer| argument. | 125 // |ca_layer| member and |old_layer| argument. |
123 ~TransformLayer(); | 126 ~TransformLayer(); |
124 void AddContentLayer(const CARendererLayerParams& params); | 127 void AddContentLayer(CARendererLayerTree* tree, |
| 128 const CARendererLayerParams& params); |
125 void CommitToCA(CALayer* superlayer, | 129 void CommitToCA(CALayer* superlayer, |
126 TransformLayer* old_layer, | 130 TransformLayer* old_layer, |
127 float scale_factor); | 131 float scale_factor); |
128 | 132 |
129 gfx::Transform transform; | 133 gfx::Transform transform; |
130 std::vector<ContentLayer> content_layers; | 134 std::vector<ContentLayer> content_layers; |
131 base::scoped_nsobject<CALayer> ca_layer; | 135 base::scoped_nsobject<CALayer> ca_layer; |
132 | 136 |
133 private: | 137 private: |
134 DISALLOW_COPY_AND_ASSIGN(TransformLayer); | 138 DISALLOW_COPY_AND_ASSIGN(TransformLayer); |
135 }; | 139 }; |
136 struct ContentLayer { | 140 struct ContentLayer { |
137 ContentLayer(base::ScopedCFTypeRef<IOSurfaceRef> io_surface, | 141 ContentLayer(CARendererLayerTree* tree, |
| 142 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, |
138 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer, | 143 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer, |
139 const gfx::RectF& contents_rect, | 144 const gfx::RectF& contents_rect, |
140 const gfx::Rect& rect, | 145 const gfx::Rect& rect, |
141 unsigned background_color, | 146 unsigned background_color, |
142 unsigned edge_aa_mask, | 147 unsigned edge_aa_mask, |
143 float opacity, | 148 float opacity, |
144 unsigned filter); | 149 unsigned filter); |
145 ContentLayer(ContentLayer&& layer); | 150 ContentLayer(ContentLayer&& layer); |
146 | 151 |
147 // See the behavior of RootLayer for the effects of these functions on the | 152 // See the behavior of RootLayer for the effects of these functions on the |
(...skipping 23 matching lines...) Expand all Loading... |
171 base::scoped_nsobject<AVSampleBufferDisplayLayer> av_layer; | 176 base::scoped_nsobject<AVSampleBufferDisplayLayer> av_layer; |
172 bool use_av_layer = false; | 177 bool use_av_layer = false; |
173 | 178 |
174 private: | 179 private: |
175 DISALLOW_COPY_AND_ASSIGN(ContentLayer); | 180 DISALLOW_COPY_AND_ASSIGN(ContentLayer); |
176 }; | 181 }; |
177 | 182 |
178 RootLayer root_layer_; | 183 RootLayer root_layer_; |
179 float scale_factor_ = 1; | 184 float scale_factor_ = 1; |
180 bool has_committed_ = false; | 185 bool has_committed_ = false; |
| 186 const bool allow_av_sample_buffer_display_layer_ = true; |
181 | 187 |
182 private: | 188 private: |
183 DISALLOW_COPY_AND_ASSIGN(CARendererLayerTree); | 189 DISALLOW_COPY_AND_ASSIGN(CARendererLayerTree); |
184 }; | 190 }; |
185 | 191 |
186 } // namespace ui | 192 } // namespace ui |
187 | 193 |
188 #endif // UI_ACCELERATED_WIDGET_MAC_CA_LAYER_TREE_MAC_H_ | 194 #endif // UI_ACCELERATED_WIDGET_MAC_CA_LAYER_TREE_MAC_H_ |
OLD | NEW |