Bug 1594425 - Part 3. Make image decoder gtests use SurfaceFormat::OS_RGBA. r=tnikkel
☠☠ backed out by 75a3afcd0b4f ☠ ☠
authorAndrew Osmond <aosmond@mozilla.com>
Fri, 08 Nov 2019 14:58:45 +0000
changeset 501350 90ce21e7e469a6418e2d964aba45bbfe26e9e8fa
parent 501349 54a28220958bbe934eafd7063fa1ed1c046ed54d
child 501351 44afbc73fe15710fcc9d1591d8a783a55473cb04
push id114168
push userdluca@mozilla.com
push dateSun, 10 Nov 2019 03:08:55 +0000
treeherdermozilla-inbound@33f64c1ef3e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1594425
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1594425 - Part 3. Make image decoder gtests use SurfaceFormat::OS_RGBA. r=tnikkel Differential Revision: https://phabricator.services.mozilla.com/D52009
image/test/fuzzing/TestDecoders.cpp
image/test/gtest/Common.cpp
image/test/gtest/Common.h
image/test/gtest/TestADAM7InterpolatingFilter.cpp
image/test/gtest/TestAnimationFrameBuffer.cpp
image/test/gtest/TestBlendAnimationFilter.cpp
image/test/gtest/TestDecodeToSurface.cpp
image/test/gtest/TestDecoders.cpp
image/test/gtest/TestDecodersPerf.cpp
image/test/gtest/TestDeinterlacingFilter.cpp
image/test/gtest/TestDownscalingFilter.cpp
image/test/gtest/TestDownscalingFilterNoSkia.cpp
image/test/gtest/TestRemoveFrameRectFilter.cpp
image/test/gtest/TestSurfacePipeIntegration.cpp
image/test/gtest/TestSurfaceSink.cpp
image/test/gtest/downscaled.icon
image/test/gtest/green.icon
--- a/image/test/fuzzing/TestDecoders.cpp
+++ b/image/test/fuzzing/TestDecoders.cpp
@@ -51,18 +51,18 @@ class DecodeToSurfaceRunnableFuzzing : p
   }
 
   void Go() {
     mSurface = ImageOps::DecodeToSurface(mInputStream.forget(), mMimeType,
                                          imgIContainer::DECODE_FLAGS_DEFAULT);
     if (!mSurface) return;
 
     if (mSurface->GetType() == SurfaceType::DATA) {
-      if (mSurface->GetFormat() == SurfaceFormat::B8G8R8X8 ||
-          mSurface->GetFormat() == SurfaceFormat::B8G8R8A8) {
+      if (mSurface->GetFormat() == SurfaceFormat::OS_RGBX ||
+          mSurface->GetFormat() == SurfaceFormat::OS_RGBA) {
         DUMMY_IF(IntSize(1, 1) == mSurface->GetSize());
         DUMMY_IF(IsSolidColor(mSurface, BGRAColor::Green(), 1));
       }
     }
   }
 
  private:
   RefPtr<SourceSurface>& mSurface;
--- a/image/test/gtest/Common.cpp
+++ b/image/test/gtest/Common.cpp
@@ -19,17 +19,16 @@
 #include "nsStreamUtils.h"
 #include "nsString.h"
 
 namespace mozilla {
 namespace image {
 
 using namespace gfx;
 
-using std::abs;
 using std::vector;
 
 static bool sImageLibInitialized = false;
 
 AutoInitializeImageLib::AutoInitializeImageLib() {
   if (MOZ_LIKELY(sImageLibInitialized)) {
     return;
   }
@@ -188,30 +187,35 @@ bool RectIsSolidColor(SourceSurface* aSu
                                        DataSourceSurface::MapType::READ);
   ASSERT_TRUE_OR_RETURN(mapping.IsMapped(), false);
   ASSERT_EQ_OR_RETURN(mapping.GetStride(), surfaceSize.width * 4, false);
 
   uint8_t* data = mapping.GetData();
   ASSERT_TRUE_OR_RETURN(data != nullptr, false);
 
   BGRAColor pmColor = aColor.Premultiply();
+  uint32_t expectedPixel = pmColor.AsPixel();
+
   int32_t rowLength = mapping.GetStride();
   for (int32_t row = rect.Y(); row < rect.YMost(); ++row) {
     for (int32_t col = rect.X(); col < rect.XMost(); ++col) {
       int32_t i = row * rowLength + col * 4;
-      if (aFuzz != 0) {
-        ASSERT_LE_OR_RETURN(abs(pmColor.mBlue - data[i + 0]), aFuzz, false);
-        ASSERT_LE_OR_RETURN(abs(pmColor.mGreen - data[i + 1]), aFuzz, false);
-        ASSERT_LE_OR_RETURN(abs(pmColor.mRed - data[i + 2]), aFuzz, false);
-        ASSERT_LE_OR_RETURN(abs(pmColor.mAlpha - data[i + 3]), aFuzz, false);
-      } else {
-        ASSERT_EQ_OR_RETURN(pmColor.mBlue, data[i + 0], false);
-        ASSERT_EQ_OR_RETURN(pmColor.mGreen, data[i + 1], false);
-        ASSERT_EQ_OR_RETURN(pmColor.mRed, data[i + 2], false);
-        ASSERT_EQ_OR_RETURN(pmColor.mAlpha, data[i + 3], false);
+      uint32_t gotPixel = *reinterpret_cast<uint32_t*>(data + i);
+      if (expectedPixel != gotPixel) {
+        BGRAColor gotColor = BGRAColor::FromPixel(gotPixel);
+        if (abs(pmColor.mBlue - gotColor.mBlue) > aFuzz ||
+            abs(pmColor.mGreen - gotColor.mGreen) > aFuzz ||
+            abs(pmColor.mRed - gotColor.mRed) > aFuzz ||
+            abs(pmColor.mAlpha - gotColor.mAlpha) > aFuzz) {
+          EXPECT_EQ(pmColor.mBlue, gotColor.mBlue);
+          EXPECT_EQ(pmColor.mGreen, gotColor.mGreen);
+          EXPECT_EQ(pmColor.mRed, gotColor.mRed);
+          EXPECT_EQ(pmColor.mAlpha, gotColor.mAlpha);
+          ASSERT_EQ_OR_RETURN(expectedPixel, gotPixel, false);
+        }
       }
     }
   }
 
   return true;
 }
 
 bool RowHasPixels(SourceSurface* aSurface, int32_t aRow,
@@ -231,20 +235,23 @@ bool RowHasPixels(SourceSurface* aSurfac
   ASSERT_EQ_OR_RETURN(mapping.GetStride(), surfaceSize.width * 4, false);
 
   uint8_t* data = mapping.GetData();
   ASSERT_TRUE_OR_RETURN(data != nullptr, false);
 
   int32_t rowLength = mapping.GetStride();
   for (int32_t col = 0; col < surfaceSize.width; ++col) {
     int32_t i = aRow * rowLength + col * 4;
-    ASSERT_EQ_OR_RETURN(aPixels[col].mBlue, data[i + 0], false);
-    ASSERT_EQ_OR_RETURN(aPixels[col].mGreen, data[i + 1], false);
-    ASSERT_EQ_OR_RETURN(aPixels[col].mRed, data[i + 2], false);
-    ASSERT_EQ_OR_RETURN(aPixels[col].mAlpha, data[i + 3], false);
+    uint32_t gotPixelData = *reinterpret_cast<uint32_t*>(data + i);
+    BGRAColor gotPixel = BGRAColor::FromPixel(gotPixelData);
+    EXPECT_EQ(aPixels[col].mBlue, gotPixel.mBlue);
+    EXPECT_EQ(aPixels[col].mGreen, gotPixel.mGreen);
+    EXPECT_EQ(aPixels[col].mRed, gotPixel.mRed);
+    EXPECT_EQ(aPixels[col].mAlpha, gotPixel.mAlpha);
+    ASSERT_EQ_OR_RETURN(aPixels[col].AsPixel(), gotPixelData, false);
   }
 
   return true;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 // SurfacePipe Helpers
 ///////////////////////////////////////////////////////////////////////////////
--- a/image/test/gtest/Common.h
+++ b/image/test/gtest/Common.h
@@ -42,16 +42,25 @@ struct BGRAColor {
         mAlpha(aAlpha),
         mPremultiplied(aPremultiplied) {}
 
   static BGRAColor Green() { return BGRAColor(0x00, 0xFF, 0x00, 0xFF); }
   static BGRAColor Red() { return BGRAColor(0x00, 0x00, 0xFF, 0xFF); }
   static BGRAColor Blue() { return BGRAColor(0xFF, 0x00, 0x00, 0xFF); }
   static BGRAColor Transparent() { return BGRAColor(0x00, 0x00, 0x00, 0x00); }
 
+  static BGRAColor FromPixel(uint32_t aPixel) {
+    uint8_t r, g, b, a;
+    r = (aPixel >> gfx::SurfaceFormatBit::OS_R) & 0xFF;
+    g = (aPixel >> gfx::SurfaceFormatBit::OS_G) & 0xFF;
+    b = (aPixel >> gfx::SurfaceFormatBit::OS_B) & 0xFF;
+    a = (aPixel >> gfx::SurfaceFormatBit::OS_A) & 0xFF;
+    return BGRAColor(b, g, r, a, true);
+  }
+
   BGRAColor Premultiply() const {
     if (!mPremultiplied) {
       return BGRAColor(gfxPreMultiply(mBlue, mAlpha),
                        gfxPreMultiply(mGreen, mAlpha),
                        gfxPreMultiply(mRed, mAlpha), mAlpha, true);
     }
     return *this;
   }
--- a/image/test/gtest/TestADAM7InterpolatingFilter.cpp
+++ b/image/test/gtest/TestADAM7InterpolatingFilter.cpp
@@ -27,26 +27,26 @@ using std::vector;
 
 template <typename Func>
 void WithADAM7InterpolatingFilter(const IntSize& aSize, Func aFunc) {
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(bool(decoder));
 
   WithFilterPipeline(
       decoder, std::forward<Func>(aFunc), ADAM7InterpolatingConfig{},
-      SurfaceConfig{decoder, aSize, SurfaceFormat::B8G8R8A8, false});
+      SurfaceConfig{decoder, aSize, SurfaceFormat::OS_RGBA, false});
 }
 
 void AssertConfiguringADAM7InterpolatingFilterFails(const IntSize& aSize) {
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(bool(decoder));
 
   AssertConfiguringPipelineFails(
       decoder, ADAM7InterpolatingConfig{},
-      SurfaceConfig{decoder, aSize, SurfaceFormat::B8G8R8A8, false});
+      SurfaceConfig{decoder, aSize, SurfaceFormat::OS_RGBA, false});
 }
 
 uint8_t InterpolateByte(uint8_t aByteA, uint8_t aByteB, float aWeight) {
   return uint8_t(aByteA * aWeight + aByteB * (1.0f - aWeight));
 }
 
 BGRAColor InterpolateColors(BGRAColor aColor1, BGRAColor aColor2,
                             float aWeight) {
--- a/image/test/gtest/TestAnimationFrameBuffer.cpp
+++ b/image/test/gtest/TestAnimationFrameBuffer.cpp
@@ -13,17 +13,17 @@ using namespace mozilla::image;
 
 static already_AddRefed<imgFrame> CreateEmptyFrame(
     const IntSize& aSize = IntSize(1, 1),
     const IntRect& aFrameRect = IntRect(0, 0, 1, 1), bool aCanRecycle = true) {
   RefPtr<imgFrame> frame = new imgFrame();
   AnimationParams animParams{aFrameRect, FrameTimeout::Forever(),
                              /* aFrameNum */ 1, BlendMethod::OVER,
                              DisposalMethod::NOT_SPECIFIED};
-  nsresult rv = frame->InitForDecoder(aSize, SurfaceFormat::B8G8R8A8, false,
+  nsresult rv = frame->InitForDecoder(aSize, SurfaceFormat::OS_RGBA, false,
                                       Some(animParams), aCanRecycle);
   EXPECT_TRUE(NS_SUCCEEDED(rv));
   RawAccessFrameRef frameRef = frame->RawAccessRef();
   frame->SetRawAccessOnly();
   // Normally the blend animation filter would set the dirty rect, but since
   // we aren't producing an actual animation here, we need to fake it.
   frame->SetDirtyRect(aFrameRect);
   frame->Finish();
--- a/image/test/gtest/TestBlendAnimationFilter.cpp
+++ b/image/test/gtest/TestBlendAnimationFilter.cpp
@@ -35,17 +35,17 @@ RawAccessFrameRef WithBlendAnimationFilt
                                            Func aFunc) {
   DecoderTestHelper decoderHelper(aDecoder);
 
   if (!aDecoder->HasAnimation()) {
     decoderHelper.PostIsAnimated(aAnimParams.mTimeout);
   }
 
   BlendAnimationConfig blendAnim{aDecoder};
-  SurfaceConfig surfaceSink{aDecoder, aOutputSize, SurfaceFormat::B8G8R8A8,
+  SurfaceConfig surfaceSink{aDecoder, aOutputSize, SurfaceFormat::OS_RGBA,
                             false, Some(aAnimParams)};
 
   auto func = [&](Decoder* aDecoder, SurfaceFilter* aFilter) {
     aFunc(aDecoder, aFilter);
   };
 
   WithFilterPipeline(aDecoder, func, false, blendAnim, surfaceSink);
 
@@ -60,18 +60,18 @@ RawAccessFrameRef WithBlendAnimationFilt
 void AssertConfiguringBlendAnimationFilterFails(const IntRect& aFrameRect,
                                                 const IntSize& aOutputSize) {
   RefPtr<Decoder> decoder = CreateTrivialBlendingDecoder();
   ASSERT_TRUE(decoder != nullptr);
 
   AnimationParams animParams{aFrameRect, FrameTimeout::FromRawMilliseconds(0),
                              0, BlendMethod::SOURCE, DisposalMethod::KEEP};
   BlendAnimationConfig blendAnim{decoder};
-  SurfaceConfig surfaceSink{decoder, aOutputSize, SurfaceFormat::B8G8R8A8,
-                            false, Some(animParams)};
+  SurfaceConfig surfaceSink{decoder, aOutputSize, SurfaceFormat::OS_RGBA, false,
+                            Some(animParams)};
   AssertConfiguringPipelineFails(decoder, blendAnim, surfaceSink);
 }
 
 TEST(ImageBlendAnimationFilter, BlendFailsForNegativeFrameRect)
 {
   // A negative frame rect size is disallowed.
   AssertConfiguringBlendAnimationFilterFails(
       IntRect(IntPoint(0, 0), IntSize(-1, -1)), IntSize(100, 100));
--- a/image/test/gtest/TestDecodeToSurface.cpp
+++ b/image/test/gtest/TestDecodeToSurface.cpp
@@ -52,18 +52,18 @@ class DecodeToSurfaceRunnable : public R
     } else {
       mSurface = ImageOps::DecodeToSurface(
           mInputStream.forget(), nsDependentCString(mTestCase.mMimeType),
           imgIContainer::DECODE_FLAGS_DEFAULT, outputSize);
     }
     ASSERT_TRUE(mSurface != nullptr);
 
     EXPECT_TRUE(mSurface->IsDataSourceSurface());
-    EXPECT_TRUE(mSurface->GetFormat() == SurfaceFormat::B8G8R8X8 ||
-                mSurface->GetFormat() == SurfaceFormat::B8G8R8A8);
+    EXPECT_TRUE(mSurface->GetFormat() == SurfaceFormat::OS_RGBX ||
+                mSurface->GetFormat() == SurfaceFormat::OS_RGBA);
 
     if (outputSize) {
       EXPECT_EQ(*outputSize, mSurface->GetSize());
     } else {
       EXPECT_EQ(mTestCase.mSize, mSurface->GetSize());
     }
 
     EXPECT_TRUE(IsSolidColor(mSurface, BGRAColor::Green(),
--- a/image/test/gtest/TestDecoders.cpp
+++ b/image/test/gtest/TestDecoders.cpp
@@ -65,18 +65,18 @@ static already_AddRefed<SourceSurface> C
 
   // Get the current frame, which is always the first frame of the image
   // because CreateAnonymousDecoder() forces a first-frame-only decode.
   RawAccessFrameRef currentFrame = aDecoder->GetCurrentFrameRef();
   RefPtr<SourceSurface> surface = currentFrame->GetSourceSurface();
 
   // Verify that the resulting surfaces matches our expectations.
   EXPECT_TRUE(surface->IsDataSourceSurface());
-  EXPECT_TRUE(surface->GetFormat() == SurfaceFormat::B8G8R8X8 ||
-              surface->GetFormat() == SurfaceFormat::B8G8R8A8);
+  EXPECT_TRUE(surface->GetFormat() == SurfaceFormat::OS_RGBX ||
+              surface->GetFormat() == SurfaceFormat::OS_RGBA);
   EXPECT_EQ(aTestCase.mOutputSize, surface->GetSize());
 
   return surface.forget();
 }
 
 static void CheckDecoderResults(const ImageTestCase& aTestCase,
                                 Decoder* aDecoder) {
   RefPtr<SourceSurface> surface = CheckDecoderState(aTestCase, aDecoder);
@@ -291,18 +291,18 @@ static void CheckAnimationDecoderResults
     EXPECT_TRUE(NS_SUCCEEDED(rv));
 
     // Check the first frame, all green.
     RawAccessFrameRef rawFrame = drawableSurface->RawAccessRef();
     RefPtr<SourceSurface> surface = rawFrame->GetSourceSurface();
 
     // Verify that the resulting surfaces matches our expectations.
     EXPECT_TRUE(surface->IsDataSourceSurface());
-    EXPECT_TRUE(surface->GetFormat() == SurfaceFormat::B8G8R8X8 ||
-                surface->GetFormat() == SurfaceFormat::B8G8R8A8);
+    EXPECT_TRUE(surface->GetFormat() == SurfaceFormat::OS_RGBX ||
+                surface->GetFormat() == SurfaceFormat::OS_RGBA);
     EXPECT_EQ(aTestCase.mOutputSize, surface->GetSize());
     EXPECT_TRUE(IsSolidColor(surface, framePixels[i],
                              aTestCase.mFlags & TEST_CASE_IS_FUZZY ? 1 : 0));
   }
 
   // Should be no more frames.
   nsresult rv = drawableSurface.Seek(framePixels.Length());
   EXPECT_TRUE(NS_FAILED(rv));
--- a/image/test/gtest/TestDecodersPerf.cpp
+++ b/image/test/gtest/TestDecodersPerf.cpp
@@ -49,18 +49,18 @@ static void CheckDecoderState(const Imag
 
   // Get the current frame, which is always the first frame of the image
   // because CreateAnonymousDecoder() forces a first-frame-only decode.
   RawAccessFrameRef currentFrame = aDecoder->GetCurrentFrameRef();
   RefPtr<SourceSurface> surface = currentFrame->GetSourceSurface();
 
   // Verify that the resulting surfaces matches our expectations.
   EXPECT_TRUE(surface->IsDataSourceSurface());
-  EXPECT_TRUE(surface->GetFormat() == SurfaceFormat::B8G8R8X8 ||
-              surface->GetFormat() == SurfaceFormat::B8G8R8A8);
+  EXPECT_TRUE(surface->GetFormat() == SurfaceFormat::OS_RGBX ||
+              surface->GetFormat() == SurfaceFormat::OS_RGBA);
   EXPECT_EQ(aOutputSize, surface->GetSize());
 }
 
 template <typename Func>
 static void WithSingleChunkDecode(const ImageTestCase& aTestCase,
                                   SourceBuffer* aSourceBuffer,
                                   const Maybe<IntSize>& aOutputSize,
                                   Func aResultChecker) {
--- a/image/test/gtest/TestDeinterlacingFilter.cpp
+++ b/image/test/gtest/TestDeinterlacingFilter.cpp
@@ -22,26 +22,26 @@ template <typename Func>
 void WithDeinterlacingFilter(const IntSize& aSize, bool aProgressiveDisplay,
                              Func aFunc) {
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(bool(decoder));
 
   WithFilterPipeline(
       decoder, std::forward<Func>(aFunc),
       DeinterlacingConfig<uint32_t>{aProgressiveDisplay},
-      SurfaceConfig{decoder, aSize, SurfaceFormat::B8G8R8A8, false});
+      SurfaceConfig{decoder, aSize, SurfaceFormat::OS_RGBA, false});
 }
 
 void AssertConfiguringDeinterlacingFilterFails(const IntSize& aSize) {
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(decoder != nullptr);
 
   AssertConfiguringPipelineFails(
       decoder, DeinterlacingConfig<uint32_t>{/* mProgressiveDisplay = */ true},
-      SurfaceConfig{decoder, aSize, SurfaceFormat::B8G8R8A8, false});
+      SurfaceConfig{decoder, aSize, SurfaceFormat::OS_RGBA, false});
 }
 
 class ImageDeinterlacingFilter : public ::testing::Test {
  protected:
   AutoInitializeImageLib mInit;
 };
 
 TEST_F(ImageDeinterlacingFilter, WritePixels100_100) {
--- a/image/test/gtest/TestDownscalingFilter.cpp
+++ b/image/test/gtest/TestDownscalingFilter.cpp
@@ -21,28 +21,28 @@ using namespace mozilla::image;
 template <typename Func>
 void WithDownscalingFilter(const IntSize& aInputSize,
                            const IntSize& aOutputSize, Func aFunc) {
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(decoder != nullptr);
 
   WithFilterPipeline(
       decoder, std::forward<Func>(aFunc),
-      DownscalingConfig{aInputSize, SurfaceFormat::B8G8R8A8},
-      SurfaceConfig{decoder, aOutputSize, SurfaceFormat::B8G8R8A8, false});
+      DownscalingConfig{aInputSize, SurfaceFormat::OS_RGBA},
+      SurfaceConfig{decoder, aOutputSize, SurfaceFormat::OS_RGBA, false});
 }
 
 void AssertConfiguringDownscalingFilterFails(const IntSize& aInputSize,
                                              const IntSize& aOutputSize) {
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(decoder != nullptr);
 
   AssertConfiguringPipelineFails(
-      decoder, DownscalingConfig{aInputSize, SurfaceFormat::B8G8R8A8},
-      SurfaceConfig{decoder, aOutputSize, SurfaceFormat::B8G8R8A8, false});
+      decoder, DownscalingConfig{aInputSize, SurfaceFormat::OS_RGBA},
+      SurfaceConfig{decoder, aOutputSize, SurfaceFormat::OS_RGBA, false});
 }
 
 TEST(ImageDownscalingFilter, WritePixels100_100to99_99)
 {
   WithDownscalingFilter(IntSize(100, 100), IntSize(99, 99),
                         [](Decoder* aDecoder, SurfaceFilter* aFilter) {
                           CheckWritePixels(
                               aDecoder, aFilter,
--- a/image/test/gtest/TestDownscalingFilterNoSkia.cpp
+++ b/image/test/gtest/TestDownscalingFilterNoSkia.cpp
@@ -45,11 +45,11 @@ using namespace mozilla::image;
 
 TEST(ImageDownscalingFilter, NoSkia)
 {
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(bool(decoder));
 
   // Configuring a DownscalingFilter should fail without Skia.
   AssertConfiguringPipelineFails(
-      decoder, DownscalingConfig{IntSize(100, 100), SurfaceFormat::B8G8R8A8},
-      SurfaceConfig{decoder, IntSize(50, 50), SurfaceFormat::B8G8R8A8, false});
+      decoder, DownscalingConfig{IntSize(100, 100), SurfaceFormat::OS_RGBA},
+      SurfaceConfig{decoder, IntSize(50, 50), SurfaceFormat::OS_RGBA, false});
 }
--- a/image/test/gtest/TestRemoveFrameRectFilter.cpp
+++ b/image/test/gtest/TestRemoveFrameRectFilter.cpp
@@ -21,27 +21,27 @@ using namespace mozilla::image;
 template <typename Func>
 void WithRemoveFrameRectFilter(const IntSize& aSize, const IntRect& aFrameRect,
                                Func aFunc) {
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(decoder != nullptr);
 
   WithFilterPipeline(
       decoder, std::forward<Func>(aFunc), RemoveFrameRectConfig{aFrameRect},
-      SurfaceConfig{decoder, aSize, SurfaceFormat::B8G8R8A8, false});
+      SurfaceConfig{decoder, aSize, SurfaceFormat::OS_RGBA, false});
 }
 
 void AssertConfiguringRemoveFrameRectFilterFails(const IntSize& aSize,
                                                  const IntRect& aFrameRect) {
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(decoder != nullptr);
 
   AssertConfiguringPipelineFails(
       decoder, RemoveFrameRectConfig{aFrameRect},
-      SurfaceConfig{decoder, aSize, SurfaceFormat::B8G8R8A8, false});
+      SurfaceConfig{decoder, aSize, SurfaceFormat::OS_RGBA, false});
 }
 
 TEST(ImageRemoveFrameRectFilter, WritePixels100_100_to_0_0_100_100)
 {
   WithRemoveFrameRectFilter(
       IntSize(100, 100), IntRect(0, 0, 100, 100),
       [](Decoder* aDecoder, SurfaceFilter* aFilter) {
         CheckWritePixels(aDecoder, aFilter,
--- a/image/test/gtest/TestSurfacePipeIntegration.cpp
+++ b/image/test/gtest/TestSurfacePipeIntegration.cpp
@@ -92,18 +92,18 @@ TEST_F(ImageSurfacePipeIntegration, Surf
   // Test that SurfacePipe objects can be move assigned.
   pipe = TestSurfacePipeFactory::SimpleSurfacePipe();
 
   // Test that SurfacePipe objects can be initialized with a pipeline.
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(decoder != nullptr);
 
   auto sink = MakeUnique<SurfaceSink>();
-  nsresult rv = sink->Configure(SurfaceConfig{decoder, IntSize(100, 100),
-                                              SurfaceFormat::B8G8R8A8, false});
+  nsresult rv = sink->Configure(
+      SurfaceConfig{decoder, IntSize(100, 100), SurfaceFormat::OS_RGBA, false});
   ASSERT_TRUE(NS_SUCCEEDED(rv));
 
   pipe = TestSurfacePipeFactory::SurfacePipeFromPipeline(sink);
 
   // Test that WritePixels() gets passed through to the underlying pipeline.
   {
     uint32_t count = 0;
     auto result = pipe.WritePixels<uint32_t>([&]() {
@@ -191,18 +191,18 @@ TEST_F(ImageSurfacePipeIntegration, Dein
   auto test = [](Decoder* aDecoder, SurfaceFilter* aFilter) {
     CheckWritePixels(aDecoder, aFilter,
                      /* aOutputRect = */ Some(IntRect(0, 0, 25, 25)));
   };
 
   WithFilterPipeline(
       decoder, test,
       DeinterlacingConfig<uint32_t>{/* mProgressiveDisplay = */ true},
-      DownscalingConfig{IntSize(100, 100), SurfaceFormat::B8G8R8A8},
-      SurfaceConfig{decoder, IntSize(25, 25), SurfaceFormat::B8G8R8A8, false});
+      DownscalingConfig{IntSize(100, 100), SurfaceFormat::OS_RGBA},
+      SurfaceConfig{decoder, IntSize(25, 25), SurfaceFormat::OS_RGBA, false});
 }
 
 TEST_F(ImageSurfacePipeIntegration,
        RemoveFrameRectBottomRightDownscaleWritePixels) {
   // This test case uses a frame rect that extends beyond the borders of the
   // image to the bottom and to the right. It looks roughly like this (with the
   // box made of '#'s representing the frame rect):
   //
@@ -246,18 +246,18 @@ TEST_F(ImageSurfacePipeIntegration,
                      /* aInputRect = */ Some(IntRect(0, 0, 100, 100)),
                      /* aInputWriteRect = */ Some(IntRect(50, 50, 100, 50)),
                      /* aOutputWriteRect = */ Some(IntRect(10, 10, 10, 10)),
                      /* aFuzz = */ 0x33);
   };
 
   WithFilterPipeline(
       decoder, test, RemoveFrameRectConfig{IntRect(50, 50, 100, 100)},
-      DownscalingConfig{IntSize(100, 100), SurfaceFormat::B8G8R8A8},
-      SurfaceConfig{decoder, IntSize(20, 20), SurfaceFormat::B8G8R8A8, false});
+      DownscalingConfig{IntSize(100, 100), SurfaceFormat::OS_RGBA},
+      SurfaceConfig{decoder, IntSize(20, 20), SurfaceFormat::OS_RGBA, false});
 }
 
 TEST_F(ImageSurfacePipeIntegration,
        RemoveFrameRectTopLeftDownscaleWritePixels) {
   // This test case uses a frame rect that extends beyond the borders of the
   // image to the top and to the left. It looks roughly like this (with the
   // box made of '#'s representing the frame rect):
   //
@@ -278,18 +278,18 @@ TEST_F(ImageSurfacePipeIntegration,
                      /* aInputRect = */ Some(IntRect(0, 0, 100, 100)),
                      /* aInputWriteRect = */ Some(IntRect(0, 0, 100, 100)),
                      /* aOutputWriteRect = */ Some(IntRect(0, 0, 10, 10)),
                      /* aFuzz = */ 0x21);
   };
 
   WithFilterPipeline(
       decoder, test, RemoveFrameRectConfig{IntRect(-50, -50, 100, 100)},
-      DownscalingConfig{IntSize(100, 100), SurfaceFormat::B8G8R8A8},
-      SurfaceConfig{decoder, IntSize(20, 20), SurfaceFormat::B8G8R8A8, false});
+      DownscalingConfig{IntSize(100, 100), SurfaceFormat::OS_RGBA},
+      SurfaceConfig{decoder, IntSize(20, 20), SurfaceFormat::OS_RGBA, false});
 }
 
 TEST_F(ImageSurfacePipeIntegration, DeinterlaceRemoveFrameRectWritePixels) {
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(decoder != nullptr);
 
   // Note that aInputRect is the full 100x100 size even though
   // RemoveFrameRectFilter is part of this pipeline, because deinterlacing
@@ -302,18 +302,17 @@ TEST_F(ImageSurfacePipeIntegration, Dein
                      /* aInputWriteRect = */ Some(IntRect(50, 50, 100, 100)),
                      /* aOutputWriteRect = */ Some(IntRect(50, 50, 50, 50)));
   };
 
   WithFilterPipeline(
       decoder, test,
       DeinterlacingConfig<uint32_t>{/* mProgressiveDisplay = */ true},
       RemoveFrameRectConfig{IntRect(50, 50, 100, 100)},
-      SurfaceConfig{decoder, IntSize(100, 100), SurfaceFormat::B8G8R8A8,
-                    false});
+      SurfaceConfig{decoder, IntSize(100, 100), SurfaceFormat::OS_RGBA, false});
 }
 
 TEST_F(ImageSurfacePipeIntegration,
        DeinterlaceRemoveFrameRectDownscaleWritePixels) {
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(decoder != nullptr);
 
   auto test = [](Decoder* aDecoder, SurfaceFilter* aFilter) {
@@ -324,28 +323,27 @@ TEST_F(ImageSurfacePipeIntegration,
                      /* aOutputWriteRect = */ Some(IntRect(10, 10, 10, 10)),
                      /* aFuzz = */ 33);
   };
 
   WithFilterPipeline(
       decoder, test,
       DeinterlacingConfig<uint32_t>{/* mProgressiveDisplay = */ true},
       RemoveFrameRectConfig{IntRect(50, 50, 100, 100)},
-      DownscalingConfig{IntSize(100, 100), SurfaceFormat::B8G8R8A8},
-      SurfaceConfig{decoder, IntSize(20, 20), SurfaceFormat::B8G8R8A8, false});
+      DownscalingConfig{IntSize(100, 100), SurfaceFormat::OS_RGBA},
+      SurfaceConfig{decoder, IntSize(20, 20), SurfaceFormat::OS_RGBA, false});
 }
 
 TEST_F(ImageSurfacePipeIntegration, ConfiguringHugeDeinterlacingBufferFails) {
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(decoder != nullptr);
 
   // When DownscalingFilter is used, we may succeed in allocating an output
   // surface for huge images, because we only need to store the scaled-down
   // version of the image. However, regardless of downscaling,
   // DeinterlacingFilter needs to allocate a buffer as large as the size of the
   // input. This can cause OOMs on operating systems that allow overcommit. This
   // test makes sure that we reject such allocations.
   AssertConfiguringPipelineFails(
       decoder, DeinterlacingConfig<uint32_t>{/* mProgressiveDisplay = */ true},
-      DownscalingConfig{IntSize(60000, 60000), SurfaceFormat::B8G8R8A8},
-      SurfaceConfig{decoder, IntSize(600, 600), SurfaceFormat::B8G8R8A8,
-                    false});
+      DownscalingConfig{IntSize(60000, 60000), SurfaceFormat::OS_RGBA},
+      SurfaceConfig{decoder, IntSize(600, 600), SurfaceFormat::OS_RGBA, false});
 }
--- a/image/test/gtest/TestSurfaceSink.cpp
+++ b/image/test/gtest/TestSurfaceSink.cpp
@@ -38,17 +38,17 @@ template <Orient Orientation, typename F
 void WithSurfaceSink(Func aFunc) {
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(decoder != nullptr);
 
   const bool flipVertically = Orientation == Orient::FLIP_VERTICALLY;
 
   WithFilterPipeline(decoder, std::forward<Func>(aFunc),
                      SurfaceConfig{decoder, IntSize(100, 100),
-                                   SurfaceFormat::B8G8R8A8, flipVertically});
+                                   SurfaceFormat::OS_RGBA, flipVertically});
 }
 
 void ResetForNextPass(SurfaceFilter* aSink) {
   aSink->ResetToFirstRow();
   EXPECT_FALSE(aSink->IsSurfaceFinished());
   Maybe<SurfaceInvalidRect> invalidRect = aSink->TakeInvalidRect();
   EXPECT_TRUE(invalidRect.isNothing());
 }
index 19785f5dcb84a0a3f1fd541f0de8ef9f3e8b4076..0ec91398663658a419d0cca1533b284e4b52e036
GIT binary patch
literal 40005
zc%1FpK?wjb3<SY@S7-cNNKF(<!mx~stxD38BuSDaNs=T<k|arzBrPZn0000000000
k0P{(bBuSDaNs=T<k|arzw4vWW9smFU00000002C2F6GA8HUIzs
index c74e62fee5f8638a051fea2806a55f2ceb402ed9..99772bada06081066c64fb962af0d1a8872d89af
GIT binary patch
literal 40004
zc%1FRF%19!2m`PMt@CdIE?hKiJIMk700000000000000000000000000000000000
O00000000000Pg_2xYsTK