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

Unified Diff: gm/colorfilterimagefilter.cpp

Issue 1619723002: Make colorimagefilter GM not fail when resource path not present (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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/colorfilterimagefilter.cpp
diff --git a/gm/colorfilterimagefilter.cpp b/gm/colorfilterimagefilter.cpp
index 49e568b1305411d2410e9098407229829937b980..daebe0d3df92dca608e0f2142c5a02f87a260e3b 100644
--- a/gm/colorfilterimagefilter.cpp
+++ b/gm/colorfilterimagefilter.cpp
@@ -67,13 +67,22 @@ static SkShader* sh_make_lineargradient1() {
static SkShader* sh_make_image() {
SkAutoTUnref<SkImage> image(GetResourceAsImage("mandrill_128.png"));
+ if (!image) {
+ return nullptr;
+ }
return image->newShader(SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
}
static void sk_gm_get_shaders(SkTDArray<SkShader*>* array) {
- *array->append() = sh_make_lineargradient0();
- *array->append() = sh_make_lineargradient1();
- *array->append() = sh_make_image();
+ if (SkShader* shader = sh_make_lineargradient0()) {
+ *array->append() = shader;
+ }
+ if (SkShader* shader = sh_make_lineargradient1()) {
+ *array->append() = shader;
+ }
+ if (SkShader* shader = sh_make_image()) {
+ *array->append() = shader;
+ }
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -198,7 +207,7 @@ DEF_SIMPLE_GM(colorfiltershader, canvas, 800, 800) {
canvas->translate(20, 20);
for (int y = 0; y < shaders.count(); ++y) {
SkShader* shader = shaders[y];
-
+
canvas->save();
for (int x = -1; x < filters.count(); ++x) {
SkColorFilter* filter = x >= 0 ? filters[x] : nullptr;
« 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