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

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 data from embedder into 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_.data.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_.data.children; }
98 Layer* child_at(size_t index) { return children_[index].get(); } 98 Layer* child_at(size_t index) { return inputs_.data.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_.data.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_.data.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_.data.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_.data.mask_layer.get(); }
130 const Layer* mask_layer() const { return mask_layer_.get(); } 128 const Layer* mask_layer() const { return inputs_.data.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_.data.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_.data.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_.data.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_.data.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_.data.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_.data.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_.data.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_.data.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_.data.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_.data.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 {
211 return inputs_.data.transform_origin;
212 }
213 213
214 bool HasAnyAnimationTargetingProperty(TargetProperty::Type property) const; 214 bool HasAnyAnimationTargetingProperty(TargetProperty::Type property) const;
215 215
216 bool ScrollOffsetAnimationWasInterrupted() const; 216 bool ScrollOffsetAnimationWasInterrupted() const;
217 217
218 void SetScrollParent(Layer* parent); 218 void SetScrollParent(Layer* parent);
219 219
220 Layer* scroll_parent() { return scroll_parent_; } 220 Layer* scroll_parent() { return inputs_.data.scroll_parent; }
221 const Layer* scroll_parent() const { return scroll_parent_; } 221 const Layer* scroll_parent() const { return inputs_.data.scroll_parent; }
222 222
223 void AddScrollChild(Layer* child); 223 void AddScrollChild(Layer* child);
224 void RemoveScrollChild(Layer* child); 224 void RemoveScrollChild(Layer* child);
225 225
226 std::set<Layer*>* scroll_children() { return scroll_children_.get(); } 226 std::set<Layer*>* scroll_children() { return scroll_children_.get(); }
227 const std::set<Layer*>* scroll_children() const { 227 const std::set<Layer*>* scroll_children() const {
228 return scroll_children_.get(); 228 return scroll_children_.get();
229 } 229 }
230 230
231 void SetClipParent(Layer* ancestor); 231 void SetClipParent(Layer* ancestor);
232 232
233 Layer* clip_parent() { return clip_parent_; } 233 Layer* clip_parent() { return inputs_.data.clip_parent; }
234 const Layer* clip_parent() const { 234 const Layer* clip_parent() const { return inputs_.data.clip_parent; }
235 return clip_parent_;
236 }
237 235
238 void AddClipChild(Layer* child); 236 void AddClipChild(Layer* child);
239 void RemoveClipChild(Layer* child); 237 void RemoveClipChild(Layer* child);
240 238
241 std::set<Layer*>* clip_children() { return clip_children_.get(); } 239 std::set<Layer*>* clip_children() { return clip_children_.get(); }
242 const std::set<Layer*>* clip_children() const { 240 const std::set<Layer*>* clip_children() const {
243 return clip_children_.get(); 241 return clip_children_.get();
244 } 242 }
245 243
246 // TODO(enne): Fix style here (and everywhere) once LayerImpl does the same. 244 // TODO(enne): Fix style here (and everywhere) once LayerImpl does the same.
247 gfx::Transform screen_space_transform() const; 245 gfx::Transform screen_space_transform() const;
248 246
249 void set_num_unclipped_descendants(size_t descendants) { 247 void set_num_unclipped_descendants(size_t descendants) {
250 num_unclipped_descendants_ = descendants; 248 num_unclipped_descendants_ = descendants;
251 } 249 }
252 size_t num_unclipped_descendants() const { 250 size_t num_unclipped_descendants() const {
253 return num_unclipped_descendants_; 251 return num_unclipped_descendants_;
254 } 252 }
255 253
256 void SetScrollOffset(const gfx::ScrollOffset& scroll_offset); 254 void SetScrollOffset(const gfx::ScrollOffset& scroll_offset);
257 255
258 gfx::ScrollOffset scroll_offset() const { return scroll_offset_; } 256 gfx::ScrollOffset scroll_offset() const { return inputs_.data.scroll_offset; }
259 void SetScrollOffsetFromImplSide(const gfx::ScrollOffset& scroll_offset); 257 void SetScrollOffsetFromImplSide(const gfx::ScrollOffset& scroll_offset);
260 258
261 void SetScrollClipLayerId(int clip_layer_id); 259 void SetScrollClipLayerId(int clip_layer_id);
262 bool scrollable() const { return scroll_clip_layer_id_ != INVALID_ID; } 260 bool scrollable() const {
261 return inputs_.data.scroll_clip_layer_id != INVALID_ID;
262 }
263 Layer* scroll_clip_layer() const; 263 Layer* scroll_clip_layer() const;
264 264
265 void SetUserScrollable(bool horizontal, bool vertical); 265 void SetUserScrollable(bool horizontal, bool vertical);
266 bool user_scrollable_horizontal() const { 266 bool user_scrollable_horizontal() const {
267 return user_scrollable_horizontal_; 267 return inputs_.data.user_scrollable_horizontal;
268 } 268 }
269 bool user_scrollable_vertical() const { return user_scrollable_vertical_; } 269 bool user_scrollable_vertical() const {
270 return inputs_.data.user_scrollable_vertical;
271 }
270 272
271 void AddMainThreadScrollingReasons(uint32_t main_thread_scrolling_reasons); 273 void AddMainThreadScrollingReasons(uint32_t main_thread_scrolling_reasons);
272 void ClearMainThreadScrollingReasons( 274 void ClearMainThreadScrollingReasons(
273 uint32_t main_thread_scrolling_reasons_to_clear); 275 uint32_t main_thread_scrolling_reasons_to_clear);
274 uint32_t main_thread_scrolling_reasons() const { 276 uint32_t main_thread_scrolling_reasons() const {
275 return main_thread_scrolling_reasons_; 277 return inputs_.data.main_thread_scrolling_reasons;
276 } 278 }
277 bool should_scroll_on_main_thread() const { 279 bool should_scroll_on_main_thread() const {
278 return !!main_thread_scrolling_reasons_; 280 return !!inputs_.data.main_thread_scrolling_reasons;
279 } 281 }
280 282
281 void SetNonFastScrollableRegion(const Region& non_fast_scrollable_region); 283 void SetNonFastScrollableRegion(const Region& non_fast_scrollable_region);
282 const Region& non_fast_scrollable_region() const { 284 const Region& non_fast_scrollable_region() const {
283 return non_fast_scrollable_region_; 285 return inputs_.data.non_fast_scrollable_region;
284 } 286 }
285 287
286 void SetTouchEventHandlerRegion(const Region& touch_event_handler_region); 288 void SetTouchEventHandlerRegion(const Region& touch_event_handler_region);
287 const Region& touch_event_handler_region() const { 289 const Region& touch_event_handler_region() const {
288 return touch_event_handler_region_; 290 return inputs_.data.touch_event_handler_region;
289 } 291 }
290 292
291 void set_did_scroll_callback(const base::Closure& callback) { 293 void set_did_scroll_callback(const base::Closure& callback) {
292 did_scroll_callback_ = callback; 294 inputs_.did_scroll_callback = callback;
293 } 295 }
294 296
295 void SetForceRenderSurfaceForTesting(bool force_render_surface); 297 void SetForceRenderSurfaceForTesting(bool force_render_surface);
296 bool force_render_surface_for_testing() const { 298 bool force_render_surface_for_testing() const {
297 return force_render_surface_for_testing_; 299 return force_render_surface_for_testing_;
298 } 300 }
299 301
300 gfx::ScrollOffset CurrentScrollOffset() const { return scroll_offset_; } 302 gfx::ScrollOffset CurrentScrollOffset() const {
303 return inputs_.data.scroll_offset;
304 }
301 305
302 void SetDoubleSided(bool double_sided); 306 void SetDoubleSided(bool double_sided);
303 bool double_sided() const { return double_sided_; } 307 bool double_sided() const { return inputs_.data.double_sided; }
304 308
305 void SetShouldFlattenTransform(bool flatten); 309 void SetShouldFlattenTransform(bool flatten);
306 bool should_flatten_transform() const { return should_flatten_transform_; } 310 bool should_flatten_transform() const {
311 return inputs_.data.should_flatten_transform;
312 }
307 313
308 bool Is3dSorted() const { return sorting_context_id_ != 0; } 314 bool Is3dSorted() const { return inputs_.data.sorting_context_id != 0; }
309 315
310 void SetUseParentBackfaceVisibility(bool use); 316 void SetUseParentBackfaceVisibility(bool use);
311 bool use_parent_backface_visibility() const { 317 bool use_parent_backface_visibility() const {
312 return use_parent_backface_visibility_; 318 return inputs_.data.use_parent_backface_visibility;
313 } 319 }
314 320
315 void SetUseLocalTransformForBackfaceVisibility(bool use_local); 321 void SetUseLocalTransformForBackfaceVisibility(bool use_local);
316 bool use_local_transform_for_backface_visibility() const { 322 bool use_local_transform_for_backface_visibility() const {
317 return use_local_transform_for_backface_visibility_; 323 return use_local_transform_for_backface_visibility_;
318 } 324 }
319 325
320 void SetShouldCheckBackfaceVisibility(bool should_check_backface_visibility); 326 void SetShouldCheckBackfaceVisibility(bool should_check_backface_visibility);
321 bool should_check_backface_visibility() const { 327 bool should_check_backface_visibility() const {
322 return should_check_backface_visibility_; 328 return should_check_backface_visibility_;
323 } 329 }
324 330
325 virtual void SetLayerTreeHost(LayerTreeHost* host); 331 virtual void SetLayerTreeHost(LayerTreeHost* host);
326 332
327 void SetIsDrawable(bool is_drawable); 333 void SetIsDrawable(bool is_drawable);
328 334
329 void SetHideLayerAndSubtree(bool hide); 335 void SetHideLayerAndSubtree(bool hide);
330 bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; } 336 bool hide_layer_and_subtree() const {
337 return inputs_.data.hide_layer_and_subtree;
338 }
331 339
332 void SetReplicaLayer(Layer* layer); 340 void SetReplicaLayer(Layer* layer);
333 Layer* replica_layer() { return replica_layer_.get(); } 341 Layer* replica_layer() { return inputs_.data.replica_layer.get(); }
334 const Layer* replica_layer() const { return replica_layer_.get(); } 342 const Layer* replica_layer() const {
343 return inputs_.data.replica_layer.get();
344 }
335 345
336 bool has_mask() const { return !!mask_layer_.get(); } 346 bool has_mask() const { return !!inputs_.data.mask_layer.get(); }
337 bool has_replica() const { return !!replica_layer_.get(); } 347 bool has_replica() const { return !!inputs_.data.replica_layer.get(); }
338 bool replica_has_mask() const { 348 bool replica_has_mask() const {
339 return replica_layer_.get() && 349 return inputs_.data.replica_layer.get() &&
340 (mask_layer_.get() || replica_layer_->mask_layer_.get()); 350 (inputs_.data.mask_layer.get() ||
351 inputs_.data.replica_layer->inputs_.data.mask_layer.get());
341 } 352 }
342 353
343 int NumDescendantsThatDrawContent() const; 354 int NumDescendantsThatDrawContent() const;
344 355
345 // This is only virtual for tests. 356 // This is only virtual for tests.
346 // TODO(awoloszyn): Remove this once we no longer need it for tests 357 // TODO(awoloszyn): Remove this once we no longer need it for tests
347 virtual bool DrawsContent() const; 358 virtual bool DrawsContent() const;
348 359
349 // This methods typically need to be overwritten by derived classes. 360 // This methods typically need to be overwritten by derived classes.
350 // TODO(chrishtr): Blink no longer resizes anything during paint. We can 361 // TODO(chrishtr): Blink no longer resizes anything during paint. We can
351 // remove this. 362 // remove this.
352 virtual void SavePaintProperties(); 363 virtual void SavePaintProperties();
353 // Returns true iff anything was updated that needs to be committed. 364 // Returns true iff anything was updated that needs to be committed.
354 virtual bool Update(); 365 virtual bool Update();
355 virtual void SetIsMask(bool is_mask) {} 366 virtual void SetIsMask(bool is_mask) {}
356 virtual bool IsSuitableForGpuRasterization() const; 367 virtual bool IsSuitableForGpuRasterization() const;
357 368
358 virtual std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 369 virtual std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
359 TakeDebugInfo(); 370 TakeDebugInfo();
360 371
361 void SetLayerClient(LayerClient* client) { client_ = client; } 372 void SetLayerClient(LayerClient* client) { inputs_.client = client; }
362 373
363 virtual void PushPropertiesTo(LayerImpl* layer); 374 virtual void PushPropertiesTo(LayerImpl* layer);
364 375
365 // Sets the type proto::LayerType that should be used for serialization 376 // Sets the type proto::LayerType that should be used for serialization
366 // of the current layer by calling LayerNode::set_type(proto::LayerType). 377 // of the current layer by calling LayerNode::set_type(proto::LayerType).
367 // TODO(nyquist): Start using a forward declared enum class when 378 // TODO(nyquist): Start using a forward declared enum class when
368 // https://github.com/google/protobuf/issues/67 has been fixed and rolled in. 379 // https://github.com/google/protobuf/issues/67 has been fixed and rolled in.
369 // This function would preferably instead return a proto::LayerType, but 380 // This function would preferably instead return a proto::LayerType, but
370 // since that is an enum (the protobuf library does not generate enum 381 // 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 382 // 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_; } 420 LayerTreeHost* layer_tree_host() { return layer_tree_host_; }
410 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } 421 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; }
411 422
412 virtual ScrollbarLayerInterface* ToScrollbarLayer(); 423 virtual ScrollbarLayerInterface* ToScrollbarLayer();
413 424
414 virtual sk_sp<SkPicture> GetPicture() const; 425 virtual sk_sp<SkPicture> GetPicture() const;
415 426
416 // Constructs a LayerImpl of the correct runtime type for this Layer type. 427 // Constructs a LayerImpl of the correct runtime type for this Layer type.
417 virtual std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); 428 virtual std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
418 429
419 bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); } 430 bool NeedsDisplayForTesting() const {
420 void ResetNeedsDisplayForTesting() { update_rect_ = gfx::Rect(); } 431 return !inputs_.data.update_rect.IsEmpty();
432 }
433 void ResetNeedsDisplayForTesting() { inputs_.data.update_rect = gfx::Rect(); }
421 434
422 RenderingStatsInstrumentation* rendering_stats_instrumentation() const; 435 RenderingStatsInstrumentation* rendering_stats_instrumentation() const;
423 436
424 const PaintProperties& paint_properties() const { 437 const PaintProperties& paint_properties() const {
425 return paint_properties_; 438 return paint_properties_;
426 } 439 }
427 440
428 void SetNeedsPushProperties(); 441 void SetNeedsPushProperties();
429 void ResetNeedsPushPropertiesForTesting(); 442 void ResetNeedsPushPropertiesForTesting();
430 443
431 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); 444 virtual void RunMicroBenchmark(MicroBenchmark* benchmark);
432 445
433 void Set3dSortingContextId(int id); 446 void Set3dSortingContextId(int id);
434 int sorting_context_id() const { return sorting_context_id_; } 447 int sorting_context_id() const { return inputs_.data.sorting_context_id; }
435 448
436 void set_property_tree_sequence_number(int sequence_number) { 449 void set_property_tree_sequence_number(int sequence_number) {
437 property_tree_sequence_number_ = sequence_number; 450 property_tree_sequence_number_ = sequence_number;
438 } 451 }
439 int property_tree_sequence_number() { return property_tree_sequence_number_; } 452 int property_tree_sequence_number() { return property_tree_sequence_number_; }
440 453
441 void SetTransformTreeIndex(int index); 454 void SetTransformTreeIndex(int index);
442 int transform_tree_index() const; 455 int transform_tree_index() const;
443 456
444 void SetClipTreeIndex(int index); 457 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_; } 499 bool subtree_property_changed() const { return subtree_property_changed_; }
487 500
488 void SetLayerPropertyChanged(); 501 void SetLayerPropertyChanged();
489 bool layer_property_changed() const { return layer_property_changed_; } 502 bool layer_property_changed() const { return layer_property_changed_; }
490 503
491 void DidBeginTracing(); 504 void DidBeginTracing();
492 505
493 int num_copy_requests_in_target_subtree(); 506 int num_copy_requests_in_target_subtree();
494 507
495 void SetElementId(ElementId id); 508 void SetElementId(ElementId id);
496 ElementId element_id() const { return element_id_; } 509 ElementId element_id() const { return inputs_.data.element_id; }
497 510
498 void SetMutableProperties(uint32_t properties); 511 void SetMutableProperties(uint32_t properties);
499 uint32_t mutable_properties() const { return mutable_properties_; } 512 uint32_t mutable_properties() const {
513 return inputs_.data.mutable_properties;
514 }
500 515
501 // Interactions with attached animations. 516 // Interactions with attached animations.
502 gfx::ScrollOffset ScrollOffsetForAnimation() const; 517 gfx::ScrollOffset ScrollOffsetForAnimation() const;
503 void OnFilterAnimated(const FilterOperations& filters); 518 void OnFilterAnimated(const FilterOperations& filters);
504 void OnOpacityAnimated(float opacity); 519 void OnOpacityAnimated(float opacity);
505 void OnTransformAnimated(const gfx::Transform& transform); 520 void OnTransformAnimated(const gfx::Transform& transform);
506 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset); 521 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset);
507 void OnTransformIsCurrentlyAnimatingChanged(bool is_animating); 522 void OnTransformIsCurrentlyAnimatingChanged(bool is_animating);
508 void OnTransformIsPotentiallyAnimatingChanged(bool is_animating); 523 void OnTransformIsPotentiallyAnimatingChanged(bool is_animating);
509 void OnOpacityIsCurrentlyAnimatingChanged(bool is_currently_animating); 524 void OnOpacityIsCurrentlyAnimatingChanged(bool is_currently_animating);
510 void OnOpacityIsPotentiallyAnimatingChanged(bool has_potential_animation); 525 void OnOpacityIsPotentiallyAnimatingChanged(bool has_potential_animation);
511 bool HasActiveAnimationForTesting() const; 526 bool HasActiveAnimationForTesting() const;
512 527
513 void SetHasWillChangeTransformHint(bool has_will_change); 528 void SetHasWillChangeTransformHint(bool has_will_change);
514 bool has_will_change_transform_hint() const { 529 bool has_will_change_transform_hint() const {
515 return has_will_change_transform_hint_; 530 return inputs_.data.has_will_change_transform_hint;
516 } 531 }
517 532
518 protected: 533 protected:
519 friend class LayerImpl; 534 friend class LayerImpl;
520 friend class TreeSynchronizer; 535 friend class TreeSynchronizer;
521 virtual ~Layer(); 536 virtual ~Layer();
522 Layer(); 537 Layer();
523 538
524 // These SetNeeds functions are in order of severity of update: 539 // These SetNeeds functions are in order of severity of update:
525 // 540 //
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 // into proto::LayerProperties. This method is not marked as const 572 // into proto::LayerProperties. This method is not marked as const
558 // as some implementations need reset member fields, similarly to 573 // as some implementations need reset member fields, similarly to
559 // PushPropertiesTo(). 574 // PushPropertiesTo().
560 virtual void LayerSpecificPropertiesToProto(proto::LayerProperties* proto); 575 virtual void LayerSpecificPropertiesToProto(proto::LayerProperties* proto);
561 576
562 // Deserialize all the necessary properties from proto::LayerProperties into 577 // Deserialize all the necessary properties from proto::LayerProperties into
563 // this Layer. 578 // this Layer.
564 virtual void FromLayerSpecificPropertiesProto( 579 virtual void FromLayerSpecificPropertiesProto(
565 const proto::LayerProperties& proto); 580 const proto::LayerProperties& proto);
566 581
567 // The update rect is the region of the compositor resource that was 582 gfx::Rect& update_rect() { return inputs_.data.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 583
578 // When true, the layer is about to perform an update. Any commit requests 584 // When true, the layer is about to perform an update. Any commit requests
579 // will be handled implicitly after the update completes. 585 // will be handled implicitly after the update completes.
580 bool ignore_set_needs_commit_; 586 bool ignore_set_needs_commit_;
581 587
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: 588 private:
588 friend class base::RefCounted<Layer>; 589 friend class base::RefCounted<Layer>;
589 friend class LayerSerializationTest; 590 friend class LayerSerializationTest;
590 friend class LayerTreeHostCommon; 591 friend class LayerTreeHostCommon;
591 592
592 void SetParent(Layer* layer); 593 void SetParent(Layer* layer);
593 bool DescendantIsFixedToContainerLayer() const; 594 bool DescendantIsFixedToContainerLayer() const;
594 595
595 // This should only be called from RemoveFromParent(). 596 // This should only be called from RemoveFromParent().
596 void RemoveChildOrDependent(Layer* child); 597 void RemoveChildOrDependent(Layer* child);
597 598
598 // If this layer has a scroll parent, it removes |this| from its list of 599 // If this layer has a scroll parent, it removes |this| from its list of
599 // scroll children. 600 // scroll children.
600 void RemoveFromScrollTree(); 601 void RemoveFromScrollTree();
601 602
602 // If this layer has a clip parent, it removes |this| from its list of clip 603 // If this layer has a clip parent, it removes |this| from its list of clip
603 // children. 604 // children.
604 void RemoveFromClipTree(); 605 void RemoveFromClipTree();
605 606
606 // When we detach or attach layer to new LayerTreeHost, all property trees' 607 // When we detach or attach layer to new LayerTreeHost, all property trees'
607 // indices becomes invalid. 608 // indices becomes invalid.
608 void InvalidatePropertyTreesIndices(); 609 void InvalidatePropertyTreesIndices();
609 610
610 LayerList children_; 611 // Encapsulates all data, callbacks or interfaces received from the embedder.
612 // TODO(khushalsagar): This is only valid when PropertyTrees are built
613 // internally in cc. Update this for the SPv2 path where blink generates
614 // PropertyTrees.
615 struct Inputs {
616 Inputs();
617 ~Inputs();
618
619 struct Data {
enne (OOO) 2016/07/07 17:32:00 I'm not sure I understand the difference between I
Khushal 2016/07/07 18:16:39 Data gets serialized directly. Rest of the inputs
enne (OOO) 2016/07/07 22:10:10 I still don't know that I see the difference. It'
Khushal 2016/07/07 22:23:07 For cases where you store data as references you h
enne (OOO) 2016/07/07 22:24:54 I'd prefer comments rather than a separate struct
620 Data();
621 ~Data();
622 int layer_id;
623
624 LayerList children;
625
626 // The update rect is the region of the compositor resource that was
627 // actually updated by the compositor. For layers that may do updating
628 // outside the compositor's control (i.e. plugin layers), this information
629 // is not available and the update rect will remain empty.
630 // Note this rect is in layer space (not content space).
631 gfx::Rect update_rect;
632
633 gfx::Size bounds;
634 bool masks_to_bounds;
635
636 scoped_refptr<Layer> mask_layer;
637
638 // Replica layer used for reflections.
639 scoped_refptr<Layer> replica_layer;
640
641 float opacity;
642 SkXfermode::Mode blend_mode;
643
644 bool is_root_for_isolated_group : 1;
645
646 bool contents_opaque : 1;
647
648 gfx::PointF position;
649 gfx::Transform transform;
650 gfx::Point3F transform_origin;
651
652 bool is_drawable : 1;
653
654 bool double_sided : 1;
655 bool should_flatten_transform : 1;
656
657 // Layers that share a sorting context id will be sorted together in 3d
658 // space. 0 is a special value that means this layer will not be sorted
659 // and will be drawn in paint order.
660 int sorting_context_id;
661
662 bool use_parent_backface_visibility : 1;
663
664 SkColor background_color;
665
666 FilterOperations filters;
667 FilterOperations background_filters;
668
669 gfx::ScrollOffset scroll_offset;
670
671 // This variable indicates which ancestor layer (if any) whose size,
672 // transformed relative to this layer, defines the maximum scroll offset
673 // for this layer.
674 int scroll_clip_layer_id;
675 bool user_scrollable_horizontal : 1;
676 bool user_scrollable_vertical : 1;
677
678 uint32_t main_thread_scrolling_reasons;
679 Region non_fast_scrollable_region;
680
681 Region touch_event_handler_region;
682
683 bool is_container_for_fixed_position_layers : 1;
684 LayerPositionConstraint position_constraint;
685
686 ElementId element_id;
687
688 uint32_t mutable_properties;
689
690 Layer* scroll_parent;
691 Layer* clip_parent;
692
693 bool has_will_change_transform_hint : 1;
694
695 bool hide_layer_and_subtree : 1;
696 };
697
698 Data data;
699 LayerClient* client;
700 base::Closure did_scroll_callback;
701 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests;
702 };
703
611 Layer* parent_; 704 Layer* parent_;
612 705
613 // Layer instances have a weak pointer to their LayerTreeHost. 706 // 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 707 // 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. 708 // updated via SetLayerTreeHost() if a layer moves between trees.
616 LayerTreeHost* layer_tree_host_; 709 LayerTreeHost* layer_tree_host_;
617 710
618 // Layer properties. 711 Inputs inputs_;
619 gfx::Size bounds_;
620 712
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_; 713 int num_descendants_that_draw_content_;
627 int transform_tree_index_; 714 int transform_tree_index_;
628 int effect_tree_index_; 715 int effect_tree_index_;
629 int clip_tree_index_; 716 int clip_tree_index_;
630 int scroll_tree_index_; 717 int scroll_tree_index_;
631 int property_tree_sequence_number_; 718 int property_tree_sequence_number_;
632 ElementId element_id_;
633 uint32_t mutable_properties_;
634 gfx::Vector2dF offset_to_transform_parent_; 719 gfx::Vector2dF offset_to_transform_parent_;
635 uint32_t main_thread_scrolling_reasons_;
636 bool should_flatten_transform_from_property_tree_ : 1; 720 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; 721 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; 722 bool use_local_transform_for_backface_visibility_ : 1;
650 bool should_check_backface_visibility_ : 1; 723 bool should_check_backface_visibility_ : 1;
651 bool force_render_surface_for_testing_ : 1; 724 bool force_render_surface_for_testing_ : 1;
652 bool subtree_property_changed_ : 1; 725 bool subtree_property_changed_ : 1;
653 bool layer_property_changed_ : 1; 726 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_; 727 SkColor safe_opaque_background_color_;
660 float opacity_;
661 SkXfermode::Mode blend_mode_;
662 // draw_blend_mode may be different than blend_mode_, 728 // draw_blend_mode may be different than blend_mode_,
663 // when a RenderSurface re-parents the layer's blend_mode. 729 // when a RenderSurface re-parents the layer's blend_mode.
664 SkXfermode::Mode draw_blend_mode_; 730 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_; 731 std::unique_ptr<std::set<Layer*>> scroll_children_;
670 732
671 Layer* clip_parent_;
672 std::unique_ptr<std::set<Layer*>> clip_children_; 733 std::unique_ptr<std::set<Layer*>> clip_children_;
673 734
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_; 735 PaintProperties paint_properties_;
687 736
688 // These all act like draw properties, so don't need push properties. 737 // These all act like draw properties, so don't need push properties.
689 gfx::Rect visible_layer_rect_; 738 gfx::Rect visible_layer_rect_;
690 size_t num_unclipped_descendants_; 739 size_t num_unclipped_descendants_;
691 740
692 DISALLOW_COPY_AND_ASSIGN(Layer); 741 DISALLOW_COPY_AND_ASSIGN(Layer);
693 }; 742 };
694 743
695 } // namespace cc 744 } // namespace cc
696 745
697 #endif // CC_LAYERS_LAYER_H_ 746 #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