Bug 1274057 (Part 2) - Add a regression test. r=njn
authorSeth Fowler <mark.seth.fowler@gmail.com>
Thu, 26 May 2016 00:19:05 -0700
changeset 340166 6725f1c8401b88e00bdf3a3ba7929bb377dfbe13
parent 340165 095bfc5ca5e7df28e00943a9f1c0cf25998db101
child 340167 3790e961ef61eeafff0e264fc961318e817a48b7
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1274057
milestone49.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 1274057 (Part 2) - Add a regression test. r=njn
image/test/gtest/TestDeinterlacingFilter.cpp
--- a/image/test/gtest/TestDeinterlacingFilter.cpp
+++ b/image/test/gtest/TestDeinterlacingFilter.cpp
@@ -190,28 +190,138 @@ TEST(ImageDeinterlacingFilter, PalettedW
 TEST(ImageDeinterlacingFilter, PalettedWriteRows)
 {
   WithPalettedDeinterlacingFilter(IntSize(100, 100),
                                   [](Decoder* aDecoder, SurfaceFilter* aFilter) {
     CheckPalettedWriteRows(aDecoder, aFilter);
   });
 }
 
+TEST(ImageDeinterlacingFilter, WritePixelsNonProgressiveOutput51_52)
+{
+  WithDeinterlacingFilter(IntSize(51, 52), /* aProgressiveDisplay = */ false,
+                          [](Decoder* aDecoder, SurfaceFilter* aFilter) {
+    // Fill the image. The output should be green for even rows and red for odd
+    // rows but we need to write the rows in the order that the deinterlacer
+    // expects them.
+    uint32_t count = 0;
+    auto result = aFilter->WritePixels<uint32_t>([&]() {
+      uint32_t row = count / 51;  // Integer division.
+      ++count;
+
+      // Note that we use a switch statement here, even though it's quite
+      // verbose, because it's useful to have the mappings between input and
+      // output rows available when debugging these tests.
+
+      switch (row) {
+        // First pass. Output rows are positioned at 8n + 0.
+        case 0:  // Output row 0.
+        case 1:  // Output row 8.
+        case 2:  // Output row 16.
+        case 3:  // Output row 24.
+        case 4:  // Output row 32.
+        case 5:  // Output row 40.
+        case 6:  // Output row 48.
+          return AsVariant(BGRAColor::Green().AsPixel());
+
+        // Second pass. Rows are positioned at 8n + 4.
+        case 7:   // Output row 4.
+        case 8:   // Output row 12.
+        case 9:   // Output row 20.
+        case 10:  // Output row 28.
+        case 11:  // Output row 36.
+        case 12:  // Output row 44.
+          return AsVariant(BGRAColor::Green().AsPixel());
+
+        // Third pass. Rows are positioned at 4n + 2.
+        case 13:  // Output row 2.
+        case 14:  // Output row 6.
+        case 15:  // Output row 10.
+        case 16:  // Output row 14.
+        case 17:  // Output row 18.
+        case 18:  // Output row 22.
+        case 19:  // Output row 26.
+        case 20:  // Output row 30.
+        case 21:  // Output row 34.
+        case 22:  // Output row 38.
+        case 23:  // Output row 42.
+        case 24:  // Output row 46.
+        case 25:  // Output row 50.
+          return AsVariant(BGRAColor::Green().AsPixel());
+
+        // Fourth pass. Rows are positioned at 2n + 1.
+        case 26:  // Output row 1.
+        case 27:  // Output row 3.
+        case 28:  // Output row 5.
+        case 29:  // Output row 7.
+        case 30:  // Output row 9.
+        case 31:  // Output row 11.
+        case 32:  // Output row 13.
+        case 33:  // Output row 15.
+        case 34:  // Output row 17.
+        case 35:  // Output row 19.
+        case 36:  // Output row 21.
+        case 37:  // Output row 23.
+        case 38:  // Output row 25.
+        case 39:  // Output row 27.
+        case 40:  // Output row 29.
+        case 41:  // Output row 31.
+        case 42:  // Output row 33.
+        case 43:  // Output row 35.
+        case 44:  // Output row 37.
+        case 45:  // Output row 39.
+        case 46:  // Output row 41.
+        case 47:  // Output row 43.
+        case 48:  // Output row 45.
+        case 49:  // Output row 47.
+        case 50:  // Output row 49.
+        case 51:  // Output row 51.
+          return AsVariant(BGRAColor::Red().AsPixel());
+
+        default:
+          MOZ_ASSERT_UNREACHABLE("Unexpected row");
+          return AsVariant(BGRAColor::Transparent().AsPixel());
+      }
+    });
+    EXPECT_EQ(WriteState::FINISHED, result);
+    EXPECT_EQ(51u * 52u, count);
+
+    AssertCorrectPipelineFinalState(aFilter,
+                                    IntRect(0, 0, 51, 52),
+                                    IntRect(0, 0, 51, 52));
+
+    // Check that the generated image is correct. As mentioned above, we expect
+    // even rows to be green and odd rows to be red.
+    RawAccessFrameRef currentFrame = aDecoder->GetCurrentFrameRef();
+    RefPtr<SourceSurface> surface = currentFrame->GetSurface();
+
+    for (uint32_t row = 0; row < 52; ++row) {
+      EXPECT_TRUE(RowsAreSolidColor(surface, row, 1,
+                                    row % 2 == 0 ? BGRAColor::Green()
+                                                 : BGRAColor::Red()));
+    }
+  });
+}
+
 TEST(ImageDeinterlacingFilter, WritePixelsOutput20_20)
 {
   WithDeinterlacingFilter(IntSize(20, 20), /* aProgressiveDisplay = */ true,
                           [](Decoder* aDecoder, SurfaceFilter* aFilter) {
     // Fill the image. The output should be green for even rows and red for odd
     // rows but we need to write the rows in the order that the deinterlacer
     // expects them.
     uint32_t count = 0;
     auto result = aFilter->WritePixels<uint32_t>([&]() {
       uint32_t row = count / 20;  // Integer division.
       ++count;
 
+      // Note that we use a switch statement here, even though it's quite
+      // verbose, because it's useful to have the mappings between input and
+      // output rows available when debugging these tests.
+
       switch (row) {
         // First pass. Output rows are positioned at 8n + 0.
         case 0:  // Output row 0.
         case 1:  // Output row 8.
         case 2:  // Output row 16.
           return AsVariant(BGRAColor::Green().AsPixel());
 
         // Second pass. Rows are positioned at 8n + 4.
@@ -271,16 +381,17 @@ TEST(ImageDeinterlacingFilter, WriteRows
                           [](Decoder* aDecoder, SurfaceFilter* aFilter) {
     // Fill the image. The output should be a repeating pattern of two green
     // rows followed by two red rows but we need to write the rows in the order
     // that the deinterlacer expects them.
     uint32_t count = 0;
     uint32_t row = 0;
     auto result = aFilter->WriteRows<uint32_t>([&](uint32_t* aRow, uint32_t aLength) {
       uint32_t color = 0;
+
       switch (row) {
         // First pass. Output rows are positioned at 8n + 0.
         case 0:  // Output row 0.
           color = BGRAColor::Green().AsPixel();
           break;
 
         // Second pass. Rows are positioned at 8n + 4.
         case 1:  // Output row 4.