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/layers/layer_client.h" | 22 #include "cc/layers/layer_client.h" |
22 #include "cc/layers/layer_impl.h" | 23 #include "cc/layers/layer_impl.h" |
23 #include "cc/layers/scrollbar_layer_interface.h" | 24 #include "cc/layers/scrollbar_layer_interface.h" |
24 #include "cc/output/copy_output_request.h" | 25 #include "cc/output/copy_output_request.h" |
25 #include "cc/output/copy_output_result.h" | 26 #include "cc/output/copy_output_result.h" |
26 #include "cc/trees/layer_tree_host.h" | 27 #include "cc/trees/layer_tree_host.h" |
27 #include "cc/trees/layer_tree_impl.h" | 28 #include "cc/trees/layer_tree_impl.h" |
28 #include "third_party/skia/include/core/SkImageFilter.h" | 29 #include "third_party/skia/include/core/SkImageFilter.h" |
29 #include "ui/gfx/geometry/rect_conversions.h" | 30 #include "ui/gfx/geometry/rect_conversions.h" |
30 #include "ui/gfx/geometry/vector2d_conversions.h" | 31 #include "ui/gfx/geometry/vector2d_conversions.h" |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 bool use_paint_properties = paint_properties_.source_frame_number == | 891 bool use_paint_properties = paint_properties_.source_frame_number == |
891 layer_tree_host_->source_frame_number(); | 892 layer_tree_host_->source_frame_number(); |
892 | 893 |
893 layer->SetTransformOrigin(transform_origin_); | 894 layer->SetTransformOrigin(transform_origin_); |
894 layer->SetBackgroundColor(background_color_); | 895 layer->SetBackgroundColor(background_color_); |
895 layer->SetBounds(use_paint_properties ? paint_properties_.bounds | 896 layer->SetBounds(use_paint_properties ? paint_properties_.bounds |
896 : bounds_); | 897 : bounds_); |
897 layer->SetContentBounds(content_bounds()); | 898 layer->SetContentBounds(content_bounds()); |
898 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); | 899 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); |
899 | 900 |
900 bool is_tracing; | 901 if (frame_viewer_instrumentation::IsTracingLayerTreeSnapshots()) |
901 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | |
902 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," TRACE_DISABLED_BY_DEFAULT( | |
903 "devtools.timeline.layers"), | |
904 &is_tracing); | |
905 if (is_tracing) | |
906 layer->SetDebugInfo(TakeDebugInfo()); | 902 layer->SetDebugInfo(TakeDebugInfo()); |
907 | 903 |
908 layer->SetDoubleSided(double_sided_); | 904 layer->SetDoubleSided(double_sided_); |
909 layer->SetDrawCheckerboardForMissingTiles( | 905 layer->SetDrawCheckerboardForMissingTiles( |
910 draw_checkerboard_for_missing_tiles_); | 906 draw_checkerboard_for_missing_tiles_); |
911 layer->SetDrawsContent(DrawsContent()); | 907 layer->SetDrawsContent(DrawsContent()); |
912 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | 908 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); |
913 layer->SetHasRenderSurface(has_render_surface_ || layer->HasCopyRequest()); | 909 layer->SetHasRenderSurface(has_render_surface_ || layer->HasCopyRequest()); |
914 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) | 910 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) |
915 layer->SetFilters(filters_); | 911 layer->SetFilters(filters_); |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 gfx::Transform xform; | 1309 gfx::Transform xform; |
1314 const bool owns_non_root_surface = parent() && render_surface(); | 1310 const bool owns_non_root_surface = parent() && render_surface(); |
1315 if (!owns_non_root_surface) { | 1311 if (!owns_non_root_surface) { |
1316 // If you're not the root, or you don't own a surface, you need to apply | 1312 // If you're not the root, or you don't own a surface, you need to apply |
1317 // your local offset. | 1313 // your local offset. |
1318 xform = node->data.to_target; | 1314 xform = node->data.to_target; |
1319 if (should_flatten_transform_from_property_tree_) | 1315 if (should_flatten_transform_from_property_tree_) |
1320 xform.FlattenTo2d(); | 1316 xform.FlattenTo2d(); |
1321 xform.Translate(offset_to_transform_parent().x(), | 1317 xform.Translate(offset_to_transform_parent().x(), |
1322 offset_to_transform_parent().y()); | 1318 offset_to_transform_parent().y()); |
| 1319 // A fixed-position layer does not necessarily have the same render target |
| 1320 // as its transform node. In particular, its transform node may be an |
| 1321 // ancestor of its render target's transform node. For example, given layer |
| 1322 // tree R->S->F, suppose F is fixed and S owns a render surface (e.g., say S |
| 1323 // has opacity 0.9 and both S and F draw content). Then F's transform node |
| 1324 // is the root node, so the target space transform from that node is defined |
| 1325 // with respect to the root render surface. But F will render to S's |
| 1326 // surface, so must apply a change of basis transform to the target space |
| 1327 // transform from its transform node. |
| 1328 if (position_constraint_.is_fixed_position()) { |
| 1329 gfx::Transform tree_target_to_render_target; |
| 1330 tree.ComputeTransform(node->data.content_target_id, |
| 1331 render_target()->transform_tree_index(), |
| 1332 &tree_target_to_render_target); |
| 1333 xform.ConcatTransform(tree_target_to_render_target); |
| 1334 } |
1323 } else { | 1335 } else { |
1324 // Surfaces need to apply their sublayer scale. | 1336 // Surfaces need to apply their sublayer scale. |
1325 xform.Scale(target_node->data.sublayer_scale.x(), | 1337 xform.Scale(target_node->data.sublayer_scale.x(), |
1326 target_node->data.sublayer_scale.y()); | 1338 target_node->data.sublayer_scale.y()); |
1327 } | 1339 } |
1328 xform.Scale(1.0 / contents_scale_x(), 1.0 / contents_scale_y()); | 1340 xform.Scale(1.0 / contents_scale_x(), 1.0 / contents_scale_y()); |
1329 return xform; | 1341 return xform; |
1330 } | 1342 } |
1331 | 1343 |
1332 float Layer::DrawOpacityFromPropertyTrees(const OpacityTree& tree) const { | 1344 float Layer::DrawOpacityFromPropertyTrees(const OpacityTree& tree) const { |
(...skipping 14 matching lines...) Expand all Loading... |
1347 return draw_opacity; | 1359 return draw_opacity; |
1348 } | 1360 } |
1349 | 1361 |
1350 void Layer::SetFrameTimingRequests( | 1362 void Layer::SetFrameTimingRequests( |
1351 const std::vector<FrameTimingRequest>& requests) { | 1363 const std::vector<FrameTimingRequest>& requests) { |
1352 frame_timing_requests_ = requests; | 1364 frame_timing_requests_ = requests; |
1353 frame_timing_requests_dirty_ = true; | 1365 frame_timing_requests_dirty_ = true; |
1354 SetNeedsCommit(); | 1366 SetNeedsCommit(); |
1355 } | 1367 } |
1356 | 1368 |
| 1369 void Layer::DidBeginTracing() { |
| 1370 // We'll be dumping layer trees as part of trace, so make sure |
| 1371 // PushPropertiesTo() propagates layer debug info to the impl |
| 1372 // side -- otherwise this won't happen for the the layers that |
| 1373 // remain unchanged since tracing started. |
| 1374 SetNeedsPushProperties(); |
| 1375 } |
| 1376 |
1357 } // namespace cc | 1377 } // namespace cc |
OLD | NEW |