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

Side by Side Diff: gm/gm_expectations.h

Issue 278633002: reland "extract some common code from PictureRenderer" (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: the fix Created 6 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
« no previous file with comments | « no previous file | gm/gm_expectations.cpp » ('j') | gm/gm_expectations.cpp » ('J')
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 *
7 * TODO(epoger): Combine this with tools/image_expectations.h, or eliminate one of the two.
6 */ 8 */
7 #ifndef gm_expectations_DEFINED 9 #ifndef gm_expectations_DEFINED
8 #define gm_expectations_DEFINED 10 #define gm_expectations_DEFINED
9 11
10 #include "gm.h" 12 #include "gm.h"
11 #include "SkBitmap.h" 13 #include "SkBitmap.h"
12 #include "SkBitmapHasher.h" 14 #include "SkBitmapHasher.h"
13 #include "SkData.h" 15 #include "SkData.h"
14 #include "SkJSONCPP.h" 16 #include "SkJSONCPP.h"
15 #include "SkOSFile.h" 17 #include "SkOSFile.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 * 211 *
210 * jsonPath: path to JSON file to read 212 * jsonPath: path to JSON file to read
211 */ 213 */
212 explicit JsonExpectationsSource(const char *jsonPath); 214 explicit JsonExpectationsSource(const char *jsonPath);
213 215
214 Expectations get(const char *testName) const SK_OVERRIDE; 216 Expectations get(const char *testName) const SK_OVERRIDE;
215 217
216 private: 218 private:
217 219
218 /** 220 /**
219 * Read as many bytes as possible (up to maxBytes) from the stream into
220 * an SkData object.
221 *
222 * If the returned SkData contains fewer than maxBytes, then EOF has bee n
223 * reached and no more data would be available from subsequent calls.
224 * (If EOF has already been reached, then this call will return an empty
225 * SkData object immediately.)
226 *
227 * If there are fewer than maxBytes bytes available to read from the
228 * stream, but the stream has not been closed yet, this call will block
229 * until there are enough bytes to read or the stream has been closed.
230 *
231 * It is up to the caller to call unref() on the returned SkData object
232 * once the data is no longer needed, so that the underlying buffer will
233 * be freed. For example:
234 *
235 * {
236 * size_t maxBytes = 256;
237 * SkAutoDataUnref dataRef(readIntoSkData(stream, maxBytes));
238 * if (NULL != dataRef.get()) {
239 * size_t bytesActuallyRead = dataRef.get()->size();
240 * // use the data...
241 * }
242 * }
243 * // underlying buffer has been freed, thanks to auto unref
244 *
245 */
246 // TODO(epoger): Move this, into SkStream.[cpp|h] as attempted in
247 // https://codereview.appspot.com/7300071 ?
248 // And maybe ReadFileIntoSkData() also?
249 static SkData* ReadIntoSkData(SkStream &stream, size_t maxBytes);
250
251 /**
252 * Wrapper around ReadIntoSkData for files: reads the entire file into
253 * an SkData object.
254 */
255 static SkData* ReadFileIntoSkData(SkFILEStream &stream) {
256 return ReadIntoSkData(stream, stream.getLength());
257 }
258
259 /**
260 * Read the file contents from jsonPath and parse them into jsonRoot. 221 * Read the file contents from jsonPath and parse them into jsonRoot.
261 * 222 *
262 * Returns true if successful. 223 * Returns true if successful.
263 */ 224 */
264 static bool Parse(const char *jsonPath, Json::Value *jsonRoot); 225 static bool Parse(const char *jsonPath, Json::Value *jsonRoot);
265 226
266 Json::Value fJsonRoot; 227 Json::Value fJsonRoot;
267 Json::Value fJsonExpectedResults; 228 Json::Value fJsonExpectedResults;
268 }; 229 };
269 230
270 } 231 }
271 #endif 232 #endif
OLDNEW
« no previous file with comments | « no previous file | gm/gm_expectations.cpp » ('j') | gm/gm_expectations.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698