Index: tools/skdiff_utils.cpp |
diff --git a/tools/skdiff_utils.cpp b/tools/skdiff_utils.cpp |
index 14a9fec7e4a126c6bfaf6d7998fbd8a442f3a8f1..a00ea7b567b3bb3ac158f673c858b1418f892b4b 100644 |
--- a/tools/skdiff_utils.cpp |
+++ b/tools/skdiff_utils.cpp |
@@ -25,27 +25,11 @@ bool are_buffers_equal(SkData* skdata1, SkData* skdata2) { |
} |
SkData* read_file(const char* file_path) { |
- SkFILEStream fileStream(file_path); |
- if (!fileStream.isValid()) { |
+ SkData* data = SkData::NewFromFileName(file_path); |
+ if (!data) { |
SkDebugf("WARNING: could not open file <%s> for reading\n", file_path); |
- return NULL; |
} |
- size_t bytesInFile = fileStream.getLength(); |
- size_t bytesLeftToRead = bytesInFile; |
- |
- void* bufferStart = sk_malloc_throw(bytesInFile); |
- char* bufferPointer = (char*)bufferStart; |
- while (bytesLeftToRead > 0) { |
- size_t bytesReadThisTime = fileStream.read(bufferPointer, bytesLeftToRead); |
- if (0 == bytesReadThisTime) { |
- SkDebugf("WARNING: error reading from <%s>\n", file_path); |
- sk_free(bufferStart); |
- return NULL; |
- } |
- bytesLeftToRead -= bytesReadThisTime; |
- bufferPointer += bytesReadThisTime; |
- } |
- return SkData::NewFromMalloc(bufferStart, bytesInFile); |
+ return data; |
} |
bool get_bitmap(SkData* fileBits, DiffResource& resource, SkImageDecoder::Mode mode) { |