OLD | NEW |
---|---|
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 #include "cc/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #include "cc/layers/layer_impl.h" | 22 #include "cc/layers/layer_impl.h" |
23 #include "cc/layers/scrollbar_layer_interface.h" | 23 #include "cc/layers/scrollbar_layer_interface.h" |
24 #include "cc/output/copy_output_request.h" | 24 #include "cc/output/copy_output_request.h" |
25 #include "cc/output/copy_output_result.h" | 25 #include "cc/output/copy_output_result.h" |
26 #include "cc/trees/draw_property_utils.h" | 26 #include "cc/trees/draw_property_utils.h" |
27 #include "cc/trees/effect_node.h" | 27 #include "cc/trees/effect_node.h" |
28 #include "cc/trees/layer_tree_host.h" | 28 #include "cc/trees/layer_tree_host.h" |
29 #include "cc/trees/layer_tree_impl.h" | 29 #include "cc/trees/layer_tree_impl.h" |
30 #include "cc/trees/mutable_properties.h" | 30 #include "cc/trees/mutable_properties.h" |
31 #include "cc/trees/mutator_host.h" | 31 #include "cc/trees/mutator_host.h" |
32 #include "cc/trees/scroll_node.h" | |
32 #include "cc/trees/transform_node.h" | 33 #include "cc/trees/transform_node.h" |
33 #include "third_party/skia/include/core/SkImageFilter.h" | 34 #include "third_party/skia/include/core/SkImageFilter.h" |
34 #include "ui/gfx/geometry/rect_conversions.h" | 35 #include "ui/gfx/geometry/rect_conversions.h" |
35 #include "ui/gfx/geometry/vector2d_conversions.h" | 36 #include "ui/gfx/geometry/vector2d_conversions.h" |
36 | 37 |
37 namespace cc { | 38 namespace cc { |
38 | 39 |
39 base::StaticAtomicSequenceNumber g_next_layer_id; | 40 base::StaticAtomicSequenceNumber g_next_layer_id; |
40 | 41 |
41 Layer::Inputs::Inputs(int layer_id) | 42 Layer::Inputs::Inputs(int layer_id) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 clip_tree_index_(ClipTree::kInvalidNodeId), | 85 clip_tree_index_(ClipTree::kInvalidNodeId), |
85 scroll_tree_index_(ScrollTree::kInvalidNodeId), | 86 scroll_tree_index_(ScrollTree::kInvalidNodeId), |
86 property_tree_sequence_number_(-1), | 87 property_tree_sequence_number_(-1), |
87 should_flatten_transform_from_property_tree_(false), | 88 should_flatten_transform_from_property_tree_(false), |
88 draws_content_(false), | 89 draws_content_(false), |
89 use_local_transform_for_backface_visibility_(false), | 90 use_local_transform_for_backface_visibility_(false), |
90 should_check_backface_visibility_(false), | 91 should_check_backface_visibility_(false), |
91 force_render_surface_for_testing_(false), | 92 force_render_surface_for_testing_(false), |
92 subtree_property_changed_(false), | 93 subtree_property_changed_(false), |
93 may_contain_video_(false), | 94 may_contain_video_(false), |
95 is_scroll_clip_layer_(false), | |
94 safe_opaque_background_color_(0), | 96 safe_opaque_background_color_(0), |
95 draw_blend_mode_(SkBlendMode::kSrcOver), | 97 draw_blend_mode_(SkBlendMode::kSrcOver), |
96 num_unclipped_descendants_(0) {} | 98 num_unclipped_descendants_(0) {} |
97 | 99 |
98 Layer::~Layer() { | 100 Layer::~Layer() { |
99 // Our parent should be holding a reference to us so there should be no | 101 // Our parent should be holding a reference to us so there should be no |
100 // way for us to be destroyed while we still have a parent. | 102 // way for us to be destroyed while we still have a parent. |
101 DCHECK(!parent()); | 103 DCHECK(!parent()); |
102 // Similarly we shouldn't have a layer tree host since it also keeps a | 104 // Similarly we shouldn't have a layer tree host since it also keeps a |
103 // reference to us. | 105 // reference to us. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 | 156 |
155 if (host && has_any_animation) | 157 if (host && has_any_animation) |
156 host->SetNeedsCommit(); | 158 host->SetNeedsCommit(); |
157 } | 159 } |
158 | 160 |
159 void Layer::SetNeedsCommit() { | 161 void Layer::SetNeedsCommit() { |
160 if (!layer_tree_host_) | 162 if (!layer_tree_host_) |
161 return; | 163 return; |
162 | 164 |
163 SetNeedsPushProperties(); | 165 SetNeedsPushProperties(); |
164 layer_tree_host_->property_trees()->needs_rebuild = true; | |
165 | |
166 if (ignore_set_needs_commit_) | |
167 return; | |
168 | |
169 layer_tree_host_->SetNeedsCommit(); | |
170 } | |
171 | |
172 void Layer::SetNeedsCommitNoRebuild() { | |
173 if (!layer_tree_host_) | |
174 return; | |
175 | |
176 SetNeedsPushProperties(); | |
177 | 166 |
178 if (ignore_set_needs_commit_) | 167 if (ignore_set_needs_commit_) |
179 return; | 168 return; |
180 | 169 |
181 layer_tree_host_->SetNeedsCommit(); | 170 layer_tree_host_->SetNeedsCommit(); |
182 } | 171 } |
183 | 172 |
184 void Layer::SetNeedsFullTreeSync() { | 173 void Layer::SetNeedsFullTreeSync() { |
185 if (!layer_tree_host_) | 174 if (!layer_tree_host_) |
186 return; | 175 return; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 | 207 |
219 void Layer::SetParent(Layer* layer) { | 208 void Layer::SetParent(Layer* layer) { |
220 DCHECK(!layer || !layer->HasAncestor(this)); | 209 DCHECK(!layer || !layer->HasAncestor(this)); |
221 | 210 |
222 parent_ = layer; | 211 parent_ = layer; |
223 SetLayerTreeHost(parent_ ? parent_->layer_tree_host() : nullptr); | 212 SetLayerTreeHost(parent_ ? parent_->layer_tree_host() : nullptr); |
224 | 213 |
225 if (!layer_tree_host_) | 214 if (!layer_tree_host_) |
226 return; | 215 return; |
227 | 216 |
228 layer_tree_host_->property_trees()->needs_rebuild = true; | 217 layer_tree_host_->property_trees()->needs_rebuild = true; |
danakj
2017/03/17 14:26:51
Maybe change these places to use the new method to
| |
229 } | 218 } |
230 | 219 |
231 void Layer::AddChild(scoped_refptr<Layer> child) { | 220 void Layer::AddChild(scoped_refptr<Layer> child) { |
232 InsertChild(child, inputs_.children.size()); | 221 InsertChild(child, inputs_.children.size()); |
233 } | 222 } |
234 | 223 |
235 void Layer::InsertChild(scoped_refptr<Layer> child, size_t index) { | 224 void Layer::InsertChild(scoped_refptr<Layer> child, size_t index) { |
236 DCHECK(IsPropertyChangeAllowed()); | 225 DCHECK(IsPropertyChangeAllowed()); |
237 child->RemoveFromParent(); | 226 child->RemoveFromParent(); |
238 AddDrawableDescendants(child->NumDescendantsThatDrawContent() + | 227 AddDrawableDescendants(child->NumDescendantsThatDrawContent() + |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 | 288 |
300 void Layer::SetBounds(const gfx::Size& size) { | 289 void Layer::SetBounds(const gfx::Size& size) { |
301 DCHECK(IsPropertyChangeAllowed()); | 290 DCHECK(IsPropertyChangeAllowed()); |
302 if (bounds() == size) | 291 if (bounds() == size) |
303 return; | 292 return; |
304 inputs_.bounds = size; | 293 inputs_.bounds = size; |
305 | 294 |
306 if (!layer_tree_host_) | 295 if (!layer_tree_host_) |
307 return; | 296 return; |
308 | 297 |
309 if (masks_to_bounds()) | 298 if (masks_to_bounds()) { |
310 SetSubtreePropertyChanged(); | 299 SetSubtreePropertyChanged(); |
300 PropertyTreesNeedRebuild(); | |
301 } | |
302 | |
303 if (scrollable()) { | |
304 if (ScrollNode* node = | |
305 layer_tree_host_->property_trees() | |
306 ->scroll_tree.UpdateNodeFromOwningLayerId(id())) { | |
307 node->bounds = inputs_.bounds; | |
308 } | |
309 } | |
310 | |
311 if (is_scroll_clip_layer_) | |
312 layer_tree_host_->property_trees()->scroll_tree.set_needs_update(true); | |
313 | |
311 SetNeedsCommit(); | 314 SetNeedsCommit(); |
312 } | 315 } |
313 | 316 |
314 Layer* Layer::RootLayer() { | 317 Layer* Layer::RootLayer() { |
315 Layer* layer = this; | 318 Layer* layer = this; |
316 while (layer->parent()) | 319 while (layer->parent()) |
317 layer = layer->parent(); | 320 layer = layer->parent(); |
318 return layer; | 321 return layer; |
319 } | 322 } |
320 | 323 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 [&source](const std::unique_ptr<CopyOutputRequest>& x) { | 357 [&source](const std::unique_ptr<CopyOutputRequest>& x) { |
355 return x->has_source() && x->source() == source; | 358 return x->has_source() && x->source() == source; |
356 }); | 359 }); |
357 if (it != inputs_.copy_requests.end()) | 360 if (it != inputs_.copy_requests.end()) |
358 inputs_.copy_requests.erase(it); | 361 inputs_.copy_requests.erase(it); |
359 } | 362 } |
360 if (request->IsEmpty()) | 363 if (request->IsEmpty()) |
361 return; | 364 return; |
362 inputs_.copy_requests.push_back(std::move(request)); | 365 inputs_.copy_requests.push_back(std::move(request)); |
363 SetSubtreePropertyChanged(); | 366 SetSubtreePropertyChanged(); |
367 PropertyTreesNeedRebuild(); | |
364 SetNeedsCommit(); | 368 SetNeedsCommit(); |
365 } | 369 } |
366 | 370 |
367 void Layer::SetBackgroundColor(SkColor background_color) { | 371 void Layer::SetBackgroundColor(SkColor background_color) { |
368 DCHECK(IsPropertyChangeAllowed()); | 372 DCHECK(IsPropertyChangeAllowed()); |
369 if (inputs_.background_color == background_color) | 373 if (inputs_.background_color == background_color) |
370 return; | 374 return; |
371 inputs_.background_color = background_color; | 375 inputs_.background_color = background_color; |
376 PropertyTreesNeedRebuild(); | |
372 SetNeedsCommit(); | 377 SetNeedsCommit(); |
373 } | 378 } |
374 | 379 |
375 void Layer::SetSafeOpaqueBackgroundColor(SkColor background_color) { | 380 void Layer::SetSafeOpaqueBackgroundColor(SkColor background_color) { |
376 DCHECK(IsPropertyChangeAllowed()); | 381 DCHECK(IsPropertyChangeAllowed()); |
377 if (safe_opaque_background_color_ == background_color) | 382 if (safe_opaque_background_color_ == background_color) |
378 return; | 383 return; |
379 safe_opaque_background_color_ = background_color; | 384 safe_opaque_background_color_ = background_color; |
380 SetNeedsPushProperties(); | 385 SetNeedsPushProperties(); |
381 } | 386 } |
382 | 387 |
383 SkColor Layer::SafeOpaqueBackgroundColor() const { | 388 SkColor Layer::SafeOpaqueBackgroundColor() const { |
384 if (contents_opaque()) | 389 if (contents_opaque()) |
385 return safe_opaque_background_color_; | 390 return safe_opaque_background_color_; |
386 SkColor color = background_color(); | 391 SkColor color = background_color(); |
387 if (SkColorGetA(color) == 255) | 392 if (SkColorGetA(color) == 255) |
388 color = SK_ColorTRANSPARENT; | 393 color = SK_ColorTRANSPARENT; |
389 return color; | 394 return color; |
390 } | 395 } |
391 | 396 |
392 void Layer::SetMasksToBounds(bool masks_to_bounds) { | 397 void Layer::SetMasksToBounds(bool masks_to_bounds) { |
393 DCHECK(IsPropertyChangeAllowed()); | 398 DCHECK(IsPropertyChangeAllowed()); |
394 if (inputs_.masks_to_bounds == masks_to_bounds) | 399 if (inputs_.masks_to_bounds == masks_to_bounds) |
395 return; | 400 return; |
396 inputs_.masks_to_bounds = masks_to_bounds; | 401 inputs_.masks_to_bounds = masks_to_bounds; |
397 SetNeedsCommit(); | 402 SetNeedsCommit(); |
403 PropertyTreesNeedRebuild(); | |
398 SetSubtreePropertyChanged(); | 404 SetSubtreePropertyChanged(); |
399 } | 405 } |
400 | 406 |
401 void Layer::SetMaskLayer(Layer* mask_layer) { | 407 void Layer::SetMaskLayer(Layer* mask_layer) { |
402 DCHECK(IsPropertyChangeAllowed()); | 408 DCHECK(IsPropertyChangeAllowed()); |
403 if (inputs_.mask_layer.get() == mask_layer) | 409 if (inputs_.mask_layer.get() == mask_layer) |
404 return; | 410 return; |
405 if (inputs_.mask_layer.get()) { | 411 if (inputs_.mask_layer.get()) { |
406 DCHECK_EQ(this, inputs_.mask_layer->parent()); | 412 DCHECK_EQ(this, inputs_.mask_layer->parent()); |
407 inputs_.mask_layer->RemoveFromParent(); | 413 inputs_.mask_layer->RemoveFromParent(); |
(...skipping 22 matching lines...) Expand all Loading... | |
430 | 436 |
431 void Layer::SetFilters(const FilterOperations& filters) { | 437 void Layer::SetFilters(const FilterOperations& filters) { |
432 DCHECK(IsPropertyChangeAllowed()); | 438 DCHECK(IsPropertyChangeAllowed()); |
433 if (inputs_.filters == filters) | 439 if (inputs_.filters == filters) |
434 return; | 440 return; |
435 inputs_.filters = filters; | 441 inputs_.filters = filters; |
436 if (inputs_.mask_layer) | 442 if (inputs_.mask_layer) |
437 inputs_.mask_layer->SetLayerMaskType( | 443 inputs_.mask_layer->SetLayerMaskType( |
438 Layer::LayerMaskType::SINGLE_TEXTURE_MASK); | 444 Layer::LayerMaskType::SINGLE_TEXTURE_MASK); |
439 SetSubtreePropertyChanged(); | 445 SetSubtreePropertyChanged(); |
446 PropertyTreesNeedRebuild(); | |
440 SetNeedsCommit(); | 447 SetNeedsCommit(); |
441 } | 448 } |
442 | 449 |
443 void Layer::SetBackgroundFilters(const FilterOperations& filters) { | 450 void Layer::SetBackgroundFilters(const FilterOperations& filters) { |
444 DCHECK(IsPropertyChangeAllowed()); | 451 DCHECK(IsPropertyChangeAllowed()); |
445 if (inputs_.background_filters == filters) | 452 if (inputs_.background_filters == filters) |
446 return; | 453 return; |
447 inputs_.background_filters = filters; | 454 inputs_.background_filters = filters; |
448 SetSubtreePropertyChanged(); | 455 SetSubtreePropertyChanged(); |
456 PropertyTreesNeedRebuild(); | |
449 SetNeedsCommit(); | 457 SetNeedsCommit(); |
450 } | 458 } |
451 | 459 |
452 void Layer::SetFiltersOrigin(const gfx::PointF& filters_origin) { | 460 void Layer::SetFiltersOrigin(const gfx::PointF& filters_origin) { |
453 DCHECK(IsPropertyChangeAllowed()); | 461 DCHECK(IsPropertyChangeAllowed()); |
454 if (inputs_.filters_origin == filters_origin) | 462 if (inputs_.filters_origin == filters_origin) |
455 return; | 463 return; |
456 inputs_.filters_origin = filters_origin; | 464 inputs_.filters_origin = filters_origin; |
457 SetSubtreePropertyChanged(); | 465 SetSubtreePropertyChanged(); |
466 PropertyTreesNeedRebuild(); | |
458 SetNeedsCommit(); | 467 SetNeedsCommit(); |
459 } | 468 } |
460 | 469 |
461 void Layer::SetOpacity(float opacity) { | 470 void Layer::SetOpacity(float opacity) { |
462 DCHECK(IsPropertyChangeAllowed()); | 471 DCHECK(IsPropertyChangeAllowed()); |
463 DCHECK_GE(opacity, 0.f); | 472 DCHECK_GE(opacity, 0.f); |
464 DCHECK_LE(opacity, 1.f); | 473 DCHECK_LE(opacity, 1.f); |
465 | 474 |
466 if (inputs_.opacity == opacity) | 475 if (inputs_.opacity == opacity) |
467 return; | 476 return; |
468 // We need to force a property tree rebuild when opacity changes from 1 to a | 477 // We need to force a property tree rebuild when opacity changes from 1 to a |
469 // non-1 value or vice-versa as render surfaces can change. | 478 // non-1 value or vice-versa as render surfaces can change. |
470 bool force_rebuild = opacity == 1.f || inputs_.opacity == 1.f; | 479 bool force_rebuild = opacity == 1.f || inputs_.opacity == 1.f; |
471 inputs_.opacity = opacity; | 480 inputs_.opacity = opacity; |
472 SetSubtreePropertyChanged(); | 481 SetSubtreePropertyChanged(); |
473 if (layer_tree_host_ && !force_rebuild) { | 482 if (layer_tree_host_ && !force_rebuild) { |
474 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 483 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
475 if (EffectNode* node = | 484 if (EffectNode* node = |
476 property_trees->effect_tree.FindNodeFromOwningLayerId(id())) { | 485 property_trees->effect_tree.UpdateNodeFromOwningLayerId(id())) { |
477 node->opacity = opacity; | 486 node->opacity = opacity; |
478 node->effect_changed = true; | 487 node->effect_changed = true; |
479 property_trees->effect_tree.set_needs_update(true); | 488 property_trees->effect_tree.set_needs_update(true); |
480 SetNeedsCommitNoRebuild(); | |
481 return; | |
482 } | 489 } |
483 } | 490 } |
491 if (layer_tree_host_ && force_rebuild) | |
492 layer_tree_host_->property_trees()->needs_rebuild = true; | |
danakj
2017/03/17 14:26:51
Use the new method? Then you don't need to check i
weiliangc
2017/03/17 20:58:41
Done.
| |
484 SetNeedsCommit(); | 493 SetNeedsCommit(); |
485 } | 494 } |
486 | 495 |
487 float Layer::EffectiveOpacity() const { | 496 float Layer::EffectiveOpacity() const { |
488 return inputs_.hide_layer_and_subtree ? 0.f : inputs_.opacity; | 497 return inputs_.hide_layer_and_subtree ? 0.f : inputs_.opacity; |
489 } | 498 } |
490 | 499 |
491 bool Layer::OpacityCanAnimateOnImplThread() const { | 500 bool Layer::OpacityCanAnimateOnImplThread() const { |
492 return false; | 501 return false; |
493 } | 502 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 case SkBlendMode::kModulate: | 547 case SkBlendMode::kModulate: |
539 // Porter Duff Compositing Operators are not yet supported | 548 // Porter Duff Compositing Operators are not yet supported |
540 // http://dev.w3.org/fxtf/compositing-1/#porterduffcompositingoperators | 549 // http://dev.w3.org/fxtf/compositing-1/#porterduffcompositingoperators |
541 NOTREACHED(); | 550 NOTREACHED(); |
542 return; | 551 return; |
543 } | 552 } |
544 | 553 |
545 inputs_.blend_mode = blend_mode; | 554 inputs_.blend_mode = blend_mode; |
546 SetNeedsCommit(); | 555 SetNeedsCommit(); |
547 SetSubtreePropertyChanged(); | 556 SetSubtreePropertyChanged(); |
557 PropertyTreesNeedRebuild(); | |
548 } | 558 } |
549 | 559 |
550 void Layer::SetIsRootForIsolatedGroup(bool root) { | 560 void Layer::SetIsRootForIsolatedGroup(bool root) { |
551 DCHECK(IsPropertyChangeAllowed()); | 561 DCHECK(IsPropertyChangeAllowed()); |
552 if (inputs_.is_root_for_isolated_group == root) | 562 if (inputs_.is_root_for_isolated_group == root) |
553 return; | 563 return; |
554 inputs_.is_root_for_isolated_group = root; | 564 inputs_.is_root_for_isolated_group = root; |
565 PropertyTreesNeedRebuild(); | |
555 SetNeedsCommit(); | 566 SetNeedsCommit(); |
556 } | 567 } |
557 | 568 |
558 void Layer::SetContentsOpaque(bool opaque) { | 569 void Layer::SetContentsOpaque(bool opaque) { |
559 DCHECK(IsPropertyChangeAllowed()); | 570 DCHECK(IsPropertyChangeAllowed()); |
560 if (inputs_.contents_opaque == opaque) | 571 if (inputs_.contents_opaque == opaque) |
561 return; | 572 return; |
562 inputs_.contents_opaque = opaque; | 573 inputs_.contents_opaque = opaque; |
563 SetNeedsCommit(); | 574 SetNeedsCommit(); |
564 SetSubtreePropertyChanged(); | 575 SetSubtreePropertyChanged(); |
576 PropertyTreesNeedRebuild(); | |
565 } | 577 } |
566 | 578 |
567 void Layer::SetPosition(const gfx::PointF& position) { | 579 void Layer::SetPosition(const gfx::PointF& position) { |
568 DCHECK(IsPropertyChangeAllowed()); | 580 DCHECK(IsPropertyChangeAllowed()); |
569 if (inputs_.position == position) | 581 if (inputs_.position == position) |
570 return; | 582 return; |
571 inputs_.position = position; | 583 inputs_.position = position; |
572 | 584 |
573 if (!layer_tree_host_) | 585 if (!layer_tree_host_) |
574 return; | 586 return; |
575 | 587 |
576 SetSubtreePropertyChanged(); | 588 SetSubtreePropertyChanged(); |
577 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 589 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
578 if (TransformNode* transform_node = | 590 if (TransformNode* transform_node = |
579 property_trees->transform_tree.FindNodeFromOwningLayerId(id())) { | 591 property_trees->transform_tree.UpdateNodeFromOwningLayerId(id())) { |
580 DCHECK_EQ(transform_tree_index(), transform_node->id); | 592 DCHECK_EQ(transform_tree_index(), transform_node->id); |
581 transform_node->update_post_local_transform(position, transform_origin()); | 593 transform_node->update_post_local_transform(position, transform_origin()); |
582 if (transform_node->sticky_position_constraint_id >= 0) { | 594 if (transform_node->sticky_position_constraint_id >= 0) { |
583 StickyPositionNodeData* sticky_data = | 595 StickyPositionNodeData* sticky_data = |
584 property_trees->transform_tree.StickyPositionData( | 596 property_trees->transform_tree.StickyPositionData( |
585 transform_tree_index()); | 597 transform_tree_index()); |
586 sticky_data->main_thread_offset = | 598 sticky_data->main_thread_offset = |
587 position.OffsetFromOrigin() - | 599 position.OffsetFromOrigin() - |
588 sticky_data->constraints.parent_relative_sticky_box_offset | 600 sticky_data->constraints.parent_relative_sticky_box_offset |
589 .OffsetFromOrigin(); | 601 .OffsetFromOrigin(); |
590 } | 602 } |
591 transform_node->needs_local_transform_update = true; | 603 transform_node->needs_local_transform_update = true; |
592 transform_node->transform_changed = true; | 604 transform_node->transform_changed = true; |
593 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); | 605 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
594 SetNeedsCommitNoRebuild(); | |
595 return; | |
596 } | 606 } |
597 | 607 |
598 SetNeedsCommit(); | 608 SetNeedsCommit(); |
599 } | 609 } |
600 | 610 |
601 bool Layer::IsContainerForFixedPositionLayers() const { | 611 bool Layer::IsContainerForFixedPositionLayers() const { |
602 return inputs_.is_container_for_fixed_position_layers; | 612 return inputs_.is_container_for_fixed_position_layers; |
603 } | 613 } |
604 | 614 |
605 bool Are2dAxisAligned(const gfx::Transform& a, const gfx::Transform& b) { | 615 bool Are2dAxisAligned(const gfx::Transform& a, const gfx::Transform& b) { |
(...skipping 13 matching lines...) Expand all Loading... | |
619 | 629 |
620 void Layer::SetTransform(const gfx::Transform& transform) { | 630 void Layer::SetTransform(const gfx::Transform& transform) { |
621 DCHECK(IsPropertyChangeAllowed()); | 631 DCHECK(IsPropertyChangeAllowed()); |
622 if (inputs_.transform == transform) | 632 if (inputs_.transform == transform) |
623 return; | 633 return; |
624 | 634 |
625 SetSubtreePropertyChanged(); | 635 SetSubtreePropertyChanged(); |
626 if (layer_tree_host_) { | 636 if (layer_tree_host_) { |
627 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 637 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
628 if (TransformNode* transform_node = | 638 if (TransformNode* transform_node = |
629 property_trees->transform_tree.FindNodeFromOwningLayerId(id())) { | 639 property_trees->transform_tree.UpdateNodeFromOwningLayerId(id())) { |
630 // We need to trigger a rebuild if we could have affected 2d axis | 640 // We need to trigger a rebuild if we could have affected 2d axis |
631 // alignment. We'll check to see if transform and inputs_.transform are | 641 // alignment. We'll check to see if transform and inputs_.transform are |
632 // axis align with respect to one another. | 642 // axis align with respect to one another. |
633 DCHECK_EQ(transform_tree_index(), transform_node->id); | 643 DCHECK_EQ(transform_tree_index(), transform_node->id); |
634 bool preserves_2d_axis_alignment = | 644 bool preserves_2d_axis_alignment = |
635 Are2dAxisAligned(inputs_.transform, transform); | 645 Are2dAxisAligned(inputs_.transform, transform); |
636 transform_node->local = transform; | 646 transform_node->local = transform; |
637 transform_node->needs_local_transform_update = true; | 647 transform_node->needs_local_transform_update = true; |
638 transform_node->transform_changed = true; | 648 transform_node->transform_changed = true; |
639 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); | 649 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
640 if (preserves_2d_axis_alignment) | 650 if (!preserves_2d_axis_alignment) |
641 SetNeedsCommitNoRebuild(); | 651 layer_tree_host_->property_trees()->needs_rebuild = true; |
danakj
2017/03/17 14:26:51
Use new method?
weiliangc
2017/03/17 20:58:41
Done.
| |
642 else | |
643 SetNeedsCommit(); | |
644 inputs_.transform = transform; | |
645 return; | |
646 } | 652 } |
647 } | 653 } |
648 | 654 |
649 inputs_.transform = transform; | 655 inputs_.transform = transform; |
650 | 656 |
651 SetNeedsCommit(); | 657 SetNeedsCommit(); |
652 } | 658 } |
653 | 659 |
654 void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) { | 660 void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) { |
655 DCHECK(IsPropertyChangeAllowed()); | 661 DCHECK(IsPropertyChangeAllowed()); |
656 if (inputs_.transform_origin == transform_origin) | 662 if (inputs_.transform_origin == transform_origin) |
657 return; | 663 return; |
658 inputs_.transform_origin = transform_origin; | 664 inputs_.transform_origin = transform_origin; |
659 | 665 |
660 if (!layer_tree_host_) | 666 if (!layer_tree_host_) |
661 return; | 667 return; |
662 | 668 |
663 SetSubtreePropertyChanged(); | 669 SetSubtreePropertyChanged(); |
664 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 670 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
665 if (TransformNode* transform_node = | 671 if (TransformNode* transform_node = |
666 property_trees->transform_tree.FindNodeFromOwningLayerId(id())) { | 672 property_trees->transform_tree.UpdateNodeFromOwningLayerId(id())) { |
667 DCHECK_EQ(transform_tree_index(), transform_node->id); | 673 DCHECK_EQ(transform_tree_index(), transform_node->id); |
668 transform_node->update_pre_local_transform(transform_origin); | 674 transform_node->update_pre_local_transform(transform_origin); |
669 transform_node->update_post_local_transform(position(), transform_origin); | 675 transform_node->update_post_local_transform(position(), transform_origin); |
670 transform_node->needs_local_transform_update = true; | 676 transform_node->needs_local_transform_update = true; |
671 transform_node->transform_changed = true; | 677 transform_node->transform_changed = true; |
672 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); | 678 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
673 SetNeedsCommitNoRebuild(); | |
674 return; | |
675 } | 679 } |
676 | 680 |
677 SetNeedsCommit(); | 681 SetNeedsCommit(); |
678 } | 682 } |
679 | 683 |
680 bool Layer::ScrollOffsetAnimationWasInterrupted() const { | 684 bool Layer::ScrollOffsetAnimationWasInterrupted() const { |
681 return GetMutatorHost()->ScrollOffsetAnimationWasInterrupted(element_id()); | 685 return GetMutatorHost()->ScrollOffsetAnimationWasInterrupted(element_id()); |
682 } | 686 } |
683 | 687 |
684 bool Layer::HasOnlyTranslationTransforms() const { | 688 bool Layer::HasOnlyTranslationTransforms() const { |
685 return GetMutatorHost()->HasOnlyTranslationTransforms( | 689 return GetMutatorHost()->HasOnlyTranslationTransforms( |
686 element_id(), GetElementTypeForAnimation()); | 690 element_id(), GetElementTypeForAnimation()); |
687 } | 691 } |
688 | 692 |
689 void Layer::SetScrollParent(Layer* parent) { | 693 void Layer::SetScrollParent(Layer* parent) { |
690 DCHECK(IsPropertyChangeAllowed()); | 694 DCHECK(IsPropertyChangeAllowed()); |
691 if (inputs_.scroll_parent == parent) | 695 if (inputs_.scroll_parent == parent) |
692 return; | 696 return; |
693 | 697 |
694 if (inputs_.scroll_parent) | 698 if (inputs_.scroll_parent) |
695 inputs_.scroll_parent->RemoveScrollChild(this); | 699 inputs_.scroll_parent->RemoveScrollChild(this); |
696 | 700 |
697 inputs_.scroll_parent = parent; | 701 inputs_.scroll_parent = parent; |
698 | 702 |
699 if (inputs_.scroll_parent) | 703 if (inputs_.scroll_parent) |
700 inputs_.scroll_parent->AddScrollChild(this); | 704 inputs_.scroll_parent->AddScrollChild(this); |
701 | 705 |
706 PropertyTreesNeedRebuild(); | |
702 SetNeedsCommit(); | 707 SetNeedsCommit(); |
703 } | 708 } |
704 | 709 |
705 void Layer::AddScrollChild(Layer* child) { | 710 void Layer::AddScrollChild(Layer* child) { |
706 if (!scroll_children_) | 711 if (!scroll_children_) |
707 scroll_children_.reset(new std::set<Layer*>); | 712 scroll_children_.reset(new std::set<Layer*>); |
708 scroll_children_->insert(child); | 713 scroll_children_->insert(child); |
709 SetNeedsCommit(); | 714 SetNeedsCommit(); |
710 } | 715 } |
711 | 716 |
(...skipping 10 matching lines...) Expand all Loading... | |
722 return; | 727 return; |
723 | 728 |
724 if (inputs_.clip_parent) | 729 if (inputs_.clip_parent) |
725 inputs_.clip_parent->RemoveClipChild(this); | 730 inputs_.clip_parent->RemoveClipChild(this); |
726 | 731 |
727 inputs_.clip_parent = ancestor; | 732 inputs_.clip_parent = ancestor; |
728 | 733 |
729 if (inputs_.clip_parent) | 734 if (inputs_.clip_parent) |
730 inputs_.clip_parent->AddClipChild(this); | 735 inputs_.clip_parent->AddClipChild(this); |
731 | 736 |
737 PropertyTreesNeedRebuild(); | |
732 SetNeedsCommit(); | 738 SetNeedsCommit(); |
733 if (layer_tree_host_) | 739 if (layer_tree_host_) |
734 layer_tree_host_->SetNeedsMetaInfoRecomputation(true); | 740 layer_tree_host_->SetNeedsMetaInfoRecomputation(true); |
735 } | 741 } |
736 | 742 |
737 void Layer::AddClipChild(Layer* child) { | 743 void Layer::AddClipChild(Layer* child) { |
738 if (!clip_children_) | 744 if (!clip_children_) |
739 clip_children_.reset(new std::set<Layer*>); | 745 clip_children_.reset(new std::set<Layer*>); |
740 clip_children_->insert(child); | 746 clip_children_->insert(child); |
741 SetNeedsCommit(); | 747 SetNeedsCommit(); |
(...skipping 14 matching lines...) Expand all Loading... | |
756 inputs_.scroll_offset = scroll_offset; | 762 inputs_.scroll_offset = scroll_offset; |
757 | 763 |
758 if (!layer_tree_host_) | 764 if (!layer_tree_host_) |
759 return; | 765 return; |
760 | 766 |
761 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 767 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
762 if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable()) | 768 if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable()) |
763 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset); | 769 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset); |
764 | 770 |
765 if (TransformNode* transform_node = | 771 if (TransformNode* transform_node = |
766 property_trees->transform_tree.FindNodeFromOwningLayerId(id())) { | 772 property_trees->transform_tree.UpdateNodeFromOwningLayerId(id())) { |
767 DCHECK_EQ(transform_tree_index(), transform_node->id); | 773 DCHECK_EQ(transform_tree_index(), transform_node->id); |
768 transform_node->scroll_offset = CurrentScrollOffset(); | 774 transform_node->scroll_offset = CurrentScrollOffset(); |
769 transform_node->needs_local_transform_update = true; | 775 transform_node->needs_local_transform_update = true; |
770 property_trees->transform_tree.set_needs_update(true); | 776 property_trees->transform_tree.set_needs_update(true); |
771 SetNeedsCommitNoRebuild(); | |
772 return; | |
773 } | 777 } |
774 | 778 |
775 SetNeedsCommit(); | 779 SetNeedsCommit(); |
776 } | 780 } |
777 | 781 |
778 void Layer::SetScrollOffsetFromImplSide( | 782 void Layer::SetScrollOffsetFromImplSide( |
779 const gfx::ScrollOffset& scroll_offset) { | 783 const gfx::ScrollOffset& scroll_offset) { |
780 DCHECK(IsPropertyChangeAllowed()); | 784 DCHECK(IsPropertyChangeAllowed()); |
781 // This function only gets called during a BeginMainFrame, so there | 785 // This function only gets called during a BeginMainFrame, so there |
782 // is no need to call SetNeedsUpdate here. | 786 // is no need to call SetNeedsUpdate here. |
783 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); | 787 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); |
784 if (inputs_.scroll_offset == scroll_offset) | 788 if (inputs_.scroll_offset == scroll_offset) |
785 return; | 789 return; |
786 inputs_.scroll_offset = scroll_offset; | 790 inputs_.scroll_offset = scroll_offset; |
787 SetNeedsPushProperties(); | 791 SetNeedsPushProperties(); |
788 | 792 |
789 bool needs_rebuild = true; | |
790 | |
791 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 793 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
792 if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable()) | 794 if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable()) |
793 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset); | 795 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset); |
794 | 796 |
795 if (TransformNode* transform_node = | 797 if (TransformNode* transform_node = |
796 property_trees->transform_tree.FindNodeFromOwningLayerId(id())) { | 798 property_trees->transform_tree.UpdateNodeFromOwningLayerId(id())) { |
797 DCHECK_EQ(transform_tree_index(), transform_node->id); | 799 DCHECK_EQ(transform_tree_index(), transform_node->id); |
798 transform_node->scroll_offset = CurrentScrollOffset(); | 800 transform_node->scroll_offset = CurrentScrollOffset(); |
799 transform_node->needs_local_transform_update = true; | 801 transform_node->needs_local_transform_update = true; |
800 property_trees->transform_tree.set_needs_update(true); | 802 property_trees->transform_tree.set_needs_update(true); |
801 needs_rebuild = false; | |
802 } | 803 } |
803 | 804 |
804 if (needs_rebuild) | |
805 property_trees->needs_rebuild = true; | |
806 | |
807 if (!inputs_.did_scroll_callback.is_null()) | 805 if (!inputs_.did_scroll_callback.is_null()) |
808 inputs_.did_scroll_callback.Run(scroll_offset); | 806 inputs_.did_scroll_callback.Run(scroll_offset); |
809 | 807 |
810 // The callback could potentially change the layer structure: | 808 // The callback could potentially change the layer structure: |
811 // "this" may have been destroyed during the process. | 809 // "this" may have been destroyed during the process. |
812 } | 810 } |
813 | 811 |
814 void Layer::SetScrollClipLayerId(int clip_layer_id) { | 812 void Layer::SetScrollClipLayerId(int clip_layer_id) { |
815 DCHECK(IsPropertyChangeAllowed()); | 813 DCHECK(IsPropertyChangeAllowed()); |
816 if (inputs_.scroll_clip_layer_id == clip_layer_id) | 814 if (inputs_.scroll_clip_layer_id == clip_layer_id) |
817 return; | 815 return; |
818 inputs_.scroll_clip_layer_id = clip_layer_id; | 816 inputs_.scroll_clip_layer_id = clip_layer_id; |
817 PropertyTreesNeedRebuild(); | |
819 SetNeedsCommit(); | 818 SetNeedsCommit(); |
820 } | 819 } |
821 | 820 |
822 Layer* Layer::scroll_clip_layer() const { | 821 Layer* Layer::scroll_clip_layer() const { |
823 DCHECK(layer_tree_host_); | 822 DCHECK(layer_tree_host_); |
824 return layer_tree_host_->LayerById(inputs_.scroll_clip_layer_id); | 823 return layer_tree_host_->LayerById(inputs_.scroll_clip_layer_id); |
825 } | 824 } |
826 | 825 |
827 void Layer::SetUserScrollable(bool horizontal, bool vertical) { | 826 void Layer::SetUserScrollable(bool horizontal, bool vertical) { |
828 DCHECK(IsPropertyChangeAllowed()); | 827 DCHECK(IsPropertyChangeAllowed()); |
829 if (inputs_.user_scrollable_horizontal == horizontal && | 828 if (inputs_.user_scrollable_horizontal == horizontal && |
830 inputs_.user_scrollable_vertical == vertical) | 829 inputs_.user_scrollable_vertical == vertical) |
831 return; | 830 return; |
832 inputs_.user_scrollable_horizontal = horizontal; | 831 inputs_.user_scrollable_horizontal = horizontal; |
833 inputs_.user_scrollable_vertical = vertical; | 832 inputs_.user_scrollable_vertical = vertical; |
ajuma
2017/03/16 23:42:11
These values go into ScrollNode, so we should upda
ajuma
2017/03/17 23:32:17
Looks like this still needs to be added.
| |
834 SetNeedsCommit(); | 833 SetNeedsCommit(); |
835 } | 834 } |
836 | 835 |
837 void Layer::AddMainThreadScrollingReasons( | 836 void Layer::AddMainThreadScrollingReasons( |
838 uint32_t main_thread_scrolling_reasons) { | 837 uint32_t main_thread_scrolling_reasons) { |
839 DCHECK(IsPropertyChangeAllowed()); | 838 DCHECK(IsPropertyChangeAllowed()); |
840 DCHECK(main_thread_scrolling_reasons); | 839 DCHECK(main_thread_scrolling_reasons); |
841 uint32_t new_reasons = | 840 uint32_t new_reasons = |
842 inputs_.main_thread_scrolling_reasons | main_thread_scrolling_reasons; | 841 inputs_.main_thread_scrolling_reasons | main_thread_scrolling_reasons; |
843 if (inputs_.main_thread_scrolling_reasons == new_reasons) | 842 if (inputs_.main_thread_scrolling_reasons == new_reasons) |
844 return; | 843 return; |
845 inputs_.main_thread_scrolling_reasons = new_reasons; | 844 inputs_.main_thread_scrolling_reasons = new_reasons; |
846 didUpdateMainThreadScrollingReasons(); | 845 didUpdateMainThreadScrollingReasons(); |
846 PropertyTreesNeedRebuild(); | |
847 SetNeedsCommit(); | 847 SetNeedsCommit(); |
848 } | 848 } |
849 | 849 |
850 void Layer::ClearMainThreadScrollingReasons( | 850 void Layer::ClearMainThreadScrollingReasons( |
851 uint32_t main_thread_scrolling_reasons_to_clear) { | 851 uint32_t main_thread_scrolling_reasons_to_clear) { |
852 DCHECK(IsPropertyChangeAllowed()); | 852 DCHECK(IsPropertyChangeAllowed()); |
853 DCHECK(main_thread_scrolling_reasons_to_clear); | 853 DCHECK(main_thread_scrolling_reasons_to_clear); |
854 uint32_t new_reasons = ~main_thread_scrolling_reasons_to_clear & | 854 uint32_t new_reasons = ~main_thread_scrolling_reasons_to_clear & |
855 inputs_.main_thread_scrolling_reasons; | 855 inputs_.main_thread_scrolling_reasons; |
856 if (new_reasons == inputs_.main_thread_scrolling_reasons) | 856 if (new_reasons == inputs_.main_thread_scrolling_reasons) |
857 return; | 857 return; |
858 inputs_.main_thread_scrolling_reasons = new_reasons; | 858 inputs_.main_thread_scrolling_reasons = new_reasons; |
859 didUpdateMainThreadScrollingReasons(); | 859 didUpdateMainThreadScrollingReasons(); |
860 PropertyTreesNeedRebuild(); | |
860 SetNeedsCommit(); | 861 SetNeedsCommit(); |
861 } | 862 } |
862 | 863 |
863 void Layer::SetNonFastScrollableRegion(const Region& region) { | 864 void Layer::SetNonFastScrollableRegion(const Region& region) { |
864 DCHECK(IsPropertyChangeAllowed()); | 865 DCHECK(IsPropertyChangeAllowed()); |
865 if (inputs_.non_fast_scrollable_region == region) | 866 if (inputs_.non_fast_scrollable_region == region) |
866 return; | 867 return; |
867 inputs_.non_fast_scrollable_region = region; | 868 inputs_.non_fast_scrollable_region = region; |
869 PropertyTreesNeedRebuild(); | |
868 SetNeedsCommit(); | 870 SetNeedsCommit(); |
869 } | 871 } |
870 | 872 |
871 void Layer::SetTouchEventHandlerRegion(const Region& region) { | 873 void Layer::SetTouchEventHandlerRegion(const Region& region) { |
872 DCHECK(IsPropertyChangeAllowed()); | 874 DCHECK(IsPropertyChangeAllowed()); |
873 if (inputs_.touch_event_handler_region == region) | 875 if (inputs_.touch_event_handler_region == region) |
874 return; | 876 return; |
875 | 877 |
876 inputs_.touch_event_handler_region = region; | 878 inputs_.touch_event_handler_region = region; |
879 PropertyTreesNeedRebuild(); | |
877 SetNeedsCommit(); | 880 SetNeedsCommit(); |
878 } | 881 } |
879 | 882 |
880 void Layer::SetForceRenderSurfaceForTesting(bool force) { | 883 void Layer::SetForceRenderSurfaceForTesting(bool force) { |
881 DCHECK(IsPropertyChangeAllowed()); | 884 DCHECK(IsPropertyChangeAllowed()); |
882 if (force_render_surface_for_testing_ == force) | 885 if (force_render_surface_for_testing_ == force) |
883 return; | 886 return; |
884 force_render_surface_for_testing_ = force; | 887 force_render_surface_for_testing_ = force; |
888 PropertyTreesNeedRebuild(); | |
885 SetNeedsCommit(); | 889 SetNeedsCommit(); |
886 } | 890 } |
887 | 891 |
888 void Layer::SetDoubleSided(bool double_sided) { | 892 void Layer::SetDoubleSided(bool double_sided) { |
889 DCHECK(IsPropertyChangeAllowed()); | 893 DCHECK(IsPropertyChangeAllowed()); |
890 if (inputs_.double_sided == double_sided) | 894 if (inputs_.double_sided == double_sided) |
891 return; | 895 return; |
892 inputs_.double_sided = double_sided; | 896 inputs_.double_sided = double_sided; |
893 SetNeedsCommit(); | 897 SetNeedsCommit(); |
898 PropertyTreesNeedRebuild(); | |
894 SetSubtreePropertyChanged(); | 899 SetSubtreePropertyChanged(); |
895 } | 900 } |
896 | 901 |
897 void Layer::Set3dSortingContextId(int id) { | 902 void Layer::Set3dSortingContextId(int id) { |
898 DCHECK(IsPropertyChangeAllowed()); | 903 DCHECK(IsPropertyChangeAllowed()); |
899 if (id == inputs_.sorting_context_id) | 904 if (id == inputs_.sorting_context_id) |
900 return; | 905 return; |
901 inputs_.sorting_context_id = id; | 906 inputs_.sorting_context_id = id; |
902 SetNeedsCommit(); | 907 SetNeedsCommit(); |
908 PropertyTreesNeedRebuild(); | |
903 SetSubtreePropertyChanged(); | 909 SetSubtreePropertyChanged(); |
904 } | 910 } |
905 | 911 |
906 void Layer::SetTransformTreeIndex(int index) { | 912 void Layer::SetTransformTreeIndex(int index) { |
907 DCHECK(IsPropertyChangeAllowed()); | 913 DCHECK(IsPropertyChangeAllowed()); |
908 if (transform_tree_index_ == index) | 914 if (transform_tree_index_ == index) |
909 return; | 915 return; |
910 transform_tree_index_ = index; | 916 transform_tree_index_ = index; |
911 SetNeedsPushProperties(); | 917 SetNeedsPushProperties(); |
912 } | 918 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
971 return scroll_tree_index_; | 977 return scroll_tree_index_; |
972 } | 978 } |
973 | 979 |
974 void Layer::InvalidatePropertyTreesIndices() { | 980 void Layer::InvalidatePropertyTreesIndices() { |
975 SetTransformTreeIndex(TransformTree::kInvalidNodeId); | 981 SetTransformTreeIndex(TransformTree::kInvalidNodeId); |
976 SetClipTreeIndex(ClipTree::kInvalidNodeId); | 982 SetClipTreeIndex(ClipTree::kInvalidNodeId); |
977 SetEffectTreeIndex(EffectTree::kInvalidNodeId); | 983 SetEffectTreeIndex(EffectTree::kInvalidNodeId); |
978 SetScrollTreeIndex(ScrollTree::kInvalidNodeId); | 984 SetScrollTreeIndex(ScrollTree::kInvalidNodeId); |
979 } | 985 } |
980 | 986 |
987 void Layer::PropertyTreesNeedRebuild() { | |
988 if (layer_tree_host_) | |
989 layer_tree_host_->property_trees()->needs_rebuild = true; | |
990 } | |
991 | |
981 void Layer::SetShouldFlattenTransform(bool should_flatten) { | 992 void Layer::SetShouldFlattenTransform(bool should_flatten) { |
982 DCHECK(IsPropertyChangeAllowed()); | 993 DCHECK(IsPropertyChangeAllowed()); |
983 if (inputs_.should_flatten_transform == should_flatten) | 994 if (inputs_.should_flatten_transform == should_flatten) |
984 return; | 995 return; |
985 inputs_.should_flatten_transform = should_flatten; | 996 inputs_.should_flatten_transform = should_flatten; |
986 SetNeedsCommit(); | 997 SetNeedsCommit(); |
998 PropertyTreesNeedRebuild(); | |
987 SetSubtreePropertyChanged(); | 999 SetSubtreePropertyChanged(); |
988 } | 1000 } |
989 | 1001 |
990 void Layer::SetUseParentBackfaceVisibility(bool use) { | 1002 void Layer::SetUseParentBackfaceVisibility(bool use) { |
991 DCHECK(IsPropertyChangeAllowed()); | 1003 DCHECK(IsPropertyChangeAllowed()); |
992 if (inputs_.use_parent_backface_visibility == use) | 1004 if (inputs_.use_parent_backface_visibility == use) |
993 return; | 1005 return; |
994 inputs_.use_parent_backface_visibility = use; | 1006 inputs_.use_parent_backface_visibility = use; |
995 SetNeedsPushProperties(); | 1007 SetNeedsPushProperties(); |
996 } | 1008 } |
(...skipping 22 matching lines...) Expand all Loading... | |
1019 UpdateDrawsContent(HasDrawableContent()); | 1031 UpdateDrawsContent(HasDrawableContent()); |
1020 } | 1032 } |
1021 | 1033 |
1022 void Layer::SetHideLayerAndSubtree(bool hide) { | 1034 void Layer::SetHideLayerAndSubtree(bool hide) { |
1023 DCHECK(IsPropertyChangeAllowed()); | 1035 DCHECK(IsPropertyChangeAllowed()); |
1024 if (inputs_.hide_layer_and_subtree == hide) | 1036 if (inputs_.hide_layer_and_subtree == hide) |
1025 return; | 1037 return; |
1026 | 1038 |
1027 inputs_.hide_layer_and_subtree = hide; | 1039 inputs_.hide_layer_and_subtree = hide; |
1028 SetNeedsCommit(); | 1040 SetNeedsCommit(); |
1041 PropertyTreesNeedRebuild(); | |
1029 SetSubtreePropertyChanged(); | 1042 SetSubtreePropertyChanged(); |
1030 } | 1043 } |
1031 | 1044 |
1032 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { | 1045 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { |
1033 if (dirty_rect.IsEmpty()) | 1046 if (dirty_rect.IsEmpty()) |
1034 return; | 1047 return; |
1035 | 1048 |
1036 SetNeedsPushProperties(); | 1049 SetNeedsPushProperties(); |
1037 inputs_.update_rect.Union(dirty_rect); | 1050 inputs_.update_rect.Union(dirty_rect); |
1038 | 1051 |
(...skipping 12 matching lines...) Expand all Loading... | |
1051 | 1064 |
1052 void Layer::SetIsContainerForFixedPositionLayers(bool container) { | 1065 void Layer::SetIsContainerForFixedPositionLayers(bool container) { |
1053 if (inputs_.is_container_for_fixed_position_layers == container) | 1066 if (inputs_.is_container_for_fixed_position_layers == container) |
1054 return; | 1067 return; |
1055 inputs_.is_container_for_fixed_position_layers = container; | 1068 inputs_.is_container_for_fixed_position_layers = container; |
1056 | 1069 |
1057 if (layer_tree_host_ && layer_tree_host_->CommitRequested()) | 1070 if (layer_tree_host_ && layer_tree_host_->CommitRequested()) |
1058 return; | 1071 return; |
1059 | 1072 |
1060 // Only request a commit if we have a fixed positioned descendant. | 1073 // Only request a commit if we have a fixed positioned descendant. |
1061 if (DescendantIsFixedToContainerLayer()) | 1074 if (DescendantIsFixedToContainerLayer()) { |
1075 PropertyTreesNeedRebuild(); | |
1062 SetNeedsCommit(); | 1076 SetNeedsCommit(); |
1077 } | |
1063 } | 1078 } |
1064 | 1079 |
1065 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { | 1080 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { |
1066 DCHECK(IsPropertyChangeAllowed()); | 1081 DCHECK(IsPropertyChangeAllowed()); |
1067 if (inputs_.position_constraint == constraint) | 1082 if (inputs_.position_constraint == constraint) |
1068 return; | 1083 return; |
1069 inputs_.position_constraint = constraint; | 1084 inputs_.position_constraint = constraint; |
1085 PropertyTreesNeedRebuild(); | |
1070 SetNeedsCommit(); | 1086 SetNeedsCommit(); |
1071 } | 1087 } |
1072 | 1088 |
1073 void Layer::SetStickyPositionConstraint( | 1089 void Layer::SetStickyPositionConstraint( |
1074 const LayerStickyPositionConstraint& constraint) { | 1090 const LayerStickyPositionConstraint& constraint) { |
1075 DCHECK(IsPropertyChangeAllowed()); | 1091 DCHECK(IsPropertyChangeAllowed()); |
1076 if (inputs_.sticky_position_constraint == constraint) | 1092 if (inputs_.sticky_position_constraint == constraint) |
1077 return; | 1093 return; |
1078 inputs_.sticky_position_constraint = constraint; | 1094 inputs_.sticky_position_constraint = constraint; |
1095 PropertyTreesNeedRebuild(); | |
1079 SetNeedsCommit(); | 1096 SetNeedsCommit(); |
1080 } | 1097 } |
1081 | 1098 |
1082 static void RunCopyCallbackOnMainThread( | 1099 static void RunCopyCallbackOnMainThread( |
1083 std::unique_ptr<CopyOutputRequest> request, | 1100 std::unique_ptr<CopyOutputRequest> request, |
1084 std::unique_ptr<CopyOutputResult> result) { | 1101 std::unique_ptr<CopyOutputResult> result) { |
1085 request->SendResult(std::move(result)); | 1102 request->SendResult(std::move(result)); |
1086 } | 1103 } |
1087 | 1104 |
1088 static void PostCopyCallbackToMainThread( | 1105 static void PostCopyCallbackToMainThread( |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1219 void Layer::UpdateDrawsContent(bool has_drawable_content) { | 1236 void Layer::UpdateDrawsContent(bool has_drawable_content) { |
1220 bool draws_content = has_drawable_content; | 1237 bool draws_content = has_drawable_content; |
1221 DCHECK(inputs_.is_drawable || !has_drawable_content); | 1238 DCHECK(inputs_.is_drawable || !has_drawable_content); |
1222 if (draws_content == draws_content_) | 1239 if (draws_content == draws_content_) |
1223 return; | 1240 return; |
1224 | 1241 |
1225 if (parent()) | 1242 if (parent()) |
1226 parent()->AddDrawableDescendants(draws_content ? 1 : -1); | 1243 parent()->AddDrawableDescendants(draws_content ? 1 : -1); |
1227 | 1244 |
1228 draws_content_ = draws_content; | 1245 draws_content_ = draws_content; |
1246 PropertyTreesNeedRebuild(); | |
1229 SetNeedsCommit(); | 1247 SetNeedsCommit(); |
1230 } | 1248 } |
1231 | 1249 |
1232 int Layer::NumDescendantsThatDrawContent() const { | 1250 int Layer::NumDescendantsThatDrawContent() const { |
1233 return num_descendants_that_draw_content_; | 1251 return num_descendants_that_draw_content_; |
1234 } | 1252 } |
1235 | 1253 |
1236 void Layer::SavePaintProperties() { | 1254 void Layer::SavePaintProperties() { |
1237 DCHECK(layer_tree_host_); | 1255 DCHECK(layer_tree_host_); |
1238 | 1256 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1320 // Do nothing. Scroll deltas will be sent from the compositor thread back | 1338 // Do nothing. Scroll deltas will be sent from the compositor thread back |
1321 // to the main thread in the same manner as during non-animated | 1339 // to the main thread in the same manner as during non-animated |
1322 // compositor-driven scrolling. | 1340 // compositor-driven scrolling. |
1323 } | 1341 } |
1324 | 1342 |
1325 void Layer::OnIsAnimatingChanged(const PropertyAnimationState& mask, | 1343 void Layer::OnIsAnimatingChanged(const PropertyAnimationState& mask, |
1326 const PropertyAnimationState& state) { | 1344 const PropertyAnimationState& state) { |
1327 DCHECK(layer_tree_host_); | 1345 DCHECK(layer_tree_host_); |
1328 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 1346 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
1329 | 1347 |
1330 TransformNode* transform_node = | |
1331 property_trees->transform_tree.FindNodeFromOwningLayerId(id()); | |
1332 DCHECK(!transform_node || transform_node->id == transform_tree_index()); | |
1333 | |
1334 EffectNode* effect_node = | |
1335 property_trees->effect_tree.FindNodeFromOwningLayerId(id()); | |
1336 DCHECK(!effect_node || effect_node->id == effect_tree_index()); | |
1337 | |
1338 for (int property = TargetProperty::FIRST_TARGET_PROPERTY; | 1348 for (int property = TargetProperty::FIRST_TARGET_PROPERTY; |
1339 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) { | 1349 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) { |
1340 switch (property) { | 1350 switch (property) { |
1341 case TargetProperty::TRANSFORM: | 1351 case TargetProperty::TRANSFORM: |
1342 if (transform_node) { | 1352 if (!mask.currently_running[property] && |
1353 !mask.potentially_animating[property]) | |
1354 continue; | |
ajuma
2017/03/16 23:42:11
This check can go outside the switch, then it does
weiliangc
2017/03/17 20:58:41
Done.
| |
1355 if (TransformNode* transform_node = | |
1356 property_trees->transform_tree.UpdateNodeFromOwningLayerId( | |
1357 id())) { | |
1358 DCHECK_EQ(transform_node->id, transform_tree_index()); | |
1343 if (mask.currently_running[property]) | 1359 if (mask.currently_running[property]) |
1344 transform_node->is_currently_animating = | 1360 transform_node->is_currently_animating = |
1345 state.currently_running[property]; | 1361 state.currently_running[property]; |
1346 if (mask.potentially_animating[property]) { | 1362 if (mask.potentially_animating[property]) { |
1347 transform_node->has_potential_animation = | 1363 transform_node->has_potential_animation = |
1348 state.potentially_animating[property]; | 1364 state.potentially_animating[property]; |
1349 if (state.potentially_animating[property]) { | 1365 if (state.potentially_animating[property]) { |
1350 transform_node->has_only_translation_animations = | 1366 transform_node->has_only_translation_animations = |
1351 HasOnlyTranslationTransforms(); | 1367 HasOnlyTranslationTransforms(); |
1352 } else { | 1368 } else { |
1353 transform_node->has_only_translation_animations = true; | 1369 transform_node->has_only_translation_animations = true; |
1354 } | 1370 } |
1355 property_trees->transform_tree.set_needs_update(true); | 1371 property_trees->transform_tree.set_needs_update(true); |
1356 } | 1372 } |
1373 } else { | |
1374 DCHECK(property_trees->needs_rebuild) | |
1375 << "Attempting to animate non existent transform node"; | |
1357 } | 1376 } |
1358 break; | 1377 break; |
1359 case TargetProperty::OPACITY: | 1378 case TargetProperty::OPACITY: |
1360 if (effect_node) { | 1379 if (!mask.currently_running[property] && |
1380 !mask.potentially_animating[property]) | |
1381 continue; | |
1382 if (EffectNode* effect_node = | |
1383 property_trees->effect_tree.UpdateNodeFromOwningLayerId(id())) { | |
1361 if (mask.currently_running[property]) | 1384 if (mask.currently_running[property]) |
1362 effect_node->is_currently_animating_opacity = | 1385 effect_node->is_currently_animating_opacity = |
1363 state.currently_running[property]; | 1386 state.currently_running[property]; |
1364 if (mask.potentially_animating[property]) { | 1387 if (mask.potentially_animating[property]) { |
1365 effect_node->has_potential_opacity_animation = | 1388 effect_node->has_potential_opacity_animation = |
1366 state.potentially_animating[property] || | 1389 state.potentially_animating[property] || |
1367 OpacityCanAnimateOnImplThread(); | 1390 OpacityCanAnimateOnImplThread(); |
1368 property_trees->effect_tree.set_needs_update(true); | 1391 property_trees->effect_tree.set_needs_update(true); |
1369 } | 1392 } |
1393 } else { | |
1394 DCHECK(property_trees->needs_rebuild) | |
1395 << "Attempting to animate opacity on non existent effect node"; | |
1370 } | 1396 } |
1371 break; | 1397 break; |
1372 case TargetProperty::FILTER: | 1398 case TargetProperty::FILTER: |
1373 if (effect_node) { | 1399 if (!mask.currently_running[property] && |
1400 !mask.potentially_animating[property]) | |
1401 continue; | |
1402 if (EffectNode* effect_node = | |
1403 property_trees->effect_tree.UpdateNodeFromOwningLayerId(id())) { | |
1374 if (mask.currently_running[property]) | 1404 if (mask.currently_running[property]) |
1375 effect_node->is_currently_animating_filter = | 1405 effect_node->is_currently_animating_filter = |
1376 state.currently_running[property]; | 1406 state.currently_running[property]; |
1377 if (mask.potentially_animating[property]) | 1407 if (mask.potentially_animating[property]) |
1378 effect_node->has_potential_filter_animation = | 1408 effect_node->has_potential_filter_animation = |
1379 state.potentially_animating[property]; | 1409 state.potentially_animating[property]; |
1410 } else { | |
1411 DCHECK(property_trees->needs_rebuild) | |
1412 << "Attempting to animate filter on non existent effect node"; | |
1380 } | 1413 } |
1381 break; | 1414 break; |
1382 default: | 1415 default: |
1383 break; | 1416 break; |
1384 } | 1417 } |
1385 } | 1418 } |
1386 } | 1419 } |
1387 | 1420 |
1388 bool Layer::HasTickingAnimationForTesting() const { | 1421 bool Layer::HasTickingAnimationForTesting() const { |
1389 return layer_tree_host_ | 1422 return layer_tree_host_ |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1502 ->num_copy_requests_in_subtree; | 1535 ->num_copy_requests_in_subtree; |
1503 } | 1536 } |
1504 | 1537 |
1505 gfx::Transform Layer::screen_space_transform() const { | 1538 gfx::Transform Layer::screen_space_transform() const { |
1506 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1539 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
1507 return draw_property_utils::ScreenSpaceTransform( | 1540 return draw_property_utils::ScreenSpaceTransform( |
1508 this, layer_tree_host_->property_trees()->transform_tree); | 1541 this, layer_tree_host_->property_trees()->transform_tree); |
1509 } | 1542 } |
1510 | 1543 |
1511 } // namespace cc | 1544 } // namespace cc |
OLD | NEW |