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/layers/layer_settings.h" | |
8 #include "cc/playback/display_item.h" | 7 #include "cc/playback/display_item.h" |
9 #include "cc/test/skia_common.h" | 8 #include "cc/test/skia_common.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
12 #include "third_party/skia/include/core/SkColor.h" | 11 #include "third_party/skia/include/core/SkColor.h" |
13 #include "third_party/skia/include/core/SkImage.h" | 12 #include "third_party/skia/include/core/SkImage.h" |
14 #include "third_party/skia/include/core/SkSurface.h" | 13 #include "third_party/skia/include/core/SkSurface.h" |
15 | 14 |
16 namespace cc { | 15 namespace cc { |
17 namespace { | 16 namespace { |
18 | 17 |
19 TEST(PictureImageLayerTest, PaintContentsToDisplayList) { | 18 TEST(PictureImageLayerTest, PaintContentsToDisplayList) { |
20 scoped_refptr<PictureImageLayer> layer = | 19 scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create(); |
21 PictureImageLayer::Create(LayerSettings()); | |
22 gfx::Rect layer_rect(200, 200); | 20 gfx::Rect layer_rect(200, 200); |
23 | 21 |
24 unsigned char image_pixels[4 * 200 * 200] = {0}; | 22 unsigned char image_pixels[4 * 200 * 200] = {0}; |
25 SkImageInfo info = | 23 SkImageInfo info = |
26 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 24 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
27 skia::RefPtr<SkSurface> image_surface = skia::AdoptRef( | 25 skia::RefPtr<SkSurface> image_surface = skia::AdoptRef( |
28 SkSurface::NewRasterDirect(info, image_pixels, info.minRowBytes())); | 26 SkSurface::NewRasterDirect(info, image_pixels, info.minRowBytes())); |
29 SkCanvas* image_canvas = image_surface->getCanvas(); | 27 SkCanvas* image_canvas = image_surface->getCanvas(); |
30 image_canvas->clear(SK_ColorRED); | 28 image_canvas->clear(SK_ColorRED); |
31 SkPaint blue_paint; | 29 SkPaint blue_paint; |
(...skipping 10 matching lines...) Expand all Loading... |
42 layer->PaintContentsToDisplayList( | 40 layer->PaintContentsToDisplayList( |
43 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | 41 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
44 unsigned char actual_pixels[4 * 200 * 200] = {0}; | 42 unsigned char actual_pixels[4 * 200 * 200] = {0}; |
45 DrawDisplayList(actual_pixels, layer_rect, display_list); | 43 DrawDisplayList(actual_pixels, layer_rect, display_list); |
46 | 44 |
47 EXPECT_EQ(0, memcmp(actual_pixels, image_pixels, 4 * 200 * 200)); | 45 EXPECT_EQ(0, memcmp(actual_pixels, image_pixels, 4 * 200 * 200)); |
48 } | 46 } |
49 | 47 |
50 } // namespace | 48 } // namespace |
51 } // namespace cc | 49 } // namespace cc |
OLD | NEW |