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

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

Issue 1626513003: Add ScrollTree builder and unit test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename other_criteria, remove is_root in GetScrollParent and fixed a previous mistake in unit test. Created 4 years, 11 months 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 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 layer_id_(g_next_layer_id.GetNext() + 1), 57 layer_id_(g_next_layer_id.GetNext() + 1),
58 ignore_set_needs_commit_(false), 58 ignore_set_needs_commit_(false),
59 sorting_context_id_(0), 59 sorting_context_id_(0),
60 parent_(nullptr), 60 parent_(nullptr),
61 layer_tree_host_(nullptr), 61 layer_tree_host_(nullptr),
62 scroll_clip_layer_id_(INVALID_ID), 62 scroll_clip_layer_id_(INVALID_ID),
63 num_descendants_that_draw_content_(0), 63 num_descendants_that_draw_content_(0),
64 transform_tree_index_(-1), 64 transform_tree_index_(-1),
65 effect_tree_index_(-1), 65 effect_tree_index_(-1),
66 clip_tree_index_(-1), 66 clip_tree_index_(-1),
67 scroll_tree_index_(-1),
67 property_tree_sequence_number_(-1), 68 property_tree_sequence_number_(-1),
68 element_id_(0), 69 element_id_(0),
69 mutable_properties_(kMutablePropertyNone), 70 mutable_properties_(kMutablePropertyNone),
70 main_thread_scrolling_reasons_( 71 main_thread_scrolling_reasons_(
71 MainThreadScrollingReason::kNotScrollingOnMain), 72 MainThreadScrollingReason::kNotScrollingOnMain),
72 should_flatten_transform_from_property_tree_(false), 73 should_flatten_transform_from_property_tree_(false),
73 have_wheel_event_handlers_(false), 74 have_wheel_event_handlers_(false),
74 have_scroll_event_handlers_(false), 75 have_scroll_event_handlers_(false),
75 user_scrollable_horizontal_(true), 76 user_scrollable_horizontal_(true),
76 user_scrollable_vertical_(true), 77 user_scrollable_vertical_(true),
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1079
1079 int Layer::effect_tree_index() const { 1080 int Layer::effect_tree_index() const {
1080 if (!layer_tree_host_ || 1081 if (!layer_tree_host_ ||
1081 layer_tree_host_->property_trees()->sequence_number != 1082 layer_tree_host_->property_trees()->sequence_number !=
1082 property_tree_sequence_number_) { 1083 property_tree_sequence_number_) {
1083 return -1; 1084 return -1;
1084 } 1085 }
1085 return effect_tree_index_; 1086 return effect_tree_index_;
1086 } 1087 }
1087 1088
1089 void Layer::SetScrollTreeIndex(int index) {
1090 DCHECK(IsPropertyChangeAllowed());
1091 if (scroll_tree_index_ == index)
1092 return;
1093 scroll_tree_index_ = index;
1094 SetNeedsPushProperties();
1095 }
1096
1097 int Layer::scroll_tree_index() const {
1098 if (!layer_tree_host_ ||
1099 layer_tree_host_->property_trees()->sequence_number !=
1100 property_tree_sequence_number_) {
1101 return -1;
1102 }
1103 return scroll_tree_index_;
1104 }
1105
1088 void Layer::InvalidatePropertyTreesIndices() { 1106 void Layer::InvalidatePropertyTreesIndices() {
1089 int invalid_property_tree_index = -1; 1107 int invalid_property_tree_index = -1;
1090 SetTransformTreeIndex(invalid_property_tree_index); 1108 SetTransformTreeIndex(invalid_property_tree_index);
1091 SetClipTreeIndex(invalid_property_tree_index); 1109 SetClipTreeIndex(invalid_property_tree_index);
1092 SetEffectTreeIndex(invalid_property_tree_index); 1110 SetEffectTreeIndex(invalid_property_tree_index);
1093 } 1111 }
1094 1112
1095 void Layer::SetShouldFlattenTransform(bool should_flatten) { 1113 void Layer::SetShouldFlattenTransform(bool should_flatten) {
1096 DCHECK(IsPropertyChangeAllowed()); 1114 DCHECK(IsPropertyChangeAllowed());
1097 if (should_flatten_transform_ == should_flatten) 1115 if (should_flatten_transform_ == should_flatten)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 #if defined(NDEBUG) 1209 #if defined(NDEBUG)
1192 if (frame_viewer_instrumentation::IsTracingLayerTreeSnapshots()) 1210 if (frame_viewer_instrumentation::IsTracingLayerTreeSnapshots())
1193 layer->SetDebugInfo(TakeDebugInfo()); 1211 layer->SetDebugInfo(TakeDebugInfo());
1194 #else 1212 #else
1195 layer->SetDebugInfo(TakeDebugInfo()); 1213 layer->SetDebugInfo(TakeDebugInfo());
1196 #endif 1214 #endif
1197 1215
1198 layer->SetTransformTreeIndex(transform_tree_index()); 1216 layer->SetTransformTreeIndex(transform_tree_index());
1199 layer->SetEffectTreeIndex(effect_tree_index()); 1217 layer->SetEffectTreeIndex(effect_tree_index());
1200 layer->SetClipTreeIndex(clip_tree_index()); 1218 layer->SetClipTreeIndex(clip_tree_index());
1219 layer->SetScrollTreeIndex(scroll_tree_index());
1201 layer->set_offset_to_transform_parent(offset_to_transform_parent_); 1220 layer->set_offset_to_transform_parent(offset_to_transform_parent_);
1202 layer->SetDoubleSided(double_sided_); 1221 layer->SetDoubleSided(double_sided_);
1203 layer->SetDrawsContent(DrawsContent()); 1222 layer->SetDrawsContent(DrawsContent());
1204 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); 1223 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_);
1205 layer->SetHasRenderSurface(has_render_surface_); 1224 layer->SetHasRenderSurface(has_render_surface_);
1206 layer->SetForceRenderSurface(force_render_surface_); 1225 layer->SetForceRenderSurface(force_render_surface_);
1207 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) 1226 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating())
1208 layer->SetFilters(filters_); 1227 layer->SetFilters(filters_);
1209 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); 1228 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly()));
1210 layer->SetBackgroundFilters(background_filters()); 1229 layer->SetBackgroundFilters(background_filters());
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 Point3FToProto(transform_origin_, base->mutable_transform_origin()); 1481 Point3FToProto(transform_origin_, base->mutable_transform_origin());
1463 base->set_background_color(background_color_); 1482 base->set_background_color(background_color_);
1464 SizeToProto(use_paint_properties ? paint_properties_.bounds : bounds_, 1483 SizeToProto(use_paint_properties ? paint_properties_.bounds : bounds_,
1465 base->mutable_bounds()); 1484 base->mutable_bounds());
1466 1485
1467 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. 1486 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372.
1468 1487
1469 base->set_transform_free_index(transform_tree_index_); 1488 base->set_transform_free_index(transform_tree_index_);
1470 base->set_effect_tree_index(effect_tree_index_); 1489 base->set_effect_tree_index(effect_tree_index_);
1471 base->set_clip_tree_index(clip_tree_index_); 1490 base->set_clip_tree_index(clip_tree_index_);
1491 base->set_scroll_tree_index(scroll_tree_index_);
1472 Vector2dFToProto(offset_to_transform_parent_, 1492 Vector2dFToProto(offset_to_transform_parent_,
1473 base->mutable_offset_to_transform_parent()); 1493 base->mutable_offset_to_transform_parent());
1474 base->set_double_sided(double_sided_); 1494 base->set_double_sided(double_sided_);
1475 base->set_draws_content(draws_content_); 1495 base->set_draws_content(draws_content_);
1476 base->set_hide_layer_and_subtree(hide_layer_and_subtree_); 1496 base->set_hide_layer_and_subtree(hide_layer_and_subtree_);
1477 base->set_has_render_surface(has_render_surface_); 1497 base->set_has_render_surface(has_render_surface_);
1478 1498
1479 // TODO(nyquist): Add support for serializing FilterOperations for 1499 // TODO(nyquist): Add support for serializing FilterOperations for
1480 // |filters_| and |background_filters_|. See crbug.com/541321. 1500 // |filters_| and |background_filters_|. See crbug.com/541321.
1481 1501
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 DCHECK(layer_tree_host_); 1572 DCHECK(layer_tree_host_);
1553 const proto::BaseLayerProperties& base = proto.base(); 1573 const proto::BaseLayerProperties& base = proto.base();
1554 1574
1555 transform_origin_ = ProtoToPoint3F(base.transform_origin()); 1575 transform_origin_ = ProtoToPoint3F(base.transform_origin());
1556 background_color_ = base.background_color(); 1576 background_color_ = base.background_color();
1557 bounds_ = ProtoToSize(base.bounds()); 1577 bounds_ = ProtoToSize(base.bounds());
1558 1578
1559 transform_tree_index_ = base.transform_free_index(); 1579 transform_tree_index_ = base.transform_free_index();
1560 effect_tree_index_ = base.effect_tree_index(); 1580 effect_tree_index_ = base.effect_tree_index();
1561 clip_tree_index_ = base.clip_tree_index(); 1581 clip_tree_index_ = base.clip_tree_index();
1582 scroll_tree_index_ = base.scroll_tree_index();
1562 offset_to_transform_parent_ = 1583 offset_to_transform_parent_ =
1563 ProtoToVector2dF(base.offset_to_transform_parent()); 1584 ProtoToVector2dF(base.offset_to_transform_parent());
1564 double_sided_ = base.double_sided(); 1585 double_sided_ = base.double_sided();
1565 draws_content_ = base.draws_content(); 1586 draws_content_ = base.draws_content();
1566 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); 1587 hide_layer_and_subtree_ = base.hide_layer_and_subtree();
1567 has_render_surface_ = base.has_render_surface(); 1588 has_render_surface_ = base.has_render_surface();
1568 masks_to_bounds_ = base.masks_to_bounds(); 1589 masks_to_bounds_ = base.masks_to_bounds();
1569 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons(); 1590 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons();
1570 have_wheel_event_handlers_ = base.have_wheel_event_handlers(); 1591 have_wheel_event_handlers_ = base.have_wheel_event_handlers();
1571 have_scroll_event_handlers_ = base.have_scroll_event_handlers(); 1592 have_scroll_event_handlers_ = base.have_scroll_event_handlers();
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 this, layer_tree_host_->property_trees()->transform_tree); 2053 this, layer_tree_host_->property_trees()->transform_tree);
2033 } 2054 }
2034 2055
2035 gfx::Transform Layer::screen_space_transform() const { 2056 gfx::Transform Layer::screen_space_transform() const {
2036 DCHECK_NE(transform_tree_index_, -1); 2057 DCHECK_NE(transform_tree_index_, -1);
2037 return ScreenSpaceTransformFromPropertyTrees( 2058 return ScreenSpaceTransformFromPropertyTrees(
2038 this, layer_tree_host_->property_trees()->transform_tree); 2059 this, layer_tree_host_->property_trees()->transform_tree);
2039 } 2060 }
2040 2061
2041 } // namespace cc 2062 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698