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

Unified Diff: samplecode/SampleFilterQuality.cpp

Issue 1422763004: Missing resources crash SampleFilterQuality. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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: samplecode/SampleFilterQuality.cpp
diff --git a/samplecode/SampleFilterQuality.cpp b/samplecode/SampleFilterQuality.cpp
index 1213b75b082d6e80f938b8d9cb0b8def5ea60d70..c37fcae457c4cc8e1b9a2521cbeb649b8d20f8e7 100644
--- a/samplecode/SampleFilterQuality.cpp
+++ b/samplecode/SampleFilterQuality.cpp
@@ -41,9 +41,10 @@ static SkShader* make_shader(const SkRect& bounds) {
colors, nullptr, SK_ARRAY_COUNT(colors),
SkShader::kClamp_TileMode);
#else
- SkString resourcePath = GetResourcePath("mandrill_128.png");
- SkAutoTUnref<SkData> data(SkData::NewFromFileName(resourcePath.c_str()));
- SkAutoTUnref<SkImage> image(SkImage::NewFromEncoded(data));
+ SkAutoTUnref<SkImage> image(GetResourceAsImage("mandrill_128.png"));
+ if (nullptr == image) {
+ return nullptr;
+ }
return image->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
#endif
}
@@ -66,7 +67,7 @@ static SkImage* make_image() {
path.moveTo(0, 0); path.lineTo(N, 0); path.lineTo(0, N); path.close();
SkPaint paint;
- paint.setShader(make_shader(SkRect::MakeWH(N, N)))->unref();
+ SkSafeUnref(paint.setShader(make_shader(SkRect::MakeWH(N, N))));
canvas->drawPath(path, paint);
return surface->newImageSnapshot();
« 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