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

Side by Side Diff: gm/gm_expectations.cpp

Issue 15014011: GM: include filename extension (.png) of each output file in JSON summary (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: slight_cleanup 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 | « 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 Json::Value jsonValue; 134 Json::Value jsonValue;
135 jsonValue[kJsonKey_ExpectedResults_AllowedBitmapHashes] = allowedChecksu mArray; 135 jsonValue[kJsonKey_ExpectedResults_AllowedBitmapHashes] = allowedChecksu mArray;
136 jsonValue[kJsonKey_ExpectedResults_IgnoreFailure] = this->ignoreFailure( ); 136 jsonValue[kJsonKey_ExpectedResults_IgnoreFailure] = this->ignoreFailure( );
137 return jsonValue; 137 return jsonValue;
138 } 138 }
139 139
140 140
141 // IndividualImageExpectationsSource class... 141 // IndividualImageExpectationsSource class...
142 142
143 Expectations IndividualImageExpectationsSource::get(const char *testName) { 143 Expectations IndividualImageExpectationsSource::get(const char *testName) {
144 SkString path = make_filename(fRootDir.c_str(), "", testName, 144 SkString path = make_filename(fRootDir.c_str(), "", testName, kPNG_FileE xtension);
145 "png");
146 SkBitmap referenceBitmap; 145 SkBitmap referenceBitmap;
147 bool decodedReferenceBitmap = 146 bool decodedReferenceBitmap =
148 SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap, 147 SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap,
149 SkBitmap::kARGB_8888_Config, 148 SkBitmap::kARGB_8888_Config,
150 SkImageDecoder::kDecodePixels_Mode, 149 SkImageDecoder::kDecodePixels_Mode,
151 NULL); 150 NULL);
152 if (decodedReferenceBitmap) { 151 if (decodedReferenceBitmap) {
153 return Expectations(referenceBitmap); 152 return Expectations(referenceBitmap);
154 } else { 153 } else {
155 return Expectations(); 154 return Expectations();
156 } 155 }
157 } 156 }
158 157
159 158
160 // JsonExpectationsSource class... 159 // JsonExpectationsSource class...
161 160
162 JsonExpectationsSource::JsonExpectationsSource(const char *jsonPath) { 161 JsonExpectationsSource::JsonExpectationsSource(const char *jsonPath) {
163 parse(jsonPath, &fJsonRoot); 162 parse(jsonPath, &fJsonRoot);
164 fJsonExpectedResults = fJsonRoot[kJsonKey_ExpectedResults]; 163 fJsonExpectedResults = fJsonRoot[kJsonKey_ExpectedResults];
165 } 164 }
166 165
167 Expectations JsonExpectationsSource::get(const char *testName) { 166 Expectations JsonExpectationsSource::get(const char *testName) {
168 return Expectations(fJsonExpectedResults[testName]); 167 SkString testNameWithExtension(testName);
168 testNameWithExtension.append(".");
169 testNameWithExtension.append(kPNG_FileExtension);
epoger 2013/05/08 19:57:16 In patchset 3, we replace all appearances of ".png
170 return Expectations(fJsonExpectedResults[testNameWithExtension.c_str()]) ;
169 } 171 }
170 172
171 /*static*/ SkData* JsonExpectationsSource::readIntoSkData(SkStream &stream, size_t maxBytes) { 173 /*static*/ SkData* JsonExpectationsSource::readIntoSkData(SkStream &stream, size_t maxBytes) {
172 if (0 == maxBytes) { 174 if (0 == maxBytes) {
173 return SkData::NewEmpty(); 175 return SkData::NewEmpty();
174 } 176 }
175 char* bufStart = reinterpret_cast<char *>(sk_malloc_throw(maxBytes)); 177 char* bufStart = reinterpret_cast<char *>(sk_malloc_throw(maxBytes));
176 char* bufPtr = bufStart; 178 char* bufPtr = bufStart;
177 size_t bytesRemaining = maxBytes; 179 size_t bytesRemaining = maxBytes;
178 while (bytesRemaining > 0) { 180 while (bytesRemaining > 0) {
(...skipping 27 matching lines...) Expand all
206 Json::Reader reader; 208 Json::Reader reader;
207 if (!reader.parse(bytes, bytes+size, *jsonRoot)) { 209 if (!reader.parse(bytes, bytes+size, *jsonRoot)) {
208 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath); 210 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath);
209 DEBUGFAIL_SEE_STDERR; 211 DEBUGFAIL_SEE_STDERR;
210 return false; 212 return false;
211 } 213 }
212 return true; 214 return true;
213 } 215 }
214 216
215 } 217 }
OLDNEW
« no previous file with comments | « gm/gm.h ('k') | gm/gmmain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698