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_factory.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) { | |
|
vmpstr
2015/10/21 22:34:14
Can this function be const?
nyquist
2015/10/23 00:12:30
Done.
| |
| 1351 proto->set_id(layer_id_); | |
| 1352 proto->set_type(proto::Base); | |
| 1353 | |
| 1354 if (parent_) { | |
|
vmpstr
2015/10/21 22:34:14
nit: braces optional.
nyquist
2015/10/23 00:12:30
Done.
| |
| 1355 proto->set_parent_id(parent_->id()); | |
| 1356 } | |
| 1357 proto->clear_children(); | |
|
vmpstr
2015/10/21 22:34:13
DCHECK that children size is 0 instead? Or are the
nyquist
2015/10/23 00:12:30
Done.
| |
| 1358 for (auto child : children_) { | |
|
vmpstr
2015/10/21 22:34:14
What's the type of child? if it's a raw pointer, t
nyquist
2015/10/23 00:12:30
Done.
| |
| 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 if (proto.has_id()) | |
|
vmpstr
2015/10/21 22:34:13
Are there cases where this isn't set? If not, then
nyquist
2015/10/23 00:12:30
Done.
| |
| 1371 layer_id_ = proto.id(); | |
| 1372 | |
| 1373 // Recursively remove all children. | |
| 1374 RemoveAllChildren(); | |
|
vmpstr
2015/10/21 22:34:13
I assume this is needed because we're using layer_
nyquist
2015/10/23 00:12:30
Yeah, the issue is if you remove all children from
| |
| 1375 for (int i = 0; i < proto.children_size(); ++i) { | |
| 1376 const proto::LayerNode& child_proto = proto.children(i); | |
| 1377 if (!child_proto.has_type()) { | |
|
vmpstr
2015/10/21 22:34:13
When would this happen?
nyquist
2015/10/23 00:12:30
DCHECK here as well now, so done.
| |
| 1378 continue; | |
| 1379 } | |
| 1380 scoped_refptr<Layer> child = | |
| 1381 LayerProtoFactory::FindOrAllocateAndConstruct(child_proto, layer_map); | |
| 1382 child->FromLayerNodeProto(child_proto, layer_map); | |
| 1383 AddChild(child); | |
| 1384 } | |
| 1385 | |
| 1386 if (mask_layer_) | |
| 1387 mask_layer_->RemoveFromParent(); | |
| 1388 if (proto.has_mask_layer()) { | |
| 1389 mask_layer_ = LayerProtoFactory::FindOrAllocateAndConstruct( | |
| 1390 proto.mask_layer(), layer_map); | |
| 1391 mask_layer_->FromLayerNodeProto(proto.mask_layer(), layer_map); | |
| 1392 mask_layer_->SetParent(this); | |
| 1393 } else { | |
| 1394 mask_layer_ = nullptr; | |
| 1395 } | |
| 1396 | |
| 1397 if (replica_layer_) | |
| 1398 replica_layer_->RemoveFromParent(); | |
| 1399 if (proto.has_replica_layer()) { | |
| 1400 replica_layer_ = LayerProtoFactory::FindOrAllocateAndConstruct( | |
| 1401 proto.replica_layer(), layer_map); | |
| 1402 replica_layer_->FromLayerNodeProto(proto.replica_layer(), layer_map); | |
| 1403 replica_layer_->SetParent(this); | |
| 1404 } else { | |
| 1405 replica_layer_ = nullptr; | |
| 1406 } | |
| 1407 } | |
| 1408 | |
| 1348 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 1409 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| 1349 return LayerImpl::Create(tree_impl, layer_id_, | 1410 return LayerImpl::Create(tree_impl, layer_id_, |
| 1350 new LayerImpl::SyncedScrollOffset); | 1411 new LayerImpl::SyncedScrollOffset); |
| 1351 } | 1412 } |
| 1352 | 1413 |
| 1353 bool Layer::DrawsContent() const { | 1414 bool Layer::DrawsContent() const { |
| 1354 return draws_content_; | 1415 return draws_content_; |
| 1355 } | 1416 } |
| 1356 | 1417 |
| 1357 bool Layer::HasDrawableContent() const { | 1418 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); | 1764 this, layer_tree_host_->property_trees()->transform_tree); |
| 1704 } | 1765 } |
| 1705 | 1766 |
| 1706 gfx::Transform Layer::screen_space_transform() const { | 1767 gfx::Transform Layer::screen_space_transform() const { |
| 1707 DCHECK_NE(transform_tree_index_, -1); | 1768 DCHECK_NE(transform_tree_index_, -1); |
| 1708 return ScreenSpaceTransformFromPropertyTrees( | 1769 return ScreenSpaceTransformFromPropertyTrees( |
| 1709 this, layer_tree_host_->property_trees()->transform_tree); | 1770 this, layer_tree_host_->property_trees()->transform_tree); |
| 1710 } | 1771 } |
| 1711 | 1772 |
| 1712 } // namespace cc | 1773 } // namespace cc |
| OLD | NEW |