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

Unified Diff: gm/image.cpp

Issue 581263002: check for failed file->data (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/image.cpp
diff --git a/gm/image.cpp b/gm/image.cpp
index b775af8b892dc1138290bc553e4cf572d293a2a5..1c2b4a7e55fe2175a5390bdf93f6325d0a13bb00 100644
--- a/gm/image.cpp
+++ b/gm/image.cpp
@@ -16,22 +16,14 @@
#include "GrContext.h"
#endif
-static SkData* fileToData(const char path[]) {
- SkFILEStream stream(path);
- if (!stream.isValid()) {
- return SkData::NewEmpty();
- }
- size_t size = stream.getLength();
- void* mem = sk_malloc_throw(size);
- stream.read(mem, size);
- return SkData::NewFromMalloc(mem, size);
-}
-
static void drawJpeg(SkCanvas* canvas, const SkISize& size) {
// TODO: Make this draw a file that is checked in, so it can
// be exercised on machines other than mike's. Will require a
// rebaseline.
- SkAutoDataUnref data(fileToData("/Users/mike/Downloads/skia.google.jpeg"));
+ SkAutoDataUnref data(SkData::NewFromFileName("/Users/mike/Downloads/skia.google.jpeg"));
tfarina 2014/09/19 16:14:49 The code of NewFromFileName (https://skia.googleso
+ if (NULL == data.get()) {
tfarina 2014/09/19 16:14:49 OK
+ return;
+ }
SkImage* image = SkImage::NewFromGenerator(
SkDecodingImageGenerator::Create(data, SkDecodingImageGenerator::Options()));
if (image) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698