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" |
| (...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 num_dependents_need_push_properties_ = 0; | |
|
vmpstr
2015/11/18 04:05:25
nit: you can just save a bool to return before cle
nyquist
2015/11/18 07:15:59
Done.
| |
| 1437 | |
| 1438 return proto->num_dependents_need_push_properties() > 0; | |
| 1439 } | |
| 1440 | |
| 1441 void Layer::FromLayerPropertiesProto(const proto::LayerProperties& proto) { | |
| 1442 DCHECK(proto.has_id()); | |
| 1443 DCHECK_EQ(layer_id_, proto.id()); | |
| 1444 DCHECK(proto.has_needs_push_properties()); | |
| 1445 needs_push_properties_ = proto.needs_push_properties(); | |
| 1446 DCHECK(proto.has_num_dependents_need_push_properties()); | |
| 1447 num_dependents_need_push_properties_ = | |
| 1448 proto.num_dependents_need_push_properties(); | |
| 1449 | |
| 1450 if (!needs_push_properties_) | |
| 1451 return; | |
| 1452 | |
| 1453 FromLayerSpecificPropertiesProto(proto); | |
| 1454 } | |
| 1455 | |
| 1456 void Layer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto) { | |
| 1457 // TODO(nyquist): Write all required properties to |proto|. | |
| 1458 // Create an empty proto::LayerProperties::base message. | |
| 1459 proto->mutable_base(); | |
| 1460 } | |
| 1461 | |
| 1462 void Layer::FromLayerSpecificPropertiesProto( | |
| 1463 const proto::LayerProperties& proto) { | |
| 1464 DCHECK(proto.has_base()); | |
| 1465 // TODO(nyquist): Read all required properties from |proto|. | |
| 1466 } | |
| 1467 | |
| 1421 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 1468 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| 1422 return LayerImpl::Create(tree_impl, layer_id_, | 1469 return LayerImpl::Create(tree_impl, layer_id_, |
| 1423 new LayerImpl::SyncedScrollOffset); | 1470 new LayerImpl::SyncedScrollOffset); |
| 1424 } | 1471 } |
| 1425 | 1472 |
| 1426 bool Layer::DrawsContent() const { | 1473 bool Layer::DrawsContent() const { |
| 1427 return draws_content_; | 1474 return draws_content_; |
| 1428 } | 1475 } |
| 1429 | 1476 |
| 1430 bool Layer::HasDrawableContent() const { | 1477 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); | 1823 this, layer_tree_host_->property_trees()->transform_tree); |
| 1777 } | 1824 } |
| 1778 | 1825 |
| 1779 gfx::Transform Layer::screen_space_transform() const { | 1826 gfx::Transform Layer::screen_space_transform() const { |
| 1780 DCHECK_NE(transform_tree_index_, -1); | 1827 DCHECK_NE(transform_tree_index_, -1); |
| 1781 return ScreenSpaceTransformFromPropertyTrees( | 1828 return ScreenSpaceTransformFromPropertyTrees( |
| 1782 this, layer_tree_host_->property_trees()->transform_tree); | 1829 this, layer_tree_host_->property_trees()->transform_tree); |
| 1783 } | 1830 } |
| 1784 | 1831 |
| 1785 } // namespace cc | 1832 } // namespace cc |
| OLD | NEW |