OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/test/skia_common.h" | 5 #include "cc/test/skia_common.h" |
6 | 6 |
7 #include "cc/playback/display_item_list.h" | 7 #include "cc/playback/display_item_list.h" |
8 #include "skia/ext/refptr.h" | 8 #include "skia/ext/refptr.h" |
9 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
10 #include "third_party/skia/include/core/SkImageGenerator.h" | 10 #include "third_party/skia/include/core/SkImageGenerator.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 scoped_refptr<DisplayItemList> list) { | 28 scoped_refptr<DisplayItemList> list) { |
29 SkImageInfo info = | 29 SkImageInfo info = |
30 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 30 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
31 SkBitmap bitmap; | 31 SkBitmap bitmap; |
32 bitmap.installPixels(info, buffer, info.minRowBytes()); | 32 bitmap.installPixels(info, buffer, info.minRowBytes()); |
33 SkCanvas canvas(bitmap); | 33 SkCanvas canvas(bitmap); |
34 canvas.clipRect(gfx::RectToSkRect(layer_rect)); | 34 canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
35 list->Raster(&canvas, NULL, gfx::Rect(), 1.0f); | 35 list->Raster(&canvas, NULL, gfx::Rect(), 1.0f); |
36 } | 36 } |
37 | 37 |
38 bool CompareDisplayListDrawingResults(const gfx::Rect& layer_rect, | |
39 scoped_refptr<DisplayItemList> list_a, | |
40 scoped_refptr<DisplayItemList> list_b) { | |
41 const size_t pixel_size = 4 * layer_rect.size().GetArea(); | |
42 | |
43 scoped_ptr<unsigned char[]> pixels_a(new unsigned char[pixel_size]); | |
44 scoped_ptr<unsigned char[]> pixels_b(new unsigned char[pixel_size]); | |
45 memset(pixels_a.get(), 0, pixel_size); | |
46 memset(pixels_b.get(), 0, pixel_size); | |
47 DrawDisplayList(pixels_a.get(), layer_rect, list_a); | |
48 DrawDisplayList(pixels_b.get(), layer_rect, list_b); | |
49 | |
50 return 0 == memcmp(pixels_a.get(), pixels_b.get(), pixel_size); | |
vmpstr
2015/12/10 01:12:19
return !memcmp(...);
David Trainor- moved to gerrit
2015/12/10 17:10:10
Done.
| |
51 } | |
52 | |
38 skia::RefPtr<SkImage> CreateDiscardableImage(const gfx::Size& size) { | 53 skia::RefPtr<SkImage> CreateDiscardableImage(const gfx::Size& size) { |
39 const SkImageInfo info = | 54 const SkImageInfo info = |
40 SkImageInfo::MakeN32Premul(size.width(), size.height()); | 55 SkImageInfo::MakeN32Premul(size.width(), size.height()); |
41 return skia::AdoptRef( | 56 return skia::AdoptRef( |
42 SkImage::NewFromGenerator(new TestImageGenerator(info))); | 57 SkImage::NewFromGenerator(new TestImageGenerator(info))); |
43 } | 58 } |
44 | 59 |
45 } // namespace cc | 60 } // namespace cc |
OLD | NEW |