Bug 1135066 - Deal with failed CreateDrawTarget. r=mstange, a=abillings
authorMilan Sreckovic <milan@mozilla.com>
Thu, 05 Mar 2015 16:38:23 -0500
changeset 257579 26960651c5d95f81afa6f66e07d854431e70e9e3
parent 257578 fffaf2a7de3d24dabdce43c082941e7013367b16
child 257580 469a0c3d1eb168c4c439d870e57015d1a58e27f4
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, abillings
bugs1135066
milestone38.0a2
Bug 1135066 - Deal with failed CreateDrawTarget. r=mstange, a=abillings
gfx/2d/BorrowedContext.h
gfx/thebes/gfxQuartzNativeDrawing.cpp
--- a/gfx/2d/BorrowedContext.h
+++ b/gfx/2d/BorrowedContext.h
@@ -82,24 +82,26 @@ public:
   BorrowedCGContext()
     : cg(nullptr)
     , mDT(nullptr)
   { }
 
   explicit BorrowedCGContext(DrawTarget *aDT)
     : mDT(aDT)
   {
+    MOZ_ASSERT(aDT, "Caller should check for nullptr");
     cg = BorrowCGContextFromDrawTarget(aDT);
   }
 
   // We can optionally Init after construction in
   // case we don't know what the DT will be at construction
   // time.
   CGContextRef Init(DrawTarget *aDT)
   {
+    MOZ_ASSERT(aDT, "Caller should check for nullptr");
     MOZ_ASSERT(!mDT, "Can't initialize twice!");
     mDT = aDT;
     cg = BorrowCGContextFromDrawTarget(aDT);
     return cg;
   }
 
   // The caller needs to call Finish if cg is non-null when
   // they are done with the context. This is currently explicit
--- a/gfx/thebes/gfxQuartzNativeDrawing.cpp
+++ b/gfx/thebes/gfxQuartzNativeDrawing.cpp
@@ -39,23 +39,26 @@ gfxQuartzNativeDrawing::BeginNativeDrawi
       return nullptr;
     }
 
     mTempDrawTarget =
       Factory::CreateDrawTarget(BackendType::COREGRAPHICS,
                                 IntSize(mNativeRect.width, mNativeRect.height),
                                 SurfaceFormat::B8G8R8A8);
 
-    transform.PostTranslate(-mNativeRect.x, -mNativeRect.y);
-    mTempDrawTarget->SetTransform(transform);
-
+    if (mTempDrawTarget) {
+        transform.PostTranslate(-mNativeRect.x, -mNativeRect.y);
+        mTempDrawTarget->SetTransform(transform);
+    }
     dt = mTempDrawTarget;
   }
-  mCGContext = mBorrowedContext.Init(dt);
-  MOZ_ASSERT(mCGContext);
+  if (dt) {
+    mCGContext = mBorrowedContext.Init(dt);
+    MOZ_ASSERT(mCGContext);
+  }
   return mCGContext;
 }
 
 void
 gfxQuartzNativeDrawing::EndNativeDrawing()
 {
   NS_ASSERTION(mCGContext, "EndNativeDrawing called without BeginNativeDrawing");