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

Side by Side Diff: cc/layers/layer.h

Issue 2128633002: cc: Set up the framework to restrict access to Layer internals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move out the inner struct. Created 4 years, 5 months 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/layers/heads_up_display_layer.cc ('k') | cc/layers/layer.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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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_LAYERS_LAYER_H_ 5 #ifndef CC_LAYERS_LAYER_H_
6 #define CC_LAYERS_LAYER_H_ 6 #define CC_LAYERS_LAYER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 public: 74 public:
75 using LayerListType = LayerList; 75 using LayerListType = LayerList;
76 using LayerIdMap = std::unordered_map<int, scoped_refptr<Layer>>; 76 using LayerIdMap = std::unordered_map<int, scoped_refptr<Layer>>;
77 77
78 enum LayerIdLabels { 78 enum LayerIdLabels {
79 INVALID_ID = -1, 79 INVALID_ID = -1,
80 }; 80 };
81 81
82 static scoped_refptr<Layer> Create(); 82 static scoped_refptr<Layer> Create();
83 83
84 int id() const { return layer_id_; } 84 int id() const { return inputs_.layer_id; }
85 85
86 Layer* RootLayer(); 86 Layer* RootLayer();
87 Layer* parent() { return parent_; } 87 Layer* parent() { return parent_; }
88 const Layer* parent() const { return parent_; } 88 const Layer* parent() const { return parent_; }
89 void AddChild(scoped_refptr<Layer> child); 89 void AddChild(scoped_refptr<Layer> child);
90 void InsertChild(scoped_refptr<Layer> child, size_t index); 90 void InsertChild(scoped_refptr<Layer> child, size_t index);
91 void ReplaceChild(Layer* reference, scoped_refptr<Layer> new_layer); 91 void ReplaceChild(Layer* reference, scoped_refptr<Layer> new_layer);
92 void RemoveFromParent(); 92 void RemoveFromParent();
93 void RemoveAllChildren(); 93 void RemoveAllChildren();
94 void SetChildren(const LayerList& children); 94 void SetChildren(const LayerList& children);
95 bool HasAncestor(const Layer* ancestor) const; 95 bool HasAncestor(const Layer* ancestor) const;
96 96
97 const LayerList& children() const { return children_; } 97 const LayerList& children() const { return inputs_.children; }
98 Layer* child_at(size_t index) { return children_[index].get(); } 98 Layer* child_at(size_t index) { return inputs_.children[index].get(); }
99 99
100 // This requests the layer and its subtree be rendered and given to the 100 // This requests the layer and its subtree be rendered and given to the
101 // callback. If the copy is unable to be produced (the layer is destroyed 101 // callback. If the copy is unable to be produced (the layer is destroyed
102 // first), then the callback is called with a nullptr/empty result. If the 102 // first), then the callback is called with a nullptr/empty result. If the
103 // request's source property is set, any prior uncommitted requests having the 103 // request's source property is set, any prior uncommitted requests having the
104 // same source will be aborted. 104 // same source will be aborted.
105 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> request); 105 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> request);
106 bool HasCopyRequest() const { 106 bool HasCopyRequest() const { return !inputs_.copy_requests.empty(); }
107 return !copy_requests_.empty();
108 }
109 107
110 void TakeCopyRequests( 108 void TakeCopyRequests(
111 std::vector<std::unique_ptr<CopyOutputRequest>>* requests); 109 std::vector<std::unique_ptr<CopyOutputRequest>>* requests);
112 110
113 virtual void SetBackgroundColor(SkColor background_color); 111 virtual void SetBackgroundColor(SkColor background_color);
114 SkColor background_color() const { return background_color_; } 112 SkColor background_color() const { return inputs_.background_color; }
115 void SetSafeOpaqueBackgroundColor(SkColor background_color); 113 void SetSafeOpaqueBackgroundColor(SkColor background_color);
116 // If contents_opaque(), return an opaque color else return a 114 // If contents_opaque(), return an opaque color else return a
117 // non-opaque color. Tries to return background_color(), if possible. 115 // non-opaque color. Tries to return background_color(), if possible.
118 SkColor SafeOpaqueBackgroundColor() const; 116 SkColor SafeOpaqueBackgroundColor() const;
119 117
120 // A layer's bounds are in logical, non-page-scaled pixels (however, the 118 // A layer's bounds are in logical, non-page-scaled pixels (however, the
121 // root layer's bounds are in physical pixels). 119 // root layer's bounds are in physical pixels).
122 void SetBounds(const gfx::Size& bounds); 120 void SetBounds(const gfx::Size& bounds);
123 gfx::Size bounds() const { return bounds_; } 121 gfx::Size bounds() const { return inputs_.bounds; }
124 122
125 void SetMasksToBounds(bool masks_to_bounds); 123 void SetMasksToBounds(bool masks_to_bounds);
126 bool masks_to_bounds() const { return masks_to_bounds_; } 124 bool masks_to_bounds() const { return inputs_.masks_to_bounds; }
127 125
128 void SetMaskLayer(Layer* mask_layer); 126 void SetMaskLayer(Layer* mask_layer);
129 Layer* mask_layer() { return mask_layer_.get(); } 127 Layer* mask_layer() { return inputs_.mask_layer.get(); }
130 const Layer* mask_layer() const { return mask_layer_.get(); } 128 const Layer* mask_layer() const { return inputs_.mask_layer.get(); }
131 129
132 virtual void SetNeedsDisplayRect(const gfx::Rect& dirty_rect); 130 virtual void SetNeedsDisplayRect(const gfx::Rect& dirty_rect);
133 void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::Rect(bounds())); } 131 void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::Rect(bounds())); }
134 132
135 virtual void SetOpacity(float opacity); 133 virtual void SetOpacity(float opacity);
136 float opacity() const { return opacity_; } 134 float opacity() const { return inputs_.opacity; }
137 float EffectiveOpacity() const; 135 float EffectiveOpacity() const;
138 bool OpacityIsAnimating() const; 136 bool OpacityIsAnimating() const;
139 bool HasPotentiallyRunningOpacityAnimation() const; 137 bool HasPotentiallyRunningOpacityAnimation() const;
140 virtual bool OpacityCanAnimateOnImplThread() const; 138 virtual bool OpacityCanAnimateOnImplThread() const;
141 139
142 virtual bool AlwaysUseActiveTreeOpacity() const; 140 virtual bool AlwaysUseActiveTreeOpacity() const;
143 141
144 void SetBlendMode(SkXfermode::Mode blend_mode); 142 void SetBlendMode(SkXfermode::Mode blend_mode);
145 SkXfermode::Mode blend_mode() const { return blend_mode_; } 143 SkXfermode::Mode blend_mode() const { return inputs_.blend_mode; }
146 144
147 void set_draw_blend_mode(SkXfermode::Mode blend_mode) { 145 void set_draw_blend_mode(SkXfermode::Mode blend_mode) {
148 if (draw_blend_mode_ == blend_mode) 146 if (draw_blend_mode_ == blend_mode)
149 return; 147 return;
150 draw_blend_mode_ = blend_mode; 148 draw_blend_mode_ = blend_mode;
151 SetNeedsPushProperties(); 149 SetNeedsPushProperties();
152 } 150 }
153 SkXfermode::Mode draw_blend_mode() const { return draw_blend_mode_; } 151 SkXfermode::Mode draw_blend_mode() const { return draw_blend_mode_; }
154 152
155 bool uses_default_blend_mode() const { 153 bool uses_default_blend_mode() const {
156 return blend_mode_ == SkXfermode::kSrcOver_Mode; 154 return inputs_.blend_mode == SkXfermode::kSrcOver_Mode;
157 } 155 }
158 156
159 // A layer is root for an isolated group when it and all its descendants are 157 // A layer is root for an isolated group when it and all its descendants are
160 // drawn over a black and fully transparent background, creating an isolated 158 // drawn over a black and fully transparent background, creating an isolated
161 // group. It should be used along with SetBlendMode(), in order to restrict 159 // group. It should be used along with SetBlendMode(), in order to restrict
162 // layers within the group to blend with layers outside this group. 160 // layers within the group to blend with layers outside this group.
163 void SetIsRootForIsolatedGroup(bool root); 161 void SetIsRootForIsolatedGroup(bool root);
164 bool is_root_for_isolated_group() const { 162 bool is_root_for_isolated_group() const {
165 return is_root_for_isolated_group_; 163 return inputs_.is_root_for_isolated_group;
166 } 164 }
167 165
168 void SetFilters(const FilterOperations& filters); 166 void SetFilters(const FilterOperations& filters);
169 const FilterOperations& filters() const { return filters_; } 167 const FilterOperations& filters() const { return inputs_.filters; }
170 bool FilterIsAnimating() const; 168 bool FilterIsAnimating() const;
171 bool HasPotentiallyRunningFilterAnimation() const; 169 bool HasPotentiallyRunningFilterAnimation() const;
172 170
173 // Background filters are filters applied to what is behind this layer, when 171 // Background filters are filters applied to what is behind this layer, when
174 // they are viewed through non-opaque regions in this layer. They are used 172 // they are viewed through non-opaque regions in this layer. They are used
175 // through the WebLayer interface, and are not exposed to HTML. 173 // through the WebLayer interface, and are not exposed to HTML.
176 void SetBackgroundFilters(const FilterOperations& filters); 174 void SetBackgroundFilters(const FilterOperations& filters);
177 const FilterOperations& background_filters() const { 175 const FilterOperations& background_filters() const {
178 return background_filters_; 176 return inputs_.background_filters;
179 } 177 }
180 178
181 virtual void SetContentsOpaque(bool opaque); 179 virtual void SetContentsOpaque(bool opaque);
182 bool contents_opaque() const { return contents_opaque_; } 180 bool contents_opaque() const { return inputs_.contents_opaque; }
183 181
184 void SetPosition(const gfx::PointF& position); 182 void SetPosition(const gfx::PointF& position);
185 gfx::PointF position() const { return position_; } 183 gfx::PointF position() const { return inputs_.position; }
186 184
187 // A layer that is a container for fixed position layers cannot be both 185 // A layer that is a container for fixed position layers cannot be both
188 // scrollable and have a non-identity transform. 186 // scrollable and have a non-identity transform.
189 void SetIsContainerForFixedPositionLayers(bool container); 187 void SetIsContainerForFixedPositionLayers(bool container);
190 bool IsContainerForFixedPositionLayers() const; 188 bool IsContainerForFixedPositionLayers() const;
191 189
192 gfx::Vector2dF FixedContainerSizeDelta() const { 190 gfx::Vector2dF FixedContainerSizeDelta() const {
193 return gfx::Vector2dF(); 191 return gfx::Vector2dF();
194 } 192 }
195 193
196 void SetPositionConstraint(const LayerPositionConstraint& constraint); 194 void SetPositionConstraint(const LayerPositionConstraint& constraint);
197 const LayerPositionConstraint& position_constraint() const { 195 const LayerPositionConstraint& position_constraint() const {
198 return position_constraint_; 196 return inputs_.position_constraint;
199 } 197 }
200 198
201 void SetTransform(const gfx::Transform& transform); 199 void SetTransform(const gfx::Transform& transform);
202 const gfx::Transform& transform() const { return transform_; } 200 const gfx::Transform& transform() const { return inputs_.transform; }
203 bool TransformIsAnimating() const; 201 bool TransformIsAnimating() const;
204 bool HasPotentiallyRunningTransformAnimation() const; 202 bool HasPotentiallyRunningTransformAnimation() const;
205 bool HasOnlyTranslationTransforms() const; 203 bool HasOnlyTranslationTransforms() const;
206 bool AnimationsPreserveAxisAlignment() const; 204 bool AnimationsPreserveAxisAlignment() const;
207 205
208 bool MaximumTargetScale(float* max_scale) const; 206 bool MaximumTargetScale(float* max_scale) const;
209 bool AnimationStartScale(float* start_scale) const; 207 bool AnimationStartScale(float* start_scale) const;
210 208
211 void SetTransformOrigin(const gfx::Point3F&); 209 void SetTransformOrigin(const gfx::Point3F&);
212 gfx::Point3F transform_origin() const { return transform_origin_; } 210 gfx::Point3F transform_origin() const { return inputs_.transform_origin; }
213 211
214 bool HasAnyAnimationTargetingProperty(TargetProperty::Type property) const; 212 bool HasAnyAnimationTargetingProperty(TargetProperty::Type property) const;
215 213
216 bool ScrollOffsetAnimationWasInterrupted() const; 214 bool ScrollOffsetAnimationWasInterrupted() const;
217 215
218 void SetScrollParent(Layer* parent); 216 void SetScrollParent(Layer* parent);
219 217
220 Layer* scroll_parent() { return scroll_parent_; } 218 Layer* scroll_parent() { return inputs_.scroll_parent; }
221 const Layer* scroll_parent() const { return scroll_parent_; } 219 const Layer* scroll_parent() const { return inputs_.scroll_parent; }
222 220
223 void AddScrollChild(Layer* child); 221 void AddScrollChild(Layer* child);
224 void RemoveScrollChild(Layer* child); 222 void RemoveScrollChild(Layer* child);
225 223
226 std::set<Layer*>* scroll_children() { return scroll_children_.get(); } 224 std::set<Layer*>* scroll_children() { return scroll_children_.get(); }
227 const std::set<Layer*>* scroll_children() const { 225 const std::set<Layer*>* scroll_children() const {
228 return scroll_children_.get(); 226 return scroll_children_.get();
229 } 227 }
230 228
231 void SetClipParent(Layer* ancestor); 229 void SetClipParent(Layer* ancestor);
232 230
233 Layer* clip_parent() { return clip_parent_; } 231 Layer* clip_parent() { return inputs_.clip_parent; }
234 const Layer* clip_parent() const { 232 const Layer* clip_parent() const { return inputs_.clip_parent; }
235 return clip_parent_;
236 }
237 233
238 void AddClipChild(Layer* child); 234 void AddClipChild(Layer* child);
239 void RemoveClipChild(Layer* child); 235 void RemoveClipChild(Layer* child);
240 236
241 std::set<Layer*>* clip_children() { return clip_children_.get(); } 237 std::set<Layer*>* clip_children() { return clip_children_.get(); }
242 const std::set<Layer*>* clip_children() const { 238 const std::set<Layer*>* clip_children() const {
243 return clip_children_.get(); 239 return clip_children_.get();
244 } 240 }
245 241
246 // TODO(enne): Fix style here (and everywhere) once LayerImpl does the same. 242 // TODO(enne): Fix style here (and everywhere) once LayerImpl does the same.
247 gfx::Transform screen_space_transform() const; 243 gfx::Transform screen_space_transform() const;
248 244
249 void set_num_unclipped_descendants(size_t descendants) { 245 void set_num_unclipped_descendants(size_t descendants) {
250 num_unclipped_descendants_ = descendants; 246 num_unclipped_descendants_ = descendants;
251 } 247 }
252 size_t num_unclipped_descendants() const { 248 size_t num_unclipped_descendants() const {
253 return num_unclipped_descendants_; 249 return num_unclipped_descendants_;
254 } 250 }
255 251
256 void SetScrollOffset(const gfx::ScrollOffset& scroll_offset); 252 void SetScrollOffset(const gfx::ScrollOffset& scroll_offset);
257 253
258 gfx::ScrollOffset scroll_offset() const { return scroll_offset_; } 254 gfx::ScrollOffset scroll_offset() const { return inputs_.scroll_offset; }
259 void SetScrollOffsetFromImplSide(const gfx::ScrollOffset& scroll_offset); 255 void SetScrollOffsetFromImplSide(const gfx::ScrollOffset& scroll_offset);
260 256
261 void SetScrollClipLayerId(int clip_layer_id); 257 void SetScrollClipLayerId(int clip_layer_id);
262 bool scrollable() const { return scroll_clip_layer_id_ != INVALID_ID; } 258 bool scrollable() const { return inputs_.scroll_clip_layer_id != INVALID_ID; }
263 Layer* scroll_clip_layer() const; 259 Layer* scroll_clip_layer() const;
264 260
265 void SetUserScrollable(bool horizontal, bool vertical); 261 void SetUserScrollable(bool horizontal, bool vertical);
266 bool user_scrollable_horizontal() const { 262 bool user_scrollable_horizontal() const {
267 return user_scrollable_horizontal_; 263 return inputs_.user_scrollable_horizontal;
268 } 264 }
269 bool user_scrollable_vertical() const { return user_scrollable_vertical_; } 265 bool user_scrollable_vertical() const {
266 return inputs_.user_scrollable_vertical;
267 }
270 268
271 void AddMainThreadScrollingReasons(uint32_t main_thread_scrolling_reasons); 269 void AddMainThreadScrollingReasons(uint32_t main_thread_scrolling_reasons);
272 void ClearMainThreadScrollingReasons( 270 void ClearMainThreadScrollingReasons(
273 uint32_t main_thread_scrolling_reasons_to_clear); 271 uint32_t main_thread_scrolling_reasons_to_clear);
274 uint32_t main_thread_scrolling_reasons() const { 272 uint32_t main_thread_scrolling_reasons() const {
275 return main_thread_scrolling_reasons_; 273 return inputs_.main_thread_scrolling_reasons;
276 } 274 }
277 bool should_scroll_on_main_thread() const { 275 bool should_scroll_on_main_thread() const {
278 return !!main_thread_scrolling_reasons_; 276 return !!inputs_.main_thread_scrolling_reasons;
279 } 277 }
280 278
281 void SetNonFastScrollableRegion(const Region& non_fast_scrollable_region); 279 void SetNonFastScrollableRegion(const Region& non_fast_scrollable_region);
282 const Region& non_fast_scrollable_region() const { 280 const Region& non_fast_scrollable_region() const {
283 return non_fast_scrollable_region_; 281 return inputs_.non_fast_scrollable_region;
284 } 282 }
285 283
286 void SetTouchEventHandlerRegion(const Region& touch_event_handler_region); 284 void SetTouchEventHandlerRegion(const Region& touch_event_handler_region);
287 const Region& touch_event_handler_region() const { 285 const Region& touch_event_handler_region() const {
288 return touch_event_handler_region_; 286 return inputs_.touch_event_handler_region;
289 } 287 }
290 288
291 void set_did_scroll_callback(const base::Closure& callback) { 289 void set_did_scroll_callback(const base::Closure& callback) {
292 did_scroll_callback_ = callback; 290 inputs_.did_scroll_callback = callback;
293 } 291 }
294 292
295 void SetForceRenderSurfaceForTesting(bool force_render_surface); 293 void SetForceRenderSurfaceForTesting(bool force_render_surface);
296 bool force_render_surface_for_testing() const { 294 bool force_render_surface_for_testing() const {
297 return force_render_surface_for_testing_; 295 return force_render_surface_for_testing_;
298 } 296 }
299 297
300 gfx::ScrollOffset CurrentScrollOffset() const { return scroll_offset_; } 298 gfx::ScrollOffset CurrentScrollOffset() const {
299 return inputs_.scroll_offset;
300 }
301 301
302 void SetDoubleSided(bool double_sided); 302 void SetDoubleSided(bool double_sided);
303 bool double_sided() const { return double_sided_; } 303 bool double_sided() const { return inputs_.double_sided; }
304 304
305 void SetShouldFlattenTransform(bool flatten); 305 void SetShouldFlattenTransform(bool flatten);
306 bool should_flatten_transform() const { return should_flatten_transform_; } 306 bool should_flatten_transform() const {
307 return inputs_.should_flatten_transform;
308 }
307 309
308 bool Is3dSorted() const { return sorting_context_id_ != 0; } 310 bool Is3dSorted() const { return inputs_.sorting_context_id != 0; }
309 311
310 void SetUseParentBackfaceVisibility(bool use); 312 void SetUseParentBackfaceVisibility(bool use);
311 bool use_parent_backface_visibility() const { 313 bool use_parent_backface_visibility() const {
312 return use_parent_backface_visibility_; 314 return inputs_.use_parent_backface_visibility;
313 } 315 }
314 316
315 void SetUseLocalTransformForBackfaceVisibility(bool use_local); 317 void SetUseLocalTransformForBackfaceVisibility(bool use_local);
316 bool use_local_transform_for_backface_visibility() const { 318 bool use_local_transform_for_backface_visibility() const {
317 return use_local_transform_for_backface_visibility_; 319 return use_local_transform_for_backface_visibility_;
318 } 320 }
319 321
320 void SetShouldCheckBackfaceVisibility(bool should_check_backface_visibility); 322 void SetShouldCheckBackfaceVisibility(bool should_check_backface_visibility);
321 bool should_check_backface_visibility() const { 323 bool should_check_backface_visibility() const {
322 return should_check_backface_visibility_; 324 return should_check_backface_visibility_;
323 } 325 }
324 326
325 virtual void SetLayerTreeHost(LayerTreeHost* host); 327 virtual void SetLayerTreeHost(LayerTreeHost* host);
326 328
327 void SetIsDrawable(bool is_drawable); 329 void SetIsDrawable(bool is_drawable);
328 330
329 void SetHideLayerAndSubtree(bool hide); 331 void SetHideLayerAndSubtree(bool hide);
330 bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; } 332 bool hide_layer_and_subtree() const { return inputs_.hide_layer_and_subtree; }
331 333
332 void SetReplicaLayer(Layer* layer); 334 void SetReplicaLayer(Layer* layer);
333 Layer* replica_layer() { return replica_layer_.get(); } 335 Layer* replica_layer() { return inputs_.replica_layer.get(); }
334 const Layer* replica_layer() const { return replica_layer_.get(); } 336 const Layer* replica_layer() const { return inputs_.replica_layer.get(); }
335 337
336 bool has_mask() const { return !!mask_layer_.get(); } 338 bool has_mask() const { return !!inputs_.mask_layer.get(); }
337 bool has_replica() const { return !!replica_layer_.get(); } 339 bool has_replica() const { return !!inputs_.replica_layer.get(); }
338 bool replica_has_mask() const { 340 bool replica_has_mask() const {
339 return replica_layer_.get() && 341 return inputs_.replica_layer.get() &&
340 (mask_layer_.get() || replica_layer_->mask_layer_.get()); 342 (inputs_.mask_layer.get() ||
343 inputs_.replica_layer->inputs_.mask_layer.get());
341 } 344 }
342 345
343 int NumDescendantsThatDrawContent() const; 346 int NumDescendantsThatDrawContent() const;
344 347
345 // This is only virtual for tests. 348 // This is only virtual for tests.
346 // TODO(awoloszyn): Remove this once we no longer need it for tests 349 // TODO(awoloszyn): Remove this once we no longer need it for tests
347 virtual bool DrawsContent() const; 350 virtual bool DrawsContent() const;
348 351
349 // This methods typically need to be overwritten by derived classes. 352 // This methods typically need to be overwritten by derived classes.
350 // TODO(chrishtr): Blink no longer resizes anything during paint. We can 353 // TODO(chrishtr): Blink no longer resizes anything during paint. We can
351 // remove this. 354 // remove this.
352 virtual void SavePaintProperties(); 355 virtual void SavePaintProperties();
353 // Returns true iff anything was updated that needs to be committed. 356 // Returns true iff anything was updated that needs to be committed.
354 virtual bool Update(); 357 virtual bool Update();
355 virtual void SetIsMask(bool is_mask) {} 358 virtual void SetIsMask(bool is_mask) {}
356 virtual bool IsSuitableForGpuRasterization() const; 359 virtual bool IsSuitableForGpuRasterization() const;
357 360
358 virtual std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 361 virtual std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
359 TakeDebugInfo(); 362 TakeDebugInfo();
360 363
361 void SetLayerClient(LayerClient* client) { client_ = client; } 364 void SetLayerClient(LayerClient* client) { inputs_.client = client; }
362 365
363 virtual void PushPropertiesTo(LayerImpl* layer); 366 virtual void PushPropertiesTo(LayerImpl* layer);
364 367
365 // Sets the type proto::LayerType that should be used for serialization 368 // Sets the type proto::LayerType that should be used for serialization
366 // of the current layer by calling LayerNode::set_type(proto::LayerType). 369 // of the current layer by calling LayerNode::set_type(proto::LayerType).
367 // TODO(nyquist): Start using a forward declared enum class when 370 // TODO(nyquist): Start using a forward declared enum class when
368 // https://github.com/google/protobuf/issues/67 has been fixed and rolled in. 371 // https://github.com/google/protobuf/issues/67 has been fixed and rolled in.
369 // This function would preferably instead return a proto::LayerType, but 372 // This function would preferably instead return a proto::LayerType, but
370 // since that is an enum (the protobuf library does not generate enum 373 // since that is an enum (the protobuf library does not generate enum
371 // classes), it can't be forward declared. We don't want to include 374 // classes), it can't be forward declared. We don't want to include
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } 412 LayerTreeHost* layer_tree_host() { return layer_tree_host_; }
410 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } 413 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; }
411 414
412 virtual ScrollbarLayerInterface* ToScrollbarLayer(); 415 virtual ScrollbarLayerInterface* ToScrollbarLayer();
413 416
414 virtual sk_sp<SkPicture> GetPicture() const; 417 virtual sk_sp<SkPicture> GetPicture() const;
415 418
416 // Constructs a LayerImpl of the correct runtime type for this Layer type. 419 // Constructs a LayerImpl of the correct runtime type for this Layer type.
417 virtual std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); 420 virtual std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
418 421
419 bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); } 422 bool NeedsDisplayForTesting() const { return !inputs_.update_rect.IsEmpty(); }
420 void ResetNeedsDisplayForTesting() { update_rect_ = gfx::Rect(); } 423 void ResetNeedsDisplayForTesting() { inputs_.update_rect = gfx::Rect(); }
421 424
422 RenderingStatsInstrumentation* rendering_stats_instrumentation() const; 425 RenderingStatsInstrumentation* rendering_stats_instrumentation() const;
423 426
424 const PaintProperties& paint_properties() const { 427 const PaintProperties& paint_properties() const {
425 return paint_properties_; 428 return paint_properties_;
426 } 429 }
427 430
428 void SetNeedsPushProperties(); 431 void SetNeedsPushProperties();
429 void ResetNeedsPushPropertiesForTesting(); 432 void ResetNeedsPushPropertiesForTesting();
430 433
431 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); 434 virtual void RunMicroBenchmark(MicroBenchmark* benchmark);
432 435
433 void Set3dSortingContextId(int id); 436 void Set3dSortingContextId(int id);
434 int sorting_context_id() const { return sorting_context_id_; } 437 int sorting_context_id() const { return inputs_.sorting_context_id; }
435 438
436 void set_property_tree_sequence_number(int sequence_number) { 439 void set_property_tree_sequence_number(int sequence_number) {
437 property_tree_sequence_number_ = sequence_number; 440 property_tree_sequence_number_ = sequence_number;
438 } 441 }
439 int property_tree_sequence_number() { return property_tree_sequence_number_; } 442 int property_tree_sequence_number() { return property_tree_sequence_number_; }
440 443
441 void SetTransformTreeIndex(int index); 444 void SetTransformTreeIndex(int index);
442 int transform_tree_index() const; 445 int transform_tree_index() const;
443 446
444 void SetClipTreeIndex(int index); 447 void SetClipTreeIndex(int index);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 bool subtree_property_changed() const { return subtree_property_changed_; } 489 bool subtree_property_changed() const { return subtree_property_changed_; }
487 490
488 void SetLayerPropertyChanged(); 491 void SetLayerPropertyChanged();
489 bool layer_property_changed() const { return layer_property_changed_; } 492 bool layer_property_changed() const { return layer_property_changed_; }
490 493
491 void DidBeginTracing(); 494 void DidBeginTracing();
492 495
493 int num_copy_requests_in_target_subtree(); 496 int num_copy_requests_in_target_subtree();
494 497
495 void SetElementId(ElementId id); 498 void SetElementId(ElementId id);
496 ElementId element_id() const { return element_id_; } 499 ElementId element_id() const { return inputs_.element_id; }
497 500
498 void SetMutableProperties(uint32_t properties); 501 void SetMutableProperties(uint32_t properties);
499 uint32_t mutable_properties() const { return mutable_properties_; } 502 uint32_t mutable_properties() const { return inputs_.mutable_properties; }
500 503
501 // Interactions with attached animations.
502 gfx::ScrollOffset ScrollOffsetForAnimation() const;
503 void OnFilterAnimated(const FilterOperations& filters);
504 void OnOpacityAnimated(float opacity);
505 void OnTransformAnimated(const gfx::Transform& transform);
506 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset);
507 void OnTransformIsCurrentlyAnimatingChanged(bool is_animating);
508 void OnTransformIsPotentiallyAnimatingChanged(bool is_animating);
509 void OnOpacityIsCurrentlyAnimatingChanged(bool is_currently_animating);
510 void OnOpacityIsPotentiallyAnimatingChanged(bool has_potential_animation);
511 bool HasActiveAnimationForTesting() const; 504 bool HasActiveAnimationForTesting() const;
512 505
513 void SetHasWillChangeTransformHint(bool has_will_change); 506 void SetHasWillChangeTransformHint(bool has_will_change);
514 bool has_will_change_transform_hint() const { 507 bool has_will_change_transform_hint() const {
515 return has_will_change_transform_hint_; 508 return inputs_.has_will_change_transform_hint;
516 } 509 }
517 510
518 protected: 511 protected:
519 friend class LayerImpl; 512 friend class LayerImpl;
520 friend class TreeSynchronizer; 513 friend class TreeSynchronizer;
521 virtual ~Layer(); 514 virtual ~Layer();
522 Layer(); 515 Layer();
523 516
524 // These SetNeeds functions are in order of severity of update: 517 // These SetNeeds functions are in order of severity of update:
525 // 518 //
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 // into proto::LayerProperties. This method is not marked as const 550 // into proto::LayerProperties. This method is not marked as const
558 // as some implementations need reset member fields, similarly to 551 // as some implementations need reset member fields, similarly to
559 // PushPropertiesTo(). 552 // PushPropertiesTo().
560 virtual void LayerSpecificPropertiesToProto(proto::LayerProperties* proto); 553 virtual void LayerSpecificPropertiesToProto(proto::LayerProperties* proto);
561 554
562 // Deserialize all the necessary properties from proto::LayerProperties into 555 // Deserialize all the necessary properties from proto::LayerProperties into
563 // this Layer. 556 // this Layer.
564 virtual void FromLayerSpecificPropertiesProto( 557 virtual void FromLayerSpecificPropertiesProto(
565 const proto::LayerProperties& proto); 558 const proto::LayerProperties& proto);
566 559
567 // The update rect is the region of the compositor resource that was 560 gfx::Rect& update_rect() { return inputs_.update_rect; }
568 // actually updated by the compositor. For layers that may do updating
569 // outside the compositor's control (i.e. plugin layers), this information
570 // is not available and the update rect will remain empty.
571 // Note this rect is in layer space (not content space).
572 gfx::Rect update_rect_;
573
574 scoped_refptr<Layer> mask_layer_;
575
576 int layer_id_;
577 561
578 // When true, the layer is about to perform an update. Any commit requests 562 // When true, the layer is about to perform an update. Any commit requests
579 // will be handled implicitly after the update completes. 563 // will be handled implicitly after the update completes.
580 bool ignore_set_needs_commit_; 564 bool ignore_set_needs_commit_;
581 565
582 // Layers that share a sorting context id will be sorted together in 3d
583 // space. 0 is a special value that means this layer will not be sorted and
584 // will be drawn in paint order.
585 int sorting_context_id_;
586
587 private: 566 private:
588 friend class base::RefCounted<Layer>; 567 friend class base::RefCounted<Layer>;
589 friend class LayerSerializationTest; 568 friend class LayerSerializationTest;
590 friend class LayerTreeHostCommon; 569 friend class LayerTreeHostCommon;
570 friend class LayerTreeHost;
571 friend class LayerInternalsForTest;
572
573 // Interactions with attached animations.
574 gfx::ScrollOffset ScrollOffsetForAnimation() const;
575 void OnFilterAnimated(const FilterOperations& filters);
576 void OnOpacityAnimated(float opacity);
577 void OnTransformAnimated(const gfx::Transform& transform);
578 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset);
579 void OnTransformIsCurrentlyAnimatingChanged(bool is_animating);
580 void OnTransformIsPotentiallyAnimatingChanged(bool is_animating);
581 void OnOpacityIsCurrentlyAnimatingChanged(bool is_currently_animating);
582 void OnOpacityIsPotentiallyAnimatingChanged(bool has_potential_animation);
591 583
592 void SetParent(Layer* layer); 584 void SetParent(Layer* layer);
593 bool DescendantIsFixedToContainerLayer() const; 585 bool DescendantIsFixedToContainerLayer() const;
594 586
595 // This should only be called from RemoveFromParent(). 587 // This should only be called from RemoveFromParent().
596 void RemoveChildOrDependent(Layer* child); 588 void RemoveChildOrDependent(Layer* child);
597 589
598 // If this layer has a scroll parent, it removes |this| from its list of 590 // If this layer has a scroll parent, it removes |this| from its list of
599 // scroll children. 591 // scroll children.
600 void RemoveFromScrollTree(); 592 void RemoveFromScrollTree();
601 593
602 // If this layer has a clip parent, it removes |this| from its list of clip 594 // If this layer has a clip parent, it removes |this| from its list of clip
603 // children. 595 // children.
604 void RemoveFromClipTree(); 596 void RemoveFromClipTree();
605 597
606 // When we detach or attach layer to new LayerTreeHost, all property trees' 598 // When we detach or attach layer to new LayerTreeHost, all property trees'
607 // indices becomes invalid. 599 // indices becomes invalid.
608 void InvalidatePropertyTreesIndices(); 600 void InvalidatePropertyTreesIndices();
609 601
610 LayerList children_; 602 // Encapsulates all data, callbacks or interfaces received from the embedder.
603 // TODO(khushalsagar): This is only valid when PropertyTrees are built
604 // internally in cc. Update this for the SPv2 path where blink generates
605 // PropertyTrees.
606 struct Inputs {
607 Inputs();
608 ~Inputs();
609
610 int layer_id;
611
612 LayerList children;
613
614 // The update rect is the region of the compositor resource that was
615 // actually updated by the compositor. For layers that may do updating
616 // outside the compositor's control (i.e. plugin layers), this information
617 // is not available and the update rect will remain empty.
618 // Note this rect is in layer space (not content space).
619 gfx::Rect update_rect;
620
621 gfx::Size bounds;
622 bool masks_to_bounds;
623
624 scoped_refptr<Layer> mask_layer;
625
626 // Replica layer used for reflections.
627 scoped_refptr<Layer> replica_layer;
628
629 float opacity;
630 SkXfermode::Mode blend_mode;
631
632 bool is_root_for_isolated_group : 1;
633
634 bool contents_opaque : 1;
635
636 gfx::PointF position;
637 gfx::Transform transform;
638 gfx::Point3F transform_origin;
639
640 bool is_drawable : 1;
641
642 bool double_sided : 1;
643 bool should_flatten_transform : 1;
644
645 // Layers that share a sorting context id will be sorted together in 3d
646 // space. 0 is a special value that means this layer will not be sorted
647 // and will be drawn in paint order.
648 int sorting_context_id;
649
650 bool use_parent_backface_visibility : 1;
651
652 SkColor background_color;
653
654 FilterOperations filters;
655 FilterOperations background_filters;
656
657 gfx::ScrollOffset scroll_offset;
658
659 // This variable indicates which ancestor layer (if any) whose size,
660 // transformed relative to this layer, defines the maximum scroll offset
661 // for this layer.
662 int scroll_clip_layer_id;
663 bool user_scrollable_horizontal : 1;
664 bool user_scrollable_vertical : 1;
665
666 uint32_t main_thread_scrolling_reasons;
667 Region non_fast_scrollable_region;
668
669 Region touch_event_handler_region;
670
671 bool is_container_for_fixed_position_layers : 1;
672 LayerPositionConstraint position_constraint;
673
674 ElementId element_id;
675
676 uint32_t mutable_properties;
677
678 Layer* scroll_parent;
679 Layer* clip_parent;
680
681 bool has_will_change_transform_hint : 1;
682
683 bool hide_layer_and_subtree : 1;
684
685 // The following elements can not and are not serialized.
686 LayerClient* client;
687 base::Closure did_scroll_callback;
688 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests;
689 };
690
611 Layer* parent_; 691 Layer* parent_;
612 692
613 // Layer instances have a weak pointer to their LayerTreeHost. 693 // Layer instances have a weak pointer to their LayerTreeHost.
614 // This pointer value is nil when a Layer is not in a tree and is 694 // This pointer value is nil when a Layer is not in a tree and is
615 // updated via SetLayerTreeHost() if a layer moves between trees. 695 // updated via SetLayerTreeHost() if a layer moves between trees.
616 LayerTreeHost* layer_tree_host_; 696 LayerTreeHost* layer_tree_host_;
617 697
618 // Layer properties. 698 Inputs inputs_;
619 gfx::Size bounds_;
620 699
621 gfx::ScrollOffset scroll_offset_;
622 // This variable indicates which ancestor layer (if any) whose size,
623 // transformed relative to this layer, defines the maximum scroll offset for
624 // this layer.
625 int scroll_clip_layer_id_;
626 int num_descendants_that_draw_content_; 700 int num_descendants_that_draw_content_;
627 int transform_tree_index_; 701 int transform_tree_index_;
628 int effect_tree_index_; 702 int effect_tree_index_;
629 int clip_tree_index_; 703 int clip_tree_index_;
630 int scroll_tree_index_; 704 int scroll_tree_index_;
631 int property_tree_sequence_number_; 705 int property_tree_sequence_number_;
632 ElementId element_id_;
633 uint32_t mutable_properties_;
634 gfx::Vector2dF offset_to_transform_parent_; 706 gfx::Vector2dF offset_to_transform_parent_;
635 uint32_t main_thread_scrolling_reasons_;
636 bool should_flatten_transform_from_property_tree_ : 1; 707 bool should_flatten_transform_from_property_tree_ : 1;
637 bool user_scrollable_horizontal_ : 1;
638 bool user_scrollable_vertical_ : 1;
639 bool is_root_for_isolated_group_ : 1;
640 bool is_container_for_fixed_position_layers_ : 1;
641 bool is_drawable_ : 1;
642 bool draws_content_ : 1; 708 bool draws_content_ : 1;
643 bool hide_layer_and_subtree_ : 1;
644 bool masks_to_bounds_ : 1;
645 bool contents_opaque_ : 1;
646 bool double_sided_ : 1;
647 bool should_flatten_transform_ : 1;
648 bool use_parent_backface_visibility_ : 1;
649 bool use_local_transform_for_backface_visibility_ : 1; 709 bool use_local_transform_for_backface_visibility_ : 1;
650 bool should_check_backface_visibility_ : 1; 710 bool should_check_backface_visibility_ : 1;
651 bool force_render_surface_for_testing_ : 1; 711 bool force_render_surface_for_testing_ : 1;
652 bool subtree_property_changed_ : 1; 712 bool subtree_property_changed_ : 1;
653 bool layer_property_changed_ : 1; 713 bool layer_property_changed_ : 1;
654 bool has_will_change_transform_hint_ : 1;
655 Region non_fast_scrollable_region_;
656 Region touch_event_handler_region_;
657 gfx::PointF position_;
658 SkColor background_color_;
659 SkColor safe_opaque_background_color_; 714 SkColor safe_opaque_background_color_;
660 float opacity_;
661 SkXfermode::Mode blend_mode_;
662 // draw_blend_mode may be different than blend_mode_, 715 // draw_blend_mode may be different than blend_mode_,
663 // when a RenderSurface re-parents the layer's blend_mode. 716 // when a RenderSurface re-parents the layer's blend_mode.
664 SkXfermode::Mode draw_blend_mode_; 717 SkXfermode::Mode draw_blend_mode_;
665 FilterOperations filters_;
666 FilterOperations background_filters_;
667 LayerPositionConstraint position_constraint_;
668 Layer* scroll_parent_;
669 std::unique_ptr<std::set<Layer*>> scroll_children_; 718 std::unique_ptr<std::set<Layer*>> scroll_children_;
670 719
671 Layer* clip_parent_;
672 std::unique_ptr<std::set<Layer*>> clip_children_; 720 std::unique_ptr<std::set<Layer*>> clip_children_;
673 721
674 gfx::Transform transform_;
675 gfx::Point3F transform_origin_;
676
677 // Replica layer used for reflections.
678 scoped_refptr<Layer> replica_layer_;
679
680 LayerClient* client_;
681
682 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests_;
683
684 base::Closure did_scroll_callback_;
685
686 PaintProperties paint_properties_; 722 PaintProperties paint_properties_;
687 723
688 // These all act like draw properties, so don't need push properties. 724 // These all act like draw properties, so don't need push properties.
689 gfx::Rect visible_layer_rect_; 725 gfx::Rect visible_layer_rect_;
690 size_t num_unclipped_descendants_; 726 size_t num_unclipped_descendants_;
691 727
692 DISALLOW_COPY_AND_ASSIGN(Layer); 728 DISALLOW_COPY_AND_ASSIGN(Layer);
693 }; 729 };
694 730
695 } // namespace cc 731 } // namespace cc
696 732
697 #endif // CC_LAYERS_LAYER_H_ 733 #endif // CC_LAYERS_LAYER_H_
OLDNEW
« no previous file with comments | « cc/layers/heads_up_display_layer.cc ('k') | cc/layers/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698