| 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/playback/display_item.h" | 7 #include "cc/playback/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 11 matching lines...) Expand all Loading... |
| 40 display_list.get(), layer_rect, | 42 display_list.get(), layer_rect, |
| 41 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | 43 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
| 42 display_list->ProcessAppendedItems(); | 44 display_list->ProcessAppendedItems(); |
| 43 unsigned char actual_pixels[4 * 200 * 200] = {0}; | 45 unsigned char actual_pixels[4 * 200 * 200] = {0}; |
| 44 DrawDisplayList(actual_pixels, layer_rect, display_list); | 46 DrawDisplayList(actual_pixels, layer_rect, display_list); |
| 45 | 47 |
| 46 EXPECT_EQ(0, memcmp(actual_pixels, image_pixels, 4 * 200 * 200)); | 48 EXPECT_EQ(0, memcmp(actual_pixels, image_pixels, 4 * 200 * 200)); |
| 47 } | 49 } |
| 48 | 50 |
| 49 TEST(PictureImageLayerTest, PaintContentsToCachedDisplayList) { | 51 TEST(PictureImageLayerTest, PaintContentsToCachedDisplayList) { |
| 50 scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create(); | 52 scoped_refptr<PictureImageLayer> layer = |
| 53 PictureImageLayer::Create(LayerSettings()); |
| 51 gfx::Rect layer_rect(200, 200); | 54 gfx::Rect layer_rect(200, 200); |
| 52 | 55 |
| 53 SkBitmap image_bitmap; | 56 SkBitmap image_bitmap; |
| 54 unsigned char image_pixels[4 * 200 * 200] = {0}; | 57 unsigned char image_pixels[4 * 200 * 200] = {0}; |
| 55 SkImageInfo info = | 58 SkImageInfo info = |
| 56 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 59 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
| 57 image_bitmap.installPixels(info, image_pixels, info.minRowBytes()); | 60 image_bitmap.installPixels(info, image_pixels, info.minRowBytes()); |
| 58 SkCanvas image_canvas(image_bitmap); | 61 SkCanvas image_canvas(image_bitmap); |
| 59 image_canvas.clear(SK_ColorRED); | 62 image_canvas.clear(SK_ColorRED); |
| 60 SkPaint blue_paint; | 63 SkPaint blue_paint; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 74 display_list->ProcessAppendedItems(); | 77 display_list->ProcessAppendedItems(); |
| 75 display_list->CreateAndCacheSkPicture(); | 78 display_list->CreateAndCacheSkPicture(); |
| 76 unsigned char actual_pixels[4 * 200 * 200] = {0}; | 79 unsigned char actual_pixels[4 * 200 * 200] = {0}; |
| 77 DrawDisplayList(actual_pixels, layer_rect, display_list); | 80 DrawDisplayList(actual_pixels, layer_rect, display_list); |
| 78 | 81 |
| 79 EXPECT_EQ(0, memcmp(actual_pixels, image_pixels, 4 * 200 * 200)); | 82 EXPECT_EQ(0, memcmp(actual_pixels, image_pixels, 4 * 200 * 200)); |
| 80 } | 83 } |
| 81 | 84 |
| 82 } // namespace | 85 } // namespace |
| 83 } // namespace cc | 86 } // namespace cc |
| OLD | NEW |