| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "compositor_state_deserializer.h" | 5 #include "compositor_state_deserializer.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "cc/animation/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
| 9 #include "cc/blimp/client_picture_cache.h" | 9 #include "cc/blimp/client_picture_cache.h" |
| 10 #include "cc/blimp/compositor_proto_state.h" | 10 #include "cc/blimp/compositor_proto_state.h" |
| 11 #include "cc/blimp/layer_tree_host_remote.h" | 11 #include "cc/blimp/layer_tree_host_remote.h" |
| 12 #include "cc/layers/content_layer_client.h" | 12 #include "cc/layers/content_layer_client.h" |
| 13 #include "cc/layers/picture_layer.h" | 13 #include "cc/layers/picture_layer.h" |
| 14 #include "cc/layers/solid_color_scrollbar_layer.h" | 14 #include "cc/layers/solid_color_scrollbar_layer.h" |
| 15 #include "cc/playback/display_item_list.h" | 15 #include "cc/playback/display_item_list.h" |
| 16 #include "cc/playback/drawing_display_item.h" | 16 #include "cc/playback/drawing_display_item.h" |
| 17 #include "cc/proto/compositor_message.pb.h" | 17 #include "cc/proto/compositor_message.pb.h" |
| 18 #include "cc/test/fake_image_serialization_processor.h" | 18 #include "cc/test/fake_image_serialization_processor.h" |
| 19 #include "cc/test/fake_layer_tree_host.h" | 19 #include "cc/test/fake_layer_tree_host.h" |
| 20 #include "cc/test/fake_layer_tree_host_client.h" | 20 #include "cc/test/fake_layer_tree_host_client.h" |
| 21 #include "cc/test/fake_proxy.h" | 21 #include "cc/test/fake_proxy.h" |
| 22 #include "cc/test/fake_remote_compositor_bridge.h" | 22 #include "cc/test/fake_remote_compositor_bridge.h" |
| 23 #include "cc/test/remote_client_layer_factory.h" | 23 #include "cc/test/remote_client_layer_factory.h" |
| 24 #include "cc/test/remote_compositor_test.h" | 24 #include "cc/test/remote_compositor_test.h" |
| 25 #include "cc/test/serialization_test_utils.h" | 25 #include "cc/test/serialization_test_utils.h" |
| 26 #include "cc/test/skia_common.h" | 26 #include "cc/test/skia_common.h" |
| 27 #include "cc/test/stub_layer_tree_host_client.h" | 27 #include "cc/test/stub_layer_tree_host_client.h" |
| 28 #include "cc/test/test_task_graph_runner.h" | 28 #include "cc/test/test_task_graph_runner.h" |
| 29 #include "cc/trees/layer_tree_host_common.h" | 29 #include "cc/trees/layer_tree_host_common.h" |
| 30 #include "skia/ext/cdl_paint.h" |
| 31 #include "skia/ext/cdl_picture_recorder.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| 31 #include "third_party/skia/include/core/SkPictureRecorder.h" | |
| 32 | 33 |
| 33 namespace cc { | 34 namespace cc { |
| 34 namespace { | 35 namespace { |
| 35 | 36 |
| 36 class FakeContentLayerClient : public ContentLayerClient { | 37 class FakeContentLayerClient : public ContentLayerClient { |
| 37 public: | 38 public: |
| 38 FakeContentLayerClient(scoped_refptr<DisplayItemList> display_list, | 39 FakeContentLayerClient(scoped_refptr<DisplayItemList> display_list, |
| 39 gfx::Rect recorded_viewport) | 40 gfx::Rect recorded_viewport) |
| 40 : display_list_(std::move(display_list)), | 41 : display_list_(std::move(display_list)), |
| 41 recorded_viewport_(recorded_viewport) {} | 42 recorded_viewport_(recorded_viewport) {} |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 332 |
| 332 TEST_F(CompositorStateDeserializerTest, PictureLayer) { | 333 TEST_F(CompositorStateDeserializerTest, PictureLayer) { |
| 333 scoped_refptr<Layer> root_layer = Layer::Create(); | 334 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 334 root_layer->SetBounds(gfx::Size(10, 10)); | 335 root_layer->SetBounds(gfx::Size(10, 10)); |
| 335 root_layer->SetIsDrawable(true); | 336 root_layer->SetIsDrawable(true); |
| 336 layer_tree_host_remote_->GetLayerTree()->SetRootLayer(root_layer); | 337 layer_tree_host_remote_->GetLayerTree()->SetRootLayer(root_layer); |
| 337 | 338 |
| 338 gfx::Size layer_size = gfx::Size(5, 5); | 339 gfx::Size layer_size = gfx::Size(5, 5); |
| 339 | 340 |
| 340 gfx::PointF offset(2.f, 3.f); | 341 gfx::PointF offset(2.f, 3.f); |
| 341 SkPictureRecorder recorder; | 342 CdlPictureRecorder recorder; |
| 342 SkCanvas* canvas; | 343 CdlCanvas* canvas; |
| 343 SkPaint red_paint; | 344 CdlPaint red_paint; |
| 344 red_paint.setColor(SK_ColorRED); | 345 red_paint.setColor(SK_ColorRED); |
| 345 canvas = recorder.beginRecording(SkRect::MakeXYWH( | 346 canvas = recorder.beginRecording(SkRect::MakeXYWH( |
| 346 offset.x(), offset.y(), layer_size.width(), layer_size.height())); | 347 offset.x(), offset.y(), layer_size.width(), layer_size.height())); |
| 347 canvas->translate(offset.x(), offset.y()); | 348 canvas->translate(offset.x(), offset.y()); |
| 348 canvas->drawRectCoords(0.f, 0.f, 4.f, 4.f, red_paint); | 349 canvas->drawRectCoords(0.f, 0.f, 4.f, 4.f, red_paint); |
| 349 sk_sp<SkPicture> test_picture = recorder.finishRecordingAsPicture(); | 350 sk_sp<CdlPicture> test_picture = recorder.finishRecordingAsPicture(); |
| 350 | 351 |
| 351 DisplayItemListSettings settings; | 352 DisplayItemListSettings settings; |
| 352 settings.use_cached_picture = false; | 353 settings.use_cached_picture = false; |
| 353 scoped_refptr<DisplayItemList> display_list = | 354 scoped_refptr<DisplayItemList> display_list = |
| 354 DisplayItemList::Create(settings); | 355 DisplayItemList::Create(settings); |
| 355 const gfx::Rect visual_rect(0, 0, 42, 42); | 356 const gfx::Rect visual_rect(0, 0, 42, 42); |
| 356 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>(visual_rect, | 357 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>(visual_rect, |
| 357 test_picture); | 358 test_picture); |
| 358 display_list->Finalize(); | 359 display_list->Finalize(); |
| 359 FakeContentLayerClient content_client(display_list, gfx::Rect(layer_size)); | 360 FakeContentLayerClient content_client(display_list, gfx::Rect(layer_size)); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 picture_layer2->id())); | 395 picture_layer2->id())); |
| 395 scoped_refptr<DisplayItemList> client_display_list2 = | 396 scoped_refptr<DisplayItemList> client_display_list2 = |
| 396 client_picture_layer2->client()->PaintContentsToDisplayList( | 397 client_picture_layer2->client()->PaintContentsToDisplayList( |
| 397 ContentLayerClient::PaintingControlSetting::PAINTING_BEHAVIOR_NORMAL); | 398 ContentLayerClient::PaintingControlSetting::PAINTING_BEHAVIOR_NORMAL); |
| 398 EXPECT_TRUE(AreDisplayListDrawingResultsSame( | 399 EXPECT_TRUE(AreDisplayListDrawingResultsSame( |
| 399 gfx::Rect(layer_size), display_list.get(), client_display_list2.get())); | 400 gfx::Rect(layer_size), display_list.get(), client_display_list2.get())); |
| 400 } | 401 } |
| 401 | 402 |
| 402 } // namespace | 403 } // namespace |
| 403 } // namespace cc | 404 } // namespace cc |
| OLD | NEW |