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

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: rebase 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 draw_blend_mode_(SkXfermode::kSrcOver_Mode), 79 draw_blend_mode_(SkXfermode::kSrcOver_Mode),
79 num_descendants_that_draw_content_(0), 80 num_descendants_that_draw_content_(0),
80 transform_tree_index_(-1), 81 transform_tree_index_(-1),
81 effect_tree_index_(-1), 82 effect_tree_index_(-1),
82 clip_tree_index_(-1), 83 clip_tree_index_(-1),
83 draw_depth_(0.f), 84 draw_depth_(0.f),
84 needs_push_properties_(false), 85 needs_push_properties_(false),
85 num_dependents_need_push_properties_(0), 86 num_dependents_need_push_properties_(0),
86 sorting_context_id_(0), 87 sorting_context_id_(0),
87 current_draw_mode_(DRAW_MODE_NONE), 88 current_draw_mode_(DRAW_MODE_NONE),
89 element_id_(0),
90 mutable_properties_(kMutablePropertyNone),
88 num_layer_or_descendants_with_copy_request_(0), 91 num_layer_or_descendants_with_copy_request_(0),
89 frame_timing_requests_dirty_(false), 92 frame_timing_requests_dirty_(false),
90 visited_(false), 93 visited_(false),
91 layer_or_descendant_is_drawn_(false), 94 layer_or_descendant_is_drawn_(false),
92 layer_or_descendant_has_input_handler_(false), 95 layer_or_descendant_has_input_handler_(false),
93 sorted_for_recursion_(false) { 96 sorted_for_recursion_(false) {
94 DCHECK_GT(layer_id_, 0); 97 DCHECK_GT(layer_id_, 0);
95 DCHECK(layer_tree_impl_); 98 DCHECK(layer_tree_impl_);
96 layer_tree_impl_->RegisterLayer(this); 99 layer_tree_impl_->RegisterLayer(this);
97 100
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 is_container_for_fixed_position_layers_); 592 is_container_for_fixed_position_layers_);
590 layer->SetPositionConstraint(position_constraint_); 593 layer->SetPositionConstraint(position_constraint_);
591 layer->SetShouldFlattenTransform(should_flatten_transform_); 594 layer->SetShouldFlattenTransform(should_flatten_transform_);
592 layer->set_should_flatten_transform_from_property_tree( 595 layer->set_should_flatten_transform_from_property_tree(
593 should_flatten_transform_from_property_tree_); 596 should_flatten_transform_from_property_tree_);
594 layer->set_draw_blend_mode(draw_blend_mode_); 597 layer->set_draw_blend_mode(draw_blend_mode_);
595 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); 598 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_);
596 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); 599 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_);
597 600
598 layer->SetScrollClipLayer(scroll_clip_layer_id_); 601 layer->SetScrollClipLayer(scroll_clip_layer_id_);
602 layer->SetElementId(element_id_);
603 layer->SetMutableProperties(mutable_properties_);
599 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); 604 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_);
600 layer->set_user_scrollable_vertical(user_scrollable_vertical_); 605 layer->set_user_scrollable_vertical(user_scrollable_vertical_);
601 606
602 layer->SetScrollCompensationAdjustment(scroll_compensation_adjustment_); 607 layer->SetScrollCompensationAdjustment(scroll_compensation_adjustment_);
603 608
604 layer->PushScrollOffset(nullptr); 609 layer->PushScrollOffset(nullptr);
605 610
606 layer->Set3dSortingContextId(sorting_context_id_); 611 layer->Set3dSortingContextId(sorting_context_id_);
607 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); 612 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_);
608 613
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 1214
1210 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { 1215 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const {
1211 if (!layer_animation_controller_) 1216 if (!layer_animation_controller_)
1212 return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this); 1217 return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this);
1213 1218
1214 Animation* opacity_animation = 1219 Animation* opacity_animation =
1215 layer_animation_controller_->GetAnimation(Animation::OPACITY); 1220 layer_animation_controller_->GetAnimation(Animation::OPACITY);
1216 return opacity_animation && opacity_animation->is_impl_only(); 1221 return opacity_animation && opacity_animation->is_impl_only();
1217 } 1222 }
1218 1223
1224 void LayerImpl::SetElementId(uint64_t element_id) {
1225 if (element_id == element_id_)
1226 return;
1227
1228 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
1229 "LayerImpl::SetElementId", "id", element_id);
1230
1231 element_id_ = element_id;
1232 SetNeedsPushProperties();
1233 }
1234
1235 void LayerImpl::SetMutableProperties(uint32_t properties) {
1236 if (mutable_properties_ == properties)
1237 return;
1238
1239 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
1240 "LayerImpl::SetMutableProperties", "properties", properties);
1241
1242 mutable_properties_ = properties;
1243 SetNeedsPushProperties();
1244 }
1245
1219 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) { 1246 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) {
1220 if (blend_mode_ == blend_mode) 1247 if (blend_mode_ == blend_mode)
1221 return; 1248 return;
1222 1249
1223 blend_mode_ = blend_mode; 1250 blend_mode_ = blend_mode;
1224 NoteLayerPropertyChangedForSubtree(); 1251 NoteLayerPropertyChangedForSubtree();
1225 } 1252 }
1226 1253
1227 void LayerImpl::SetIsRootForIsolatedGroup(bool root) { 1254 void LayerImpl::SetIsRootForIsolatedGroup(bool root) {
1228 if (is_root_for_isolated_group_ == root) 1255 if (is_root_for_isolated_group_ == root)
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 MathUtil::AddToTracedValue("bounds", bounds_, state); 1650 MathUtil::AddToTracedValue("bounds", bounds_, state);
1624 1651
1625 state->SetDouble("opacity", opacity()); 1652 state->SetDouble("opacity", opacity());
1626 1653
1627 MathUtil::AddToTracedValue("position", position_, state); 1654 MathUtil::AddToTracedValue("position", position_, state);
1628 1655
1629 state->SetInteger("draws_content", DrawsContent()); 1656 state->SetInteger("draws_content", DrawsContent());
1630 state->SetInteger("gpu_memory_usage", 1657 state->SetInteger("gpu_memory_usage",
1631 base::saturated_cast<int>(GPUMemoryUsageInBytes())); 1658 base::saturated_cast<int>(GPUMemoryUsageInBytes()));
1632 1659
1660 if (mutable_properties_ != kMutablePropertyNone) {
1661 state->SetInteger("element_id", base::saturated_cast<int>(element_id_));
1662 state->SetInteger("mutable_properties", mutable_properties_);
1663 }
1664
1633 MathUtil::AddToTracedValue( 1665 MathUtil::AddToTracedValue(
1634 "scroll_offset", scroll_offset_ ? scroll_offset_->Current(IsActive()) 1666 "scroll_offset", scroll_offset_ ? scroll_offset_->Current(IsActive())
1635 : gfx::ScrollOffset(), 1667 : gfx::ScrollOffset(),
1636 state); 1668 state);
1637 1669
1638 MathUtil::AddToTracedValue("transform_origin", transform_origin_, state); 1670 MathUtil::AddToTracedValue("transform_origin", transform_origin_, state);
1639 1671
1640 bool clipped; 1672 bool clipped;
1641 gfx::QuadF layer_quad = 1673 gfx::QuadF layer_quad =
1642 MathUtil::MapQuad(ScreenSpaceTransform(), 1674 MathUtil::MapQuad(ScreenSpaceTransform(),
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1833 .layer_transforms_should_scale_layer_contents) { 1865 .layer_transforms_should_scale_layer_contents) {
1834 return default_scale; 1866 return default_scale;
1835 } 1867 }
1836 1868
1837 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1869 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1838 DrawTransform(), default_scale); 1870 DrawTransform(), default_scale);
1839 return std::max(transform_scales.x(), transform_scales.y()); 1871 return std::max(transform_scales.x(), transform_scales.y());
1840 } 1872 }
1841 1873
1842 } // namespace cc 1874 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698