Verified Commit bea32e17 authored by Jim Blandy's avatar Jim Blandy Committed by ma1
Browse files

Bug 2045796: Saturate when rounding up pixman trapezoid edges. a=diannaS DONTBUILD

When rounding the edge coordinates of a non-antialised edge upwards,
use saturating addition, just in case the coordinates are close to the
limit of `pixman_fixed_t`'s range.

Original Revision: https://phabricator.services.mozilla.com/D314811

Differential Revision: https://phabricator.services.mozilla.com/D317287
parent 51071b8f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -63,3 +63,5 @@ pixman-export.patch: make sure pixman symbols are not exported in libxul
pixman-interp.patch: use lower quality interpolation by default on mobile

pixman-rename.patch: include pixman-rename.h for renaming of external symbols

pixman-edge-saturate.patch: Saturate when rounding up trapezoid edges
+5 −2
Original line number Diff line number Diff line
@@ -53,10 +53,13 @@ RASTERIZE_EDGES (pixman_image_t *image,
	 * when the sample point lies exactly on the line, we round towards
	 * north-west.
	 *
	 * Use 64 bits to get a saturating add, in case lx or rx are near
	 * the limits of pixman_fixed_t.
	 *
	 * (The AA case does a similar  adjustment in RENDER_SAMPLES_X)
	 */
	lx += X_FRAC_FIRST(1) - pixman_fixed_e;
	rx += X_FRAC_FIRST(1) - pixman_fixed_e;
	lx = (pixman_fixed_t) MIN ((int64_t) lx + (X_FRAC_FIRST(1) - pixman_fixed_e), INT32_MAX);
	rx = (pixman_fixed_t) MIN ((int64_t) rx + (X_FRAC_FIRST(1) - pixman_fixed_e), INT32_MAX);
#endif
	/* clip X */
	if (lx < 0)
+23 −0
Original line number Diff line number Diff line
From: Jim Blandy <jimb@mozilla.com>
Subject: Saturate when rounding up trapezoid edges

diff --git a/gfx/cairo/libpixman/src/pixman-edge-imp.h b/gfx/cairo/libpixman/src/pixman-edge-imp.h
index a4698eddb281..39e8d71d2568 100644
--- a/gfx/cairo/libpixman/src/pixman-edge-imp.h
+++ b/gfx/cairo/libpixman/src/pixman-edge-imp.h
@@ -53,10 +53,13 @@ RASTERIZE_EDGES (pixman_image_t  *image,
 	 * when the sample point lies exactly on the line, we round towards
 	 * north-west.
 	 *
+	 * Use 64 bits to get a saturating add, in case lx or rx are near
+	 * the limits of pixman_fixed_t.
+	 *
 	 * (The AA case does a similar  adjustment in RENDER_SAMPLES_X)
 	 */
-	lx += X_FRAC_FIRST(1) - pixman_fixed_e;
-	rx += X_FRAC_FIRST(1) - pixman_fixed_e;
+	lx = (pixman_fixed_t) MIN ((int64_t) lx + (X_FRAC_FIRST(1) - pixman_fixed_e), INT32_MAX);
+	rx = (pixman_fixed_t) MIN ((int64_t) rx + (X_FRAC_FIRST(1) - pixman_fixed_e), INT32_MAX);
 #endif
 	/* clip X */
 	if (lx < 0)