Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: cc/layers/layer.cc

Issue 1423523002: Add support for (de)serializing cc::Layer properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@serialize-layer-hierarchy
Patch Set: Addressed comments from dtrainor@ Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 void Layer::ToLayerPropertiesProto(proto::LayerUpdate* layer_update) {
1422 if (!needs_push_properties_ && num_dependents_need_push_properties_ == 0)
1423 return;
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_)
vmpstr 2015/11/17 21:05:44 Is this to reduce the size of the proto? That is,
nyquist 2015/11/18 00:24:34 Yes. I do think that we could optimize this in the
1433 LayerSpecificPropertiesToProto(proto);
1434
1435 if (num_dependents_need_push_properties_ > 0) {
1436 for (const auto& child : children_) {
1437 child->ToLayerPropertiesProto(layer_update);
1438 }
1439 if (mask_layer_)
1440 mask_layer_->ToLayerPropertiesProto(layer_update);
1441 if (replica_layer_)
1442 replica_layer_->ToLayerPropertiesProto(layer_update);
1443 }
1444
1445 needs_push_properties_ = false;
1446 num_dependents_need_push_properties_ = 0;
1447 }
1448
1449 void Layer::FromLayerPropertiesProto(const proto::LayerProperties& proto) {
vmpstr 2015/11/17 21:05:44 It's a little bit confusing that ToLayerProperties
nyquist 2015/11/18 00:24:34 Yeah, that's in LayerProtoConverter. I've made the
1450 DCHECK(proto.has_id());
1451 DCHECK_EQ(layer_id_, proto.id());
1452 DCHECK(proto.has_needs_push_properties());
1453 needs_push_properties_ = proto.needs_push_properties();
1454 DCHECK(proto.has_num_dependents_need_push_properties());
1455 num_dependents_need_push_properties_ =
1456 proto.num_dependents_need_push_properties();
1457
1458 if (!needs_push_properties_)
1459 return;
1460
1461 FromLayerSpecificPropertiesProto(proto);
1462 }
1463
1464 void Layer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto) {
1465 // TODO(nyquist): Write all required properties to |proto|.
1466 // Create an empty proto::LayerProperties::base message.
1467 proto->mutable_base();
1468 }
1469
1470 void Layer::FromLayerSpecificPropertiesProto(
1471 const proto::LayerProperties& proto) {
1472 DCHECK(proto.has_base());
1473 // TODO(nyquist): Read all required properties from |proto|.
1474 }
1475
1421 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { 1476 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
1422 return LayerImpl::Create(tree_impl, layer_id_, 1477 return LayerImpl::Create(tree_impl, layer_id_,
1423 new LayerImpl::SyncedScrollOffset); 1478 new LayerImpl::SyncedScrollOffset);
1424 } 1479 }
1425 1480
1426 bool Layer::DrawsContent() const { 1481 bool Layer::DrawsContent() const {
1427 return draws_content_; 1482 return draws_content_;
1428 } 1483 }
1429 1484
1430 bool Layer::HasDrawableContent() const { 1485 bool Layer::HasDrawableContent() const {
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 this, layer_tree_host_->property_trees()->transform_tree); 1831 this, layer_tree_host_->property_trees()->transform_tree);
1777 } 1832 }
1778 1833
1779 gfx::Transform Layer::screen_space_transform() const { 1834 gfx::Transform Layer::screen_space_transform() const {
1780 DCHECK_NE(transform_tree_index_, -1); 1835 DCHECK_NE(transform_tree_index_, -1);
1781 return ScreenSpaceTransformFromPropertyTrees( 1836 return ScreenSpaceTransformFromPropertyTrees(
1782 this, layer_tree_host_->property_trees()->transform_tree); 1837 this, layer_tree_host_->property_trees()->transform_tree);
1783 } 1838 }
1784 1839
1785 } // namespace cc 1840 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698