| 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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 if (background_filters_ == filters) | 460 if (background_filters_ == filters) |
| 461 return; | 461 return; |
| 462 background_filters_ = filters; | 462 background_filters_ = filters; |
| 463 SetNeedsCommit(); | 463 SetNeedsCommit(); |
| 464 } | 464 } |
| 465 | 465 |
| 466 void Layer::SetOpacity(float opacity) { | 466 void Layer::SetOpacity(float opacity) { |
| 467 DCHECK(IsPropertyChangeAllowed()); | 467 DCHECK(IsPropertyChangeAllowed()); |
| 468 if (opacity_ == opacity) | 468 if (opacity_ == opacity) |
| 469 return; | 469 return; |
| 470 // We need to force a property tree rebuild when opacity changes from 1 to a |
| 471 // non-1 value or vice-versa as render surfaces can change. |
| 472 bool force_rebuild = opacity == 1.f || opacity_ == 1.f; |
| 470 opacity_ = opacity; | 473 opacity_ = opacity; |
| 471 SetSubtreePropertyChanged(); | 474 SetSubtreePropertyChanged(); |
| 475 if (layer_tree_host_ && !force_rebuild) { |
| 476 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
| 477 auto effect_id_to_index = property_trees->effect_id_to_index_map.find(id()); |
| 478 if (effect_id_to_index != property_trees->effect_id_to_index_map.end()) { |
| 479 EffectNode* node = |
| 480 property_trees->effect_tree.Node(effect_id_to_index->second); |
| 481 node->data.opacity = opacity; |
| 482 node->data.effect_changed = true; |
| 483 property_trees->effect_tree.set_needs_update(true); |
| 484 SetNeedsCommitNoRebuild(); |
| 485 return; |
| 486 } |
| 487 } |
| 472 SetNeedsCommit(); | 488 SetNeedsCommit(); |
| 473 } | 489 } |
| 474 | 490 |
| 475 float Layer::EffectiveOpacity() const { | 491 float Layer::EffectiveOpacity() const { |
| 476 return hide_layer_and_subtree_ ? 0.f : opacity_; | 492 return hide_layer_and_subtree_ ? 0.f : opacity_; |
| 477 } | 493 } |
| 478 | 494 |
| 479 bool Layer::OpacityIsAnimating() const { | 495 bool Layer::OpacityIsAnimating() const { |
| 480 DCHECK(layer_tree_host_); | 496 DCHECK(layer_tree_host_); |
| 481 return layer_tree_host_->IsAnimatingOpacityProperty(this); | 497 return layer_tree_host_->IsAnimatingOpacityProperty(this); |
| (...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 ->data.num_copy_requests_in_subtree; | 1786 ->data.num_copy_requests_in_subtree; |
| 1771 } | 1787 } |
| 1772 | 1788 |
| 1773 gfx::Transform Layer::screen_space_transform() const { | 1789 gfx::Transform Layer::screen_space_transform() const { |
| 1774 DCHECK_NE(transform_tree_index_, -1); | 1790 DCHECK_NE(transform_tree_index_, -1); |
| 1775 return draw_property_utils::ScreenSpaceTransform( | 1791 return draw_property_utils::ScreenSpaceTransform( |
| 1776 this, layer_tree_host_->property_trees()->transform_tree); | 1792 this, layer_tree_host_->property_trees()->transform_tree); |
| 1777 } | 1793 } |
| 1778 | 1794 |
| 1779 } // namespace cc | 1795 } // namespace cc |
| OLD | NEW |