| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkBitmapHasher.h" | 8 #include "SkBitmapHasher.h" |
| 9 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| 11 #include "SkColor.h" | 11 #include "SkColor.h" |
| 12 #include "Test.h" | 12 #include "Test.h" |
| 13 #include "TestClassDef.h" | |
| 14 | 13 |
| 15 // Word size that is large enough to hold results of any checksum type. | 14 // Word size that is large enough to hold results of any checksum type. |
| 16 typedef uint64_t checksum_result; | 15 typedef uint64_t checksum_result; |
| 17 | 16 |
| 18 // Fill in bitmap with test data. | 17 // Fill in bitmap with test data. |
| 19 static void CreateTestBitmap(SkBitmap &bitmap, SkBitmap::Config config, int widt
h, int height, | 18 static void CreateTestBitmap(SkBitmap &bitmap, SkBitmap::Config config, int widt
h, int height, |
| 20 SkColor color, skiatest::Reporter* reporter) { | 19 SkColor color, skiatest::Reporter* reporter) { |
| 21 bitmap.setConfig(config, width, height); | 20 bitmap.setConfig(config, width, height); |
| 22 REPORTER_ASSERT(reporter, bitmap.allocPixels()); | 21 REPORTER_ASSERT(reporter, bitmap.allocPixels()); |
| 23 bitmap.setAlphaType(kOpaque_SkAlphaType); | 22 bitmap.setAlphaType(kOpaque_SkAlphaType); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 34 REPORTER_ASSERT(reporter, digest == 0xfb2903562766ef87ULL); | 33 REPORTER_ASSERT(reporter, digest == 0xfb2903562766ef87ULL); |
| 35 // same pixel data but different dimensions should yield a different checksu
m | 34 // same pixel data but different dimensions should yield a different checksu
m |
| 36 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_ColorBLUE
, reporter); | 35 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_ColorBLUE
, reporter); |
| 37 REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest)); | 36 REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest)); |
| 38 REPORTER_ASSERT(reporter, digest == 0xfe04023fb97d0f61ULL); | 37 REPORTER_ASSERT(reporter, digest == 0xfe04023fb97d0f61ULL); |
| 39 // same dimensions but different color should yield a different checksum | 38 // same dimensions but different color should yield a different checksum |
| 40 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_ColorGREE
N, reporter); | 39 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_ColorGREE
N, reporter); |
| 41 REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest)); | 40 REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest)); |
| 42 REPORTER_ASSERT(reporter, digest == 0x2423c51cad6d1edcULL); | 41 REPORTER_ASSERT(reporter, digest == 0x2423c51cad6d1edcULL); |
| 43 } | 42 } |
| OLD | NEW |