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

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

Issue 1405993008: compositor-worker: plumb element id and mutable properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/numerics/safe_conversions.h" 8 #include "base/numerics/safe_conversions.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
11 #include "base/trace_event/trace_event_argument.h" 11 #include "base/trace_event/trace_event_argument.h"
12 #include "cc/animation/animation_registrar.h" 12 #include "cc/animation/animation_registrar.h"
13 #include "cc/animation/mutable_properties.h"
13 #include "cc/base/math_util.h" 14 #include "cc/base/math_util.h"
14 #include "cc/base/simple_enclosed_region.h" 15 #include "cc/base/simple_enclosed_region.h"
15 #include "cc/debug/debug_colors.h" 16 #include "cc/debug/debug_colors.h"
16 #include "cc/debug/layer_tree_debug_state.h" 17 #include "cc/debug/layer_tree_debug_state.h"
17 #include "cc/debug/micro_benchmark_impl.h" 18 #include "cc/debug/micro_benchmark_impl.h"
18 #include "cc/debug/traced_value.h" 19 #include "cc/debug/traced_value.h"
19 #include "cc/input/scroll_state.h" 20 #include "cc/input/scroll_state.h"
20 #include "cc/layers/layer.h" 21 #include "cc/layers/layer.h"
21 #include "cc/layers/layer_utils.h" 22 #include "cc/layers/layer_utils.h"
22 #include "cc/output/copy_output_request.h" 23 #include "cc/output/copy_output_request.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 draw_blend_mode_(SkXfermode::kSrcOver_Mode), 78 draw_blend_mode_(SkXfermode::kSrcOver_Mode),
78 num_descendants_that_draw_content_(0), 79 num_descendants_that_draw_content_(0),
79 transform_tree_index_(-1), 80 transform_tree_index_(-1),
80 effect_tree_index_(-1), 81 effect_tree_index_(-1),
81 clip_tree_index_(-1), 82 clip_tree_index_(-1),
82 draw_depth_(0.f), 83 draw_depth_(0.f),
83 needs_push_properties_(false), 84 needs_push_properties_(false),
84 num_dependents_need_push_properties_(0), 85 num_dependents_need_push_properties_(0),
85 sorting_context_id_(0), 86 sorting_context_id_(0),
86 current_draw_mode_(DRAW_MODE_NONE), 87 current_draw_mode_(DRAW_MODE_NONE),
88 element_id_(0),
89 mutable_properties_(kMutablePropertyNone),
87 num_layer_or_descendants_with_copy_request_(0), 90 num_layer_or_descendants_with_copy_request_(0),
88 frame_timing_requests_dirty_(false), 91 frame_timing_requests_dirty_(false),
89 visited_(false), 92 visited_(false),
90 layer_or_descendant_is_drawn_(false), 93 layer_or_descendant_is_drawn_(false),
91 layer_or_descendant_has_input_handler_(false), 94 layer_or_descendant_has_input_handler_(false),
92 sorted_for_recursion_(false) { 95 sorted_for_recursion_(false) {
93 DCHECK_GT(layer_id_, 0); 96 DCHECK_GT(layer_id_, 0);
94 DCHECK(layer_tree_impl_); 97 DCHECK(layer_tree_impl_);
95 layer_tree_impl_->RegisterLayer(this); 98 layer_tree_impl_->RegisterLayer(this);
96 99
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 is_container_for_fixed_position_layers_); 590 is_container_for_fixed_position_layers_);
588 layer->SetPositionConstraint(position_constraint_); 591 layer->SetPositionConstraint(position_constraint_);
589 layer->SetShouldFlattenTransform(should_flatten_transform_); 592 layer->SetShouldFlattenTransform(should_flatten_transform_);
590 layer->set_should_flatten_transform_from_property_tree( 593 layer->set_should_flatten_transform_from_property_tree(
591 should_flatten_transform_from_property_tree_); 594 should_flatten_transform_from_property_tree_);
592 layer->set_draw_blend_mode(draw_blend_mode_); 595 layer->set_draw_blend_mode(draw_blend_mode_);
593 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); 596 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_);
594 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); 597 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_);
595 598
596 layer->SetScrollClipLayer(scroll_clip_layer_id_); 599 layer->SetScrollClipLayer(scroll_clip_layer_id_);
600 layer->SetElementId(element_id_);
601 layer->SetMutableProperties(mutable_properties_);
597 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); 602 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_);
598 layer->set_user_scrollable_vertical(user_scrollable_vertical_); 603 layer->set_user_scrollable_vertical(user_scrollable_vertical_);
599 604
600 layer->SetScrollCompensationAdjustment(scroll_compensation_adjustment_); 605 layer->SetScrollCompensationAdjustment(scroll_compensation_adjustment_);
601 606
602 layer->PushScrollOffset(nullptr); 607 layer->PushScrollOffset(nullptr);
603 608
604 layer->Set3dSortingContextId(sorting_context_id_); 609 layer->Set3dSortingContextId(sorting_context_id_);
605 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); 610 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_);
606 611
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 1212
1208 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { 1213 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const {
1209 if (!layer_animation_controller_) 1214 if (!layer_animation_controller_)
1210 return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this); 1215 return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this);
1211 1216
1212 Animation* opacity_animation = 1217 Animation* opacity_animation =
1213 layer_animation_controller_->GetAnimation(Animation::OPACITY); 1218 layer_animation_controller_->GetAnimation(Animation::OPACITY);
1214 return opacity_animation && opacity_animation->is_impl_only(); 1219 return opacity_animation && opacity_animation->is_impl_only();
1215 } 1220 }
1216 1221
1222 void LayerImpl::SetElementId(uint64_t element_id) {
1223 if (element_id == element_id_)
1224 return;
1225
1226 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
1227 "LayerImpl::SetElementId", "id", element_id);
1228
1229 element_id_ = element_id;
1230 SetNeedsPushProperties();
1231 }
1232
1233 void LayerImpl::SetMutableProperties(uint32_t properties) {
1234 if (mutable_properties_ == properties)
1235 return;
1236
1237 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
1238 "LayerImpl::SetMutableProperties", "properties", properties);
1239
1240 mutable_properties_ = properties;
1241 SetNeedsPushProperties();
1242 }
1243
1217 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) { 1244 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) {
1218 if (blend_mode_ == blend_mode) 1245 if (blend_mode_ == blend_mode)
1219 return; 1246 return;
1220 1247
1221 blend_mode_ = blend_mode; 1248 blend_mode_ = blend_mode;
1222 NoteLayerPropertyChangedForSubtree(); 1249 NoteLayerPropertyChangedForSubtree();
1223 } 1250 }
1224 1251
1225 void LayerImpl::SetIsRootForIsolatedGroup(bool root) { 1252 void LayerImpl::SetIsRootForIsolatedGroup(bool root) {
1226 if (is_root_for_isolated_group_ == root) 1253 if (is_root_for_isolated_group_ == root)
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 MathUtil::AddToTracedValue("bounds", bounds_, state); 1648 MathUtil::AddToTracedValue("bounds", bounds_, state);
1622 1649
1623 state->SetDouble("opacity", opacity()); 1650 state->SetDouble("opacity", opacity());
1624 1651
1625 MathUtil::AddToTracedValue("position", position_, state); 1652 MathUtil::AddToTracedValue("position", position_, state);
1626 1653
1627 state->SetInteger("draws_content", DrawsContent()); 1654 state->SetInteger("draws_content", DrawsContent());
1628 state->SetInteger("gpu_memory_usage", 1655 state->SetInteger("gpu_memory_usage",
1629 base::saturated_cast<int>(GPUMemoryUsageInBytes())); 1656 base::saturated_cast<int>(GPUMemoryUsageInBytes()));
1630 1657
1658 if (mutable_properties_ != kMutablePropertyNone) {
1659 state->SetInteger("element_id", base::saturated_cast<int>(element_id_));
1660 state->SetInteger("mutable_properties", mutable_properties_);
1661 }
1662
1631 MathUtil::AddToTracedValue( 1663 MathUtil::AddToTracedValue(
1632 "scroll_offset", scroll_offset_ ? scroll_offset_->Current(IsActive()) 1664 "scroll_offset", scroll_offset_ ? scroll_offset_->Current(IsActive())
1633 : gfx::ScrollOffset(), 1665 : gfx::ScrollOffset(),
1634 state); 1666 state);
1635 1667
1636 MathUtil::AddToTracedValue("transform_origin", transform_origin_, state); 1668 MathUtil::AddToTracedValue("transform_origin", transform_origin_, state);
1637 1669
1638 bool clipped; 1670 bool clipped;
1639 gfx::QuadF layer_quad = 1671 gfx::QuadF layer_quad =
1640 MathUtil::MapQuad(screen_space_transform(), 1672 MathUtil::MapQuad(screen_space_transform(),
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 } 1837 }
1806 1838
1807 // TODO(enne): the transform needs to come from property trees instead of 1839 // TODO(enne): the transform needs to come from property trees instead of
1808 // draw properties. 1840 // draw properties.
1809 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1841 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1810 draw_properties().target_space_transform, default_scale); 1842 draw_properties().target_space_transform, default_scale);
1811 return std::max(transform_scales.x(), transform_scales.y()); 1843 return std::max(transform_scales.x(), transform_scales.y());
1812 } 1844 }
1813 1845
1814 } // namespace cc 1846 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698