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