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

Side by Side Diff: tools/skimage_main.cpp

Issue 15883004: GM: create GmResultDigest that encapsulates digest type ("bitmap-64bitMD5") and value (12345) (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: add_isValid Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « tests/BitmapHasherTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "gm_expectations.h" 8 #include "gm_expectations.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkBitmapHasher.h"
11 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
12 #include "SkCommandLineFlags.h" 11 #include "SkCommandLineFlags.h"
13 #include "SkData.h" 12 #include "SkData.h"
14 #include "SkGraphics.h" 13 #include "SkGraphics.h"
15 #include "SkImageDecoder.h" 14 #include "SkImageDecoder.h"
16 #include "SkImageEncoder.h" 15 #include "SkImageEncoder.h"
17 #include "SkOSFile.h" 16 #include "SkOSFile.h"
18 #include "SkRandom.h" 17 #include "SkRandom.h"
19 #include "SkStream.h" 18 #include "SkStream.h"
20 #include "SkTArray.h" 19 #include "SkTArray.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 SkASSERT(rect.fBottom < maxY); 172 SkASSERT(rect.fBottom < maxY);
174 } 173 }
175 } 174 }
176 return rect; 175 return rect;
177 } 176 }
178 177
179 // Stored expectations to be written to a file if createExpectationsPath is spec ified. 178 // Stored expectations to be written to a file if createExpectationsPath is spec ified.
180 static Json::Value gExpectationsToWrite; 179 static Json::Value gExpectationsToWrite;
181 180
182 /** 181 /**
183 * If expectations are to be recorded, record the expected checksum of bitmap i nto global 182 * If expectations are to be recorded, record the bitmap expectations into glob al
184 * expectations array. 183 * expectations array.
185 */ 184 */
186 static void write_expectations(const SkBitmap& bitmap, const char* filename) { 185 static void write_expectations(const SkBitmap& bitmap, const char* filename) {
187 if (!FLAGS_createExpectationsPath.isEmpty()) { 186 if (!FLAGS_createExpectationsPath.isEmpty()) {
188 // Creates an Expectations object, and add it to the list to write. 187 // Creates an Expectations object, and add it to the list to write.
189 skiagm::Expectations expectation(bitmap); 188 skiagm::Expectations expectation(bitmap);
190 Json::Value value = expectation.asJsonValue(); 189 Json::Value value = expectation.asJsonValue();
191 gExpectationsToWrite[filename] = value; 190 gExpectationsToWrite[filename] = value;
192 } 191 }
193 } 192 }
(...skipping 18 matching lines...) Expand all
212 211
213 skiagm::Expectations jsExpectation = gJsonExpectations->get(filename); 212 skiagm::Expectations jsExpectation = gJsonExpectations->get(filename);
214 if (jsExpectation.empty()) { 213 if (jsExpectation.empty()) {
215 if (failureArray != NULL) { 214 if (failureArray != NULL) {
216 failureArray->push_back().printf("decoded %s, but could not find exp ectation.", 215 failureArray->push_back().printf("decoded %s, but could not find exp ectation.",
217 filename); 216 filename);
218 } 217 }
219 return false; 218 return false;
220 } 219 }
221 220
222 SkHashDigest checksum; 221 skiagm::GmResultDigest resultDigest(bitmap);
223 if (!SkBitmapHasher::ComputeDigest(bitmap, &checksum)) { 222 if (!resultDigest.isValid()) {
224 if (failureArray != NULL) { 223 if (failureArray != NULL) {
225 failureArray->push_back().printf("decoded %s, but could not create a checksum.", 224 failureArray->push_back().printf("decoded %s, but could not create a GmResultDigest.",
226 filename); 225 filename);
227 } 226 }
228 return false; 227 return false;
229 } 228 }
230 229
231 if (jsExpectation.match(checksum)) { 230 if (jsExpectation.match(resultDigest)) {
232 return true; 231 return true;
233 } 232 }
234 233
235 if (failureArray != NULL) { 234 if (failureArray != NULL) {
236 failureArray->push_back().printf("decoded %s, but the result does not ma tch " 235 failureArray->push_back().printf("decoded %s, but the result does not ma tch "
237 "expectations.", 236 "expectations.",
238 filename); 237 filename);
239 } 238 }
240 return false; 239 return false;
241 } 240 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 } 564 }
566 565
567 return failed ? -1 : 0; 566 return failed ? -1 : 0;
568 } 567 }
569 568
570 #if !defined SK_BUILD_FOR_IOS 569 #if !defined SK_BUILD_FOR_IOS
571 int main(int argc, char * const argv[]) { 570 int main(int argc, char * const argv[]) {
572 return tool_main(argc, (char**) argv); 571 return tool_main(argc, (char**) argv);
573 } 572 }
574 #endif 573 #endif
OLDNEW
« no previous file with comments | « tests/BitmapHasherTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698