| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 subtree_property_changed_(false), | 83 subtree_property_changed_(false), |
| 84 background_color_(0), | 84 background_color_(0), |
| 85 safe_opaque_background_color_(0), | 85 safe_opaque_background_color_(0), |
| 86 opacity_(1.f), | 86 opacity_(1.f), |
| 87 blend_mode_(SkXfermode::kSrcOver_Mode), | 87 blend_mode_(SkXfermode::kSrcOver_Mode), |
| 88 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 88 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
| 89 scroll_parent_(nullptr), | 89 scroll_parent_(nullptr), |
| 90 clip_parent_(nullptr), | 90 clip_parent_(nullptr), |
| 91 replica_layer_(nullptr), | 91 replica_layer_(nullptr), |
| 92 client_(nullptr), | 92 client_(nullptr), |
| 93 num_unclipped_descendants_(0), | 93 num_unclipped_descendants_(0) {} |
| 94 frame_timing_requests_dirty_(false) {} | |
| 95 | 94 |
| 96 Layer::~Layer() { | 95 Layer::~Layer() { |
| 97 // Our parent should be holding a reference to us so there should be no | 96 // Our parent should be holding a reference to us so there should be no |
| 98 // way for us to be destroyed while we still have a parent. | 97 // way for us to be destroyed while we still have a parent. |
| 99 DCHECK(!parent()); | 98 DCHECK(!parent()); |
| 100 // Similarly we shouldn't have a layer tree host since it also keeps a | 99 // Similarly we shouldn't have a layer tree host since it also keeps a |
| 101 // reference to us. | 100 // reference to us. |
| 102 DCHECK(!layer_tree_host()); | 101 DCHECK(!layer_tree_host()); |
| 103 | 102 |
| 104 RemoveFromScrollTree(); | 103 RemoveFromScrollTree(); |
| (...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 layer->PassCopyRequests(&main_thread_copy_requests); | 1262 layer->PassCopyRequests(&main_thread_copy_requests); |
| 1264 } | 1263 } |
| 1265 | 1264 |
| 1266 // If the main thread commits multiple times before the impl thread actually | 1265 // If the main thread commits multiple times before the impl thread actually |
| 1267 // draws, then damage tracking will become incorrect if we simply clobber the | 1266 // draws, then damage tracking will become incorrect if we simply clobber the |
| 1268 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 1267 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
| 1269 // union) any update changes that have occurred on the main thread. | 1268 // union) any update changes that have occurred on the main thread. |
| 1270 update_rect_.Union(layer->update_rect()); | 1269 update_rect_.Union(layer->update_rect()); |
| 1271 layer->SetUpdateRect(update_rect_); | 1270 layer->SetUpdateRect(update_rect_); |
| 1272 | 1271 |
| 1273 if (frame_timing_requests_dirty_) { | |
| 1274 layer->SetFrameTimingRequests(frame_timing_requests_); | |
| 1275 frame_timing_requests_dirty_ = false; | |
| 1276 } | |
| 1277 | |
| 1278 // Reset any state that should be cleared for the next update. | 1272 // Reset any state that should be cleared for the next update. |
| 1279 subtree_property_changed_ = false; | 1273 subtree_property_changed_ = false; |
| 1280 update_rect_ = gfx::Rect(); | 1274 update_rect_ = gfx::Rect(); |
| 1281 | 1275 |
| 1282 layer_tree_host()->RemoveLayerShouldPushProperties(this); | 1276 layer_tree_host()->RemoveLayerShouldPushProperties(this); |
| 1283 } | 1277 } |
| 1284 | 1278 |
| 1285 void Layer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { | 1279 void Layer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { |
| 1286 proto->set_type(proto::LayerNode::LAYER); | 1280 proto->set_type(proto::LayerNode::LAYER); |
| 1287 } | 1281 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1469 | 1463 |
| 1470 ScrollOffsetToProto(scroll_offset_, base->mutable_scroll_offset()); | 1464 ScrollOffsetToProto(scroll_offset_, base->mutable_scroll_offset()); |
| 1471 | 1465 |
| 1472 // TODO(nyquist): Figure out what to do with CopyRequests. | 1466 // TODO(nyquist): Figure out what to do with CopyRequests. |
| 1473 // See crbug.com/570374. | 1467 // See crbug.com/570374. |
| 1474 | 1468 |
| 1475 RectToProto(update_rect_, base->mutable_update_rect()); | 1469 RectToProto(update_rect_, base->mutable_update_rect()); |
| 1476 | 1470 |
| 1477 // TODO(nyquist): Figure out what to do with LayerAnimationController. | 1471 // TODO(nyquist): Figure out what to do with LayerAnimationController. |
| 1478 // See crbug.com/570376. | 1472 // See crbug.com/570376. |
| 1479 // TODO(nyquist): Figure out what to do with FrameTimingRequests. See | |
| 1480 // crbug.com/570377. | |
| 1481 | 1473 |
| 1482 update_rect_ = gfx::Rect(); | 1474 update_rect_ = gfx::Rect(); |
| 1483 } | 1475 } |
| 1484 | 1476 |
| 1485 void Layer::FromLayerSpecificPropertiesProto( | 1477 void Layer::FromLayerSpecificPropertiesProto( |
| 1486 const proto::LayerProperties& proto) { | 1478 const proto::LayerProperties& proto) { |
| 1487 DCHECK(proto.has_base()); | 1479 DCHECK(proto.has_base()); |
| 1488 DCHECK(layer_tree_host_); | 1480 DCHECK(layer_tree_host_); |
| 1489 const proto::BaseLayerProperties& base = proto.base(); | 1481 const proto::BaseLayerProperties& base = proto.base(); |
| 1490 | 1482 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 num_descendants_that_draw_content_ += num; | 1778 num_descendants_that_draw_content_ += num; |
| 1787 SetNeedsCommit(); | 1779 SetNeedsCommit(); |
| 1788 if (parent()) | 1780 if (parent()) |
| 1789 parent()->AddDrawableDescendants(num); | 1781 parent()->AddDrawableDescendants(num); |
| 1790 } | 1782 } |
| 1791 | 1783 |
| 1792 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1784 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
| 1793 benchmark->RunOnLayer(this); | 1785 benchmark->RunOnLayer(this); |
| 1794 } | 1786 } |
| 1795 | 1787 |
| 1796 void Layer::SetFrameTimingRequests( | |
| 1797 const std::vector<FrameTimingRequest>& requests) { | |
| 1798 // TODO(vmpstr): Early out if there are no changes earlier in the call stack. | |
| 1799 if (requests == frame_timing_requests_) | |
| 1800 return; | |
| 1801 frame_timing_requests_ = requests; | |
| 1802 frame_timing_requests_dirty_ = true; | |
| 1803 SetNeedsCommit(); | |
| 1804 } | |
| 1805 | |
| 1806 void Layer::SetElementId(uint64_t id) { | 1788 void Layer::SetElementId(uint64_t id) { |
| 1807 DCHECK(IsPropertyChangeAllowed()); | 1789 DCHECK(IsPropertyChangeAllowed()); |
| 1808 if (element_id_ == id) | 1790 if (element_id_ == id) |
| 1809 return; | 1791 return; |
| 1810 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1792 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 1811 "Layer::SetElementId", "id", id); | 1793 "Layer::SetElementId", "id", id); |
| 1812 element_id_ = id; | 1794 element_id_ = id; |
| 1813 SetNeedsCommit(); | 1795 SetNeedsCommit(); |
| 1814 } | 1796 } |
| 1815 | 1797 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1838 ->data.num_copy_requests_in_subtree; | 1820 ->data.num_copy_requests_in_subtree; |
| 1839 } | 1821 } |
| 1840 | 1822 |
| 1841 gfx::Transform Layer::screen_space_transform() const { | 1823 gfx::Transform Layer::screen_space_transform() const { |
| 1842 DCHECK_NE(transform_tree_index_, -1); | 1824 DCHECK_NE(transform_tree_index_, -1); |
| 1843 return draw_property_utils::ScreenSpaceTransform( | 1825 return draw_property_utils::ScreenSpaceTransform( |
| 1844 this, layer_tree_host_->property_trees()->transform_tree); | 1826 this, layer_tree_host_->property_trees()->transform_tree); |
| 1845 } | 1827 } |
| 1846 | 1828 |
| 1847 } // namespace cc | 1829 } // namespace cc |
| OLD | NEW |