Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: tests/CodecTest.cpp

Issue 1913173003: SkMD5: .update() -> .write() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-04-22 (Friday) 16:17:21 EDT Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 }
OLDNEW
« src/core/SkMD5.cpp ('K') | « src/core/SkMD5.cpp ('k') | tests/MD5Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698