Bug 668344: Deal with missing Direct2D device in Azure. r=jrmuizel
authorBas Schouten <bschouten@mozilla.com>
Tue, 07 Feb 2012 06:14:21 +0100
changeset 87828 0b14a07b9ac404bb270942e114edca1f775ea8a8
parent 87802 20240add1d35006c37e0c963a6dc3add30b7e72f
child 87829 c0077ffef8017b0a6130f425017e55e8fef86e10
push id975
push userffxbld
push dateTue, 13 Mar 2012 21:39:16 +0000
treeherdermozilla-aurora@99faebf9dc36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs668344
milestone13.0a1
Bug 668344: Deal with missing Direct2D device in Azure. r=jrmuizel
content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
gfx/layers/basic/BasicLayers.cpp
gfx/thebes/gfxWindowsPlatform.cpp
--- a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
+++ b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
@@ -3021,16 +3021,21 @@ struct NS_STACK_CLASS nsCanvasBidiProces
         endRun = mTextRun->GetLength();
       }
 
       const gfxTextRun::CompressedGlyph *glyphs = mTextRun->GetCharacterGlyphs();
 
       RefPtr<ScaledFont> scaledFont =
         gfxPlatform::GetPlatform()->GetScaledFontForFont(font);
 
+      if (!scaledFont) {
+        // This can occur when something switched DirectWrite off.
+        return;
+      }
+
       GlyphBuffer buffer;
 
       std::vector<Glyph> glyphBuf;
 
       for (PRUint32 i = runs[c].mCharacterOffset; i < endRun; i++) {
         Glyph newGlyph;
         if (glyphs[i].IsSimpleGlyph()) {
           newGlyph.mIndex = glyphs[i].GetSimpleGlyph();
--- a/gfx/layers/basic/BasicLayers.cpp
+++ b/gfx/layers/basic/BasicLayers.cpp
@@ -1197,16 +1197,21 @@ BasicCanvasLayer::Paint(gfxContext* aCon
 
 void
 BasicCanvasLayer::PaintWithOpacity(gfxContext* aContext,
                                    float aOpacity)
 {
   NS_ASSERTION(BasicManager()->InDrawing(),
                "Can only draw in drawing phase");
 
+  if (!mSurface) {
+    NS_WARNING("No valid surface to draw!");
+    return;
+  }
+
   nsRefPtr<gfxPattern> pat = new gfxPattern(mSurface);
 
   pat->SetFilter(mFilter);
   pat->SetExtend(gfxPattern::EXTEND_PAD);
 
   gfxMatrix m;
   if (mNeedsYFlip) {
     m = aContext->CurrentMatrix();
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -513,16 +513,21 @@ gfxWindowsPlatform::GetThebesSurfaceForD
 {
 #ifdef XP_WIN
   if (aTarget->GetType() == BACKEND_DIRECT2D) {
     void *surface = aTarget->GetUserData(&kThebesSurfaceKey);
     if (surface) {
       nsRefPtr<gfxASurface> surf = static_cast<gfxASurface*>(surface);
       return surf.forget();
     } else {
+      if (!GetD2DDevice()) {
+        // We no longer have a D2D device, can't do this.
+        return NULL;
+      }
+
       RefPtr<ID3D10Texture2D> texture =
         static_cast<ID3D10Texture2D*>(aTarget->GetNativeSurface(NATIVE_SURFACE_D3D10_TEXTURE));
 
       if (!texture) {
         return gfxPlatform::GetThebesSurfaceForDrawTarget(aTarget);
       }
 
       aTarget->Flush();