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 |
11 #include <deque> | 11 #include <deque> |
12 #include <memory> | 12 #include <memory> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/mac/scoped_cftyperef.h" | 15 #include "base/mac/scoped_cftyperef.h" |
16 #include "base/mac/scoped_nsobject.h" | 16 #include "base/mac/scoped_nsobject.h" |
17 #include "ui/accelerated_widget_mac/accelerated_widget_mac_export.h" | 17 #include "ui/accelerated_widget_mac/accelerated_widget_mac_export.h" |
18 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
19 #include "ui/gfx/geometry/rect_f.h" | 19 #include "ui/gfx/geometry/rect_f.h" |
20 #include "ui/gfx/mac/io_surface.h" | 20 #include "ui/gfx/mac/io_surface.h" |
21 #include "ui/gfx/transform.h" | 21 #include "ui/gfx/transform.h" |
22 | 22 |
23 @class AVSampleBufferDisplayLayer; | 23 @class AVSampleBufferDisplayLayer; |
24 | 24 |
25 namespace ui { | 25 namespace ui { |
26 | 26 |
27 struct CARendererLayerParams; | |
28 | |
29 // The CARendererLayerTree will construct a hierarchy of CALayers from a linear | 27 // The CARendererLayerTree will construct a hierarchy of CALayers from a linear |
30 // list provided by the CoreAnimation renderer using the algorithm and structure | 28 // list provided by the CoreAnimation renderer using the algorithm and structure |
31 // referenced described in | 29 // referenced described in |
32 // https://docs.google.com/document/d/1DtSN9zzvCF44_FQPM7ie01UxGHagQ66zfF5L9Hnig
QY/edit?usp=sharing | 30 // https://docs.google.com/document/d/1DtSN9zzvCF44_FQPM7ie01UxGHagQ66zfF5L9Hnig
QY/edit?usp=sharing |
33 class ACCELERATED_WIDGET_MAC_EXPORT CARendererLayerTree { | 31 class ACCELERATED_WIDGET_MAC_EXPORT CARendererLayerTree { |
34 public: | 32 public: |
35 CARendererLayerTree(); | 33 CARendererLayerTree(); |
36 | 34 |
37 // This will remove all CALayers from this tree from their superlayer. | 35 // This will remove all CALayers from this tree from their superlayer. |
38 ~CARendererLayerTree(); | 36 ~CARendererLayerTree(); |
39 | 37 |
40 // Append the description of a new CALayer to the tree. This will not | 38 // Append the description of a new CALayer to the tree. This will not |
41 // create any new CALayers until CommitScheduledCALayers is called. This | 39 // create any new CALayers until CommitScheduledCALayers is called. This |
42 // cannot be called anymore after CommitScheduledCALayers has been called. | 40 // cannot be called anymore after CommitScheduledCALayers has been called. |
43 bool ScheduleCALayer(const CARendererLayerParams& params); | 41 bool ScheduleCALayer(bool is_clipped, |
| 42 const gfx::Rect& clip_rect, |
| 43 unsigned sorting_context_id, |
| 44 const gfx::Transform& transform, |
| 45 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, |
| 46 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer, |
| 47 const gfx::RectF& contents_rect, |
| 48 const gfx::Rect& rect, |
| 49 unsigned background_color, |
| 50 unsigned edge_aa_mask, |
| 51 float opacity, |
| 52 unsigned filter); |
44 | 53 |
45 // Create a CALayer tree for the scheduled layers, and set |superlayer| to | 54 // Create a CALayer tree for the scheduled layers, and set |superlayer| to |
46 // have only this tree as its sublayers. If |old_tree| is non-null, then try | 55 // have only this tree as its sublayers. If |old_tree| is non-null, then try |
47 // to re-use the CALayers of |old_tree| as much as possible. |old_tree| will | 56 // to re-use the CALayers of |old_tree| as much as possible. |old_tree| will |
48 // be destroyed at the end of the function, and any CALayers in it which were | 57 // be destroyed at the end of the function, and any CALayers in it which were |
49 // not re-used by |this| will be removed from the CALayer hierarchy. | 58 // not re-used by |this| will be removed from the CALayer hierarchy. |
50 void CommitScheduledCALayers(CALayer* superlayer, | 59 void CommitScheduledCALayers(CALayer* superlayer, |
51 std::unique_ptr<CARendererLayerTree> old_tree, | 60 std::unique_ptr<CARendererLayerTree> old_tree, |
52 float scale_factor); | 61 float scale_factor); |
53 | 62 |
(...skipping 12 matching lines...) Expand all Loading... |
66 | 75 |
67 struct RootLayer { | 76 struct RootLayer { |
68 RootLayer(); | 77 RootLayer(); |
69 | 78 |
70 // This will remove |ca_layer| from its superlayer, if |ca_layer| is | 79 // This will remove |ca_layer| from its superlayer, if |ca_layer| is |
71 // non-nil. | 80 // non-nil. |
72 ~RootLayer(); | 81 ~RootLayer(); |
73 | 82 |
74 // Append a new content layer, without modifying the actual CALayer | 83 // Append a new content layer, without modifying the actual CALayer |
75 // structure. | 84 // structure. |
76 bool AddContentLayer(const CARendererLayerParams& params); | 85 bool AddContentLayer( |
| 86 bool is_clipped, |
| 87 const gfx::Rect& clip_rect, |
| 88 unsigned sorting_context_id, |
| 89 const gfx::Transform& transform, |
| 90 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, |
| 91 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer, |
| 92 const gfx::RectF& contents_rect, |
| 93 const gfx::Rect& rect, |
| 94 unsigned background_color, |
| 95 unsigned edge_aa_mask, |
| 96 float opacity, |
| 97 unsigned filter); |
77 | 98 |
78 // Allocate CALayers for this layer and its children, and set their | 99 // Allocate CALayers for this layer and its children, and set their |
79 // properties appropriately. Re-use the CALayers from |old_layer| if | 100 // properties appropriately. Re-use the CALayers from |old_layer| if |
80 // possible. If re-using a CALayer from |old_layer|, reset its |ca_layer| | 101 // 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. | 102 // to nil, so that its destructor will not remove an active CALayer. |
82 void CommitToCA(CALayer* superlayer, | 103 void CommitToCA(CALayer* superlayer, |
83 RootLayer* old_layer, | 104 RootLayer* old_layer, |
84 float scale_factor); | 105 float scale_factor); |
85 | 106 |
86 std::vector<ClipAndSortingLayer> clip_and_sorting_layers; | 107 std::vector<ClipAndSortingLayer> clip_and_sorting_layers; |
87 base::scoped_nsobject<CALayer> ca_layer; | 108 base::scoped_nsobject<CALayer> ca_layer; |
88 | 109 |
89 private: | 110 private: |
90 DISALLOW_COPY_AND_ASSIGN(RootLayer); | 111 DISALLOW_COPY_AND_ASSIGN(RootLayer); |
91 }; | 112 }; |
92 struct ClipAndSortingLayer { | 113 struct ClipAndSortingLayer { |
93 ClipAndSortingLayer(bool is_clipped, | 114 ClipAndSortingLayer(bool is_clipped, |
94 gfx::Rect clip_rect, | 115 gfx::Rect clip_rect, |
95 unsigned sorting_context_id, | 116 unsigned sorting_context_id, |
96 bool is_singleton_sorting_context); | 117 bool is_singleton_sorting_context); |
97 ClipAndSortingLayer(ClipAndSortingLayer&& layer); | 118 ClipAndSortingLayer(ClipAndSortingLayer&& layer); |
98 | 119 |
99 // See the behavior of RootLayer for the effects of these functions on the | 120 // See the behavior of RootLayer for the effects of these functions on the |
100 // |ca_layer| member and |old_layer| argument. | 121 // |ca_layer| member and |old_layer| argument. |
101 ~ClipAndSortingLayer(); | 122 ~ClipAndSortingLayer(); |
102 void AddContentLayer(const CARendererLayerParams& params); | 123 void AddContentLayer( |
| 124 const gfx::Transform& transform, |
| 125 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, |
| 126 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer, |
| 127 const gfx::RectF& contents_rect, |
| 128 const gfx::Rect& rect, |
| 129 unsigned background_color, |
| 130 unsigned edge_aa_mask, |
| 131 float opacity, |
| 132 unsigned filter); |
103 void CommitToCA(CALayer* superlayer, | 133 void CommitToCA(CALayer* superlayer, |
104 ClipAndSortingLayer* old_layer, | 134 ClipAndSortingLayer* old_layer, |
105 float scale_factor); | 135 float scale_factor); |
106 | 136 |
107 std::vector<TransformLayer> transform_layers; | 137 std::vector<TransformLayer> transform_layers; |
108 bool is_clipped = false; | 138 bool is_clipped = false; |
109 gfx::Rect clip_rect; | 139 gfx::Rect clip_rect; |
110 unsigned sorting_context_id = 0; | 140 unsigned sorting_context_id = 0; |
111 bool is_singleton_sorting_context = false; | 141 bool is_singleton_sorting_context = false; |
112 base::scoped_nsobject<CALayer> ca_layer; | 142 base::scoped_nsobject<CALayer> ca_layer; |
113 | 143 |
114 private: | 144 private: |
115 DISALLOW_COPY_AND_ASSIGN(ClipAndSortingLayer); | 145 DISALLOW_COPY_AND_ASSIGN(ClipAndSortingLayer); |
116 }; | 146 }; |
117 struct TransformLayer { | 147 struct TransformLayer { |
118 TransformLayer(const gfx::Transform& transform); | 148 TransformLayer(const gfx::Transform& transform); |
119 TransformLayer(TransformLayer&& layer); | 149 TransformLayer(TransformLayer&& layer); |
120 | 150 |
121 // See the behavior of RootLayer for the effects of these functions on the | 151 // See the behavior of RootLayer for the effects of these functions on the |
122 // |ca_layer| member and |old_layer| argument. | 152 // |ca_layer| member and |old_layer| argument. |
123 ~TransformLayer(); | 153 ~TransformLayer(); |
124 void AddContentLayer(const CARendererLayerParams& params); | 154 void AddContentLayer( |
| 155 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, |
| 156 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer, |
| 157 const gfx::RectF& contents_rect, |
| 158 const gfx::Rect& rect, |
| 159 unsigned background_color, |
| 160 unsigned edge_aa_mask, |
| 161 float opacity, |
| 162 unsigned filter); |
125 void CommitToCA(CALayer* superlayer, | 163 void CommitToCA(CALayer* superlayer, |
126 TransformLayer* old_layer, | 164 TransformLayer* old_layer, |
127 float scale_factor); | 165 float scale_factor); |
128 | 166 |
129 gfx::Transform transform; | 167 gfx::Transform transform; |
130 std::vector<ContentLayer> content_layers; | 168 std::vector<ContentLayer> content_layers; |
131 base::scoped_nsobject<CALayer> ca_layer; | 169 base::scoped_nsobject<CALayer> ca_layer; |
132 | 170 |
133 private: | 171 private: |
134 DISALLOW_COPY_AND_ASSIGN(TransformLayer); | 172 DISALLOW_COPY_AND_ASSIGN(TransformLayer); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 float scale_factor_ = 1; | 217 float scale_factor_ = 1; |
180 bool has_committed_ = false; | 218 bool has_committed_ = false; |
181 | 219 |
182 private: | 220 private: |
183 DISALLOW_COPY_AND_ASSIGN(CARendererLayerTree); | 221 DISALLOW_COPY_AND_ASSIGN(CARendererLayerTree); |
184 }; | 222 }; |
185 | 223 |
186 } // namespace ui | 224 } // namespace ui |
187 | 225 |
188 #endif // UI_ACCELERATED_WIDGET_MAC_CA_LAYER_TREE_MAC_H_ | 226 #endif // UI_ACCELERATED_WIDGET_MAC_CA_LAYER_TREE_MAC_H_ |
OLD | NEW |