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

Unified Diff: gm/gm_expectations.cpp

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/gm_expectations.h ('k') | gyp/tools.gyp » ('j') | gyp/tools.gyp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gm_expectations.cpp
diff --git a/gm/gm_expectations.cpp b/gm/gm_expectations.cpp
index f46a572458f4439a950c5e0d7af6cf6df87b1708..28493ddd9e9c26f5fa5d5596c8da53432902d527 100644
--- a/gm/gm_expectations.cpp
+++ b/gm/gm_expectations.cpp
@@ -3,10 +3,13 @@
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
+ *
+ * TODO(epoger): Combine this with tools/image_expectations.cpp, or eliminate one of the two.
*/
#include "gm_expectations.h"
#include "SkBitmapHasher.h"
+#include "SkData.h"
#include "SkImageDecoder.h"
#define DEBUGFAIL_SEE_STDERR SkDEBUGFAIL("see stderr for message")
@@ -219,33 +222,8 @@ namespace skiagm {
return Expectations(fJsonExpectedResults[testName]);
}
- /*static*/ SkData* JsonExpectationsSource::ReadIntoSkData(SkStream &stream, size_t maxBytes) {
- if (0 == maxBytes) {
- return SkData::NewEmpty();
- }
- char* bufStart = reinterpret_cast<char *>(sk_malloc_throw(maxBytes));
- char* bufPtr = bufStart;
- size_t bytesRemaining = maxBytes;
- while (bytesRemaining > 0) {
- size_t bytesReadThisTime = stream.read(bufPtr, bytesRemaining);
- if (0 == bytesReadThisTime) {
- break;
- }
- bytesRemaining -= bytesReadThisTime;
- bufPtr += bytesReadThisTime;
- }
- return SkData::NewFromMalloc(bufStart, maxBytes - bytesRemaining);
- }
-
/*static*/ bool JsonExpectationsSource::Parse(const char *jsonPath, Json::Value *jsonRoot) {
- SkFILEStream inFile(jsonPath);
- if (!inFile.isValid()) {
- SkDebugf("unable to read JSON file %s\n", jsonPath);
- DEBUGFAIL_SEE_STDERR;
- return false;
- }
-
- SkAutoDataUnref dataRef(ReadFileIntoSkData(inFile));
+ SkAutoDataUnref dataRef(SkData::NewFromFileName(jsonPath));
epoger 2014/05/08 20:17:14 Thanks for the tip! Last time I touched this stuf
if (NULL == dataRef.get()) {
SkDebugf("error reading JSON file %s\n", jsonPath);
DEBUGFAIL_SEE_STDERR;
« no previous file with comments | « gm/gm_expectations.h ('k') | gyp/tools.gyp » ('j') | gyp/tools.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698