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

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

Issue 1783613004: CC Animation: Erase cc::LayerSettings everywhere. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@eraseandroid
Patch Set: Rebase. Created 4 years, 9 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 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 "cc/layers/heads_up_display_layer.h" 7 #include "cc/layers/heads_up_display_layer.h"
8 #include "cc/layers/layer.h" 8 #include "cc/layers/layer.h"
9 #include "cc/layers/layer_settings.h"
10 #include "cc/proto/layer.pb.h" 9 #include "cc/proto/layer.pb.h"
11 #include "cc/proto/layer_tree_host.pb.h" 10 #include "cc/proto/layer_tree_host.pb.h"
12 #include "cc/test/fake_layer_tree_host.h" 11 #include "cc/test/fake_layer_tree_host.h"
13 #include "cc/test/fake_layer_tree_host_client.h" 12 #include "cc/test/fake_layer_tree_host_client.h"
14 #include "cc/test/layer_tree_test.h" 13 #include "cc/test/layer_tree_test.h"
15 #include "cc/test/test_task_graph_runner.h" 14 #include "cc/test/test_task_graph_runner.h"
16 #include "cc/trees/layer_tree_settings.h" 15 #include "cc/trees/layer_tree_settings.h"
17 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/skia/include/core/SkColor.h" 17 #include "third_party/skia/include/core/SkColor.h"
19 #include "ui/gfx/geometry/point.h" 18 #include "ui/gfx/geometry/point.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 167
169 void RunAllMembersChangedTest() { 168 void RunAllMembersChangedTest() {
170 layer_tree_host_src_->needs_full_tree_sync_ = 169 layer_tree_host_src_->needs_full_tree_sync_ =
171 !layer_tree_host_src_->needs_full_tree_sync_; 170 !layer_tree_host_src_->needs_full_tree_sync_;
172 layer_tree_host_src_->needs_meta_info_recomputation_ = 171 layer_tree_host_src_->needs_meta_info_recomputation_ =
173 !layer_tree_host_src_->needs_meta_info_recomputation_; 172 !layer_tree_host_src_->needs_meta_info_recomputation_;
174 layer_tree_host_src_->source_frame_number_ *= 3; 173 layer_tree_host_src_->source_frame_number_ *= 3;
175 layer_tree_host_src_->meta_information_sequence_number_ *= 3; 174 layer_tree_host_src_->meta_information_sequence_number_ *= 3;
176 175
177 // Just fake setup a layer for both source and dest. 176 // Just fake setup a layer for both source and dest.
178 scoped_refptr<Layer> root_layer_src = Layer::Create(LayerSettings()); 177 scoped_refptr<Layer> root_layer_src = Layer::Create();
179 layer_tree_host_src_->SetRootLayer(root_layer_src); 178 layer_tree_host_src_->SetRootLayer(root_layer_src);
180 layer_tree_host_dst_->SetRootLayer(Layer::Create(LayerSettings())); 179 layer_tree_host_dst_->SetRootLayer(Layer::Create());
181 root_layer_src->SetDoubleSided(!root_layer_src->double_sided()); 180 root_layer_src->SetDoubleSided(!root_layer_src->double_sided());
182 181
183 layer_tree_host_src_->debug_state_.show_replica_screen_space_rects = 182 layer_tree_host_src_->debug_state_.show_replica_screen_space_rects =
184 !layer_tree_host_src_->debug_state_.show_replica_screen_space_rects; 183 !layer_tree_host_src_->debug_state_.show_replica_screen_space_rects;
185 layer_tree_host_src_->device_viewport_size_ = gfx::Size(3, 14); 184 layer_tree_host_src_->device_viewport_size_ = gfx::Size(3, 14);
186 layer_tree_host_src_->top_controls_shrink_blink_size_ = 185 layer_tree_host_src_->top_controls_shrink_blink_size_ =
187 !layer_tree_host_src_->top_controls_shrink_blink_size_; 186 !layer_tree_host_src_->top_controls_shrink_blink_size_;
188 layer_tree_host_src_->top_controls_height_ = 187 layer_tree_host_src_->top_controls_height_ =
189 layer_tree_host_src_->top_controls_height_ * 3 + 1; 188 layer_tree_host_src_->top_controls_height_ * 3 + 1;
190 layer_tree_host_src_->top_controls_shown_ratio_ = 189 layer_tree_host_src_->top_controls_shown_ratio_ =
(...skipping 13 matching lines...) Expand all
204 !layer_tree_host_src_->has_gpu_rasterization_trigger_; 203 !layer_tree_host_src_->has_gpu_rasterization_trigger_;
205 layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_ = 204 layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_ =
206 !layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_; 205 !layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_;
207 layer_tree_host_src_->background_color_ = SK_ColorMAGENTA; 206 layer_tree_host_src_->background_color_ = SK_ColorMAGENTA;
208 layer_tree_host_src_->has_transparent_background_ = 207 layer_tree_host_src_->has_transparent_background_ =
209 !layer_tree_host_src_->has_transparent_background_; 208 !layer_tree_host_src_->has_transparent_background_;
210 layer_tree_host_src_->id_ = layer_tree_host_src_->id_ * 3 + 1; 209 layer_tree_host_src_->id_ = layer_tree_host_src_->id_ * 3 + 1;
211 layer_tree_host_src_->next_commit_forces_redraw_ = 210 layer_tree_host_src_->next_commit_forces_redraw_ =
212 !layer_tree_host_src_->next_commit_forces_redraw_; 211 !layer_tree_host_src_->next_commit_forces_redraw_;
213 212
214 layer_tree_host_src_->hud_layer_ = 213 layer_tree_host_src_->hud_layer_ = HeadsUpDisplayLayer::Create();
215 HeadsUpDisplayLayer::Create(LayerSettings());
216 root_layer_src->AddChild(layer_tree_host_src_->hud_layer_); 214 root_layer_src->AddChild(layer_tree_host_src_->hud_layer_);
217 layer_tree_host_src_->overscroll_elasticity_layer_ = 215 layer_tree_host_src_->overscroll_elasticity_layer_ = Layer::Create();
218 Layer::Create(LayerSettings());
219 root_layer_src->AddChild( 216 root_layer_src->AddChild(
220 layer_tree_host_src_->overscroll_elasticity_layer_); 217 layer_tree_host_src_->overscroll_elasticity_layer_);
221 layer_tree_host_src_->page_scale_layer_ = Layer::Create(LayerSettings()); 218 layer_tree_host_src_->page_scale_layer_ = Layer::Create();
222 root_layer_src->AddChild(layer_tree_host_src_->page_scale_layer_); 219 root_layer_src->AddChild(layer_tree_host_src_->page_scale_layer_);
223 layer_tree_host_src_->inner_viewport_scroll_layer_ = 220 layer_tree_host_src_->inner_viewport_scroll_layer_ = Layer::Create();
224 Layer::Create(LayerSettings());
225 root_layer_src->AddChild( 221 root_layer_src->AddChild(
226 layer_tree_host_src_->inner_viewport_scroll_layer_); 222 layer_tree_host_src_->inner_viewport_scroll_layer_);
227 layer_tree_host_src_->outer_viewport_scroll_layer_ = 223 layer_tree_host_src_->outer_viewport_scroll_layer_ = Layer::Create();
228 Layer::Create(LayerSettings());
229 root_layer_src->AddChild( 224 root_layer_src->AddChild(
230 layer_tree_host_src_->outer_viewport_scroll_layer_); 225 layer_tree_host_src_->outer_viewport_scroll_layer_);
231 226
232 // Set in_paint_layer_contents_ only after all calls to AddChild() have 227 // Set in_paint_layer_contents_ only after all calls to AddChild() have
233 // finished to ensure it's allowed to do so at that time. 228 // finished to ensure it's allowed to do so at that time.
234 layer_tree_host_src_->in_paint_layer_contents_ = 229 layer_tree_host_src_->in_paint_layer_contents_ =
235 !layer_tree_host_src_->in_paint_layer_contents_; 230 !layer_tree_host_src_->in_paint_layer_contents_;
236 231
237 LayerSelectionBound sel_bound; 232 LayerSelectionBound sel_bound;
238 sel_bound.edge_top = gfx::Point(14, 3); 233 sel_bound.edge_top = gfx::Point(14, 3);
239 LayerSelection selection; 234 LayerSelection selection;
240 selection.start = sel_bound; 235 selection.start = sel_bound;
241 layer_tree_host_src_->selection_ = selection; 236 layer_tree_host_src_->selection_ = selection;
242 237
243 layer_tree_host_src_->property_trees_.sequence_number = 238 layer_tree_host_src_->property_trees_.sequence_number =
244 layer_tree_host_src_->property_trees_.sequence_number * 3 + 1; 239 layer_tree_host_src_->property_trees_.sequence_number * 3 + 1;
245 240
246 layer_tree_host_src_->surface_id_namespace_ = 241 layer_tree_host_src_->surface_id_namespace_ =
247 layer_tree_host_src_->surface_id_namespace_ * 3 + 1; 242 layer_tree_host_src_->surface_id_namespace_ * 3 + 1;
248 layer_tree_host_src_->next_surface_sequence_ = 243 layer_tree_host_src_->next_surface_sequence_ =
249 layer_tree_host_src_->next_surface_sequence_ * 3 + 1; 244 layer_tree_host_src_->next_surface_sequence_ * 3 + 1;
250 245
251 VerifySerializationAndDeserialization(); 246 VerifySerializationAndDeserialization();
252 } 247 }
253 248
254 void RunLayersChangedTest() { 249 void RunLayersChangedTest() {
255 // Just fake setup a layer for both source and dest. 250 // Just fake setup a layer for both source and dest.
256 scoped_refptr<Layer> root_layer_src = Layer::Create(LayerSettings()); 251 scoped_refptr<Layer> root_layer_src = Layer::Create();
257 layer_tree_host_src_->SetRootLayer(root_layer_src); 252 layer_tree_host_src_->SetRootLayer(root_layer_src);
258 layer_tree_host_dst_->SetRootLayer(Layer::Create(LayerSettings())); 253 layer_tree_host_dst_->SetRootLayer(Layer::Create());
259 root_layer_src->SetDoubleSided(!root_layer_src->double_sided()); 254 root_layer_src->SetDoubleSided(!root_layer_src->double_sided());
260 255
261 // No HUD layer or |overscroll_elasticity_layer_|, or the inner/outer 256 // No HUD layer or |overscroll_elasticity_layer_|, or the inner/outer
262 // viewport scroll layers. 257 // viewport scroll layers.
263 layer_tree_host_src_->overscroll_elasticity_layer_ = 258 layer_tree_host_src_->overscroll_elasticity_layer_ = Layer::Create();
264 Layer::Create(LayerSettings());
265 root_layer_src->AddChild( 259 root_layer_src->AddChild(
266 layer_tree_host_src_->overscroll_elasticity_layer_); 260 layer_tree_host_src_->overscroll_elasticity_layer_);
267 261
268 VerifySerializationAndDeserialization(); 262 VerifySerializationAndDeserialization();
269 } 263 }
270 264
271 void LayersChangedMultipleSerializations() { 265 void LayersChangedMultipleSerializations() {
272 // Just fake setup a layer for both source and dest. 266 // Just fake setup a layer for both source and dest.
273 scoped_refptr<Layer> root_layer_src = Layer::Create(LayerSettings()); 267 scoped_refptr<Layer> root_layer_src = Layer::Create();
274 layer_tree_host_src_->SetRootLayer(root_layer_src); 268 layer_tree_host_src_->SetRootLayer(root_layer_src);
275 layer_tree_host_dst_->SetRootLayer(Layer::Create(LayerSettings())); 269 layer_tree_host_dst_->SetRootLayer(Layer::Create());
276 root_layer_src->SetDoubleSided(!root_layer_src->double_sided()); 270 root_layer_src->SetDoubleSided(!root_layer_src->double_sided());
277 271
278 // Ensure that all the layers work correctly for multiple rounds of 272 // Ensure that all the layers work correctly for multiple rounds of
279 // serialization and deserialization. 273 // serialization and deserialization.
280 layer_tree_host_src_->hud_layer_ = 274 layer_tree_host_src_->hud_layer_ = HeadsUpDisplayLayer::Create();
281 HeadsUpDisplayLayer::Create(LayerSettings());
282 root_layer_src->AddChild(layer_tree_host_src_->hud_layer_); 275 root_layer_src->AddChild(layer_tree_host_src_->hud_layer_);
283 layer_tree_host_src_->overscroll_elasticity_layer_ = 276 layer_tree_host_src_->overscroll_elasticity_layer_ = Layer::Create();
284 Layer::Create(LayerSettings());
285 root_layer_src->AddChild( 277 root_layer_src->AddChild(
286 layer_tree_host_src_->overscroll_elasticity_layer_); 278 layer_tree_host_src_->overscroll_elasticity_layer_);
287 layer_tree_host_src_->page_scale_layer_ = Layer::Create(LayerSettings()); 279 layer_tree_host_src_->page_scale_layer_ = Layer::Create();
288 root_layer_src->AddChild(layer_tree_host_src_->page_scale_layer_); 280 root_layer_src->AddChild(layer_tree_host_src_->page_scale_layer_);
289 layer_tree_host_src_->inner_viewport_scroll_layer_ = 281 layer_tree_host_src_->inner_viewport_scroll_layer_ = Layer::Create();
290 Layer::Create(LayerSettings());
291 root_layer_src->AddChild( 282 root_layer_src->AddChild(
292 layer_tree_host_src_->inner_viewport_scroll_layer_); 283 layer_tree_host_src_->inner_viewport_scroll_layer_);
293 layer_tree_host_src_->outer_viewport_scroll_layer_ = 284 layer_tree_host_src_->outer_viewport_scroll_layer_ = Layer::Create();
294 Layer::Create(LayerSettings());
295 root_layer_src->AddChild( 285 root_layer_src->AddChild(
296 layer_tree_host_src_->outer_viewport_scroll_layer_); 286 layer_tree_host_src_->outer_viewport_scroll_layer_);
297 287
298 VerifySerializationAndDeserialization(); 288 VerifySerializationAndDeserialization();
299 VerifySerializationAndDeserialization(); 289 VerifySerializationAndDeserialization();
300 290
301 layer_tree_host_src_->hud_layer_ = nullptr; 291 layer_tree_host_src_->hud_layer_ = nullptr;
302 VerifySerializationAndDeserialization(); 292 VerifySerializationAndDeserialization();
303 layer_tree_host_src_->overscroll_elasticity_layer_ = nullptr; 293 layer_tree_host_src_->overscroll_elasticity_layer_ = nullptr;
304 VerifySerializationAndDeserialization(); 294 VerifySerializationAndDeserialization();
(...skipping 21 matching lines...) Expand all
326 316
327 TEST_F(LayerTreeHostSerializationTest, LayersChanged) { 317 TEST_F(LayerTreeHostSerializationTest, LayersChanged) {
328 RunLayersChangedTest(); 318 RunLayersChangedTest();
329 } 319 }
330 320
331 TEST_F(LayerTreeHostSerializationTest, LayersChangedMultipleSerializations) { 321 TEST_F(LayerTreeHostSerializationTest, LayersChangedMultipleSerializations) {
332 LayersChangedMultipleSerializations(); 322 LayersChangedMultipleSerializations();
333 } 323 }
334 324
335 } // namespace cc 325 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698