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

Side by Side Diff: cc/trees/layer_tree_host_unittest_serialization.cc

Issue 2253143002: Revert of cc: Move data to LayerTree from LayerTreeHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@layer_tree_change
Patch Set: Created 4 years, 4 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/trees/layer_tree_host_unittest_scroll.cc ('k') | cc/trees/layer_tree_host_unittest_video.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "cc/layers/empty_content_layer_client.h" 10 #include "cc/layers/empty_content_layer_client.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 proto::LayerTreeHost proto; 102 proto::LayerTreeHost proto;
103 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree(); 103 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree();
104 LayerTree* layer_tree_dst = layer_tree_host_dst_->GetLayerTree(); 104 LayerTree* layer_tree_dst = layer_tree_host_dst_->GetLayerTree();
105 105
106 std::unordered_set<Layer*> layers_that_should_push_properties_src = 106 std::unordered_set<Layer*> layers_that_should_push_properties_src =
107 layer_tree_src->LayersThatShouldPushProperties(); 107 layer_tree_src->LayersThatShouldPushProperties();
108 std::vector<std::unique_ptr<SwapPromise>> swap_promises; 108 std::vector<std::unique_ptr<SwapPromise>> swap_promises;
109 layer_tree_host_src_->ToProtobufForCommit(&proto, &swap_promises); 109 layer_tree_host_src_->ToProtobufForCommit(&proto, &swap_promises);
110 layer_tree_host_dst_->FromProtobufForCommit(proto); 110 layer_tree_host_dst_->FromProtobufForCommit(proto);
111 111
112 EXPECT_EQ(layer_tree_src->needs_full_tree_sync_, 112 EXPECT_EQ(layer_tree_host_src_->needs_full_tree_sync_,
113 layer_tree_dst->needs_full_tree_sync_); 113 layer_tree_host_dst_->needs_full_tree_sync_);
114 EXPECT_EQ(layer_tree_src->needs_meta_info_recomputation_, 114 EXPECT_EQ(layer_tree_host_src_->needs_meta_info_recomputation_,
115 layer_tree_dst->needs_meta_info_recomputation_); 115 layer_tree_host_dst_->needs_meta_info_recomputation_);
116 EXPECT_EQ(layer_tree_host_src_->source_frame_number_, 116 EXPECT_EQ(layer_tree_host_src_->source_frame_number_,
117 layer_tree_host_dst_->source_frame_number_); 117 layer_tree_host_dst_->source_frame_number_);
118 EXPECT_EQ(layer_tree_host_src_->root_layer()->id(), 118 EXPECT_EQ(layer_tree_host_src_->root_layer()->id(),
119 layer_tree_host_dst_->root_layer()->id()); 119 layer_tree_host_dst_->root_layer()->id());
120 EXPECT_EQ(layer_tree_host_dst_.get(), 120 EXPECT_EQ(layer_tree_host_dst_.get(),
121 layer_tree_dst->inputs_.root_layer->layer_tree_host()); 121 layer_tree_host_dst_->root_layer_->layer_tree_host());
122 EXPECT_EQ(layer_tree_src->inputs_.root_layer->double_sided(), 122 EXPECT_EQ(layer_tree_host_src_->root_layer_->double_sided(),
123 layer_tree_dst->inputs_.root_layer->double_sided()); 123 layer_tree_host_dst_->root_layer_->double_sided());
124 EXPECT_EQ( 124 EXPECT_EQ(
125 layer_tree_host_src_->debug_state_.show_replica_screen_space_rects, 125 layer_tree_host_src_->debug_state_.show_replica_screen_space_rects,
126 layer_tree_host_dst_->debug_state_.show_replica_screen_space_rects); 126 layer_tree_host_dst_->debug_state_.show_replica_screen_space_rects);
127 EXPECT_EQ(layer_tree_src->inputs_.device_viewport_size, 127 EXPECT_EQ(layer_tree_host_src_->device_viewport_size_,
128 layer_tree_dst->inputs_.device_viewport_size); 128 layer_tree_host_dst_->device_viewport_size_);
129 EXPECT_EQ(layer_tree_src->inputs_.top_controls_shrink_blink_size, 129 EXPECT_EQ(layer_tree_host_src_->top_controls_shrink_blink_size_,
130 layer_tree_dst->inputs_.top_controls_shrink_blink_size); 130 layer_tree_host_dst_->top_controls_shrink_blink_size_);
131 EXPECT_EQ(layer_tree_src->inputs_.top_controls_height, 131 EXPECT_EQ(layer_tree_host_src_->top_controls_height_,
132 layer_tree_dst->inputs_.top_controls_height); 132 layer_tree_host_dst_->top_controls_height_);
133 EXPECT_EQ(layer_tree_src->inputs_.top_controls_shown_ratio, 133 EXPECT_EQ(layer_tree_host_src_->top_controls_shown_ratio_,
134 layer_tree_dst->inputs_.top_controls_shown_ratio); 134 layer_tree_host_dst_->top_controls_shown_ratio_);
135 EXPECT_EQ(layer_tree_src->inputs_.device_scale_factor, 135 EXPECT_EQ(layer_tree_host_src_->device_scale_factor_,
136 layer_tree_dst->inputs_.device_scale_factor); 136 layer_tree_host_dst_->device_scale_factor_);
137 EXPECT_EQ(layer_tree_src->inputs_.painted_device_scale_factor, 137 EXPECT_EQ(layer_tree_host_src_->painted_device_scale_factor_,
138 layer_tree_dst->inputs_.painted_device_scale_factor); 138 layer_tree_host_dst_->painted_device_scale_factor_);
139 EXPECT_EQ(layer_tree_src->inputs_.page_scale_factor, 139 EXPECT_EQ(layer_tree_host_src_->page_scale_factor_,
140 layer_tree_dst->inputs_.page_scale_factor); 140 layer_tree_host_dst_->page_scale_factor_);
141 EXPECT_EQ(layer_tree_src->inputs_.min_page_scale_factor, 141 EXPECT_EQ(layer_tree_host_src_->min_page_scale_factor_,
142 layer_tree_dst->inputs_.min_page_scale_factor); 142 layer_tree_host_dst_->min_page_scale_factor_);
143 EXPECT_EQ(layer_tree_src->inputs_.max_page_scale_factor, 143 EXPECT_EQ(layer_tree_host_src_->max_page_scale_factor_,
144 layer_tree_dst->inputs_.max_page_scale_factor); 144 layer_tree_host_dst_->max_page_scale_factor_);
145 EXPECT_EQ(layer_tree_src->elastic_overscroll_, 145 EXPECT_EQ(layer_tree_host_src_->elastic_overscroll_,
146 layer_tree_dst->elastic_overscroll_); 146 layer_tree_host_dst_->elastic_overscroll_);
147 EXPECT_EQ(layer_tree_host_src_->has_gpu_rasterization_trigger_, 147 EXPECT_EQ(layer_tree_host_src_->has_gpu_rasterization_trigger_,
148 layer_tree_host_dst_->has_gpu_rasterization_trigger_); 148 layer_tree_host_dst_->has_gpu_rasterization_trigger_);
149 EXPECT_EQ(layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_, 149 EXPECT_EQ(layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_,
150 layer_tree_host_dst_->content_is_suitable_for_gpu_rasterization_); 150 layer_tree_host_dst_->content_is_suitable_for_gpu_rasterization_);
151 EXPECT_EQ(layer_tree_src->inputs_.background_color, 151 EXPECT_EQ(layer_tree_host_src_->background_color_,
152 layer_tree_dst->inputs_.background_color); 152 layer_tree_host_dst_->background_color_);
153 EXPECT_EQ(layer_tree_src->inputs_.has_transparent_background, 153 EXPECT_EQ(layer_tree_host_src_->has_transparent_background_,
154 layer_tree_dst->inputs_.has_transparent_background); 154 layer_tree_host_dst_->has_transparent_background_);
155 EXPECT_EQ(layer_tree_src->in_paint_layer_contents(), 155 EXPECT_EQ(layer_tree_src->in_paint_layer_contents(),
156 layer_tree_dst->in_paint_layer_contents()); 156 layer_tree_dst->in_paint_layer_contents());
157 EXPECT_EQ(layer_tree_host_src_->id_, layer_tree_host_dst_->id_); 157 EXPECT_EQ(layer_tree_host_src_->id_, layer_tree_host_dst_->id_);
158 EXPECT_EQ(layer_tree_host_src_->next_commit_forces_redraw_, 158 EXPECT_EQ(layer_tree_host_src_->next_commit_forces_redraw_,
159 layer_tree_host_dst_->next_commit_forces_redraw_); 159 layer_tree_host_dst_->next_commit_forces_redraw_);
160 for (auto* layer : layers_that_should_push_properties_src) { 160 for (auto* layer : layers_that_should_push_properties_src) {
161 EXPECT_TRUE(layer_tree_dst->LayerNeedsPushPropertiesForTesting( 161 EXPECT_TRUE(layer_tree_dst->LayerNeedsPushPropertiesForTesting(
162 layer_tree_dst->LayerById(layer->id()))); 162 layer_tree_dst->LayerById(layer->id())));
163 } 163 }
164 164
165 if (layer_tree_src->hud_layer_) { 165 if (layer_tree_host_src_->hud_layer_) {
166 EXPECT_EQ(layer_tree_src->hud_layer_->id(), 166 EXPECT_EQ(layer_tree_host_src_->hud_layer_->id(),
167 layer_tree_dst->hud_layer_->id()); 167 layer_tree_host_dst_->hud_layer_->id());
168 // The HUD layer member is a HeadsUpDisplayLayer instead of Layer, so 168 // The HUD layer member is a HeadsUpDisplayLayer instead of Layer, so
169 // inspect the proto to see if it contains the the right layer type. 169 // inspect the proto to see if it contains the the right layer type.
170 bool found_hud_layer_type = false; 170 bool found_hud_layer_type = false;
171 for (int i = 0; i < proto.layer_tree().root_layer().children_size(); 171 for (int i = 0; i < proto.root_layer().children_size(); ++i) {
172 ++i) { 172 if (proto.root_layer().children(i).id() ==
173 if (proto.layer_tree().root_layer().children(i).id() == 173 layer_tree_host_src_->hud_layer_->id()) {
174 layer_tree_src->hud_layer_->id()) {
175 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, 174 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER,
176 proto.layer_tree().root_layer().children(i).type()); 175 proto.root_layer().children(i).type());
177 found_hud_layer_type = true; 176 found_hud_layer_type = true;
178 break; 177 break;
179 } 178 }
180 } 179 }
181 EXPECT_TRUE(found_hud_layer_type); 180 EXPECT_TRUE(found_hud_layer_type);
182 } else { 181 } else {
183 EXPECT_FALSE(layer_tree_dst->hud_layer_); 182 EXPECT_FALSE(layer_tree_host_dst_->hud_layer_);
184 } 183 }
185 if (layer_tree_src->overscroll_elasticity_layer()) { 184 if (layer_tree_host_src_->overscroll_elasticity_layer_) {
186 EXPECT_EQ(layer_tree_src->overscroll_elasticity_layer()->id(), 185 EXPECT_EQ(layer_tree_host_src_->overscroll_elasticity_layer_->id(),
187 layer_tree_dst->overscroll_elasticity_layer()->id()); 186 layer_tree_host_dst_->overscroll_elasticity_layer_->id());
188 } else { 187 } else {
189 EXPECT_FALSE(layer_tree_dst->overscroll_elasticity_layer()); 188 EXPECT_FALSE(layer_tree_host_dst_->overscroll_elasticity_layer_);
190 } 189 }
191 if (layer_tree_src->page_scale_layer()) { 190 if (layer_tree_host_src_->page_scale_layer_) {
192 EXPECT_EQ(layer_tree_src->page_scale_layer()->id(), 191 EXPECT_EQ(layer_tree_host_src_->page_scale_layer_->id(),
193 layer_tree_dst->page_scale_layer()->id()); 192 layer_tree_host_dst_->page_scale_layer_->id());
194 } else { 193 } else {
195 EXPECT_FALSE(layer_tree_dst->page_scale_layer()); 194 EXPECT_FALSE(layer_tree_host_dst_->page_scale_layer_);
196 } 195 }
197 if (layer_tree_src->inner_viewport_scroll_layer()) { 196 if (layer_tree_host_src_->inner_viewport_scroll_layer_) {
198 EXPECT_EQ(layer_tree_src->inner_viewport_scroll_layer()->id(), 197 EXPECT_EQ(layer_tree_host_src_->inner_viewport_scroll_layer_->id(),
199 layer_tree_dst->inner_viewport_scroll_layer()->id()); 198 layer_tree_host_dst_->inner_viewport_scroll_layer_->id());
200 } else { 199 } else {
201 EXPECT_FALSE(layer_tree_dst->inner_viewport_scroll_layer()); 200 EXPECT_FALSE(layer_tree_host_dst_->inner_viewport_scroll_layer_);
202 } 201 }
203 if (layer_tree_src->outer_viewport_scroll_layer()) { 202 if (layer_tree_host_src_->outer_viewport_scroll_layer_) {
204 EXPECT_EQ(layer_tree_src->outer_viewport_scroll_layer()->id(), 203 EXPECT_EQ(layer_tree_host_src_->outer_viewport_scroll_layer_->id(),
205 layer_tree_dst->outer_viewport_scroll_layer()->id()); 204 layer_tree_host_dst_->outer_viewport_scroll_layer_->id());
206 } else { 205 } else {
207 EXPECT_FALSE(layer_tree_dst->outer_viewport_scroll_layer()); 206 EXPECT_FALSE(layer_tree_host_dst_->outer_viewport_scroll_layer_);
208 } 207 }
209 EXPECT_EQ(layer_tree_src->inputs_.selection, 208 EXPECT_EQ(layer_tree_host_src_->selection_,
210 layer_tree_dst->inputs_.selection); 209 layer_tree_host_dst_->selection_);
211 EXPECT_EQ(layer_tree_src->property_trees_, layer_tree_dst->property_trees_); 210 EXPECT_EQ(layer_tree_host_src_->property_trees_,
211 layer_tree_host_dst_->property_trees_);
212 EXPECT_EQ(layer_tree_host_src_->surface_client_id_, 212 EXPECT_EQ(layer_tree_host_src_->surface_client_id_,
213 layer_tree_host_dst_->surface_client_id_); 213 layer_tree_host_dst_->surface_client_id_);
214 EXPECT_EQ(layer_tree_host_src_->next_surface_sequence_, 214 EXPECT_EQ(layer_tree_host_src_->next_surface_sequence_,
215 layer_tree_host_dst_->next_surface_sequence_); 215 layer_tree_host_dst_->next_surface_sequence_);
216 216
217 // All layers must have a property tree index that matches PropertyTrees. 217 // All layers must have a property tree index that matches PropertyTrees.
218 if (layer_tree_dst->property_trees_.sequence_number) { 218 if (layer_tree_host_dst_->property_trees_.sequence_number) {
219 int seq_num = layer_tree_dst->property_trees_.sequence_number; 219 int seq_num = layer_tree_host_dst_->property_trees_.sequence_number;
220 LayerTreeHostCommon::CallFunctionForEveryLayer( 220 LayerTreeHostCommon::CallFunctionForEveryLayer(
221 layer_tree_host_dst_.get(), [seq_num](Layer* layer) { 221 layer_tree_host_dst_.get(), [seq_num](Layer* layer) {
222 EXPECT_EQ(seq_num, layer->property_tree_sequence_number()); 222 EXPECT_EQ(seq_num, layer->property_tree_sequence_number());
223 }); 223 });
224 } 224 }
225 } 225 }
226 226
227 void RunAllMembersChangedTest() { 227 void RunAllMembersChangedTest() {
228 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree(); 228 layer_tree_host_src_->needs_full_tree_sync_ =
229 229 !layer_tree_host_src_->needs_full_tree_sync_;
230 layer_tree_src->needs_full_tree_sync_ = 230 layer_tree_host_src_->needs_meta_info_recomputation_ =
231 !layer_tree_src->needs_full_tree_sync_; 231 !layer_tree_host_src_->needs_meta_info_recomputation_;
232 layer_tree_src->needs_meta_info_recomputation_ =
233 !layer_tree_src->needs_meta_info_recomputation_;
234 layer_tree_host_src_->source_frame_number_ *= 3; 232 layer_tree_host_src_->source_frame_number_ *= 3;
235 233
236 // Just fake setup a layer for both source and dest. 234 // Just fake setup a layer for both source and dest.
237 scoped_refptr<Layer> root_layer_src = Layer::Create(); 235 scoped_refptr<Layer> root_layer_src = Layer::Create();
238 layer_tree_host_src_->SetRootLayer(root_layer_src); 236 layer_tree_host_src_->SetRootLayer(root_layer_src);
239 layer_tree_host_dst_->SetRootLayer(Layer::Create()); 237 layer_tree_host_dst_->SetRootLayer(Layer::Create());
240 root_layer_src->SetDoubleSided(!root_layer_src->double_sided()); 238 root_layer_src->SetDoubleSided(!root_layer_src->double_sided());
241 239
242 layer_tree_host_src_->debug_state_.show_replica_screen_space_rects = 240 layer_tree_host_src_->debug_state_.show_replica_screen_space_rects =
243 !layer_tree_host_src_->debug_state_.show_replica_screen_space_rects; 241 !layer_tree_host_src_->debug_state_.show_replica_screen_space_rects;
244 layer_tree_src->inputs_.device_viewport_size = gfx::Size(3, 14); 242 layer_tree_host_src_->device_viewport_size_ = gfx::Size(3, 14);
245 layer_tree_src->inputs_.top_controls_shrink_blink_size = 243 layer_tree_host_src_->top_controls_shrink_blink_size_ =
246 !layer_tree_src->inputs_.top_controls_shrink_blink_size; 244 !layer_tree_host_src_->top_controls_shrink_blink_size_;
247 layer_tree_src->inputs_.top_controls_height = 245 layer_tree_host_src_->top_controls_height_ =
248 layer_tree_src->inputs_.top_controls_height * 3 + 1; 246 layer_tree_host_src_->top_controls_height_ * 3 + 1;
249 layer_tree_src->inputs_.top_controls_shown_ratio = 247 layer_tree_host_src_->top_controls_shown_ratio_ =
250 layer_tree_src->inputs_.top_controls_shown_ratio * 3 + 1; 248 layer_tree_host_src_->top_controls_shown_ratio_ * 3 + 1;
251 layer_tree_src->inputs_.device_scale_factor = 249 layer_tree_host_src_->device_scale_factor_ =
252 layer_tree_src->inputs_.device_scale_factor * 3 + 1; 250 layer_tree_host_src_->device_scale_factor_ * 3 + 1;
253 layer_tree_src->inputs_.painted_device_scale_factor = 251 layer_tree_host_src_->painted_device_scale_factor_ =
254 layer_tree_src->inputs_.painted_device_scale_factor * 3 + 1; 252 layer_tree_host_src_->painted_device_scale_factor_ * 3 + 1;
255 layer_tree_src->inputs_.page_scale_factor = 253 layer_tree_host_src_->page_scale_factor_ =
256 layer_tree_src->inputs_.page_scale_factor * 3 + 1; 254 layer_tree_host_src_->page_scale_factor_ * 3 + 1;
257 layer_tree_src->inputs_.min_page_scale_factor = 255 layer_tree_host_src_->min_page_scale_factor_ =
258 layer_tree_src->inputs_.min_page_scale_factor * 3 + 1; 256 layer_tree_host_src_->min_page_scale_factor_ * 3 + 1;
259 layer_tree_src->inputs_.max_page_scale_factor = 257 layer_tree_host_src_->max_page_scale_factor_ =
260 layer_tree_src->inputs_.max_page_scale_factor * 3 + 1; 258 layer_tree_host_src_->max_page_scale_factor_ * 3 + 1;
261 layer_tree_host_src_->elastic_overscroll_ = gfx::Vector2dF(3, 14); 259 layer_tree_host_src_->elastic_overscroll_ = gfx::Vector2dF(3, 14);
262 layer_tree_host_src_->has_gpu_rasterization_trigger_ = 260 layer_tree_host_src_->has_gpu_rasterization_trigger_ =
263 !layer_tree_host_src_->has_gpu_rasterization_trigger_; 261 !layer_tree_host_src_->has_gpu_rasterization_trigger_;
264 layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_ = 262 layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_ =
265 !layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_; 263 !layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_;
266 layer_tree_src->inputs_.background_color = SK_ColorMAGENTA; 264 layer_tree_host_src_->background_color_ = SK_ColorMAGENTA;
267 layer_tree_src->inputs_.has_transparent_background = 265 layer_tree_host_src_->has_transparent_background_ =
268 !layer_tree_src->inputs_.has_transparent_background; 266 !layer_tree_host_src_->has_transparent_background_;
269 layer_tree_host_src_->id_ = layer_tree_host_src_->id_ * 3 + 1; 267 layer_tree_host_src_->id_ = layer_tree_host_src_->id_ * 3 + 1;
270 layer_tree_host_src_->next_commit_forces_redraw_ = 268 layer_tree_host_src_->next_commit_forces_redraw_ =
271 !layer_tree_host_src_->next_commit_forces_redraw_; 269 !layer_tree_host_src_->next_commit_forces_redraw_;
272 270
273 layer_tree_src->hud_layer_ = HeadsUpDisplayLayer::Create(); 271 layer_tree_host_src_->hud_layer_ = HeadsUpDisplayLayer::Create();
274 root_layer_src->AddChild(layer_tree_src->hud_layer_); 272 root_layer_src->AddChild(layer_tree_host_src_->hud_layer_);
275 273 layer_tree_host_src_->overscroll_elasticity_layer_ = Layer::Create();
276 scoped_refptr<Layer> overscroll_elasticity_layer = Layer::Create(); 274 root_layer_src->AddChild(
277 scoped_refptr<Layer> page_scale_layer = Layer::Create(); 275 layer_tree_host_src_->overscroll_elasticity_layer_);
278 scoped_refptr<Layer> inner_viewport_scroll_layer = Layer::Create(); 276 layer_tree_host_src_->page_scale_layer_ = Layer::Create();
279 scoped_refptr<Layer> outer_viewport_scroll_layer = Layer::Create(); 277 root_layer_src->AddChild(layer_tree_host_src_->page_scale_layer_);
280 278 layer_tree_host_src_->inner_viewport_scroll_layer_ = Layer::Create();
281 root_layer_src->AddChild(overscroll_elasticity_layer); 279 root_layer_src->AddChild(
282 root_layer_src->AddChild(page_scale_layer); 280 layer_tree_host_src_->inner_viewport_scroll_layer_);
283 root_layer_src->AddChild(inner_viewport_scroll_layer); 281 layer_tree_host_src_->outer_viewport_scroll_layer_ = Layer::Create();
284 root_layer_src->AddChild(outer_viewport_scroll_layer); 282 root_layer_src->AddChild(
285 283 layer_tree_host_src_->outer_viewport_scroll_layer_);
286 layer_tree_src->RegisterViewportLayers(
287 overscroll_elasticity_layer, page_scale_layer,
288 inner_viewport_scroll_layer, outer_viewport_scroll_layer);
289 284
290 // Set in_paint_layer_contents_ only after all calls to AddChild() have 285 // Set in_paint_layer_contents_ only after all calls to AddChild() have
291 // finished to ensure it's allowed to do so at that time. 286 // finished to ensure it's allowed to do so at that time.
287 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree();
292 layer_tree_src->in_paint_layer_contents_ = 288 layer_tree_src->in_paint_layer_contents_ =
293 !layer_tree_src->in_paint_layer_contents(); 289 !layer_tree_src->in_paint_layer_contents();
294 290
295 LayerSelectionBound sel_bound; 291 LayerSelectionBound sel_bound;
296 sel_bound.edge_top = gfx::Point(14, 3); 292 sel_bound.edge_top = gfx::Point(14, 3);
297 LayerSelection selection; 293 LayerSelection selection;
298 selection.start = sel_bound; 294 selection.start = sel_bound;
299 layer_tree_src->inputs_.selection = selection; 295 layer_tree_host_src_->selection_ = selection;
300 296
301 layer_tree_src->property_trees_.sequence_number = 297 layer_tree_host_src_->property_trees_.sequence_number =
302 layer_tree_src->property_trees_.sequence_number * 3 + 1; 298 layer_tree_host_src_->property_trees_.sequence_number * 3 + 1;
303 299
304 layer_tree_host_src_->surface_client_id_ = 300 layer_tree_host_src_->surface_client_id_ =
305 layer_tree_host_src_->surface_client_id_ * 3 + 1; 301 layer_tree_host_src_->surface_client_id_ * 3 + 1;
306 layer_tree_host_src_->next_surface_sequence_ = 302 layer_tree_host_src_->next_surface_sequence_ =
307 layer_tree_host_src_->next_surface_sequence_ * 3 + 1; 303 layer_tree_host_src_->next_surface_sequence_ * 3 + 1;
308 304
309 VerifySerializationAndDeserialization(); 305 VerifySerializationAndDeserialization();
310 } 306 }
311 307
312 void RunLayersChangedTest() { 308 void RunLayersChangedTest() {
313 // Just fake setup a layer for both source and dest. 309 // Just fake setup a layer for both source and dest.
314 scoped_refptr<Layer> root_layer_src = Layer::Create(); 310 scoped_refptr<Layer> root_layer_src = Layer::Create();
315 layer_tree_host_src_->SetRootLayer(root_layer_src); 311 layer_tree_host_src_->SetRootLayer(root_layer_src);
316 layer_tree_host_dst_->SetRootLayer(Layer::Create()); 312 layer_tree_host_dst_->SetRootLayer(Layer::Create());
317 root_layer_src->SetDoubleSided(!root_layer_src->double_sided()); 313 root_layer_src->SetDoubleSided(!root_layer_src->double_sided());
318 314
319 // No HUD layer or |overscroll_elasticity_layer_|, or the inner/outer 315 // No HUD layer or |overscroll_elasticity_layer_|, or the inner/outer
320 // viewport scroll layers. 316 // viewport scroll layers.
321 scoped_refptr<Layer> overscroll_elasticity_layer = Layer::Create(); 317 layer_tree_host_src_->overscroll_elasticity_layer_ = Layer::Create();
322 layer_tree_host_src_->GetLayerTree()->inputs_.overscroll_elasticity_layer = 318 root_layer_src->AddChild(
323 overscroll_elasticity_layer; 319 layer_tree_host_src_->overscroll_elasticity_layer_);
324 root_layer_src->AddChild(overscroll_elasticity_layer);
325 320
326 VerifySerializationAndDeserialization(); 321 VerifySerializationAndDeserialization();
327 } 322 }
328 323
329 void RunLayersChangedMultipleSerializations() { 324 void RunLayersChangedMultipleSerializations() {
330 // Just fake setup a layer for both source and dest. 325 // Just fake setup a layer for both source and dest.
331 scoped_refptr<Layer> root_layer_src = Layer::Create(); 326 scoped_refptr<Layer> root_layer_src = Layer::Create();
332 layer_tree_host_src_->SetRootLayer(root_layer_src); 327 layer_tree_host_src_->SetRootLayer(root_layer_src);
333 layer_tree_host_dst_->SetRootLayer(Layer::Create()); 328 layer_tree_host_dst_->SetRootLayer(Layer::Create());
334 root_layer_src->SetDoubleSided(!root_layer_src->double_sided()); 329 root_layer_src->SetDoubleSided(!root_layer_src->double_sided());
335 330
336 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree();
337
338 // Ensure that all the layers work correctly for multiple rounds of 331 // Ensure that all the layers work correctly for multiple rounds of
339 // serialization and deserialization. 332 // serialization and deserialization.
340 layer_tree_src->hud_layer_ = HeadsUpDisplayLayer::Create(); 333 layer_tree_host_src_->hud_layer_ = HeadsUpDisplayLayer::Create();
341 root_layer_src->AddChild(layer_tree_src->hud_layer_); 334 root_layer_src->AddChild(layer_tree_host_src_->hud_layer_);
342 335 layer_tree_host_src_->overscroll_elasticity_layer_ = Layer::Create();
343 scoped_refptr<Layer> overscroll_elasticity_layer = Layer::Create(); 336 root_layer_src->AddChild(
344 scoped_refptr<Layer> page_scale_layer = Layer::Create(); 337 layer_tree_host_src_->overscroll_elasticity_layer_);
345 scoped_refptr<Layer> inner_viewport_scroll_layer = Layer::Create(); 338 layer_tree_host_src_->page_scale_layer_ = Layer::Create();
346 scoped_refptr<Layer> outer_viewport_scroll_layer = Layer::Create(); 339 root_layer_src->AddChild(layer_tree_host_src_->page_scale_layer_);
347 340 layer_tree_host_src_->inner_viewport_scroll_layer_ = Layer::Create();
348 root_layer_src->AddChild(overscroll_elasticity_layer); 341 root_layer_src->AddChild(
349 root_layer_src->AddChild(page_scale_layer); 342 layer_tree_host_src_->inner_viewport_scroll_layer_);
350 root_layer_src->AddChild(inner_viewport_scroll_layer); 343 layer_tree_host_src_->outer_viewport_scroll_layer_ = Layer::Create();
351 root_layer_src->AddChild(outer_viewport_scroll_layer); 344 root_layer_src->AddChild(
352 layer_tree_host_src_->GetLayerTree()->RegisterViewportLayers( 345 layer_tree_host_src_->outer_viewport_scroll_layer_);
353 overscroll_elasticity_layer, page_scale_layer,
354 inner_viewport_scroll_layer, outer_viewport_scroll_layer);
355 346
356 VerifySerializationAndDeserialization(); 347 VerifySerializationAndDeserialization();
357 VerifySerializationAndDeserialization(); 348 VerifySerializationAndDeserialization();
358 349
359 layer_tree_src->hud_layer_ = nullptr; 350 layer_tree_host_src_->hud_layer_ = nullptr;
360 VerifySerializationAndDeserialization(); 351 VerifySerializationAndDeserialization();
361 layer_tree_host_src_->GetLayerTree()->inputs_.overscroll_elasticity_layer = 352 layer_tree_host_src_->overscroll_elasticity_layer_ = nullptr;
362 nullptr;
363 VerifySerializationAndDeserialization(); 353 VerifySerializationAndDeserialization();
364 layer_tree_host_src_->GetLayerTree()->inputs_.page_scale_layer = nullptr; 354 layer_tree_host_src_->page_scale_layer_ = nullptr;
365 VerifySerializationAndDeserialization(); 355 VerifySerializationAndDeserialization();
366 layer_tree_host_src_->GetLayerTree()->inputs_.inner_viewport_scroll_layer = 356 layer_tree_host_src_->inner_viewport_scroll_layer_ = nullptr;
367 nullptr;
368 VerifySerializationAndDeserialization(); 357 VerifySerializationAndDeserialization();
369 layer_tree_host_src_->GetLayerTree()->inputs_.outer_viewport_scroll_layer = 358 layer_tree_host_src_->outer_viewport_scroll_layer_ = nullptr;
370 nullptr;
371 VerifySerializationAndDeserialization(); 359 VerifySerializationAndDeserialization();
372 } 360 }
373 361
374 void RunPictureLayerMultipleSerializationsTest() { 362 void RunPictureLayerMultipleSerializationsTest() {
375 // Just fake setup a layer for both source and dest. 363 // Just fake setup a layer for both source and dest.
376 scoped_refptr<Layer> root_layer_src = Layer::Create(); 364 scoped_refptr<Layer> root_layer_src = Layer::Create();
377 layer_tree_host_src_->SetRootLayer(root_layer_src); 365 layer_tree_host_src_->SetRootLayer(root_layer_src);
378 layer_tree_host_dst_->SetRootLayer(Layer::Create()); 366 layer_tree_host_dst_->SetRootLayer(Layer::Create());
379 367
380 // Ensure that a PictureLayer work correctly for multiple rounds of 368 // Ensure that a PictureLayer work correctly for multiple rounds of
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 451
464 TEST_F(LayerTreeHostSerializationTest, AddAndRemoveNodeFromLayerTree) { 452 TEST_F(LayerTreeHostSerializationTest, AddAndRemoveNodeFromLayerTree) {
465 RunAddAndRemoveNodeFromLayerTree(); 453 RunAddAndRemoveNodeFromLayerTree();
466 } 454 }
467 455
468 TEST_F(LayerTreeHostSerializationTest, PictureLayerMultipleSerializations) { 456 TEST_F(LayerTreeHostSerializationTest, PictureLayerMultipleSerializations) {
469 RunPictureLayerMultipleSerializationsTest(); 457 RunPictureLayerMultipleSerializationsTest();
470 } 458 }
471 459
472 } // namespace cc 460 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_scroll.cc ('k') | cc/trees/layer_tree_host_unittest_video.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698