Bug 1264246 - verify that SkCanvas::getClipBounds succeeds before using result. r=mchang
authorLee Salzman <lsalzman@mozilla.com>
Wed, 13 Apr 2016 16:34:07 -0400
changeset 330966 1442d37b64495edacde3e4e0aba8e6e627adb966
parent 330965 af97159979d24895030137be678cbfd5beea681c
child 330967 3f87c987333bc59831fe9a3142abbad591a9f3f9
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmchang
bugs1264246
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1264246 - verify that SkCanvas::getClipBounds succeeds before using result. r=mchang
gfx/2d/DrawTargetSkia.cpp
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -267,17 +267,19 @@ SetPaintPattern(SkPaint& aPaint, const P
     }
   }
 }
 
 static inline Rect
 GetClipBounds(SkCanvas *aCanvas)
 {
   SkRect clipBounds;
-  aCanvas->getClipBounds(&clipBounds);
+  if (!aCanvas->getClipBounds(&clipBounds)) {
+    return Rect();
+  }
   return SkRectToRect(clipBounds);
 }
 
 struct AutoPaintSetup {
   AutoPaintSetup(SkCanvas *aCanvas, const DrawOptions& aOptions, const Pattern& aPattern, const Rect* aMaskBounds = nullptr)
     : mNeedsRestore(false), mAlpha(1.0)
   {
     Init(aCanvas, aOptions, aMaskBounds);
@@ -304,19 +306,18 @@ struct AutoPaintSetup {
 
     //TODO: Can we set greyscale somehow?
     if (aOptions.mAntialiasMode != AntialiasMode::NONE) {
       mPaint.setAntiAlias(true);
     } else {
       mPaint.setAntiAlias(false);
     }
 
-    Rect clipBounds = GetClipBounds(aCanvas);
     bool needsGroup = !IsOperatorBoundByMask(aOptions.mCompositionOp) &&
-                      (!aMaskBounds || !aMaskBounds->Contains(clipBounds));
+                      (!aMaskBounds || !aMaskBounds->Contains(GetClipBounds(aCanvas)));
 
     // TODO: We could skip the temporary for operator_source and just
     // clear the clip rect. The other operators would be harder
     // but could be worth it to skip pushing a group.
     if (needsGroup) {
       mPaint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
       SkPaint temp;
       temp.setXfermodeMode(GfxOpToSkiaOp(aOptions.mCompositionOp));