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

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

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years 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/blimp/engine_picture_cache.h ('k') | cc/blink/scrollbar_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 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 <memory> 5 #include <memory>
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "cc/animation/animation_host.h" 9 #include "cc/animation/animation_host.h"
10 #include "cc/blimp/layer_tree_host_remote.h" 10 #include "cc/blimp/layer_tree_host_remote.h"
11 #include "cc/layers/empty_content_layer_client.h" 11 #include "cc/layers/empty_content_layer_client.h"
12 #include "cc/layers/layer.h" 12 #include "cc/layers/layer.h"
13 #include "cc/layers/solid_color_scrollbar_layer.h" 13 #include "cc/layers/solid_color_scrollbar_layer.h"
14 #include "cc/proto/layer.pb.h" 14 #include "cc/proto/layer.pb.h"
15 #include "cc/proto/layer_tree_host.pb.h" 15 #include "cc/proto/layer_tree_host.pb.h"
16 #include "cc/test/fake_image_serialization_processor.h" 16 #include "cc/test/fake_image_serialization_processor.h"
17 #include "cc/test/fake_layer_tree_host.h" 17 #include "cc/test/fake_layer_tree_host.h"
18 #include "cc/test/fake_layer_tree_host_client.h" 18 #include "cc/test/fake_layer_tree_host_client.h"
19 #include "cc/test/fake_picture_layer.h" 19 #include "cc/test/fake_picture_layer.h"
20 #include "cc/test/fake_recording_source.h" 20 #include "cc/test/fake_recording_source.h"
21 #include "cc/test/remote_client_layer_factory.h" 21 #include "cc/test/remote_client_layer_factory.h"
22 #include "cc/test/remote_compositor_test.h" 22 #include "cc/test/remote_compositor_test.h"
23 #include "cc/test/serialization_test_utils.h" 23 #include "cc/test/serialization_test_utils.h"
24 #include "cc/trees/layer_tree.h" 24 #include "cc/trees/layer_tree.h"
25 #include "cc/trees/layer_tree_host_common.h" 25 #include "cc/trees/layer_tree_host_common.h"
26 #include "cc/trees/layer_tree_settings.h" 26 #include "cc/trees/layer_tree_settings.h"
27 #include "skia/ext/cdl_paint.h"
27 #include "third_party/skia/include/core/SkColor.h" 28 #include "third_party/skia/include/core/SkColor.h"
28 #include "ui/gfx/geometry/point.h" 29 #include "ui/gfx/geometry/point.h"
29 #include "ui/gfx/geometry/size.h" 30 #include "ui/gfx/geometry/size.h"
30 #include "ui/gfx/geometry/vector2d_f.h" 31 #include "ui/gfx/geometry/vector2d_f.h"
31 32
32 namespace cc { 33 namespace cc {
33 34
34 #define EXPECT_CLIENT_LAYER_DIRTY(engine_layer) \ 35 #define EXPECT_CLIENT_LAYER_DIRTY(engine_layer) \
35 do { \ 36 do { \
36 Layer* client_layer = compositor_state_deserializer_->GetLayerForEngineId( \ 37 Layer* client_layer = compositor_state_deserializer_->GetLayerForEngineId( \
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 360
360 LayerTree* engine_layer_tree = layer_tree_host_remote_->GetLayerTree(); 361 LayerTree* engine_layer_tree = layer_tree_host_remote_->GetLayerTree();
361 scoped_refptr<Layer> root_layer_src = Layer::Create(); 362 scoped_refptr<Layer> root_layer_src = Layer::Create();
362 engine_layer_tree->SetRootLayer(root_layer_src); 363 engine_layer_tree->SetRootLayer(root_layer_src);
363 364
364 // Ensure that a PictureLayer work correctly for multiple rounds of 365 // Ensure that a PictureLayer work correctly for multiple rounds of
365 // serialization and deserialization. 366 // serialization and deserialization.
366 FakeContentLayerClient content_client; 367 FakeContentLayerClient content_client;
367 gfx::Size bounds(256, 256); 368 gfx::Size bounds(256, 256);
368 content_client.set_bounds(bounds); 369 content_client.set_bounds(bounds);
369 SkPaint simple_paint; 370 CdlPaint simple_paint;
370 simple_paint.setColor(SkColorSetARGB(255, 12, 23, 34)); 371 simple_paint.setColor(SkColorSetARGB(255, 12, 23, 34));
371 content_client.add_draw_rect(gfx::Rect(bounds), simple_paint); 372 content_client.add_draw_rect(gfx::Rect(bounds), simple_paint);
372 scoped_refptr<FakePictureLayer> picture_layer_src = 373 scoped_refptr<FakePictureLayer> picture_layer_src =
373 FakePictureLayer::Create(&content_client); 374 FakePictureLayer::Create(&content_client);
374 375
375 root_layer_src->AddChild(picture_layer_src); 376 root_layer_src->AddChild(picture_layer_src);
376 picture_layer_src->SetNearestNeighbor(!picture_layer_src->nearest_neighbor()); 377 picture_layer_src->SetNearestNeighbor(!picture_layer_src->nearest_neighbor());
377 picture_layer_src->SetNeedsDisplay(); 378 picture_layer_src->SetNeedsDisplay();
378 VerifySerializationAndDeserialization(); 379 VerifySerializationAndDeserialization();
379 layer_tree_host_in_process_->UpdateLayers(); 380 layer_tree_host_in_process_->UpdateLayers();
380 VerifySerializedPictureLayersAreIdentical( 381 VerifySerializedPictureLayersAreIdentical(
381 picture_layer_src.get(), compositor_state_deserializer_.get()); 382 picture_layer_src.get(), compositor_state_deserializer_.get());
382 383
383 // Another round. 384 // Another round.
384 picture_layer_src->SetNeedsDisplay(); 385 picture_layer_src->SetNeedsDisplay();
385 SkPaint new_paint; 386 CdlPaint new_paint;
386 new_paint.setColor(SkColorSetARGB(255, 12, 32, 44)); 387 new_paint.setColor(SkColorSetARGB(255, 12, 32, 44));
387 content_client.add_draw_rect(gfx::Rect(bounds), new_paint); 388 content_client.add_draw_rect(gfx::Rect(bounds), new_paint);
388 VerifySerializationAndDeserialization(); 389 VerifySerializationAndDeserialization();
389 layer_tree_host_in_process_->UpdateLayers(); 390 layer_tree_host_in_process_->UpdateLayers();
390 VerifySerializedPictureLayersAreIdentical( 391 VerifySerializedPictureLayersAreIdentical(
391 picture_layer_src.get(), compositor_state_deserializer_.get()); 392 picture_layer_src.get(), compositor_state_deserializer_.get());
392 } 393 }
393 394
394 TEST_F(LayerTreeHostSerializationTest, EmptyPictureLayerSerialization) { 395 TEST_F(LayerTreeHostSerializationTest, EmptyPictureLayerSerialization) {
395 // Override the layer factor to create FakePictureLayers in the deserializer. 396 // Override the layer factor to create FakePictureLayers in the deserializer.
396 compositor_state_deserializer_->SetLayerFactoryForTesting( 397 compositor_state_deserializer_->SetLayerFactoryForTesting(
397 base::MakeUnique<RemoteClientLayerFactory>()); 398 base::MakeUnique<RemoteClientLayerFactory>());
398 399
399 LayerTree* engine_layer_tree = layer_tree_host_remote_->GetLayerTree(); 400 LayerTree* engine_layer_tree = layer_tree_host_remote_->GetLayerTree();
400 scoped_refptr<Layer> root_layer_src = Layer::Create(); 401 scoped_refptr<Layer> root_layer_src = Layer::Create();
401 engine_layer_tree->SetRootLayer(root_layer_src); 402 engine_layer_tree->SetRootLayer(root_layer_src);
402 scoped_refptr<FakePictureLayer> picture_layer_src = 403 scoped_refptr<FakePictureLayer> picture_layer_src =
403 FakePictureLayer::Create(EmptyContentLayerClient::GetInstance()); 404 FakePictureLayer::Create(EmptyContentLayerClient::GetInstance());
404 root_layer_src->AddChild(picture_layer_src); 405 root_layer_src->AddChild(picture_layer_src);
405 picture_layer_src->SetNeedsDisplay(); 406 picture_layer_src->SetNeedsDisplay();
406 VerifySerializationAndDeserialization(); 407 VerifySerializationAndDeserialization();
407 layer_tree_host_in_process_->UpdateLayers(); 408 layer_tree_host_in_process_->UpdateLayers();
408 VerifySerializedPictureLayersAreIdentical( 409 VerifySerializedPictureLayersAreIdentical(
409 picture_layer_src.get(), compositor_state_deserializer_.get()); 410 picture_layer_src.get(), compositor_state_deserializer_.get());
410 } 411 }
411 412
412 } // namespace cc 413 } // namespace cc
OLDNEW
« no previous file with comments | « cc/blimp/engine_picture_cache.h ('k') | cc/blink/scrollbar_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698