| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "cc/paint/display_item_list.h" | 10 #include "cc/paint/display_item_list.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 void DrawDisplayList(unsigned char* buffer, | 44 void DrawDisplayList(unsigned char* buffer, |
| 45 const gfx::Rect& layer_rect, | 45 const gfx::Rect& layer_rect, |
| 46 scoped_refptr<const DisplayItemList> list) { | 46 scoped_refptr<const DisplayItemList> list) { |
| 47 SkImageInfo info = | 47 SkImageInfo info = |
| 48 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 48 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
| 49 SkBitmap bitmap; | 49 SkBitmap bitmap; |
| 50 bitmap.installPixels(info, buffer, info.minRowBytes()); | 50 bitmap.installPixels(info, buffer, info.minRowBytes()); |
| 51 SkCanvas canvas(bitmap); | 51 SkCanvas canvas(bitmap); |
| 52 canvas.clipRect(gfx::RectToSkRect(layer_rect)); | 52 canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
| 53 list->Raster(&canvas, NULL, layer_rect, 1.0f); | 53 list->Raster(&canvas); |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool AreDisplayListDrawingResultsSame(const gfx::Rect& layer_rect, | 56 bool AreDisplayListDrawingResultsSame(const gfx::Rect& layer_rect, |
| 57 const DisplayItemList* list_a, | 57 const DisplayItemList* list_a, |
| 58 const DisplayItemList* list_b) { | 58 const DisplayItemList* list_b) { |
| 59 const size_t pixel_size = 4 * layer_rect.size().GetArea(); | 59 const size_t pixel_size = 4 * layer_rect.size().GetArea(); |
| 60 | 60 |
| 61 std::unique_ptr<unsigned char[]> pixels_a(new unsigned char[pixel_size]); | 61 std::unique_ptr<unsigned char[]> pixels_a(new unsigned char[pixel_size]); |
| 62 std::unique_ptr<unsigned char[]> pixels_b(new unsigned char[pixel_size]); | 62 std::unique_ptr<unsigned char[]> pixels_b(new unsigned char[pixel_size]); |
| 63 memset(pixels_a.get(), 0, pixel_size); | 63 memset(pixels_a.get(), 0, pixel_size); |
| 64 memset(pixels_b.get(), 0, pixel_size); | 64 memset(pixels_b.get(), 0, pixel_size); |
| 65 DrawDisplayList(pixels_a.get(), layer_rect, list_a); | 65 DrawDisplayList(pixels_a.get(), layer_rect, list_a); |
| 66 DrawDisplayList(pixels_b.get(), layer_rect, list_b); | 66 DrawDisplayList(pixels_b.get(), layer_rect, list_b); |
| 67 | 67 |
| 68 return !memcmp(pixels_a.get(), pixels_b.get(), pixel_size); | 68 return !memcmp(pixels_a.get(), pixels_b.get(), pixel_size); |
| 69 } | 69 } |
| 70 | 70 |
| 71 sk_sp<SkImage> CreateDiscardableImage(const gfx::Size& size) { | 71 sk_sp<SkImage> CreateDiscardableImage(const gfx::Size& size) { |
| 72 return SkImage::MakeFromGenerator(base::MakeUnique<TestImageGenerator>( | 72 return SkImage::MakeFromGenerator(base::MakeUnique<TestImageGenerator>( |
| 73 SkImageInfo::MakeN32Premul(size.width(), size.height()))); | 73 SkImageInfo::MakeN32Premul(size.width(), size.height()))); |
| 74 } | 74 } |
| 75 | 75 |
| 76 } // namespace cc | 76 } // namespace cc |
| OLD | NEW |