Bug 1117304 - Make sure the tile filter doesn't call CopyRect on surfaces with different formats. r=Bas, a=sledru
authorMarkus Stange <mstange@themasta.com>
Mon, 05 Jan 2015 18:40:27 +0100
changeset 232466 94ff84d3339e128d8ff59d3e9d72f03ee0610d61
parent 232465 014e3858e10690a1ae6d46fe1ce095aa07db0b81
child 232467 b27709406790872cdefdff60a62095fd491745b6
child 232489 26eeb4e56866d81a9c4f9dd41bfc312d3ee8d3c7
push id55
push userryanvm@gmail.com
push dateMon, 26 Jan 2015 20:57:35 +0000
treeherdermozilla-b2g37_v2_2@b27709406790 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, sledru
bugs1117304
milestone37.0a2
Bug 1117304 - Make sure the tile filter doesn't call CopyRect on surfaces with different formats. r=Bas, a=sledru
gfx/2d/FilterNodeSoftware.cpp
--- a/gfx/2d/FilterNodeSoftware.cpp
+++ b/gfx/2d/FilterNodeSoftware.cpp
@@ -1542,17 +1542,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();
 }