| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 scroll_clip_layer_id(INVALID_ID), | 60 scroll_clip_layer_id(INVALID_ID), |
| 61 user_scrollable_horizontal(true), | 61 user_scrollable_horizontal(true), |
| 62 user_scrollable_vertical(true), | 62 user_scrollable_vertical(true), |
| 63 main_thread_scrolling_reasons( | 63 main_thread_scrolling_reasons( |
| 64 MainThreadScrollingReason::kNotScrollingOnMain), | 64 MainThreadScrollingReason::kNotScrollingOnMain), |
| 65 is_container_for_fixed_position_layers(false), | 65 is_container_for_fixed_position_layers(false), |
| 66 mutable_properties(MutableProperty::kNone), | 66 mutable_properties(MutableProperty::kNone), |
| 67 scroll_parent(nullptr), | 67 scroll_parent(nullptr), |
| 68 clip_parent(nullptr), | 68 clip_parent(nullptr), |
| 69 has_will_change_transform_hint(false), | 69 has_will_change_transform_hint(false), |
| 70 has_preferred_raster_scale(false), |
| 70 hide_layer_and_subtree(false), | 71 hide_layer_and_subtree(false), |
| 71 client(nullptr) {} | 72 client(nullptr), |
| 73 preferred_raster_scale(1.0) {} |
| 72 | 74 |
| 73 Layer::Inputs::~Inputs() {} | 75 Layer::Inputs::~Inputs() {} |
| 74 | 76 |
| 75 scoped_refptr<Layer> Layer::Create() { | 77 scoped_refptr<Layer> Layer::Create() { |
| 76 return make_scoped_refptr(new Layer()); | 78 return make_scoped_refptr(new Layer()); |
| 77 } | 79 } |
| 78 | 80 |
| 79 Layer::Layer() | 81 Layer::Layer() |
| 80 : ignore_set_needs_commit_(false), | 82 : ignore_set_needs_commit_(false), |
| 81 parent_(nullptr), | 83 parent_(nullptr), |
| (...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 ->scroll_tree.SetScrollOffsetClobberActiveValue(layer->id()); | 1177 ->scroll_tree.SetScrollOffsetClobberActiveValue(layer->id()); |
| 1176 | 1178 |
| 1177 // If the main thread commits multiple times before the impl thread actually | 1179 // If the main thread commits multiple times before the impl thread actually |
| 1178 // draws, then damage tracking will become incorrect if we simply clobber the | 1180 // draws, then damage tracking will become incorrect if we simply clobber the |
| 1179 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 1181 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
| 1180 // union) any update changes that have occurred on the main thread. | 1182 // union) any update changes that have occurred on the main thread. |
| 1181 inputs_.update_rect.Union(layer->update_rect()); | 1183 inputs_.update_rect.Union(layer->update_rect()); |
| 1182 layer->SetUpdateRect(inputs_.update_rect); | 1184 layer->SetUpdateRect(inputs_.update_rect); |
| 1183 | 1185 |
| 1184 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); | 1186 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); |
| 1187 if (has_preferred_raster_scale()) |
| 1188 layer->SetPreferredRasterScale(preferred_raster_scale()); |
| 1189 else |
| 1190 layer->ClearPreferredRasterScale(); |
| 1185 layer->SetNeedsPushProperties(); | 1191 layer->SetNeedsPushProperties(); |
| 1186 | 1192 |
| 1187 // Reset any state that should be cleared for the next update. | 1193 // Reset any state that should be cleared for the next update. |
| 1188 subtree_property_changed_ = false; | 1194 subtree_property_changed_ = false; |
| 1189 inputs_.update_rect = gfx::Rect(); | 1195 inputs_.update_rect = gfx::Rect(); |
| 1190 | 1196 |
| 1191 layer_tree_->RemoveLayerShouldPushProperties(this); | 1197 layer_tree_->RemoveLayerShouldPushProperties(this); |
| 1192 } | 1198 } |
| 1193 | 1199 |
| 1194 void Layer::TakeCopyRequests( | 1200 void Layer::TakeCopyRequests( |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1753 : false; | 1759 : false; |
| 1754 } | 1760 } |
| 1755 | 1761 |
| 1756 void Layer::SetHasWillChangeTransformHint(bool has_will_change) { | 1762 void Layer::SetHasWillChangeTransformHint(bool has_will_change) { |
| 1757 if (inputs_.has_will_change_transform_hint == has_will_change) | 1763 if (inputs_.has_will_change_transform_hint == has_will_change) |
| 1758 return; | 1764 return; |
| 1759 inputs_.has_will_change_transform_hint = has_will_change; | 1765 inputs_.has_will_change_transform_hint = has_will_change; |
| 1760 SetNeedsCommit(); | 1766 SetNeedsCommit(); |
| 1761 } | 1767 } |
| 1762 | 1768 |
| 1769 void Layer::SetPreferredRasterScale(float preferred_raster_scale) { |
| 1770 if (inputs_.has_preferred_raster_scale && |
| 1771 inputs_.preferred_raster_scale == preferred_raster_scale) |
| 1772 return; |
| 1773 |
| 1774 inputs_.has_preferred_raster_scale = true; |
| 1775 inputs_.preferred_raster_scale = preferred_raster_scale; |
| 1776 SetNeedsCommit(); |
| 1777 } |
| 1778 |
| 1779 void Layer::ClearPreferredRasterScale() { |
| 1780 if (!inputs_.has_preferred_raster_scale) |
| 1781 return; |
| 1782 inputs_.has_preferred_raster_scale = false; |
| 1783 inputs_.preferred_raster_scale = 1.0f; |
| 1784 SetNeedsCommit(); |
| 1785 } |
| 1786 |
| 1763 AnimationHost* Layer::GetAnimationHost() const { | 1787 AnimationHost* Layer::GetAnimationHost() const { |
| 1764 return layer_tree_ ? layer_tree_->animation_host() : nullptr; | 1788 return layer_tree_ ? layer_tree_->animation_host() : nullptr; |
| 1765 } | 1789 } |
| 1766 | 1790 |
| 1767 ElementListType Layer::GetElementTypeForAnimation() const { | 1791 ElementListType Layer::GetElementTypeForAnimation() const { |
| 1768 return ElementListType::ACTIVE; | 1792 return ElementListType::ACTIVE; |
| 1769 } | 1793 } |
| 1770 | 1794 |
| 1771 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { | 1795 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { |
| 1772 return nullptr; | 1796 return nullptr; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1862 | 1886 |
| 1863 LayerTree* Layer::GetLayerTree() const { | 1887 LayerTree* Layer::GetLayerTree() const { |
| 1864 return layer_tree_; | 1888 return layer_tree_; |
| 1865 } | 1889 } |
| 1866 | 1890 |
| 1867 void Layer::SetLayerIdForTesting(int id) { | 1891 void Layer::SetLayerIdForTesting(int id) { |
| 1868 inputs_.layer_id = id; | 1892 inputs_.layer_id = id; |
| 1869 } | 1893 } |
| 1870 | 1894 |
| 1871 } // namespace cc | 1895 } // namespace cc |
| OLD | NEW |