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 200534 5d4bc3da7c283414df1a52e81b3300883a79e2c6
parent 200533 1d185e671e91cc848523a5fbcac803d8a10a207c
child 200535 5ee3807b4bb24c5fef5d4262c05749118a98943c
push id177
push userryanvm@gmail.com
push dateMon, 26 Jan 2015 21:07:03 +0000
treeherdermozilla-esr31@5ee3807b4bb2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, sledru
bugs1117304
milestone31.4.0
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
@@ -1563,17 +1563,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 (!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;
 }