OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "Resources.h" | 8 #include "Resources.h" |
9 #include "SkAndroidCodec.h" | 9 #include "SkAndroidCodec.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 SkString fullPath = GetResourcePath(path); | 25 SkString fullPath = GetResourcePath(path); |
26 return SkStream::NewFromFile(fullPath.c_str()); | 26 return SkStream::NewFromFile(fullPath.c_str()); |
27 } | 27 } |
28 | 28 |
29 static void md5(const SkBitmap& bm, SkMD5::Digest* digest) { | 29 static void md5(const SkBitmap& bm, SkMD5::Digest* digest) { |
30 SkAutoLockPixels autoLockPixels(bm); | 30 SkAutoLockPixels autoLockPixels(bm); |
31 SkASSERT(bm.getPixels()); | 31 SkASSERT(bm.getPixels()); |
32 SkMD5 md5; | 32 SkMD5 md5; |
33 size_t rowLen = bm.info().bytesPerPixel() * bm.width(); | 33 size_t rowLen = bm.info().bytesPerPixel() * bm.width(); |
34 for (int y = 0; y < bm.height(); ++y) { | 34 for (int y = 0; y < bm.height(); ++y) { |
35 md5.update(static_cast<uint8_t*>(bm.getAddr(0, y)), rowLen); | 35 md5.write(bm.getAddr(0, y), rowLen); |
36 } | 36 } |
37 md5.finish(*digest); | 37 md5.finish(*digest); |
38 } | 38 } |
39 | 39 |
40 /** | 40 /** |
41 * Compute the digest for bm and compare it to a known good digest. | 41 * Compute the digest for bm and compare it to a known good digest. |
42 * @param r Reporter to assert that bm's digest matches goodDigest. | 42 * @param r Reporter to assert that bm's digest matches goodDigest. |
43 * @param goodDigest The known good digest to compare to. | 43 * @param goodDigest The known good digest to compare to. |
44 * @param bm The bitmap to test. | 44 * @param bm The bitmap to test. |
45 */ | 45 */ |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 // Now test an image which is too big. Any image with a larger header (i.e. | 965 // Now test an image which is too big. Any image with a larger header (i.e. |
966 // has bigger width/height) is also too big. | 966 // has bigger width/height) is also too big. |
967 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header | 967 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header |
968 0x84, 0x80, 0x00, // W: 65536 | 968 0x84, 0x80, 0x00, // W: 65536 |
969 0x84, 0x80, 0x00 }; // H: 65536 | 969 0x84, 0x80, 0x00 }; // H: 65536 |
970 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); | 970 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); |
971 codec.reset(SkCodec::NewFromStream(stream.release())); | 971 codec.reset(SkCodec::NewFromStream(stream.release())); |
972 | 972 |
973 REPORTER_ASSERT(r, !codec); | 973 REPORTER_ASSERT(r, !codec); |
974 } | 974 } |
OLD | NEW |