Bug 1392143 - P6. Use constants in coordinate calculations. r=mattwoodrow
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 07 Sep 2017 19:36:20 +0200
changeset 379704 9b99855c32cac452f6e6ded85e6b96769f9d6318
parent 379703 0e76e3df87497dd708ea3affc7e7dafb532d71c0
child 379705 5a0fd0db0fb0188b7fe8a0db79138b72f977ebc0
push id32461
push userkwierso@gmail.com
push dateFri, 08 Sep 2017 20:15:32 +0000
treeherdermozilla-central@dd3736e98e4e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1392143
milestone57.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 1392143 - P6. Use constants in coordinate calculations. r=mattwoodrow This shows how the coordinates were actually calculated. and will make it easier should the video size needs to ever be changed again. MozReview-Commit-ID: KkQNqz00Aw0
toolkit/components/gfx/SanityTest.js
--- a/toolkit/components/gfx/SanityTest.js
+++ b/toolkit/components/gfx/SanityTest.js
@@ -13,16 +13,20 @@ const XUL_NS = "http://www.mozilla.org/k
 const FRAME_SCRIPT_URL = "chrome://gfxsanity/content/gfxFrameScript.js";
 
 const PAGE_WIDTH = 160;
 const PAGE_HEIGHT = 234;
 const LEFT_EDGE = 8;
 const TOP_EDGE = 8;
 const CANVAS_WIDTH = 32;
 const CANVAS_HEIGHT = 64;
+// If those values are ever changed, make sure to update
+// WMFVideoMFTManager::CanUseDXVA accordingly.
+const VIDEO_WIDTH = 132;
+const VIDEO_HEIGHT = 132;
 const DRIVER_PREF = "sanity-test.driver-version";
 const DEVICE_PREF = "sanity-test.device-id";
 const VERSION_PREF = "sanity-test.version";
 const ADVANCED_LAYERS_PREF = "sanity-test.advanced-layers";
 const DISABLE_VIDEO_PREF = "media.hardware-video-decoding.failed";
 const RUNNING_PREF = "sanity-test.running";
 const TIMEOUT_SEC = 20;
 
@@ -101,31 +105,29 @@ function takeWindowSnapshot(win, ctx) {
   var flags = ctx.DRAWWINDOW_DRAW_CARET | ctx.DRAWWINDOW_DRAW_VIEW | ctx.DRAWWINDOW_USE_WIDGET_LAYERS;
   ctx.drawWindow(win.ownerGlobal, 0, 0, PAGE_WIDTH, PAGE_HEIGHT, "rgb(255,255,255)", flags);
 }
 
 // Verify that all the 4 coloured squares of the video
 // render as expected (with a tolerance of 64 to allow for
 // yuv->rgb differences between platforms).
 //
-// The video is 132*132, and is split into quadrants of
-// different colours. The top left of the video is 8,72
-// and we test a pixel 33,33 into each quadrant to avoid
+// The video is VIDEO_WIDTH*VIDEO_HEIGHT, and is split into quadrants of
+// different colours. The top left of the video is LEFT_EDGE,TOP_EDGE+CANVAS_HEIGHT
+// and we test a pixel into the middle of each quadrant to avoid
 // blending differences at the edges.
-// If those values are ever changed, make sure to update
-// WMFVideoMFTManager::CanUseDXVA accordingly.
 //
 // We allow massive amounts of fuzz for the colours since
 // it can depend hugely on the yuv -> rgb conversion, and
 // we don't want to fail unnecessarily.
 function verifyVideoRendering(ctx) {
-  return testPixel(ctx, 41, 105, 255, 255, 255, 255, 64) &&
-    testPixel(ctx, 107, 105, 0, 255, 0, 255, 64) &&
-    testPixel(ctx, 41, 171, 0, 0, 255, 255, 64) &&
-    testPixel(ctx, 107, 171, 255, 0, 0, 255, 64);
+  return testPixel(ctx, LEFT_EDGE + VIDEO_WIDTH / 4, TOP_EDGE + CANVAS_HEIGHT + VIDEO_HEIGHT / 4, 255, 255, 255, 255, 64) &&
+    testPixel(ctx, LEFT_EDGE + 3 * VIDEO_WIDTH / 4, TOP_EDGE + CANVAS_HEIGHT + VIDEO_HEIGHT / 4, 0, 255, 0, 255, 64) &&
+    testPixel(ctx, LEFT_EDGE + VIDEO_WIDTH / 4, TOP_EDGE + CANVAS_HEIGHT + 3 * VIDEO_HEIGHT / 4, 0, 0, 255, 255, 64) &&
+    testPixel(ctx, LEFT_EDGE + 3 * VIDEO_WIDTH / 4, TOP_EDGE + CANVAS_HEIGHT + 3 * VIDEO_HEIGHT / 4, 255, 0, 0, 255, 64);
 }
 
 // Verify that the middle of the layers test is the color we expect.
 // It's a red CANVAS_WIDTHxCANVAS_HEIGHT square, test a pixel deep into the
 // square to prevent fuzzing, and another outside the expected limit of the
 // square to check that scaling occurred properly. The square is drawn LEFT_EDGE
 // pixels from the window's left edge and TOP_EDGE from the window's top edge.
 function verifyLayersRendering(ctx) {