Bug 1262338 (Part 4) - Add a new test for downscaling combined with a top-left frame rect. r=njn
authorSeth Fowler <mark.seth.fowler@gmail.com>
Wed, 25 May 2016 22:48:29 -0700
changeset 338143 62e88bb12275849e9882e47836466985b349638e
parent 338142 fc7ce4b5807cf02d6132e823439f3bc84904b2df
child 338144 e13e5ddca69f284c514fb46e5225b8f73210e208
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1262338
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 1262338 (Part 4) - Add a new test for downscaling combined with a top-left frame rect. r=njn
image/test/gtest/TestSurfacePipeIntegration.cpp
--- a/image/test/gtest/TestSurfacePipeIntegration.cpp
+++ b/image/test/gtest/TestSurfacePipeIntegration.cpp
@@ -119,18 +119,30 @@ TEST(ImageSurfacePipeIntegration, Deinte
   WithFilterPipeline(decoder, test,
                      DeinterlacingConfig<uint32_t> { /* mProgressiveDisplay = */ true },
                      DownscalingConfig { IntSize(100, 100),
                                          SurfaceFormat::B8G8R8A8 },
                      SurfaceConfig { decoder, 0, IntSize(25, 25),
                                      SurfaceFormat::B8G8R8A8, false });
 }
 
-TEST(ImageSurfacePipeIntegration, RemoveFrameRectDownscaleWritePixels)
+TEST(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):
+  //
+  // +------------+
+  // +            +
+  // +      +------------+
+  // +      +############+
+  // +------+############+
+  //        +############+
+  //        +------------+
+
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(decoder != nullptr);
 
   // Note that aInputWriteRect is 100x50 because RemoveFrameRectFilter ignores
   // trailing rows that don't show up in the output. (Leading rows unfortunately
   // can't be ignored.) So the action of the pipeline is as follows:
   //
   // (1) RemoveFrameRectFilter reads a 100x50 region of the input.
@@ -163,17 +175,17 @@ TEST(ImageSurfacePipeIntegration, Remove
   WithFilterPipeline(decoder, test,
                      RemoveFrameRectConfig { IntRect(50, 50, 100, 100) },
                      DownscalingConfig { IntSize(100, 100),
                                          SurfaceFormat::B8G8R8A8 },
                      SurfaceConfig { decoder, 0, IntSize(20, 20),
                                      SurfaceFormat::B8G8R8A8, false });
 }
 
-TEST(ImageSurfacePipeIntegration, RemoveFrameRectDownscaleWriteRows)
+TEST(ImageSurfacePipeIntegration, RemoveFrameRectBottomRightDownscaleWriteRows)
 {
   RefPtr<Decoder> decoder = CreateTrivialDecoder();
   ASSERT_TRUE(decoder != nullptr);
 
   // See the WritePixels version of this test for a discussion of where the
   // numbers below come from.
 
   auto test = [](Decoder* aDecoder, SurfaceFilter* aFilter) {
@@ -188,16 +200,73 @@ TEST(ImageSurfacePipeIntegration, Remove
   WithFilterPipeline(decoder, test,
                      RemoveFrameRectConfig { IntRect(50, 50, 100, 100) },
                      DownscalingConfig { IntSize(100, 100),
                                          SurfaceFormat::B8G8R8A8 },
                      SurfaceConfig { decoder, 0, IntSize(20, 20),
                                      SurfaceFormat::B8G8R8A8, false });
 }
 
+TEST(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):
+  //
+  // +------------+
+  // +############+
+  // +############+------+
+  // +############+      +
+  // +------------+      +
+  //        +            +
+  //        +------------+
+
+  RefPtr<Decoder> decoder = CreateTrivialDecoder();
+  ASSERT_TRUE(decoder != nullptr);
+
+  auto test = [](Decoder* aDecoder, SurfaceFilter* aFilter) {
+    CheckWritePixels(aDecoder, aFilter,
+                     /* aOutputRect = */ Some(IntRect(0, 0, 20, 20)),
+                     /* 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, 0, IntSize(20, 20),
+                                     SurfaceFormat::B8G8R8A8, false });
+}
+
+TEST(ImageSurfacePipeIntegration, RemoveFrameRectTopLeftDownscaleWriteRows)
+{
+  RefPtr<Decoder> decoder = CreateTrivialDecoder();
+  ASSERT_TRUE(decoder != nullptr);
+
+  auto test = [](Decoder* aDecoder, SurfaceFilter* aFilter) {
+    CheckWriteRows(aDecoder, aFilter,
+                   /* aOutputRect = */ Some(IntRect(0, 0, 20, 20)),
+                   /* 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, 0, IntSize(20, 20),
+                                     SurfaceFormat::B8G8R8A8, false });
+}
+
+
 TEST(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
   // requires reading every row.