Bug 1117304 - Make sure the tile filter doesn't call CopyRect on surfaces with different formats. r=Bas, a=2.1+
authorMarkus Stange <mstange@themasta.com>
Mon, 05 Jan 2015 18:40:27 +0100
changeset 221663 0ad6c4a55e181acbb82cfed6446ae546fbdb35c1
parent 221662 d237891897698d07b727345c053b87eeecb30530
child 221664 a20cbb3466e47f79c199bcac8e41ffa2376caeff
push id344
push userryanvm@gmail.com
push dateTue, 27 Jan 2015 03:07:58 +0000
treeherdermozilla-b2g34_v2_1@f37f23eb2ada [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, 2.1
bugs1117304
milestone34.0
Bug 1117304 - Make sure the tile filter doesn't call CopyRect on surfaces with different formats. r=Bas, a=2.1+
gfx/2d/FilterNodeSoftware.cpp
--- a/gfx/2d/FilterNodeSoftware.cpp
+++ b/gfx/2d/FilterNodeSoftware.cpp
@@ -1551,17 +1551,26 @@ FilterNodeTileSoftware::Render(const Int
         // We delay creating the target until now because we want to use the
         // same format as our input filter, and we do not actually know the
         // input format before we call GetInputDataSourceSurface.
         target = Factory::CreateDataSourceSurface(aRect.Size(), input->GetFormat());
         if (MOZ2D_WARN_IF(!target)) {
           return nullptr;
         }
       }
-      MOZ_ASSERT(input->GetFormat() == target->GetFormat(), "different surface formats from the same input?");
+
+      if (input->GetFormat() != target->GetFormat()) {
+        // Different rectangles of the input can have different formats. If
+        // that happens, just convert everything to B8G8R8A8.
+        target = FilterProcessing::ConvertToB8G8R8A8(target);
+        input = FilterProcessing::ConvertToB8G8R8A8(input);
+        if (MOZ2D_WARN_IF(!target) || MOZ2D_WARN_IF(!input)) {
+          return nullptr;
+        }
+      }
 
       CopyRect(input, target, srcRect - srcRect.TopLeft(), destRect.TopLeft() - aRect.TopLeft());
     }
   }
 
   return target.forget();
 }