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

Side by Side Diff: gm/gm_expectations.h

Issue 274463004: Revert of extract some common code from PictureRenderer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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') | 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 *
7 * TODO(epoger): Combine this with tools/image_expectations.h, or eliminate one of the two.
8 */ 6 */
9 #ifndef gm_expectations_DEFINED 7 #ifndef gm_expectations_DEFINED
10 #define gm_expectations_DEFINED 8 #define gm_expectations_DEFINED
11 9
12 #include "gm.h" 10 #include "gm.h"
13 #include "SkBitmap.h" 11 #include "SkBitmap.h"
14 #include "SkBitmapHasher.h" 12 #include "SkBitmapHasher.h"
15 #include "SkData.h" 13 #include "SkData.h"
16 #include "SkJSONCPP.h" 14 #include "SkJSONCPP.h"
17 #include "SkOSFile.h" 15 #include "SkOSFile.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 * 209 *
212 * jsonPath: path to JSON file to read 210 * jsonPath: path to JSON file to read
213 */ 211 */
214 explicit JsonExpectationsSource(const char *jsonPath); 212 explicit JsonExpectationsSource(const char *jsonPath);
215 213
216 Expectations get(const char *testName) const SK_OVERRIDE; 214 Expectations get(const char *testName) const SK_OVERRIDE;
217 215
218 private: 216 private:
219 217
220 /** 218 /**
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 /**
221 * Read the file contents from jsonPath and parse them into jsonRoot. 260 * Read the file contents from jsonPath and parse them into jsonRoot.
222 * 261 *
223 * Returns true if successful. 262 * Returns true if successful.
224 */ 263 */
225 static bool Parse(const char *jsonPath, Json::Value *jsonRoot); 264 static bool Parse(const char *jsonPath, Json::Value *jsonRoot);
226 265
227 Json::Value fJsonRoot; 266 Json::Value fJsonRoot;
228 Json::Value fJsonExpectedResults; 267 Json::Value fJsonExpectedResults;
229 }; 268 };
230 269
231 } 270 }
232 #endif 271 #endif
OLDNEW
« no previous file with comments | « no previous file | gm/gm_expectations.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698