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

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: Add static asserts for mutable properties enum. s/ASSERT/EXPECT/ in unit test. 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 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 draw_blend_mode_(SkXfermode::kSrcOver_Mode), 77 draw_blend_mode_(SkXfermode::kSrcOver_Mode),
77 num_descendants_that_draw_content_(0), 78 num_descendants_that_draw_content_(0),
78 transform_tree_index_(-1), 79 transform_tree_index_(-1),
79 effect_tree_index_(-1), 80 effect_tree_index_(-1),
80 clip_tree_index_(-1), 81 clip_tree_index_(-1),
81 draw_depth_(0.f), 82 draw_depth_(0.f),
82 needs_push_properties_(false), 83 needs_push_properties_(false),
83 num_dependents_need_push_properties_(0), 84 num_dependents_need_push_properties_(0),
84 sorting_context_id_(0), 85 sorting_context_id_(0),
85 current_draw_mode_(DRAW_MODE_NONE), 86 current_draw_mode_(DRAW_MODE_NONE),
87 element_id_(0),
88 mutable_properties_(kMutablePropertyNone),
86 num_layer_or_descendants_with_copy_request_(0), 89 num_layer_or_descendants_with_copy_request_(0),
87 frame_timing_requests_dirty_(false), 90 frame_timing_requests_dirty_(false),
88 visited_(false), 91 visited_(false),
89 layer_or_descendant_is_drawn_(false), 92 layer_or_descendant_is_drawn_(false),
90 layer_or_descendant_has_input_handler_(false), 93 layer_or_descendant_has_input_handler_(false),
91 sorted_for_recursion_(false) { 94 sorted_for_recursion_(false) {
92 DCHECK_GT(layer_id_, 0); 95 DCHECK_GT(layer_id_, 0);
93 DCHECK(layer_tree_impl_); 96 DCHECK(layer_tree_impl_);
94 layer_tree_impl_->RegisterLayer(this); 97 layer_tree_impl_->RegisterLayer(this);
95 98
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 is_container_for_fixed_position_layers_); 586 is_container_for_fixed_position_layers_);
584 layer->SetPositionConstraint(position_constraint_); 587 layer->SetPositionConstraint(position_constraint_);
585 layer->SetShouldFlattenTransform(should_flatten_transform_); 588 layer->SetShouldFlattenTransform(should_flatten_transform_);
586 layer->set_should_flatten_transform_from_property_tree( 589 layer->set_should_flatten_transform_from_property_tree(
587 should_flatten_transform_from_property_tree_); 590 should_flatten_transform_from_property_tree_);
588 layer->set_draw_blend_mode(draw_blend_mode_); 591 layer->set_draw_blend_mode(draw_blend_mode_);
589 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); 592 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_);
590 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); 593 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_);
591 594
592 layer->SetScrollClipLayer(scroll_clip_layer_id_); 595 layer->SetScrollClipLayer(scroll_clip_layer_id_);
596 layer->SetElementId(element_id_);
597 layer->SetMutableProperties(mutable_properties_);
593 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); 598 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_);
594 layer->set_user_scrollable_vertical(user_scrollable_vertical_); 599 layer->set_user_scrollable_vertical(user_scrollable_vertical_);
595 600
596 layer->SetScrollCompensationAdjustment(scroll_compensation_adjustment_); 601 layer->SetScrollCompensationAdjustment(scroll_compensation_adjustment_);
597 602
598 layer->PushScrollOffset(nullptr); 603 layer->PushScrollOffset(nullptr);
599 604
600 layer->Set3dSortingContextId(sorting_context_id_); 605 layer->Set3dSortingContextId(sorting_context_id_);
601 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); 606 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_);
602 607
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 1205
1201 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { 1206 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const {
1202 if (!layer_animation_controller_) 1207 if (!layer_animation_controller_)
1203 return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this); 1208 return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this);
1204 1209
1205 Animation* opacity_animation = 1210 Animation* opacity_animation =
1206 layer_animation_controller_->GetAnimation(Animation::OPACITY); 1211 layer_animation_controller_->GetAnimation(Animation::OPACITY);
1207 return opacity_animation && opacity_animation->is_impl_only(); 1212 return opacity_animation && opacity_animation->is_impl_only();
1208 } 1213 }
1209 1214
1215 void LayerImpl::SetElementId(uint64_t element_id) {
1216 if (element_id == element_id_)
1217 return;
1218
1219 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
1220 "LayerImpl::SetElementId", "id", element_id);
1221
1222 element_id_ = element_id;
1223 SetNeedsPushProperties();
1224 }
1225
1226 void LayerImpl::SetMutableProperties(uint32_t properties) {
1227 if (mutable_properties_ == properties)
1228 return;
1229
1230 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
1231 "LayerImpl::SetMutableProperties", "properties", properties);
1232
1233 mutable_properties_ = properties;
1234 SetNeedsPushProperties();
1235 }
1236
1210 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) { 1237 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) {
1211 if (blend_mode_ == blend_mode) 1238 if (blend_mode_ == blend_mode)
1212 return; 1239 return;
1213 1240
1214 blend_mode_ = blend_mode; 1241 blend_mode_ = blend_mode;
1215 NoteLayerPropertyChangedForSubtree(); 1242 NoteLayerPropertyChangedForSubtree();
1216 } 1243 }
1217 1244
1218 void LayerImpl::SetIsRootForIsolatedGroup(bool root) { 1245 void LayerImpl::SetIsRootForIsolatedGroup(bool root) {
1219 if (is_root_for_isolated_group_ == root) 1246 if (is_root_for_isolated_group_ == root)
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 MathUtil::AddToTracedValue("bounds", bounds_, state); 1641 MathUtil::AddToTracedValue("bounds", bounds_, state);
1615 1642
1616 state->SetDouble("opacity", opacity()); 1643 state->SetDouble("opacity", opacity());
1617 1644
1618 MathUtil::AddToTracedValue("position", position_, state); 1645 MathUtil::AddToTracedValue("position", position_, state);
1619 1646
1620 state->SetInteger("draws_content", DrawsContent()); 1647 state->SetInteger("draws_content", DrawsContent());
1621 state->SetInteger("gpu_memory_usage", 1648 state->SetInteger("gpu_memory_usage",
1622 base::saturated_cast<int>(GPUMemoryUsageInBytes())); 1649 base::saturated_cast<int>(GPUMemoryUsageInBytes()));
1623 1650
1651 if (mutable_properties_ != kMutablePropertyNone) {
1652 state->SetInteger("element_id", base::saturated_cast<int>(element_id_));
1653 state->SetInteger("mutable_properties", mutable_properties_);
1654 }
1655
1624 MathUtil::AddToTracedValue( 1656 MathUtil::AddToTracedValue(
1625 "scroll_offset", scroll_offset_ ? scroll_offset_->Current(IsActive()) 1657 "scroll_offset", scroll_offset_ ? scroll_offset_->Current(IsActive())
1626 : gfx::ScrollOffset(), 1658 : gfx::ScrollOffset(),
1627 state); 1659 state);
1628 1660
1629 MathUtil::AddToTracedValue("transform_origin", transform_origin_, state); 1661 MathUtil::AddToTracedValue("transform_origin", transform_origin_, state);
1630 1662
1631 bool clipped; 1663 bool clipped;
1632 gfx::QuadF layer_quad = 1664 gfx::QuadF layer_quad =
1633 MathUtil::MapQuad(screen_space_transform(), 1665 MathUtil::MapQuad(screen_space_transform(),
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 } 1830 }
1799 1831
1800 // TODO(enne): the transform needs to come from property trees instead of 1832 // TODO(enne): the transform needs to come from property trees instead of
1801 // draw properties. 1833 // draw properties.
1802 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1834 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1803 draw_properties().target_space_transform, default_scale); 1835 draw_properties().target_space_transform, default_scale);
1804 return std::max(transform_scales.x(), transform_scales.y()); 1836 return std::max(transform_scales.x(), transform_scales.y());
1805 } 1837 }
1806 1838
1807 } // namespace cc 1839 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698