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

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

Issue 2755803003: cc: Remove SetNeedsCommitNoRebuild from Layer API (Closed)
Patch Set: address review comment Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #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
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
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
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
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
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
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
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
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
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
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
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 (ScrollNode* node = layer_tree_host_->property_trees()
ajuma 2017/03/20 20:30:40 Also, need to check for a null layer_tree_host her
831 ->scroll_tree.UpdateNodeFromOwningLayerId(id())) {
832 node->user_scrollable_horizontal = horizontal;
833 node->user_scrollable_vertical = vertical;
834 layer_tree_host_->property_trees()->scroll_tree.set_needs_update(true);
ajuma 2017/03/20 18:22:49 Is this line needed? The scroll tree update doesn'
835 }
834 SetNeedsCommit(); 836 SetNeedsCommit();
835 } 837 }
836 838
837 void Layer::AddMainThreadScrollingReasons( 839 void Layer::AddMainThreadScrollingReasons(
838 uint32_t main_thread_scrolling_reasons) { 840 uint32_t main_thread_scrolling_reasons) {
839 DCHECK(IsPropertyChangeAllowed()); 841 DCHECK(IsPropertyChangeAllowed());
840 DCHECK(main_thread_scrolling_reasons); 842 DCHECK(main_thread_scrolling_reasons);
841 uint32_t new_reasons = 843 uint32_t new_reasons =
842 inputs_.main_thread_scrolling_reasons | main_thread_scrolling_reasons; 844 inputs_.main_thread_scrolling_reasons | main_thread_scrolling_reasons;
843 if (inputs_.main_thread_scrolling_reasons == new_reasons) 845 if (inputs_.main_thread_scrolling_reasons == new_reasons)
844 return; 846 return;
845 inputs_.main_thread_scrolling_reasons = new_reasons; 847 inputs_.main_thread_scrolling_reasons = new_reasons;
846 didUpdateMainThreadScrollingReasons(); 848 didUpdateMainThreadScrollingReasons();
849 SetPropertyTreesNeedRebuild();
847 SetNeedsCommit(); 850 SetNeedsCommit();
848 } 851 }
849 852
850 void Layer::ClearMainThreadScrollingReasons( 853 void Layer::ClearMainThreadScrollingReasons(
851 uint32_t main_thread_scrolling_reasons_to_clear) { 854 uint32_t main_thread_scrolling_reasons_to_clear) {
852 DCHECK(IsPropertyChangeAllowed()); 855 DCHECK(IsPropertyChangeAllowed());
853 DCHECK(main_thread_scrolling_reasons_to_clear); 856 DCHECK(main_thread_scrolling_reasons_to_clear);
854 uint32_t new_reasons = ~main_thread_scrolling_reasons_to_clear & 857 uint32_t new_reasons = ~main_thread_scrolling_reasons_to_clear &
855 inputs_.main_thread_scrolling_reasons; 858 inputs_.main_thread_scrolling_reasons;
856 if (new_reasons == inputs_.main_thread_scrolling_reasons) 859 if (new_reasons == inputs_.main_thread_scrolling_reasons)
857 return; 860 return;
858 inputs_.main_thread_scrolling_reasons = new_reasons; 861 inputs_.main_thread_scrolling_reasons = new_reasons;
859 didUpdateMainThreadScrollingReasons(); 862 didUpdateMainThreadScrollingReasons();
863 SetPropertyTreesNeedRebuild();
860 SetNeedsCommit(); 864 SetNeedsCommit();
861 } 865 }
862 866
863 void Layer::SetNonFastScrollableRegion(const Region& region) { 867 void Layer::SetNonFastScrollableRegion(const Region& region) {
864 DCHECK(IsPropertyChangeAllowed()); 868 DCHECK(IsPropertyChangeAllowed());
865 if (inputs_.non_fast_scrollable_region == region) 869 if (inputs_.non_fast_scrollable_region == region)
866 return; 870 return;
867 inputs_.non_fast_scrollable_region = region; 871 inputs_.non_fast_scrollable_region = region;
872 SetPropertyTreesNeedRebuild();
868 SetNeedsCommit(); 873 SetNeedsCommit();
869 } 874 }
870 875
871 void Layer::SetTouchEventHandlerRegion(const Region& region) { 876 void Layer::SetTouchEventHandlerRegion(const Region& region) {
872 DCHECK(IsPropertyChangeAllowed()); 877 DCHECK(IsPropertyChangeAllowed());
873 if (inputs_.touch_event_handler_region == region) 878 if (inputs_.touch_event_handler_region == region)
874 return; 879 return;
875 880
876 inputs_.touch_event_handler_region = region; 881 inputs_.touch_event_handler_region = region;
882 SetPropertyTreesNeedRebuild();
877 SetNeedsCommit(); 883 SetNeedsCommit();
878 } 884 }
879 885
880 void Layer::SetForceRenderSurfaceForTesting(bool force) { 886 void Layer::SetForceRenderSurfaceForTesting(bool force) {
881 DCHECK(IsPropertyChangeAllowed()); 887 DCHECK(IsPropertyChangeAllowed());
882 if (force_render_surface_for_testing_ == force) 888 if (force_render_surface_for_testing_ == force)
883 return; 889 return;
884 force_render_surface_for_testing_ = force; 890 force_render_surface_for_testing_ = force;
891 SetPropertyTreesNeedRebuild();
885 SetNeedsCommit(); 892 SetNeedsCommit();
886 } 893 }
887 894
888 void Layer::SetDoubleSided(bool double_sided) { 895 void Layer::SetDoubleSided(bool double_sided) {
889 DCHECK(IsPropertyChangeAllowed()); 896 DCHECK(IsPropertyChangeAllowed());
890 if (inputs_.double_sided == double_sided) 897 if (inputs_.double_sided == double_sided)
891 return; 898 return;
892 inputs_.double_sided = double_sided; 899 inputs_.double_sided = double_sided;
893 SetNeedsCommit(); 900 SetNeedsCommit();
901 SetPropertyTreesNeedRebuild();
894 SetSubtreePropertyChanged(); 902 SetSubtreePropertyChanged();
895 } 903 }
896 904
897 void Layer::Set3dSortingContextId(int id) { 905 void Layer::Set3dSortingContextId(int id) {
898 DCHECK(IsPropertyChangeAllowed()); 906 DCHECK(IsPropertyChangeAllowed());
899 if (id == inputs_.sorting_context_id) 907 if (id == inputs_.sorting_context_id)
900 return; 908 return;
901 inputs_.sorting_context_id = id; 909 inputs_.sorting_context_id = id;
902 SetNeedsCommit(); 910 SetNeedsCommit();
911 SetPropertyTreesNeedRebuild();
903 SetSubtreePropertyChanged(); 912 SetSubtreePropertyChanged();
904 } 913 }
905 914
906 void Layer::SetTransformTreeIndex(int index) { 915 void Layer::SetTransformTreeIndex(int index) {
907 DCHECK(IsPropertyChangeAllowed()); 916 DCHECK(IsPropertyChangeAllowed());
908 if (transform_tree_index_ == index) 917 if (transform_tree_index_ == index)
909 return; 918 return;
910 transform_tree_index_ = index; 919 transform_tree_index_ = index;
911 SetNeedsPushProperties(); 920 SetNeedsPushProperties();
912 } 921 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 return scroll_tree_index_; 980 return scroll_tree_index_;
972 } 981 }
973 982
974 void Layer::InvalidatePropertyTreesIndices() { 983 void Layer::InvalidatePropertyTreesIndices() {
975 SetTransformTreeIndex(TransformTree::kInvalidNodeId); 984 SetTransformTreeIndex(TransformTree::kInvalidNodeId);
976 SetClipTreeIndex(ClipTree::kInvalidNodeId); 985 SetClipTreeIndex(ClipTree::kInvalidNodeId);
977 SetEffectTreeIndex(EffectTree::kInvalidNodeId); 986 SetEffectTreeIndex(EffectTree::kInvalidNodeId);
978 SetScrollTreeIndex(ScrollTree::kInvalidNodeId); 987 SetScrollTreeIndex(ScrollTree::kInvalidNodeId);
979 } 988 }
980 989
990 void Layer::SetPropertyTreesNeedRebuild() {
991 if (layer_tree_host_)
992 layer_tree_host_->property_trees()->needs_rebuild = true;
993 }
994
981 void Layer::SetShouldFlattenTransform(bool should_flatten) { 995 void Layer::SetShouldFlattenTransform(bool should_flatten) {
982 DCHECK(IsPropertyChangeAllowed()); 996 DCHECK(IsPropertyChangeAllowed());
983 if (inputs_.should_flatten_transform == should_flatten) 997 if (inputs_.should_flatten_transform == should_flatten)
984 return; 998 return;
985 inputs_.should_flatten_transform = should_flatten; 999 inputs_.should_flatten_transform = should_flatten;
986 SetNeedsCommit(); 1000 SetNeedsCommit();
1001 SetPropertyTreesNeedRebuild();
987 SetSubtreePropertyChanged(); 1002 SetSubtreePropertyChanged();
988 } 1003 }
989 1004
990 void Layer::SetUseParentBackfaceVisibility(bool use) { 1005 void Layer::SetUseParentBackfaceVisibility(bool use) {
991 DCHECK(IsPropertyChangeAllowed()); 1006 DCHECK(IsPropertyChangeAllowed());
992 if (inputs_.use_parent_backface_visibility == use) 1007 if (inputs_.use_parent_backface_visibility == use)
993 return; 1008 return;
994 inputs_.use_parent_backface_visibility = use; 1009 inputs_.use_parent_backface_visibility = use;
995 SetNeedsPushProperties(); 1010 SetNeedsPushProperties();
996 } 1011 }
(...skipping 22 matching lines...) Expand all
1019 UpdateDrawsContent(HasDrawableContent()); 1034 UpdateDrawsContent(HasDrawableContent());
1020 } 1035 }
1021 1036
1022 void Layer::SetHideLayerAndSubtree(bool hide) { 1037 void Layer::SetHideLayerAndSubtree(bool hide) {
1023 DCHECK(IsPropertyChangeAllowed()); 1038 DCHECK(IsPropertyChangeAllowed());
1024 if (inputs_.hide_layer_and_subtree == hide) 1039 if (inputs_.hide_layer_and_subtree == hide)
1025 return; 1040 return;
1026 1041
1027 inputs_.hide_layer_and_subtree = hide; 1042 inputs_.hide_layer_and_subtree = hide;
1028 SetNeedsCommit(); 1043 SetNeedsCommit();
1044 SetPropertyTreesNeedRebuild();
1029 SetSubtreePropertyChanged(); 1045 SetSubtreePropertyChanged();
1030 } 1046 }
1031 1047
1032 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { 1048 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) {
1033 if (dirty_rect.IsEmpty()) 1049 if (dirty_rect.IsEmpty())
1034 return; 1050 return;
1035 1051
1036 SetNeedsPushProperties(); 1052 SetNeedsPushProperties();
1037 inputs_.update_rect.Union(dirty_rect); 1053 inputs_.update_rect.Union(dirty_rect);
1038 1054
(...skipping 12 matching lines...) Expand all
1051 1067
1052 void Layer::SetIsContainerForFixedPositionLayers(bool container) { 1068 void Layer::SetIsContainerForFixedPositionLayers(bool container) {
1053 if (inputs_.is_container_for_fixed_position_layers == container) 1069 if (inputs_.is_container_for_fixed_position_layers == container)
1054 return; 1070 return;
1055 inputs_.is_container_for_fixed_position_layers = container; 1071 inputs_.is_container_for_fixed_position_layers = container;
1056 1072
1057 if (layer_tree_host_ && layer_tree_host_->CommitRequested()) 1073 if (layer_tree_host_ && layer_tree_host_->CommitRequested())
1058 return; 1074 return;
1059 1075
1060 // Only request a commit if we have a fixed positioned descendant. 1076 // Only request a commit if we have a fixed positioned descendant.
1061 if (DescendantIsFixedToContainerLayer()) 1077 if (DescendantIsFixedToContainerLayer()) {
1078 SetPropertyTreesNeedRebuild();
1062 SetNeedsCommit(); 1079 SetNeedsCommit();
1080 }
1063 } 1081 }
1064 1082
1065 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { 1083 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) {
1066 DCHECK(IsPropertyChangeAllowed()); 1084 DCHECK(IsPropertyChangeAllowed());
1067 if (inputs_.position_constraint == constraint) 1085 if (inputs_.position_constraint == constraint)
1068 return; 1086 return;
1069 inputs_.position_constraint = constraint; 1087 inputs_.position_constraint = constraint;
1088 SetPropertyTreesNeedRebuild();
1070 SetNeedsCommit(); 1089 SetNeedsCommit();
1071 } 1090 }
1072 1091
1073 void Layer::SetStickyPositionConstraint( 1092 void Layer::SetStickyPositionConstraint(
1074 const LayerStickyPositionConstraint& constraint) { 1093 const LayerStickyPositionConstraint& constraint) {
1075 DCHECK(IsPropertyChangeAllowed()); 1094 DCHECK(IsPropertyChangeAllowed());
1076 if (inputs_.sticky_position_constraint == constraint) 1095 if (inputs_.sticky_position_constraint == constraint)
1077 return; 1096 return;
1078 inputs_.sticky_position_constraint = constraint; 1097 inputs_.sticky_position_constraint = constraint;
1098 SetPropertyTreesNeedRebuild();
1079 SetNeedsCommit(); 1099 SetNeedsCommit();
1080 } 1100 }
1081 1101
1082 static void RunCopyCallbackOnMainThread( 1102 static void RunCopyCallbackOnMainThread(
1083 std::unique_ptr<CopyOutputRequest> request, 1103 std::unique_ptr<CopyOutputRequest> request,
1084 std::unique_ptr<CopyOutputResult> result) { 1104 std::unique_ptr<CopyOutputResult> result) {
1085 request->SendResult(std::move(result)); 1105 request->SendResult(std::move(result));
1086 } 1106 }
1087 1107
1088 static void PostCopyCallbackToMainThread( 1108 static void PostCopyCallbackToMainThread(
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 void Layer::UpdateDrawsContent(bool has_drawable_content) { 1239 void Layer::UpdateDrawsContent(bool has_drawable_content) {
1220 bool draws_content = has_drawable_content; 1240 bool draws_content = has_drawable_content;
1221 DCHECK(inputs_.is_drawable || !has_drawable_content); 1241 DCHECK(inputs_.is_drawable || !has_drawable_content);
1222 if (draws_content == draws_content_) 1242 if (draws_content == draws_content_)
1223 return; 1243 return;
1224 1244
1225 if (parent()) 1245 if (parent())
1226 parent()->AddDrawableDescendants(draws_content ? 1 : -1); 1246 parent()->AddDrawableDescendants(draws_content ? 1 : -1);
1227 1247
1228 draws_content_ = draws_content; 1248 draws_content_ = draws_content;
1249 SetPropertyTreesNeedRebuild();
1229 SetNeedsCommit(); 1250 SetNeedsCommit();
1230 } 1251 }
1231 1252
1232 int Layer::NumDescendantsThatDrawContent() const { 1253 int Layer::NumDescendantsThatDrawContent() const {
1233 return num_descendants_that_draw_content_; 1254 return num_descendants_that_draw_content_;
1234 } 1255 }
1235 1256
1236 void Layer::SavePaintProperties() { 1257 void Layer::SavePaintProperties() {
1237 DCHECK(layer_tree_host_); 1258 DCHECK(layer_tree_host_);
1238 1259
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 // Do nothing. Scroll deltas will be sent from the compositor thread back 1341 // 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 1342 // to the main thread in the same manner as during non-animated
1322 // compositor-driven scrolling. 1343 // compositor-driven scrolling.
1323 } 1344 }
1324 1345
1325 void Layer::OnIsAnimatingChanged(const PropertyAnimationState& mask, 1346 void Layer::OnIsAnimatingChanged(const PropertyAnimationState& mask,
1326 const PropertyAnimationState& state) { 1347 const PropertyAnimationState& state) {
1327 DCHECK(layer_tree_host_); 1348 DCHECK(layer_tree_host_);
1328 PropertyTrees* property_trees = layer_tree_host_->property_trees(); 1349 PropertyTrees* property_trees = layer_tree_host_->property_trees();
1329 1350
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; 1351 for (int property = TargetProperty::FIRST_TARGET_PROPERTY;
1339 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) { 1352 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) {
1353 if (!mask.currently_running[property] &&
1354 !mask.potentially_animating[property])
1355 continue;
1356
1340 switch (property) { 1357 switch (property) {
1341 case TargetProperty::TRANSFORM: 1358 case TargetProperty::TRANSFORM:
1342 if (transform_node) { 1359 if (TransformNode* transform_node =
1360 property_trees->transform_tree.UpdateNodeFromOwningLayerId(
1361 id())) {
1362 DCHECK_EQ(transform_node->id, transform_tree_index());
1343 if (mask.currently_running[property]) 1363 if (mask.currently_running[property])
1344 transform_node->is_currently_animating = 1364 transform_node->is_currently_animating =
1345 state.currently_running[property]; 1365 state.currently_running[property];
1346 if (mask.potentially_animating[property]) { 1366 if (mask.potentially_animating[property]) {
1347 transform_node->has_potential_animation = 1367 transform_node->has_potential_animation =
1348 state.potentially_animating[property]; 1368 state.potentially_animating[property];
1349 if (state.potentially_animating[property]) { 1369 if (state.potentially_animating[property]) {
1350 transform_node->has_only_translation_animations = 1370 transform_node->has_only_translation_animations =
1351 HasOnlyTranslationTransforms(); 1371 HasOnlyTranslationTransforms();
1352 } else { 1372 } else {
1353 transform_node->has_only_translation_animations = true; 1373 transform_node->has_only_translation_animations = true;
1354 } 1374 }
1355 property_trees->transform_tree.set_needs_update(true); 1375 property_trees->transform_tree.set_needs_update(true);
1356 } 1376 }
1377 } else {
1378 DCHECK(property_trees->needs_rebuild)
1379 << "Attempting to animate non existent transform node";
1357 } 1380 }
1358 break; 1381 break;
1359 case TargetProperty::OPACITY: 1382 case TargetProperty::OPACITY:
1360 if (effect_node) { 1383 if (EffectNode* effect_node =
1384 property_trees->effect_tree.UpdateNodeFromOwningLayerId(id())) {
1361 if (mask.currently_running[property]) 1385 if (mask.currently_running[property])
1362 effect_node->is_currently_animating_opacity = 1386 effect_node->is_currently_animating_opacity =
1363 state.currently_running[property]; 1387 state.currently_running[property];
1364 if (mask.potentially_animating[property]) { 1388 if (mask.potentially_animating[property]) {
1365 effect_node->has_potential_opacity_animation = 1389 effect_node->has_potential_opacity_animation =
1366 state.potentially_animating[property] || 1390 state.potentially_animating[property] ||
1367 OpacityCanAnimateOnImplThread(); 1391 OpacityCanAnimateOnImplThread();
1368 property_trees->effect_tree.set_needs_update(true); 1392 property_trees->effect_tree.set_needs_update(true);
1369 } 1393 }
1394 } else {
1395 DCHECK(property_trees->needs_rebuild)
1396 << "Attempting to animate opacity on non existent effect node";
1370 } 1397 }
1371 break; 1398 break;
1372 case TargetProperty::FILTER: 1399 case TargetProperty::FILTER:
1373 if (effect_node) { 1400 if (EffectNode* effect_node =
1401 property_trees->effect_tree.UpdateNodeFromOwningLayerId(id())) {
1374 if (mask.currently_running[property]) 1402 if (mask.currently_running[property])
1375 effect_node->is_currently_animating_filter = 1403 effect_node->is_currently_animating_filter =
1376 state.currently_running[property]; 1404 state.currently_running[property];
1377 if (mask.potentially_animating[property]) 1405 if (mask.potentially_animating[property])
1378 effect_node->has_potential_filter_animation = 1406 effect_node->has_potential_filter_animation =
1379 state.potentially_animating[property]; 1407 state.potentially_animating[property];
1408 } else {
1409 DCHECK(property_trees->needs_rebuild)
1410 << "Attempting to animate filter on non existent effect node";
1380 } 1411 }
1381 break; 1412 break;
1382 default: 1413 default:
1383 break; 1414 break;
1384 } 1415 }
1385 } 1416 }
1386 } 1417 }
1387 1418
1388 bool Layer::HasTickingAnimationForTesting() const { 1419 bool Layer::HasTickingAnimationForTesting() const {
1389 return layer_tree_host_ 1420 return layer_tree_host_
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 ->num_copy_requests_in_subtree; 1533 ->num_copy_requests_in_subtree;
1503 } 1534 }
1504 1535
1505 gfx::Transform Layer::screen_space_transform() const { 1536 gfx::Transform Layer::screen_space_transform() const {
1506 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); 1537 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId);
1507 return draw_property_utils::ScreenSpaceTransform( 1538 return draw_property_utils::ScreenSpaceTransform(
1508 this, layer_tree_host_->property_trees()->transform_tree); 1539 this, layer_tree_host_->property_trees()->transform_tree);
1509 } 1540 }
1510 1541
1511 } // namespace cc 1542 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698