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

Side by Side Diff: gm/gm_expectations.cpp

Issue 14890017: GM: include filename extension (.png) of each output file in JSON summary (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: 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
« gm/gm.h ('K') | « gm/gm.h ('k') | gm/gmmain.cpp » ('j') | 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 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 "gm_expectations.h" 8 #include "gm_expectations.h"
9 #include "SkBitmapHasher.h" 9 #include "SkBitmapHasher.h"
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 Json::Value jsonValue; 155 Json::Value jsonValue;
156 jsonValue[kJsonKey_ExpectedResults_AllowedBitmapHashes] = allowedChecksu mArray; 156 jsonValue[kJsonKey_ExpectedResults_AllowedBitmapHashes] = allowedChecksu mArray;
157 jsonValue[kJsonKey_ExpectedResults_IgnoreFailure] = this->ignoreFailure( ); 157 jsonValue[kJsonKey_ExpectedResults_IgnoreFailure] = this->ignoreFailure( );
158 return jsonValue; 158 return jsonValue;
159 } 159 }
160 160
161 161
162 // IndividualImageExpectationsSource class... 162 // IndividualImageExpectationsSource class...
163 163
164 Expectations IndividualImageExpectationsSource::get(const char *testName) { 164 Expectations IndividualImageExpectationsSource::get(const char *testName) {
165 SkString path = make_filename(fRootDir.c_str(), "", testName, 165 SkString path = make_filename(fRootDir.c_str(), "", testName, kPNG_FileE xtension);
166 "png");
167 SkBitmap referenceBitmap; 166 SkBitmap referenceBitmap;
168 bool decodedReferenceBitmap = 167 bool decodedReferenceBitmap =
169 SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap, 168 SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap,
170 SkBitmap::kARGB_8888_Config, 169 SkBitmap::kARGB_8888_Config,
171 SkImageDecoder::kDecodePixels_Mode, 170 SkImageDecoder::kDecodePixels_Mode,
172 NULL); 171 NULL);
173 if (decodedReferenceBitmap) { 172 if (decodedReferenceBitmap) {
174 return Expectations(referenceBitmap); 173 return Expectations(referenceBitmap);
175 } else { 174 } else {
176 return Expectations(); 175 return Expectations();
177 } 176 }
178 } 177 }
179 178
180 179
181 // JsonExpectationsSource class... 180 // JsonExpectationsSource class...
182 181
183 JsonExpectationsSource::JsonExpectationsSource(const char *jsonPath) { 182 JsonExpectationsSource::JsonExpectationsSource(const char *jsonPath) {
184 Parse(jsonPath, &fJsonRoot); 183 Parse(jsonPath, &fJsonRoot);
185 fJsonExpectedResults = fJsonRoot[kJsonKey_ExpectedResults]; 184 fJsonExpectedResults = fJsonRoot[kJsonKey_ExpectedResults];
186 } 185 }
187 186
188 Expectations JsonExpectationsSource::get(const char *testName) { 187 Expectations JsonExpectationsSource::get(const char *testName) {
189 return Expectations(fJsonExpectedResults[testName]); 188 SkString testNameWithExtension(testName);
189 testNameWithExtension.append(".");
190 testNameWithExtension.append(kPNG_FileExtension);
191 return Expectations(fJsonExpectedResults[testNameWithExtension.c_str()]) ;
190 } 192 }
191 193
192 /*static*/ SkData* JsonExpectationsSource::ReadIntoSkData(SkStream &stream, size_t maxBytes) { 194 /*static*/ SkData* JsonExpectationsSource::ReadIntoSkData(SkStream &stream, size_t maxBytes) {
193 if (0 == maxBytes) { 195 if (0 == maxBytes) {
194 return SkData::NewEmpty(); 196 return SkData::NewEmpty();
195 } 197 }
196 char* bufStart = reinterpret_cast<char *>(sk_malloc_throw(maxBytes)); 198 char* bufStart = reinterpret_cast<char *>(sk_malloc_throw(maxBytes));
197 char* bufPtr = bufStart; 199 char* bufPtr = bufStart;
198 size_t bytesRemaining = maxBytes; 200 size_t bytesRemaining = maxBytes;
199 while (bytesRemaining > 0) { 201 while (bytesRemaining > 0) {
(...skipping 27 matching lines...) Expand all
227 Json::Reader reader; 229 Json::Reader reader;
228 if (!reader.parse(bytes, bytes+size, *jsonRoot)) { 230 if (!reader.parse(bytes, bytes+size, *jsonRoot)) {
229 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath); 231 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath);
230 DEBUGFAIL_SEE_STDERR; 232 DEBUGFAIL_SEE_STDERR;
231 return false; 233 return false;
232 } 234 }
233 return true; 235 return true;
234 } 236 }
235 237
236 } 238 }
OLDNEW
« gm/gm.h ('K') | « gm/gm.h ('k') | gm/gmmain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698