Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "cc/animation/animation.h" | 15 #include "cc/animation/animation.h" |
| 16 #include "cc/animation/animation_events.h" | 16 #include "cc/animation/animation_events.h" |
| 17 #include "cc/animation/animation_registrar.h" | 17 #include "cc/animation/animation_registrar.h" |
| 18 #include "cc/animation/keyframed_animation_curve.h" | 18 #include "cc/animation/keyframed_animation_curve.h" |
| 19 #include "cc/animation/layer_animation_controller.h" | 19 #include "cc/animation/layer_animation_controller.h" |
| 20 #include "cc/base/simple_enclosed_region.h" | 20 #include "cc/base/simple_enclosed_region.h" |
| 21 #include "cc/debug/frame_viewer_instrumentation.h" | 21 #include "cc/debug/frame_viewer_instrumentation.h" |
| 22 #include "cc/layers/layer_client.h" | 22 #include "cc/layers/layer_client.h" |
| 23 #include "cc/layers/layer_impl.h" | 23 #include "cc/layers/layer_impl.h" |
| 24 #include "cc/layers/layer_proto_converter.h" | |
| 24 #include "cc/layers/scrollbar_layer_interface.h" | 25 #include "cc/layers/scrollbar_layer_interface.h" |
| 25 #include "cc/output/copy_output_request.h" | 26 #include "cc/output/copy_output_request.h" |
| 26 #include "cc/output/copy_output_result.h" | 27 #include "cc/output/copy_output_result.h" |
| 28 #include "cc/proto/layer.pb.h" | |
| 27 #include "cc/trees/draw_property_utils.h" | 29 #include "cc/trees/draw_property_utils.h" |
| 28 #include "cc/trees/layer_tree_host.h" | 30 #include "cc/trees/layer_tree_host.h" |
| 29 #include "cc/trees/layer_tree_impl.h" | 31 #include "cc/trees/layer_tree_impl.h" |
| 30 #include "third_party/skia/include/core/SkImageFilter.h" | 32 #include "third_party/skia/include/core/SkImageFilter.h" |
| 31 #include "ui/gfx/geometry/rect_conversions.h" | 33 #include "ui/gfx/geometry/rect_conversions.h" |
| 32 #include "ui/gfx/geometry/vector2d_conversions.h" | 34 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 33 | 35 |
| 34 namespace cc { | 36 namespace cc { |
| 35 | 37 |
| 36 base::StaticAtomicSequenceNumber g_next_layer_id; | 38 base::StaticAtomicSequenceNumber g_next_layer_id; |
| (...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1338 layer->SetIsAffectedByPageScale(is_page_scale_layer || parent_affected); | 1340 layer->SetIsAffectedByPageScale(is_page_scale_layer || parent_affected); |
| 1339 | 1341 |
| 1340 // Reset any state that should be cleared for the next update. | 1342 // Reset any state that should be cleared for the next update. |
| 1341 stacking_order_changed_ = false; | 1343 stacking_order_changed_ = false; |
| 1342 update_rect_ = gfx::Rect(); | 1344 update_rect_ = gfx::Rect(); |
| 1343 | 1345 |
| 1344 needs_push_properties_ = false; | 1346 needs_push_properties_ = false; |
| 1345 num_dependents_need_push_properties_ = 0; | 1347 num_dependents_need_push_properties_ = 0; |
| 1346 } | 1348 } |
| 1347 | 1349 |
| 1350 void Layer::ToLayerNodeProto(proto::LayerNode* proto) const { | |
| 1351 proto->set_id(layer_id_); | |
| 1352 proto->set_type(proto::Base); | |
|
vmpstr
2015/10/23 21:26:10
I assume that layer overrides would do something l
nyquist
2015/10/26 03:14:29
Done.
From what I can understand, it should be en
| |
| 1353 | |
| 1354 if (parent_) | |
| 1355 proto->set_parent_id(parent_->id()); | |
| 1356 | |
| 1357 DCHECK_EQ(0, proto->children_size()); | |
| 1358 for (const auto& child : children_) { | |
| 1359 child->ToLayerNodeProto(proto->add_children()); | |
| 1360 } | |
| 1361 | |
| 1362 if (mask_layer_) | |
| 1363 mask_layer_->ToLayerNodeProto(proto->mutable_mask_layer()); | |
| 1364 if (replica_layer_) | |
| 1365 replica_layer_->ToLayerNodeProto(proto->mutable_replica_layer()); | |
| 1366 } | |
| 1367 | |
| 1368 void Layer::FromLayerNodeProto(const proto::LayerNode& proto, | |
| 1369 const LayerIdMap& layer_map) { | |
| 1370 DCHECK(proto.has_id()); | |
| 1371 layer_id_ = proto.id(); | |
| 1372 | |
| 1373 // Recursively remove all children. In the case of when the updated | |
| 1374 // hierarchy has no children, or the children has changed, the old list | |
| 1375 // of children must be removed. The whole hierarchy is always sent, so | |
| 1376 // if there were no change in the children, they will be correctly added back | |
| 1377 // below. | |
| 1378 RemoveAllChildren(); | |
| 1379 for (int i = 0; i < proto.children_size(); ++i) { | |
| 1380 const proto::LayerNode& child_proto = proto.children(i); | |
| 1381 DCHECK(child_proto.has_type()); | |
| 1382 scoped_refptr<Layer> child = | |
| 1383 LayerProtoConverter::FindOrAllocateAndConstruct(child_proto, layer_map); | |
| 1384 child->FromLayerNodeProto(child_proto, layer_map); | |
| 1385 AddChild(child); | |
| 1386 } | |
| 1387 | |
| 1388 if (mask_layer_) | |
| 1389 mask_layer_->RemoveFromParent(); | |
| 1390 if (proto.has_mask_layer()) { | |
| 1391 mask_layer_ = LayerProtoConverter::FindOrAllocateAndConstruct( | |
| 1392 proto.mask_layer(), layer_map); | |
| 1393 mask_layer_->FromLayerNodeProto(proto.mask_layer(), layer_map); | |
| 1394 mask_layer_->SetParent(this); | |
| 1395 } else { | |
| 1396 mask_layer_ = nullptr; | |
| 1397 } | |
| 1398 | |
| 1399 if (replica_layer_) | |
| 1400 replica_layer_->RemoveFromParent(); | |
| 1401 if (proto.has_replica_layer()) { | |
| 1402 replica_layer_ = LayerProtoConverter::FindOrAllocateAndConstruct( | |
| 1403 proto.replica_layer(), layer_map); | |
| 1404 replica_layer_->FromLayerNodeProto(proto.replica_layer(), layer_map); | |
| 1405 replica_layer_->SetParent(this); | |
| 1406 } else { | |
| 1407 replica_layer_ = nullptr; | |
| 1408 } | |
| 1409 } | |
| 1410 | |
| 1348 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 1411 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| 1349 return LayerImpl::Create(tree_impl, layer_id_, | 1412 return LayerImpl::Create(tree_impl, layer_id_, |
| 1350 new LayerImpl::SyncedScrollOffset); | 1413 new LayerImpl::SyncedScrollOffset); |
| 1351 } | 1414 } |
| 1352 | 1415 |
| 1353 bool Layer::DrawsContent() const { | 1416 bool Layer::DrawsContent() const { |
| 1354 return draws_content_; | 1417 return draws_content_; |
| 1355 } | 1418 } |
| 1356 | 1419 |
| 1357 bool Layer::HasDrawableContent() const { | 1420 bool Layer::HasDrawableContent() const { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1703 this, layer_tree_host_->property_trees()->transform_tree); | 1766 this, layer_tree_host_->property_trees()->transform_tree); |
| 1704 } | 1767 } |
| 1705 | 1768 |
| 1706 gfx::Transform Layer::screen_space_transform() const { | 1769 gfx::Transform Layer::screen_space_transform() const { |
| 1707 DCHECK_NE(transform_tree_index_, -1); | 1770 DCHECK_NE(transform_tree_index_, -1); |
| 1708 return ScreenSpaceTransformFromPropertyTrees( | 1771 return ScreenSpaceTransformFromPropertyTrees( |
| 1709 this, layer_tree_host_->property_trees()->transform_tree); | 1772 this, layer_tree_host_->property_trees()->transform_tree); |
| 1710 } | 1773 } |
| 1711 | 1774 |
| 1712 } // namespace cc | 1775 } // namespace cc |
| OLD | NEW |