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

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: Merge with master Created 4 years, 10 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
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_(MutableProperty::kNone), 70 mutable_properties_(MutableProperty::kNone),
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 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 1082
1082 int Layer::effect_tree_index() const { 1083 int Layer::effect_tree_index() const {
1083 if (!layer_tree_host_ || 1084 if (!layer_tree_host_ ||
1084 layer_tree_host_->property_trees()->sequence_number != 1085 layer_tree_host_->property_trees()->sequence_number !=
1085 property_tree_sequence_number_) { 1086 property_tree_sequence_number_) {
1086 return -1; 1087 return -1;
1087 } 1088 }
1088 return effect_tree_index_; 1089 return effect_tree_index_;
1089 } 1090 }
1090 1091
1092 void Layer::SetScrollTreeIndex(int index) {
1093 DCHECK(IsPropertyChangeAllowed());
1094 if (scroll_tree_index_ == index)
1095 return;
1096 scroll_tree_index_ = index;
1097 SetNeedsPushProperties();
1098 }
1099
1100 int Layer::scroll_tree_index() const {
1101 if (!layer_tree_host_ ||
1102 layer_tree_host_->property_trees()->sequence_number !=
1103 property_tree_sequence_number_) {
1104 return -1;
1105 }
1106 return scroll_tree_index_;
1107 }
1108
1091 void Layer::InvalidatePropertyTreesIndices() { 1109 void Layer::InvalidatePropertyTreesIndices() {
1092 int invalid_property_tree_index = -1; 1110 int invalid_property_tree_index = -1;
1093 SetTransformTreeIndex(invalid_property_tree_index); 1111 SetTransformTreeIndex(invalid_property_tree_index);
1094 SetClipTreeIndex(invalid_property_tree_index); 1112 SetClipTreeIndex(invalid_property_tree_index);
1095 SetEffectTreeIndex(invalid_property_tree_index); 1113 SetEffectTreeIndex(invalid_property_tree_index);
1096 } 1114 }
1097 1115
1098 void Layer::SetShouldFlattenTransform(bool should_flatten) { 1116 void Layer::SetShouldFlattenTransform(bool should_flatten) {
1099 DCHECK(IsPropertyChangeAllowed()); 1117 DCHECK(IsPropertyChangeAllowed());
1100 if (should_flatten_transform_ == should_flatten) 1118 if (should_flatten_transform_ == should_flatten)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 #if defined(NDEBUG) 1212 #if defined(NDEBUG)
1195 if (frame_viewer_instrumentation::IsTracingLayerTreeSnapshots()) 1213 if (frame_viewer_instrumentation::IsTracingLayerTreeSnapshots())
1196 layer->SetDebugInfo(TakeDebugInfo()); 1214 layer->SetDebugInfo(TakeDebugInfo());
1197 #else 1215 #else
1198 layer->SetDebugInfo(TakeDebugInfo()); 1216 layer->SetDebugInfo(TakeDebugInfo());
1199 #endif 1217 #endif
1200 1218
1201 layer->SetTransformTreeIndex(transform_tree_index()); 1219 layer->SetTransformTreeIndex(transform_tree_index());
1202 layer->SetEffectTreeIndex(effect_tree_index()); 1220 layer->SetEffectTreeIndex(effect_tree_index());
1203 layer->SetClipTreeIndex(clip_tree_index()); 1221 layer->SetClipTreeIndex(clip_tree_index());
1222 layer->SetScrollTreeIndex(scroll_tree_index());
1204 layer->set_offset_to_transform_parent(offset_to_transform_parent_); 1223 layer->set_offset_to_transform_parent(offset_to_transform_parent_);
1205 layer->SetDoubleSided(double_sided_); 1224 layer->SetDoubleSided(double_sided_);
1206 layer->SetDrawsContent(DrawsContent()); 1225 layer->SetDrawsContent(DrawsContent());
1207 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); 1226 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_);
1208 layer->SetHasRenderSurface(has_render_surface_); 1227 layer->SetHasRenderSurface(has_render_surface_);
1209 layer->SetForceRenderSurface(force_render_surface_); 1228 layer->SetForceRenderSurface(force_render_surface_);
1210 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) 1229 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating())
1211 layer->SetFilters(filters_); 1230 layer->SetFilters(filters_);
1212 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); 1231 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly()));
1213 layer->SetBackgroundFilters(background_filters()); 1232 layer->SetBackgroundFilters(background_filters());
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 Point3FToProto(transform_origin_, base->mutable_transform_origin()); 1483 Point3FToProto(transform_origin_, base->mutable_transform_origin());
1465 base->set_background_color(background_color_); 1484 base->set_background_color(background_color_);
1466 SizeToProto(use_paint_properties ? paint_properties_.bounds : bounds_, 1485 SizeToProto(use_paint_properties ? paint_properties_.bounds : bounds_,
1467 base->mutable_bounds()); 1486 base->mutable_bounds());
1468 1487
1469 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. 1488 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372.
1470 1489
1471 base->set_transform_free_index(transform_tree_index_); 1490 base->set_transform_free_index(transform_tree_index_);
1472 base->set_effect_tree_index(effect_tree_index_); 1491 base->set_effect_tree_index(effect_tree_index_);
1473 base->set_clip_tree_index(clip_tree_index_); 1492 base->set_clip_tree_index(clip_tree_index_);
1493 base->set_scroll_tree_index(scroll_tree_index_);
1474 Vector2dFToProto(offset_to_transform_parent_, 1494 Vector2dFToProto(offset_to_transform_parent_,
1475 base->mutable_offset_to_transform_parent()); 1495 base->mutable_offset_to_transform_parent());
1476 base->set_double_sided(double_sided_); 1496 base->set_double_sided(double_sided_);
1477 base->set_draws_content(draws_content_); 1497 base->set_draws_content(draws_content_);
1478 base->set_hide_layer_and_subtree(hide_layer_and_subtree_); 1498 base->set_hide_layer_and_subtree(hide_layer_and_subtree_);
1479 base->set_has_render_surface(has_render_surface_); 1499 base->set_has_render_surface(has_render_surface_);
1480 1500
1481 // TODO(nyquist): Add support for serializing FilterOperations for 1501 // TODO(nyquist): Add support for serializing FilterOperations for
1482 // |filters_| and |background_filters_|. See crbug.com/541321. 1502 // |filters_| and |background_filters_|. See crbug.com/541321.
1483 1503
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 DCHECK(layer_tree_host_); 1574 DCHECK(layer_tree_host_);
1555 const proto::BaseLayerProperties& base = proto.base(); 1575 const proto::BaseLayerProperties& base = proto.base();
1556 1576
1557 transform_origin_ = ProtoToPoint3F(base.transform_origin()); 1577 transform_origin_ = ProtoToPoint3F(base.transform_origin());
1558 background_color_ = base.background_color(); 1578 background_color_ = base.background_color();
1559 bounds_ = ProtoToSize(base.bounds()); 1579 bounds_ = ProtoToSize(base.bounds());
1560 1580
1561 transform_tree_index_ = base.transform_free_index(); 1581 transform_tree_index_ = base.transform_free_index();
1562 effect_tree_index_ = base.effect_tree_index(); 1582 effect_tree_index_ = base.effect_tree_index();
1563 clip_tree_index_ = base.clip_tree_index(); 1583 clip_tree_index_ = base.clip_tree_index();
1584 scroll_tree_index_ = base.scroll_tree_index();
1564 offset_to_transform_parent_ = 1585 offset_to_transform_parent_ =
1565 ProtoToVector2dF(base.offset_to_transform_parent()); 1586 ProtoToVector2dF(base.offset_to_transform_parent());
1566 double_sided_ = base.double_sided(); 1587 double_sided_ = base.double_sided();
1567 draws_content_ = base.draws_content(); 1588 draws_content_ = base.draws_content();
1568 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); 1589 hide_layer_and_subtree_ = base.hide_layer_and_subtree();
1569 has_render_surface_ = base.has_render_surface(); 1590 has_render_surface_ = base.has_render_surface();
1570 masks_to_bounds_ = base.masks_to_bounds(); 1591 masks_to_bounds_ = base.masks_to_bounds();
1571 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons(); 1592 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons();
1572 have_wheel_event_handlers_ = base.have_wheel_event_handlers(); 1593 have_wheel_event_handlers_ = base.have_wheel_event_handlers();
1573 have_scroll_event_handlers_ = base.have_scroll_event_handlers(); 1594 have_scroll_event_handlers_ = base.have_scroll_event_handlers();
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 this, layer_tree_host_->property_trees()->transform_tree); 2048 this, layer_tree_host_->property_trees()->transform_tree);
2028 } 2049 }
2029 2050
2030 gfx::Transform Layer::screen_space_transform() const { 2051 gfx::Transform Layer::screen_space_transform() const {
2031 DCHECK_NE(transform_tree_index_, -1); 2052 DCHECK_NE(transform_tree_index_, -1);
2032 return ScreenSpaceTransformFromPropertyTrees( 2053 return ScreenSpaceTransformFromPropertyTrees(
2033 this, layer_tree_host_->property_trees()->transform_tree); 2054 this, layer_tree_host_->property_trees()->transform_tree);
2034 } 2055 }
2035 2056
2036 } // namespace cc 2057 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698