OLD | NEW |
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/layers/picture_image_layer.h" | 5 #include "cc/layers/picture_image_layer.h" |
6 | 6 |
7 #include "cc/resources/display_item.h" | 7 #include "cc/resources/display_item.h" |
8 #include "cc/test/skia_common.h" | 8 #include "cc/test/skia_common.h" |
| 9 #include "cc/trees/layer_tree_settings.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
11 #include "third_party/skia/include/core/SkCanvas.h" | 12 #include "third_party/skia/include/core/SkCanvas.h" |
12 #include "third_party/skia/include/core/SkColor.h" | 13 #include "third_party/skia/include/core/SkColor.h" |
13 | 14 |
14 namespace cc { | 15 namespace cc { |
15 namespace { | 16 namespace { |
16 | 17 |
17 TEST(PictureImageLayerTest, PaintContentsToDisplayList) { | 18 TEST(PictureImageLayerTest, PaintContentsToDisplayList) { |
18 scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create(); | 19 scoped_refptr<PictureImageLayer> layer = |
| 20 PictureImageLayer::Create(LayerSettings()); |
19 gfx::Rect layer_rect(200, 200); | 21 gfx::Rect layer_rect(200, 200); |
20 | 22 |
21 SkBitmap image_bitmap; | 23 SkBitmap image_bitmap; |
22 unsigned char image_pixels[4 * 200 * 200] = {0}; | 24 unsigned char image_pixels[4 * 200 * 200] = {0}; |
23 SkImageInfo info = | 25 SkImageInfo info = |
24 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 26 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
25 image_bitmap.installPixels(info, image_pixels, info.minRowBytes()); | 27 image_bitmap.installPixels(info, image_pixels, info.minRowBytes()); |
26 SkCanvas image_canvas(image_bitmap); | 28 SkCanvas image_canvas(image_bitmap); |
27 image_canvas.clear(SK_ColorRED); | 29 image_canvas.clear(SK_ColorRED); |
28 SkPaint blue_paint; | 30 SkPaint blue_paint; |
(...skipping 10 matching lines...) Expand all Loading... |
39 layer->PaintContentsToDisplayList( | 41 layer->PaintContentsToDisplayList( |
40 display_list.get(), layer_rect, | 42 display_list.get(), layer_rect, |
41 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | 43 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
42 unsigned char actual_pixels[4 * 200 * 200] = {0}; | 44 unsigned char actual_pixels[4 * 200 * 200] = {0}; |
43 DrawDisplayList(actual_pixels, layer_rect, display_list); | 45 DrawDisplayList(actual_pixels, layer_rect, display_list); |
44 | 46 |
45 EXPECT_EQ(0, memcmp(actual_pixels, image_pixels, 4 * 200 * 200)); | 47 EXPECT_EQ(0, memcmp(actual_pixels, image_pixels, 4 * 200 * 200)); |
46 } | 48 } |
47 | 49 |
48 TEST(PictureImageLayerTest, PaintContentsToCachedDisplayList) { | 50 TEST(PictureImageLayerTest, PaintContentsToCachedDisplayList) { |
49 scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create(); | 51 scoped_refptr<PictureImageLayer> layer = |
| 52 PictureImageLayer::Create(LayerSettings()); |
50 gfx::Rect layer_rect(200, 200); | 53 gfx::Rect layer_rect(200, 200); |
51 | 54 |
52 SkBitmap image_bitmap; | 55 SkBitmap image_bitmap; |
53 unsigned char image_pixels[4 * 200 * 200] = {0}; | 56 unsigned char image_pixels[4 * 200 * 200] = {0}; |
54 SkImageInfo info = | 57 SkImageInfo info = |
55 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 58 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
56 image_bitmap.installPixels(info, image_pixels, info.minRowBytes()); | 59 image_bitmap.installPixels(info, image_pixels, info.minRowBytes()); |
57 SkCanvas image_canvas(image_bitmap); | 60 SkCanvas image_canvas(image_bitmap); |
58 image_canvas.clear(SK_ColorRED); | 61 image_canvas.clear(SK_ColorRED); |
59 SkPaint blue_paint; | 62 SkPaint blue_paint; |
(...skipping 12 matching lines...) Expand all Loading... |
72 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | 75 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
73 display_list->CreateAndCacheSkPicture(); | 76 display_list->CreateAndCacheSkPicture(); |
74 unsigned char actual_pixels[4 * 200 * 200] = {0}; | 77 unsigned char actual_pixels[4 * 200 * 200] = {0}; |
75 DrawDisplayList(actual_pixels, layer_rect, display_list); | 78 DrawDisplayList(actual_pixels, layer_rect, display_list); |
76 | 79 |
77 EXPECT_EQ(0, memcmp(actual_pixels, image_pixels, 4 * 200 * 200)); | 80 EXPECT_EQ(0, memcmp(actual_pixels, image_pixels, 4 * 200 * 200)); |
78 } | 81 } |
79 | 82 |
80 } // namespace | 83 } // namespace |
81 } // namespace cc | 84 } // namespace cc |
OLD | NEW |