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())) { |
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; |
| 830 if (!layer_tree_host_) |
| 831 return; |
| 832 |
| 833 if (ScrollNode* node = layer_tree_host_->property_trees() |
| 834 ->scroll_tree.UpdateNodeFromOwningLayerId(id())) { |
| 835 node->user_scrollable_horizontal = horizontal; |
| 836 node->user_scrollable_vertical = vertical; |
| 837 } |
834 SetNeedsCommit(); | 838 SetNeedsCommit(); |
835 } | 839 } |
836 | 840 |
837 void Layer::AddMainThreadScrollingReasons( | 841 void Layer::AddMainThreadScrollingReasons( |
838 uint32_t main_thread_scrolling_reasons) { | 842 uint32_t main_thread_scrolling_reasons) { |
839 DCHECK(IsPropertyChangeAllowed()); | 843 DCHECK(IsPropertyChangeAllowed()); |
840 DCHECK(main_thread_scrolling_reasons); | 844 DCHECK(main_thread_scrolling_reasons); |
841 uint32_t new_reasons = | 845 uint32_t new_reasons = |
842 inputs_.main_thread_scrolling_reasons | main_thread_scrolling_reasons; | 846 inputs_.main_thread_scrolling_reasons | main_thread_scrolling_reasons; |
843 if (inputs_.main_thread_scrolling_reasons == new_reasons) | 847 if (inputs_.main_thread_scrolling_reasons == new_reasons) |
844 return; | 848 return; |
845 inputs_.main_thread_scrolling_reasons = new_reasons; | 849 inputs_.main_thread_scrolling_reasons = new_reasons; |
846 didUpdateMainThreadScrollingReasons(); | 850 didUpdateMainThreadScrollingReasons(); |
| 851 SetPropertyTreesNeedRebuild(); |
847 SetNeedsCommit(); | 852 SetNeedsCommit(); |
848 } | 853 } |
849 | 854 |
850 void Layer::ClearMainThreadScrollingReasons( | 855 void Layer::ClearMainThreadScrollingReasons( |
851 uint32_t main_thread_scrolling_reasons_to_clear) { | 856 uint32_t main_thread_scrolling_reasons_to_clear) { |
852 DCHECK(IsPropertyChangeAllowed()); | 857 DCHECK(IsPropertyChangeAllowed()); |
853 DCHECK(main_thread_scrolling_reasons_to_clear); | 858 DCHECK(main_thread_scrolling_reasons_to_clear); |
854 uint32_t new_reasons = ~main_thread_scrolling_reasons_to_clear & | 859 uint32_t new_reasons = ~main_thread_scrolling_reasons_to_clear & |
855 inputs_.main_thread_scrolling_reasons; | 860 inputs_.main_thread_scrolling_reasons; |
856 if (new_reasons == inputs_.main_thread_scrolling_reasons) | 861 if (new_reasons == inputs_.main_thread_scrolling_reasons) |
857 return; | 862 return; |
858 inputs_.main_thread_scrolling_reasons = new_reasons; | 863 inputs_.main_thread_scrolling_reasons = new_reasons; |
859 didUpdateMainThreadScrollingReasons(); | 864 didUpdateMainThreadScrollingReasons(); |
| 865 SetPropertyTreesNeedRebuild(); |
860 SetNeedsCommit(); | 866 SetNeedsCommit(); |
861 } | 867 } |
862 | 868 |
863 void Layer::SetNonFastScrollableRegion(const Region& region) { | 869 void Layer::SetNonFastScrollableRegion(const Region& region) { |
864 DCHECK(IsPropertyChangeAllowed()); | 870 DCHECK(IsPropertyChangeAllowed()); |
865 if (inputs_.non_fast_scrollable_region == region) | 871 if (inputs_.non_fast_scrollable_region == region) |
866 return; | 872 return; |
867 inputs_.non_fast_scrollable_region = region; | 873 inputs_.non_fast_scrollable_region = region; |
| 874 SetPropertyTreesNeedRebuild(); |
868 SetNeedsCommit(); | 875 SetNeedsCommit(); |
869 } | 876 } |
870 | 877 |
871 void Layer::SetTouchEventHandlerRegion(const Region& region) { | 878 void Layer::SetTouchEventHandlerRegion(const Region& region) { |
872 DCHECK(IsPropertyChangeAllowed()); | 879 DCHECK(IsPropertyChangeAllowed()); |
873 if (inputs_.touch_event_handler_region == region) | 880 if (inputs_.touch_event_handler_region == region) |
874 return; | 881 return; |
875 | 882 |
876 inputs_.touch_event_handler_region = region; | 883 inputs_.touch_event_handler_region = region; |
| 884 SetPropertyTreesNeedRebuild(); |
877 SetNeedsCommit(); | 885 SetNeedsCommit(); |
878 } | 886 } |
879 | 887 |
880 void Layer::SetForceRenderSurfaceForTesting(bool force) { | 888 void Layer::SetForceRenderSurfaceForTesting(bool force) { |
881 DCHECK(IsPropertyChangeAllowed()); | 889 DCHECK(IsPropertyChangeAllowed()); |
882 if (force_render_surface_for_testing_ == force) | 890 if (force_render_surface_for_testing_ == force) |
883 return; | 891 return; |
884 force_render_surface_for_testing_ = force; | 892 force_render_surface_for_testing_ = force; |
| 893 SetPropertyTreesNeedRebuild(); |
885 SetNeedsCommit(); | 894 SetNeedsCommit(); |
886 } | 895 } |
887 | 896 |
888 void Layer::SetDoubleSided(bool double_sided) { | 897 void Layer::SetDoubleSided(bool double_sided) { |
889 DCHECK(IsPropertyChangeAllowed()); | 898 DCHECK(IsPropertyChangeAllowed()); |
890 if (inputs_.double_sided == double_sided) | 899 if (inputs_.double_sided == double_sided) |
891 return; | 900 return; |
892 inputs_.double_sided = double_sided; | 901 inputs_.double_sided = double_sided; |
893 SetNeedsCommit(); | 902 SetNeedsCommit(); |
| 903 SetPropertyTreesNeedRebuild(); |
894 SetSubtreePropertyChanged(); | 904 SetSubtreePropertyChanged(); |
895 } | 905 } |
896 | 906 |
897 void Layer::Set3dSortingContextId(int id) { | 907 void Layer::Set3dSortingContextId(int id) { |
898 DCHECK(IsPropertyChangeAllowed()); | 908 DCHECK(IsPropertyChangeAllowed()); |
899 if (id == inputs_.sorting_context_id) | 909 if (id == inputs_.sorting_context_id) |
900 return; | 910 return; |
901 inputs_.sorting_context_id = id; | 911 inputs_.sorting_context_id = id; |
902 SetNeedsCommit(); | 912 SetNeedsCommit(); |
| 913 SetPropertyTreesNeedRebuild(); |
903 SetSubtreePropertyChanged(); | 914 SetSubtreePropertyChanged(); |
904 } | 915 } |
905 | 916 |
906 void Layer::SetTransformTreeIndex(int index) { | 917 void Layer::SetTransformTreeIndex(int index) { |
907 DCHECK(IsPropertyChangeAllowed()); | 918 DCHECK(IsPropertyChangeAllowed()); |
908 if (transform_tree_index_ == index) | 919 if (transform_tree_index_ == index) |
909 return; | 920 return; |
910 transform_tree_index_ = index; | 921 transform_tree_index_ = index; |
911 SetNeedsPushProperties(); | 922 SetNeedsPushProperties(); |
912 } | 923 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 return scroll_tree_index_; | 982 return scroll_tree_index_; |
972 } | 983 } |
973 | 984 |
974 void Layer::InvalidatePropertyTreesIndices() { | 985 void Layer::InvalidatePropertyTreesIndices() { |
975 SetTransformTreeIndex(TransformTree::kInvalidNodeId); | 986 SetTransformTreeIndex(TransformTree::kInvalidNodeId); |
976 SetClipTreeIndex(ClipTree::kInvalidNodeId); | 987 SetClipTreeIndex(ClipTree::kInvalidNodeId); |
977 SetEffectTreeIndex(EffectTree::kInvalidNodeId); | 988 SetEffectTreeIndex(EffectTree::kInvalidNodeId); |
978 SetScrollTreeIndex(ScrollTree::kInvalidNodeId); | 989 SetScrollTreeIndex(ScrollTree::kInvalidNodeId); |
979 } | 990 } |
980 | 991 |
| 992 void Layer::SetPropertyTreesNeedRebuild() { |
| 993 if (layer_tree_host_) |
| 994 layer_tree_host_->property_trees()->needs_rebuild = true; |
| 995 } |
| 996 |
981 void Layer::SetShouldFlattenTransform(bool should_flatten) { | 997 void Layer::SetShouldFlattenTransform(bool should_flatten) { |
982 DCHECK(IsPropertyChangeAllowed()); | 998 DCHECK(IsPropertyChangeAllowed()); |
983 if (inputs_.should_flatten_transform == should_flatten) | 999 if (inputs_.should_flatten_transform == should_flatten) |
984 return; | 1000 return; |
985 inputs_.should_flatten_transform = should_flatten; | 1001 inputs_.should_flatten_transform = should_flatten; |
986 SetNeedsCommit(); | 1002 SetNeedsCommit(); |
| 1003 SetPropertyTreesNeedRebuild(); |
987 SetSubtreePropertyChanged(); | 1004 SetSubtreePropertyChanged(); |
988 } | 1005 } |
989 | 1006 |
990 void Layer::SetUseParentBackfaceVisibility(bool use) { | 1007 void Layer::SetUseParentBackfaceVisibility(bool use) { |
991 DCHECK(IsPropertyChangeAllowed()); | 1008 DCHECK(IsPropertyChangeAllowed()); |
992 if (inputs_.use_parent_backface_visibility == use) | 1009 if (inputs_.use_parent_backface_visibility == use) |
993 return; | 1010 return; |
994 inputs_.use_parent_backface_visibility = use; | 1011 inputs_.use_parent_backface_visibility = use; |
995 SetNeedsPushProperties(); | 1012 SetNeedsPushProperties(); |
996 } | 1013 } |
(...skipping 22 matching lines...) Expand all Loading... |
1019 UpdateDrawsContent(HasDrawableContent()); | 1036 UpdateDrawsContent(HasDrawableContent()); |
1020 } | 1037 } |
1021 | 1038 |
1022 void Layer::SetHideLayerAndSubtree(bool hide) { | 1039 void Layer::SetHideLayerAndSubtree(bool hide) { |
1023 DCHECK(IsPropertyChangeAllowed()); | 1040 DCHECK(IsPropertyChangeAllowed()); |
1024 if (inputs_.hide_layer_and_subtree == hide) | 1041 if (inputs_.hide_layer_and_subtree == hide) |
1025 return; | 1042 return; |
1026 | 1043 |
1027 inputs_.hide_layer_and_subtree = hide; | 1044 inputs_.hide_layer_and_subtree = hide; |
1028 SetNeedsCommit(); | 1045 SetNeedsCommit(); |
| 1046 SetPropertyTreesNeedRebuild(); |
1029 SetSubtreePropertyChanged(); | 1047 SetSubtreePropertyChanged(); |
1030 } | 1048 } |
1031 | 1049 |
1032 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { | 1050 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { |
1033 if (dirty_rect.IsEmpty()) | 1051 if (dirty_rect.IsEmpty()) |
1034 return; | 1052 return; |
1035 | 1053 |
1036 SetNeedsPushProperties(); | 1054 SetNeedsPushProperties(); |
1037 inputs_.update_rect.Union(dirty_rect); | 1055 inputs_.update_rect.Union(dirty_rect); |
1038 | 1056 |
(...skipping 12 matching lines...) Expand all Loading... |
1051 | 1069 |
1052 void Layer::SetIsContainerForFixedPositionLayers(bool container) { | 1070 void Layer::SetIsContainerForFixedPositionLayers(bool container) { |
1053 if (inputs_.is_container_for_fixed_position_layers == container) | 1071 if (inputs_.is_container_for_fixed_position_layers == container) |
1054 return; | 1072 return; |
1055 inputs_.is_container_for_fixed_position_layers = container; | 1073 inputs_.is_container_for_fixed_position_layers = container; |
1056 | 1074 |
1057 if (layer_tree_host_ && layer_tree_host_->CommitRequested()) | 1075 if (layer_tree_host_ && layer_tree_host_->CommitRequested()) |
1058 return; | 1076 return; |
1059 | 1077 |
1060 // Only request a commit if we have a fixed positioned descendant. | 1078 // Only request a commit if we have a fixed positioned descendant. |
1061 if (DescendantIsFixedToContainerLayer()) | 1079 if (DescendantIsFixedToContainerLayer()) { |
| 1080 SetPropertyTreesNeedRebuild(); |
1062 SetNeedsCommit(); | 1081 SetNeedsCommit(); |
| 1082 } |
1063 } | 1083 } |
1064 | 1084 |
1065 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { | 1085 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { |
1066 DCHECK(IsPropertyChangeAllowed()); | 1086 DCHECK(IsPropertyChangeAllowed()); |
1067 if (inputs_.position_constraint == constraint) | 1087 if (inputs_.position_constraint == constraint) |
1068 return; | 1088 return; |
1069 inputs_.position_constraint = constraint; | 1089 inputs_.position_constraint = constraint; |
| 1090 SetPropertyTreesNeedRebuild(); |
1070 SetNeedsCommit(); | 1091 SetNeedsCommit(); |
1071 } | 1092 } |
1072 | 1093 |
1073 void Layer::SetStickyPositionConstraint( | 1094 void Layer::SetStickyPositionConstraint( |
1074 const LayerStickyPositionConstraint& constraint) { | 1095 const LayerStickyPositionConstraint& constraint) { |
1075 DCHECK(IsPropertyChangeAllowed()); | 1096 DCHECK(IsPropertyChangeAllowed()); |
1076 if (inputs_.sticky_position_constraint == constraint) | 1097 if (inputs_.sticky_position_constraint == constraint) |
1077 return; | 1098 return; |
1078 inputs_.sticky_position_constraint = constraint; | 1099 inputs_.sticky_position_constraint = constraint; |
| 1100 SetPropertyTreesNeedRebuild(); |
1079 SetNeedsCommit(); | 1101 SetNeedsCommit(); |
1080 } | 1102 } |
1081 | 1103 |
1082 static void RunCopyCallbackOnMainThread( | 1104 static void RunCopyCallbackOnMainThread( |
1083 std::unique_ptr<CopyOutputRequest> request, | 1105 std::unique_ptr<CopyOutputRequest> request, |
1084 std::unique_ptr<CopyOutputResult> result) { | 1106 std::unique_ptr<CopyOutputResult> result) { |
1085 request->SendResult(std::move(result)); | 1107 request->SendResult(std::move(result)); |
1086 } | 1108 } |
1087 | 1109 |
1088 static void PostCopyCallbackToMainThread( | 1110 static void PostCopyCallbackToMainThread( |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 void Layer::UpdateDrawsContent(bool has_drawable_content) { | 1241 void Layer::UpdateDrawsContent(bool has_drawable_content) { |
1220 bool draws_content = has_drawable_content; | 1242 bool draws_content = has_drawable_content; |
1221 DCHECK(inputs_.is_drawable || !has_drawable_content); | 1243 DCHECK(inputs_.is_drawable || !has_drawable_content); |
1222 if (draws_content == draws_content_) | 1244 if (draws_content == draws_content_) |
1223 return; | 1245 return; |
1224 | 1246 |
1225 if (parent()) | 1247 if (parent()) |
1226 parent()->AddDrawableDescendants(draws_content ? 1 : -1); | 1248 parent()->AddDrawableDescendants(draws_content ? 1 : -1); |
1227 | 1249 |
1228 draws_content_ = draws_content; | 1250 draws_content_ = draws_content; |
| 1251 SetPropertyTreesNeedRebuild(); |
1229 SetNeedsCommit(); | 1252 SetNeedsCommit(); |
1230 } | 1253 } |
1231 | 1254 |
1232 int Layer::NumDescendantsThatDrawContent() const { | 1255 int Layer::NumDescendantsThatDrawContent() const { |
1233 return num_descendants_that_draw_content_; | 1256 return num_descendants_that_draw_content_; |
1234 } | 1257 } |
1235 | 1258 |
1236 void Layer::SavePaintProperties() { | 1259 void Layer::SavePaintProperties() { |
1237 DCHECK(layer_tree_host_); | 1260 DCHECK(layer_tree_host_); |
1238 | 1261 |
(...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 | 1343 // 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 | 1344 // to the main thread in the same manner as during non-animated |
1322 // compositor-driven scrolling. | 1345 // compositor-driven scrolling. |
1323 } | 1346 } |
1324 | 1347 |
1325 void Layer::OnIsAnimatingChanged(const PropertyAnimationState& mask, | 1348 void Layer::OnIsAnimatingChanged(const PropertyAnimationState& mask, |
1326 const PropertyAnimationState& state) { | 1349 const PropertyAnimationState& state) { |
1327 DCHECK(layer_tree_host_); | 1350 DCHECK(layer_tree_host_); |
1328 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 1351 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
1329 | 1352 |
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; | 1353 for (int property = TargetProperty::FIRST_TARGET_PROPERTY; |
1339 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) { | 1354 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) { |
| 1355 if (!mask.currently_running[property] && |
| 1356 !mask.potentially_animating[property]) |
| 1357 continue; |
| 1358 |
1340 switch (property) { | 1359 switch (property) { |
1341 case TargetProperty::TRANSFORM: | 1360 case TargetProperty::TRANSFORM: |
1342 if (transform_node) { | 1361 if (TransformNode* transform_node = |
| 1362 property_trees->transform_tree.UpdateNodeFromOwningLayerId( |
| 1363 id())) { |
| 1364 DCHECK_EQ(transform_node->id, transform_tree_index()); |
1343 if (mask.currently_running[property]) | 1365 if (mask.currently_running[property]) |
1344 transform_node->is_currently_animating = | 1366 transform_node->is_currently_animating = |
1345 state.currently_running[property]; | 1367 state.currently_running[property]; |
1346 if (mask.potentially_animating[property]) { | 1368 if (mask.potentially_animating[property]) { |
1347 transform_node->has_potential_animation = | 1369 transform_node->has_potential_animation = |
1348 state.potentially_animating[property]; | 1370 state.potentially_animating[property]; |
1349 if (state.potentially_animating[property]) { | 1371 if (state.potentially_animating[property]) { |
1350 transform_node->has_only_translation_animations = | 1372 transform_node->has_only_translation_animations = |
1351 HasOnlyTranslationTransforms(); | 1373 HasOnlyTranslationTransforms(); |
1352 } else { | 1374 } else { |
1353 transform_node->has_only_translation_animations = true; | 1375 transform_node->has_only_translation_animations = true; |
1354 } | 1376 } |
1355 property_trees->transform_tree.set_needs_update(true); | 1377 property_trees->transform_tree.set_needs_update(true); |
1356 } | 1378 } |
| 1379 } else { |
| 1380 DCHECK(property_trees->needs_rebuild) |
| 1381 << "Attempting to animate non existent transform node"; |
1357 } | 1382 } |
1358 break; | 1383 break; |
1359 case TargetProperty::OPACITY: | 1384 case TargetProperty::OPACITY: |
1360 if (effect_node) { | 1385 if (EffectNode* effect_node = |
| 1386 property_trees->effect_tree.UpdateNodeFromOwningLayerId(id())) { |
1361 if (mask.currently_running[property]) | 1387 if (mask.currently_running[property]) |
1362 effect_node->is_currently_animating_opacity = | 1388 effect_node->is_currently_animating_opacity = |
1363 state.currently_running[property]; | 1389 state.currently_running[property]; |
1364 if (mask.potentially_animating[property]) { | 1390 if (mask.potentially_animating[property]) { |
1365 effect_node->has_potential_opacity_animation = | 1391 effect_node->has_potential_opacity_animation = |
1366 state.potentially_animating[property] || | 1392 state.potentially_animating[property] || |
1367 OpacityCanAnimateOnImplThread(); | 1393 OpacityCanAnimateOnImplThread(); |
1368 property_trees->effect_tree.set_needs_update(true); | 1394 property_trees->effect_tree.set_needs_update(true); |
1369 } | 1395 } |
| 1396 } else { |
| 1397 DCHECK(property_trees->needs_rebuild) |
| 1398 << "Attempting to animate opacity on non existent effect node"; |
1370 } | 1399 } |
1371 break; | 1400 break; |
1372 case TargetProperty::FILTER: | 1401 case TargetProperty::FILTER: |
1373 if (effect_node) { | 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 |