Bug 1329296 - don't use ExtractSubset on null SkImage when accessing surface pattern fails. r=mchang
authorLee Salzman <lsalzman@mozilla.com>
Fri, 06 Jan 2017 15:23:17 -0500
changeset 356436 8059df49f5d0ba84e48557a7e7eba89482a8a696
parent 356435 bb4089cd9b19f8df190bcd9daa2c20b9bfe446c5
child 356437 46cb4ee497868904876ee4dd99125e834ccd3f05
push id10621
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 16:02:43 +0000
treeherdermozilla-aurora@dca7b42e6c67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmchang
bugs1329296
milestone53.0a1
Bug 1329296 - don't use ExtractSubset on null SkImage when accessing surface pattern fails. r=mchang MozReview-Commit-ID: I9K07esTA0W
gfx/2d/DrawTargetSkia.cpp
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -468,34 +468,34 @@ SetPaintPattern(SkPaint& aPaint, const P
                                                                        mode, 0, &mat);
         aPaint.setShader(shader);
       }
       break;
     }
     case PatternType::SURFACE: {
       const SurfacePattern& pat = static_cast<const SurfacePattern&>(aPattern);
       sk_sp<SkImage> image = GetSkImageForSurface(pat.mSurface);
+      if (!image) {
+        aPaint.setColor(SK_ColorTRANSPARENT);
+        break;
+      }
 
       SkMatrix mat;
       GfxMatrixToSkiaMatrix(pat.mMatrix, mat);
       mat.postTranslate(SkFloatToScalar(aOffset.x), SkFloatToScalar(aOffset.y));
 
       if (!pat.mSamplingRect.IsEmpty()) {
         image = ExtractSubset(image, pat.mSamplingRect);
         mat.preTranslate(pat.mSamplingRect.x, pat.mSamplingRect.y);
       }
 
       SkShader::TileMode xTileMode = ExtendModeToTileMode(pat.mExtendMode, Axis::X_AXIS);
       SkShader::TileMode yTileMode = ExtendModeToTileMode(pat.mExtendMode, Axis::Y_AXIS);
 
-      if (image) {
-        aPaint.setShader(image->makeShader(xTileMode, yTileMode, &mat));
-      } else {
-        aPaint.setColor(SK_ColorTRANSPARENT);
-      }
+      aPaint.setShader(image->makeShader(xTileMode, yTileMode, &mat));
 
       if (pat.mSamplingFilter == SamplingFilter::POINT) {
         aPaint.setFilterQuality(kNone_SkFilterQuality);
       }
       break;
     }
   }
 }