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" |
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 if (proto.has_replica_layer()) { | 1411 if (proto.has_replica_layer()) { |
1412 replica_layer_ = LayerProtoConverter::FindOrAllocateAndConstruct( | 1412 replica_layer_ = LayerProtoConverter::FindOrAllocateAndConstruct( |
1413 proto.replica_layer(), layer_map); | 1413 proto.replica_layer(), layer_map); |
1414 replica_layer_->FromLayerNodeProto(proto.replica_layer(), layer_map); | 1414 replica_layer_->FromLayerNodeProto(proto.replica_layer(), layer_map); |
1415 replica_layer_->SetParent(this); | 1415 replica_layer_->SetParent(this); |
1416 } else { | 1416 } else { |
1417 replica_layer_ = nullptr; | 1417 replica_layer_ = nullptr; |
1418 } | 1418 } |
1419 } | 1419 } |
1420 | 1420 |
| 1421 bool Layer::ToLayerPropertiesProto(proto::LayerUpdate* layer_update) { |
| 1422 if (!needs_push_properties_ && num_dependents_need_push_properties_ == 0) |
| 1423 return false; |
| 1424 |
| 1425 // Always set properties metadata for serialized layers. |
| 1426 proto::LayerProperties* proto = layer_update->add_layers(); |
| 1427 proto->set_id(layer_id_); |
| 1428 proto->set_needs_push_properties(needs_push_properties_); |
| 1429 proto->set_num_dependents_need_push_properties( |
| 1430 num_dependents_need_push_properties_); |
| 1431 |
| 1432 if (needs_push_properties_) |
| 1433 LayerSpecificPropertiesToProto(proto); |
| 1434 |
| 1435 needs_push_properties_ = false; |
| 1436 |
| 1437 bool descendant_needs_push_properties = |
| 1438 num_dependents_need_push_properties_ > 0; |
| 1439 num_dependents_need_push_properties_ = 0; |
| 1440 |
| 1441 return descendant_needs_push_properties; |
| 1442 } |
| 1443 |
| 1444 void Layer::FromLayerPropertiesProto(const proto::LayerProperties& proto) { |
| 1445 DCHECK(proto.has_id()); |
| 1446 DCHECK_EQ(layer_id_, proto.id()); |
| 1447 DCHECK(proto.has_needs_push_properties()); |
| 1448 needs_push_properties_ = proto.needs_push_properties(); |
| 1449 DCHECK(proto.has_num_dependents_need_push_properties()); |
| 1450 num_dependents_need_push_properties_ = |
| 1451 proto.num_dependents_need_push_properties(); |
| 1452 |
| 1453 if (!needs_push_properties_) |
| 1454 return; |
| 1455 |
| 1456 FromLayerSpecificPropertiesProto(proto); |
| 1457 } |
| 1458 |
| 1459 void Layer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto) { |
| 1460 // TODO(nyquist): Write all required properties to |proto|. |
| 1461 // Create an empty proto::LayerProperties::base message. |
| 1462 proto->mutable_base(); |
| 1463 } |
| 1464 |
| 1465 void Layer::FromLayerSpecificPropertiesProto( |
| 1466 const proto::LayerProperties& proto) { |
| 1467 DCHECK(proto.has_base()); |
| 1468 // TODO(nyquist): Read all required properties from |proto|. |
| 1469 } |
| 1470 |
1421 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 1471 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
1422 return LayerImpl::Create(tree_impl, layer_id_, | 1472 return LayerImpl::Create(tree_impl, layer_id_, |
1423 new LayerImpl::SyncedScrollOffset); | 1473 new LayerImpl::SyncedScrollOffset); |
1424 } | 1474 } |
1425 | 1475 |
1426 bool Layer::DrawsContent() const { | 1476 bool Layer::DrawsContent() const { |
1427 return draws_content_; | 1477 return draws_content_; |
1428 } | 1478 } |
1429 | 1479 |
1430 bool Layer::HasDrawableContent() const { | 1480 bool Layer::HasDrawableContent() const { |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1776 this, layer_tree_host_->property_trees()->transform_tree); | 1826 this, layer_tree_host_->property_trees()->transform_tree); |
1777 } | 1827 } |
1778 | 1828 |
1779 gfx::Transform Layer::screen_space_transform() const { | 1829 gfx::Transform Layer::screen_space_transform() const { |
1780 DCHECK_NE(transform_tree_index_, -1); | 1830 DCHECK_NE(transform_tree_index_, -1); |
1781 return ScreenSpaceTransformFromPropertyTrees( | 1831 return ScreenSpaceTransformFromPropertyTrees( |
1782 this, layer_tree_host_->property_trees()->transform_tree); | 1832 this, layer_tree_host_->property_trees()->transform_tree); |
1783 } | 1833 } |
1784 | 1834 |
1785 } // namespace cc | 1835 } // namespace cc |
OLD | NEW |