<div dir="ltr"><div><div><div><div>Please, find enclose the patch to make pixman compatible with stride*height.<br></div>I create a macro #define STRIDE_MULT(stride, height) ((ssize_t)(stride)*(height)) and replace every multiplication.<br>
</div>I also change make_random_bytes (int n_bytes); by make_random_bytes (size_t n_bytes); in utils.c and utils.h<br><br></div>make check of course do not fails for me but I didn't change anything to test when stride*height > 2^31<br>
<br></div>This patch needs review and some tests needs to be add when stride*height > 2^31<div><br>diff --git a/demos/gtk-utils.c b/demos/gtk-utils.c<br>index 32d4aec..f9eee7f 100644<br>--- a/demos/gtk-utils.c<br>+++ b/demos/gtk-utils.c<br>
@@ -83,8 +83,8 @@ pixbuf_from_argb32 (uint32_t *bits,<br> <br> for (i = 0; i < height; ++i)<br> {<br>- uint32_t *src_row = &bits[i * (stride / 4)];<br>- uint32_t *dst_row = p_bits + i * (p_stride / 4);<br>
+ uint32_t *src_row = &bits[STRIDE_MULT (i, stride / 4)];<br>+ uint32_t *dst_row = p_bits + STRIDE_MULT (i, p_stride / 4);<br> <br> a8r8g8b8_to_rgba_np (dst_row, src_row, width);<br> }<br>diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c<br>
index 4f0642d..ce0191c 100644<br>--- a/pixman/pixman-access.c<br>+++ b/pixman/pixman-access.c<br>@@ -164,15 +164,15 @@<br> * YV12 setup and access macros<br> */<br> <br>-#define YV12_SETUP(image) \<br>
- bits_image_t *__bits_image = (bits_image_t *)image; \<br>- uint32_t *bits = __bits_image->bits; \<br>- int stride = __bits_image->rowstride; \<br>
- int offset0 = stride < 0 ? \<br>- ((-stride) >> 1) * ((__bits_image->height - 1) >> 1) - stride : \<br>- stride * __bits_image->height; \<br>
- int offset1 = stride < 0 ? \<br>- offset0 + ((-stride) >> 1) * ((__bits_image->height) >> 1) : \<br>+#define YV12_SETUP(image) \<br>
+ bits_image_t *__bits_image = (bits_image_t *)image; \<br>+ uint32_t *bits = __bits_image->bits; \<br>+ int stride = __bits_image->rowstride; \<br>
+ ssize_t offset0 = stride < 0 ? \<br>+ STRIDE_MULT ((-stride) >> 1, (__bits_image->height - 1) >> 1) - stride : \<br>+ STRIDE_MULT (stride, __bits_image->height); \<br>
+ ssize_t offset1 = stride < 0 ? \<br>+ offset0 + STRIDE_MULT ((-stride) >> 1, (__bits_image->height) >> 1) : \<br> offset0 + (offset0 >> 2)<br>
<br> /* Note no trailing semicolon on the above macro; if it's there, then<br>@@ -182,15 +182,15 @@<br> */<br> <br> #define YV12_Y(line) \<br>- ((uint8_t *) ((bits) + (stride) * (line)))<br>
+ ((uint8_t *) ((bits) + STRIDE_MULT (stride, line)))<br> <br> #define YV12_U(line) \<br> ((uint8_t *) ((bits) + offset1 + \<br>
- ((stride) >> 1) * ((line) >> 1)))<br>+ STRIDE_MULT ((stride) >> 1, (line) >> 1)))<br> <br> #define YV12_V(line) \<br>
((uint8_t *) ((bits) + offset0 + \<br>- ((stride) >> 1) * ((line) >> 1)))<br>+ STRIDE_MULT ((stride) >> 1, (line) >> 1)))<br>
<br> /* Misc. helpers */<br> <br>@@ -415,56 +415,56 @@ convert_and_store_pixel (bits_image_t * image,<br> }<br> }<br> <br>-#define MAKE_ACCESSORS(format) \<br>- static void \<br>
- fetch_scanline_ ## format (bits_image_t *image, \<br>- int x, \<br>- int y, \<br>- int width, \<br>
- uint32_t * buffer, \<br>- const uint32_t *mask) \<br>- { \<br>- uint8_t *bits = \<br>- (uint8_t *)(image->bits + y * image->rowstride); \<br>
- int i; \<br>- \<br>- for (i = 0; i < width; ++i) \<br>- { \<br>- *buffer++ = \<br>
+#define MAKE_ACCESSORS(format) \<br>+ static void \<br>+ fetch_scanline_ ## format (bits_image_t *image, \<br>+ int x, \<br>
+ int y, \<br>+ int width, \<br>+ uint32_t * buffer, \<br>+ const uint32_t *mask) \<br>
+ { \<br>+ uint8_t *bits = \<br>+ (uint8_t *)(image->bits + STRIDE_MULT (y, image->rowstride)); \<br>+ int i; \<br>
+ \<br>+ for (i = 0; i < width; ++i) \<br>+ { \<br>+ *buffer++ = \<br> fetch_and_convert_pixel (image, bits, x + i, PIXMAN_ ## format); \<br>
- } \<br>- } \<br>- \<br>- static void \<br>- store_scanline_ ## format (bits_image_t * image, \<br>
- int x, \<br>- int y, \<br>- int width, \<br>- const uint32_t *values) \<br>
- { \<br>- uint8_t *dest = \<br>- (uint8_t *)(image->bits + y * image->rowstride); \<br>- int i; \<br>
- \<br>- for (i = 0; i < width; ++i) \<br>- { \<br>- convert_and_store_pixel ( \<br>- image, dest, i + x, PIXMAN_ ## format, values[i]); \<br>
- } \<br>- } \<br>- \<br>- static uint32_t \<br>- fetch_pixel_ ## format (bits_image_t *image, \<br>
- int offset, \<br>- int line) \<br>- { \<br>- uint8_t *bits = \<br>- (uint8_t *)(image->bits + line * image->rowstride); \<br>
- \<br>- return fetch_and_convert_pixel ( \<br>- image, bits, offset, PIXMAN_ ## format); \<br>- } \<br>- \<br>
+ } \<br>+ } \<br>+ \<br>+ static void \<br>+ store_scanline_ ## format (bits_image_t * image, \<br>
+ int x, \<br>+ int y, \<br>+ int width, \<br>+ const uint32_t *values) \<br>
+ { \<br>+ uint8_t *dest = \<br>+ (uint8_t *)(image->bits + STRIDE_MULT (y, image->rowstride)); \<br>+ int i; \<br>
+ \<br>+ for (i = 0; i < width; ++i) \<br>+ { \<br>+ convert_and_store_pixel ( \<br>
+ image, dest, i + x, PIXMAN_ ## format, values[i]); \<br>+ } \<br>+ } \<br>+ \<br>
+ static uint32_t \<br>
+ fetch_pixel_ ## format (bits_image_t *image, \<br>+ int offset, \<br>+ int line) \<br>+ { \<br>
+ uint8_t *bits = \<br>+ (uint8_t *)(image->bits + STRIDE_MULT (line, image->rowstride)); \<br>+ \<br>+ return fetch_and_convert_pixel ( \<br>
+ image, bits, offset, PIXMAN_ ## format); \<br>+ } \<br>+ \<br> static const void *const __dummy__ ## format<br>
<br> MAKE_ACCESSORS(a8r8g8b8);<br>@@ -590,7 +590,7 @@ fetch_scanline_a8r8g8b8_sRGB_float (bits_image_t * image,<br> uint32_t * b,<br> const uint32_t *mask)<br> {<br>- const uint32_t *bits = image->bits + y * image->rowstride;<br>
+ const uint32_t *bits = image->bits + STRIDE_MULT (y, image->rowstride);<br> const uint32_t *pixel = bits + x;<br> const uint32_t *end = pixel + width;<br> argb_t *buffer = (argb_t *)b;<br>@@ -619,7 +619,7 @@ fetch_scanline_a2r10g10b10_float (bits_image_t * image,<br>
uint32_t * b,<br> const uint32_t *mask)<br> {<br>- const uint32_t *bits = image->bits + y * image->rowstride;<br>+ const uint32_t *bits = image->bits + STRIDE_MULT (y, image->rowstride);<br>
const uint32_t *pixel = bits + x;<br> const uint32_t *end = pixel + width;<br> argb_t *buffer = (argb_t *)b;<br>@@ -650,7 +650,7 @@ fetch_scanline_x2r10g10b10_float (bits_image_t *image,<br> uint32_t * b,<br>
const uint32_t *mask)<br> {<br>- const uint32_t *bits = image->bits + y * image->rowstride;<br>+ const uint32_t *bits = image->bits + STRIDE_MULT (y, image->rowstride);<br> const uint32_t *pixel = (uint32_t *)bits + x;<br>
const uint32_t *end = pixel + width;<br> argb_t *buffer = (argb_t *)b;<br>@@ -680,7 +680,7 @@ fetch_scanline_a2b10g10r10_float (bits_image_t *image,<br> uint32_t * b,<br> const uint32_t *mask)<br>
{<br>- const uint32_t *bits = image->bits + y * image->rowstride;<br>+ const uint32_t *bits = image->bits + STRIDE_MULT (y, image->rowstride);<br> const uint32_t *pixel = bits + x;<br> const uint32_t *end = pixel + width;<br>
argb_t *buffer = (argb_t *)b;<br>@@ -711,7 +711,7 @@ fetch_scanline_x2b10g10r10_float (bits_image_t *image,<br> uint32_t * b,<br> const uint32_t *mask)<br> {<br>- const uint32_t *bits = image->bits + y * image->rowstride;<br>
+ const uint32_t *bits = image->bits + STRIDE_MULT (y, image->rowstride);<br> const uint32_t *pixel = (uint32_t *)bits + x;<br> const uint32_t *end = pixel + width;<br> argb_t *buffer = (argb_t *)b;<br>
@@ -740,7 +740,7 @@ fetch_scanline_yuy2 (bits_image_t *image,<br> uint32_t * buffer,<br> const uint32_t *mask)<br> {<br>- const uint32_t *bits = image->bits + image->rowstride * line;<br>
+ const uint32_t *bits = image->bits + STRIDE_MULT (image->rowstride, line);<br> int i;<br> <br> for (i = 0; i < width; i++)<br>@@ -810,7 +810,7 @@ fetch_pixel_x2r10g10b10_float (bits_image_t *image,<br>
int offset,<br> int line)<br> {<br>- uint32_t *bits = image->bits + line * image->rowstride;<br>+ uint32_t *bits = image->bits + STRIDE_MULT (line, image->rowstride);<br>
uint32_t p = READ (image, bits + offset);<br> uint64_t r = (p >> 20) & 0x3ff;<br> uint64_t g = (p >> 10) & 0x3ff;<br>@@ -830,7 +830,7 @@ fetch_pixel_a2r10g10b10_float (bits_image_t *image,<br>
int offset,<br> int line)<br> {<br>- uint32_t *bits = image->bits + line * image->rowstride;<br>+ uint32_t *bits = image->bits + STRIDE_MULT (line, image->rowstride);<br>
uint32_t p = READ (image, bits + offset);<br> uint64_t a = p >> 30;<br> uint64_t r = (p >> 20) & 0x3ff;<br>@@ -851,7 +851,7 @@ fetch_pixel_a2b10g10r10_float (bits_image_t *image,<br> int offset,<br>
int line)<br> {<br>- uint32_t *bits = image->bits + line * image->rowstride;<br>+ uint32_t *bits = image->bits + STRIDE_MULT (line, image->rowstride);<br> uint32_t p = READ (image, bits + offset);<br>
uint64_t a = p >> 30;<br> uint64_t b = (p >> 20) & 0x3ff;<br>@@ -872,7 +872,7 @@ fetch_pixel_x2b10g10r10_float (bits_image_t *image,<br> int offset,<br> int line)<br>
{<br>- uint32_t *bits = image->bits + line * image->rowstride;<br>+ uint32_t *bits = image->bits + STRIDE_MULT (line, image->rowstride);<br> uint32_t p = READ (image, bits + offset);<br> uint64_t b = (p >> 20) & 0x3ff;<br>
uint64_t g = (p >> 10) & 0x3ff;<br>@@ -892,7 +892,7 @@ fetch_pixel_a8r8g8b8_sRGB_float (bits_image_t *image,<br> int offset,<br> int line)<br> {<br>- uint32_t *bits = image->bits + line * image->rowstride;<br>
+ uint32_t *bits = image->bits + STRIDE_MULT (line, image->rowstride);<br> uint32_t p = READ (image, bits + offset);<br> argb_t argb;<br> <br>@@ -910,7 +910,7 @@ fetch_pixel_yuy2 (bits_image_t *image,<br>
int offset,<br> int line)<br> {<br>- const uint32_t *bits = image->bits + image->rowstride * line;<br>+ const uint32_t *bits = image->bits + STRIDE_MULT (image->rowstride, line);<br>
<br> int16_t y, u, v;<br> int32_t r, g, b;<br>@@ -969,7 +969,7 @@ store_scanline_a2r10g10b10_float (bits_image_t * image,<br> int width,<br> const uint32_t *v)<br>
{<br>- uint32_t *bits = image->bits + image->rowstride * y;<br>+ uint32_t *bits = image->bits + STRIDE_MULT (image->rowstride, y);<br> uint32_t *pixel = bits + x;<br> argb_t *values = (argb_t *)v;<br>
int i;<br>@@ -995,7 +995,7 @@ store_scanline_x2r10g10b10_float (bits_image_t * image,<br> int width,<br> const uint32_t *v)<br> {<br>- uint32_t *bits = image->bits + image->rowstride * y;<br>
+ uint32_t *bits = image->bits + STRIDE_MULT (image->rowstride, y);<br> uint32_t *pixel = bits + x;<br> argb_t *values = (argb_t *)v;<br> int i;<br>@@ -1020,7 +1020,7 @@ store_scanline_a2b10g10r10_float (bits_image_t * image,<br>
int width,<br> const uint32_t *v)<br> {<br>- uint32_t *bits = image->bits + image->rowstride * y;<br>+ uint32_t *bits = image->bits + STRIDE_MULT (image->rowstride, y);<br>
uint32_t *pixel = bits + x;<br> argb_t *values = (argb_t *)v;<br> int i;<br>@@ -1046,7 +1046,7 @@ store_scanline_x2b10g10r10_float (bits_image_t * image,<br> int width,<br> const uint32_t *v)<br>
{<br>- uint32_t *bits = image->bits + image->rowstride * y;<br>+ uint32_t *bits = image->bits + STRIDE_MULT (image->rowstride, y);<br> uint32_t *pixel = bits + x;<br> argb_t *values = (argb_t *)v;<br>
int i;<br>@@ -1071,7 +1071,7 @@ store_scanline_a8r8g8b8_sRGB_float (bits_image_t * image,<br> int width,<br> const uint32_t *v)<br> {<br>- uint32_t *bits = image->bits + image->rowstride * y;<br>
+ uint32_t *bits = image->bits + STRIDE_MULT (image->rowstride, y);<br> uint32_t *pixel = bits + x;<br> argb_t *values = (argb_t *)v;<br> int i;<br>@@ -1144,7 +1144,7 @@ fetch_scanline_a8r8g8b8_32_sRGB (bits_image_t *image,<br>
uint32_t *buffer,<br> const uint32_t *mask)<br> {<br>- const uint32_t *bits = image->bits + y * image->rowstride;<br>+ const uint32_t *bits = image->bits + STRIDE_MULT (y, image->rowstride);<br>
const uint32_t *pixel = (uint32_t *)bits + x;<br> const uint32_t *end = pixel + width;<br> uint32_t tmp;<br>@@ -1173,7 +1173,7 @@ fetch_pixel_a8r8g8b8_32_sRGB (bits_image_t *image,<br> int offset,<br>
int line)<br> {<br>- uint32_t *bits = image->bits + line * image->rowstride;<br>+ uint32_t *bits = image->bits + STRIDE_MULT (line, image->rowstride);<br> uint32_t tmp = READ (image, bits + offset);<br>
uint8_t a, r, g, b;<br> <br>@@ -1196,7 +1196,7 @@ store_scanline_a8r8g8b8_32_sRGB (bits_image_t *image,<br> int width,<br> const uint32_t *v)<br>
{<br>- uint32_t *bits = image->bits + image->rowstride * y;<br>+ uint32_t *bits = image->bits + STRIDE_MULT (image->rowstride, y);<br> uint64_t *values = (uint64_t *)v;<br> uint32_t *pixel = bits + x;<br>
uint64_t tmp;<br>diff --git a/pixman/pixman-arm-neon.c b/pixman/pixman-arm-neon.c<br>index 60e9c78..4e848a1 100644<br>--- a/pixman/pixman-arm-neon.c<br>+++ b/pixman/pixman-arm-neon.c<br>@@ -202,7 +202,7 @@ arm_neon_fill (pixman_implementation_t *imp,<br>
pixman_composite_src_n_8_asm_neon (<br> width,<br> height,<br>- (uint8_t *)(((char *) bits) + y * byte_stride + x),<br>+ (uint8_t *)(((char *) bits) + STRIDE_MULT (y, byte_stride) + x),<br>
byte_stride,<br> _xor & 0xff);<br> return TRUE;<br>@@ -210,7 +210,7 @@ arm_neon_fill (pixman_implementation_t *imp,<br> pixman_composite_src_n_0565_asm_neon (<br> width,<br> height,<br>
- (uint16_t *)(((char *) bits) + y * byte_stride + x * 2),<br>+ (uint16_t *)(((char *) bits) + STRIDE_MULT (y, byte_stride) + x * 2),<br> byte_stride / 2,<br> _xor & 0xffff);<br> return TRUE;<br>
@@ -218,7 +218,7 @@ arm_neon_fill (pixman_implementation_t *imp,<br> pixman_composite_src_n_8888_asm_neon (<br> width,<br> height,<br>- (uint32_t *)(((char *) bits) + y * byte_stride + x * 4),<br>
+ (uint32_t *)(((char *) bits) + STRIDE_MULT (y, byte_stride) + x * 4),<br> byte_stride / 4,<br> _xor);<br> return TRUE;<br>@@ -251,17 +251,17 @@ arm_neon_blt (pixman_implementation_t *imp,<br>
pixman_composite_src_0565_0565_asm_neon (<br>
width, height,<br> (uint16_t *)(((char *) dst_bits) +<br>- dest_y * dst_stride * 4 + dest_x * 2), dst_stride * 2,<br>+ STRIDE_MULT (dest_y, dst_stride) * 4 + dest_x * 2), dst_stride * 2,<br>
(uint16_t *)(((char *) src_bits) +<br>- src_y * src_stride * 4 + src_x * 2), src_stride * 2);<br>+ STRIDE_MULT (src_y, src_stride) * 4 + src_x * 2), src_stride * 2);<br> return TRUE;<br> case 32:<br>
pixman_composite_src_8888_8888_asm_neon (<br> width, height,<br> (uint32_t *)(((char *) dst_bits) +<br>- dest_y * dst_stride * 4 + dest_x * 4), dst_stride,<br>+ STRIDE_MULT (dest_y, dst_stride) * 4 + dest_x * 4), dst_stride,<br>
(uint32_t *)(((char *) src_bits) +<br>- src_y * src_stride * 4 + src_x * 4), src_stride);<br>+ STRIDE_MULT (src_y, src_stride) * 4 + src_x * 4), src_stride);<br> return TRUE;<br> default:<br>
return FALSE;<br>diff --git a/pixman/pixman-arm-simd.c b/pixman/pixman-arm-simd.c<br>index af062e1..3e06f42 100644<br>--- a/pixman/pixman-arm-simd.c<br>+++ b/pixman/pixman-arm-simd.c<br>@@ -99,7 +99,7 @@ arm_simd_fill (pixman_implementation_t *imp,<br>
pixman_composite_src_n_8_asm_armv6 (<br> width,<br> height,<br>- (uint8_t *)(((char *) bits) + y * byte_stride + x),<br>+ (uint8_t *)(((char *) bits) + STRIDE_MULT (y, byte_stride) + x),<br>
byte_stride,<br> _xor & 0xff);<br> return TRUE;<br>@@ -107,7 +107,7 @@ arm_simd_fill (pixman_implementation_t *imp,<br> pixman_composite_src_n_0565_asm_armv6 (<br> width,<br> height,<br>
- (uint16_t *)(((char *) bits) + y * byte_stride + x * 2),<br>+ (uint16_t *)(((char *) bits) + STRIDE_MULT (y, byte_stride) + x * 2),<br> byte_stride / 2,<br> _xor & 0xffff);<br> return TRUE;<br>
@@ -115,7 +115,7 @@ arm_simd_fill (pixman_implementation_t *imp,<br> pixman_composite_src_n_8888_asm_armv6 (<br> width,<br> height,<br>- (uint32_t *)(((char *) bits) + y * byte_stride + x * 4),<br>
+ (uint32_t *)(((char *) bits) + STRIDE_MULT (y, byte_stride) + x * 4),<br> byte_stride / 4,<br> _xor);<br> return TRUE;<br>@@ -148,25 +148,25 @@ arm_simd_blt (pixman_implementation_t *imp,<br>
pixman_composite_src_8_8_asm_armv6 (<br>
width, height,<br> (uint8_t *)(((char *) dst_bits) +<br>- dest_y * dst_stride * 4 + dest_x * 1), dst_stride * 4,<br>+ STRIDE_MULT (dest_y, dst_stride) * 4 + dest_x * 1), dst_stride * 4,<br>
(uint8_t *)(((char *) src_bits) +<br>- src_y * src_stride * 4 + src_x * 1), src_stride * 4);<br>+ STRIDE_MULT (src_y, src_stride) * 4 + src_x * 1), src_stride * 4);<br> return TRUE;<br>
case 16:<br> pixman_composite_src_0565_0565_asm_armv6 (<br> width, height,<br> (uint16_t *)(((char *) dst_bits) +<br>- dest_y * dst_stride * 4 + dest_x * 2), dst_stride * 2,<br>+ STRIDE_MULT (dest_y, dst_stride) * 4 + dest_x * 2), dst_stride * 2,<br>
(uint16_t *)(((char *) src_bits) +<br>- src_y * src_stride * 4 + src_x * 2), src_stride * 2);<br>+ STRIDE_MULT (src_y, src_stride) * 4 + src_x * 2), src_stride * 2);<br> return TRUE;<br> case 32:<br>
pixman_composite_src_8888_8888_asm_armv6 (<br> width, height,<br> (uint32_t *)(((char *) dst_bits) +<br>- dest_y * dst_stride * 4 + dest_x * 4), dst_stride,<br>+ STRIDE_MULT (dest_y, dst_stride) * 4 + dest_x * 4), dst_stride,<br>
(uint32_t *)(((char *) src_bits) +<br>- src_y * src_stride * 4 + src_x * 4), src_stride);<br>+ STRIDE_MULT (src_y, src_stride) * 4 + src_x * 4), src_stride);<br> return TRUE;<br> default:<br>
return FALSE;<br>diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c<br>index f9121a3..ab0b74e 100644<br>--- a/pixman/pixman-bits-image.c<br>+++ b/pixman/pixman-bits-image.c<br>@@ -926,7 +926,7 @@ create_bits (pixman_format_code_t format,<br>
if (_pixman_multiply_overflows_size (height, stride))<br> return NULL;<br> <br>- buf_size = height * stride;<br>+ buf_size = STRIDE_MULT (height, stride);<br> <br> if (rowstride_bytes)<br> *rowstride_bytes = stride;<br>
diff --git a/pixman/pixman-edge.c b/pixman/pixman-edge.c<br>index ad6dfc4..556247f 100644<br>--- a/pixman/pixman-edge.c<br>+++ b/pixman/pixman-edge.c<br>@@ -167,7 +167,7 @@ rasterize_edges_8 (pixman_image_t *image,<br> int stride = (image)->bits.rowstride;<br>
int width = (image)->bits.width;<br> <br>- line = buf + pixman_fixed_to_int (y) * stride;<br>+ line = buf + STRIDE_MULT (pixman_fixed_to_int (y), stride);<br> <br> for (;;)<br> {<br>diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c<br>
index b06d1b2..5569c7b 100644<br>--- a/pixman/pixman-fast-path.c<br>+++ b/pixman/pixman-fast-path.c<br>@@ -1170,8 +1170,8 @@ fast_composite_src_memcpy (pixman_implementation_t *imp,<br> src_stride = src_image->bits.rowstride * 4;<br>
dst_stride = dest_image->bits.rowstride * 4;<br> <br>- src = (uint8_t *)src_image->bits.bits + src_y * src_stride + src_x * bpp;<br>- dst = (uint8_t *)dest_image->bits.bits + dest_y * dst_stride + dest_x * bpp;<br>
+ src = (uint8_t *)src_image->bits.bits + STRIDE_MULT (src_y, src_stride) + src_x * bpp;<br>+ dst = (uint8_t *)dest_image->bits.bits + STRIDE_MULT (dest_y, dst_stride) + dest_x * bpp;<br> <br> while (height--)<br>
{<br>@@ -1517,7 +1517,7 @@ fast_composite_scaled_nearest (pixman_implementation_t *imp,<br> {<br> int w = width;<br> <br>- uint32_t *src = src_line + y * src_stride;<br>+ uint32_t *src = src_line + STRIDE_MULT (y, src_stride);<br>
<br> while (w >= 2)<br> {<br>@@ -1582,7 +1582,7 @@ blt_rotated_90_trivial_##suffix (pix_type *dst, \<br> for (y = 0; y < h; y++) \<br>
{ \<br> const pix_type *s = src + (h - y - 1); \<br>- pix_type *d = dst + dst_stride * y; \<br>
+ pix_type *d = dst + STRIDE_MULT (dst_stride, y); \<br> for (x = 0; x < w; x++) \<br> { \<br>
*d++ = *s; \<br>@@ -1602,8 +1602,8 @@ blt_rotated_270_trivial_##suffix (pix_type *dst, \<br> int x, y; \<br>
for (y = 0; y < h; y++) \<br> { \<br>- const pix_type *s = src + src_stride * (w - 1) + y; \<br>
- pix_type *d = dst + dst_stride * y; \<br>+ const pix_type *s = src + STRIDE_MULT (src_stride, (w - 1)) + y; \<br>+ pix_type *d = dst + STRIDE_MULT (dst_stride, y); \<br>
for (x = 0; x < w; x++) \<br> { \<br> *d++ = *s; \<br>
@@ -1648,7 +1648,7 @@ blt_rotated_90_##suffix (pix_type *dst, \<br> H); \<br> \<br>
dst += leading_pixels; \<br>- src += leading_pixels * src_stride; \<br>+ src += STRIDE_MULT (leading_pixels, src_stride); \<br>
W -= leading_pixels; \<br> } \<br> \<br>
@@ -1667,7 +1667,7 @@ blt_rotated_90_##suffix (pix_type *dst, \<br> blt_rotated_90_trivial_##suffix ( \<br> dst + x, \<br>
dst_stride, \<br>- src + src_stride * x, \<br>+ src + STRIDE_MULT (src_stride, x), \<br>
src_stride, \<br> TILE_SIZE, \<br> H); \<br>
@@ -1679,7 +1679,7 @@ blt_rotated_90_##suffix (pix_type *dst, \<br> blt_rotated_90_trivial_##suffix ( \<br> dst + W, \<br>
dst_stride, \<br>- src + W * src_stride, \<br>+ src + STRIDE_MULT (W, src_stride), \<br>
src_stride, \<br> trailing_pixels, \<br> H); \<br>
@@ -1716,7 +1716,7 @@ blt_rotated_270_##suffix (pix_type *dst, \<br> blt_rotated_270_trivial_##suffix ( \<br> dst, \<br>
dst_stride, \<br>- src + src_stride * (W - leading_pixels), \<br>+ src + STRIDE_MULT (src_stride, (W - leading_pixels)), \<br>
src_stride, \<br> leading_pixels, \<br> H); \<br>
@@ -1732,7 +1732,7 @@ blt_rotated_270_##suffix (pix_type *dst, \<br> if (trailing_pixels > W) \<br> trailing_pixels = W; \<br>
W -= trailing_pixels; \<br>- src += trailing_pixels * src_stride; \<br>+ src += STRIDE_MULT (trailing_pixels, src_stride); \<br>
} \<br> \<br> for (x = 0; x < W; x += TILE_SIZE) \<br>
@@ -1741,7 +1741,7 @@ blt_rotated_270_##suffix (pix_type *dst, \<br> blt_rotated_270_trivial_##suffix ( \<br> dst + x, \<br>
dst_stride, \<br>- src + src_stride * (W - x - TILE_SIZE), \<br>+ src + STRIDE_MULT (src_stride, (W - x - TILE_SIZE)), \<br>
src_stride, \<br> TILE_SIZE, \<br> H); \<br>
@@ -1753,7 +1753,7 @@ blt_rotated_270_##suffix (pix_type *dst, \<br> blt_rotated_270_trivial_##suffix ( \<br> dst + W, \<br>
dst_stride, \<br>- src - trailing_pixels * src_stride, \<br>+ src - STRIDE_MULT (trailing_pixels, src_stride), \<br>
src_stride, \<br> trailing_pixels, \<br> H); \<br>
@@ -2029,7 +2029,7 @@ pixman_fill1 (uint32_t *bits,<br> int height,<br> uint32_t filler)<br> {<br>- uint32_t *dst = bits + y * stride + (x >> 5);<br>+ uint32_t *dst = bits + STRIDE_MULT (y, stride) + (x >> 5);<br>
int offs = x & 31;<br> <br> if (filler & 1)<br>@@ -2064,7 +2064,7 @@ pixman_fill8 (uint32_t *bits,<br> uint8_t v = filler & 0xff;<br> int i;<br> <br>- dst = dst + y * byte_stride + x;<br>+ dst = dst + STRIDE_MULT (y, byte_stride) + x;<br>
<br> while (height--)<br> {<br>@@ -2090,7 +2090,7 @@ pixman_fill16 (uint32_t *bits,<br> uint16_t v = filler & 0xffff;<br> int i;<br> <br>- dst = dst + y * short_stride + x;<br>+ dst = dst + STRIDE_MULT (y, short_stride) + x;<br>
<br> while (height--)<br> {<br>@@ -2112,7 +2112,7 @@ pixman_fill32 (uint32_t *bits,<br> {<br> int i;<br> <br>- bits = bits + y * stride + x;<br>+ bits = bits + STRIDE_MULT (y, stride) + x;<br> <br> while (height--)<br>
{<br>@@ -2279,7 +2279,7 @@ static void<br> fetch_horizontal (bits_image_t *image, line_t *line,<br> int y, pixman_fixed_t x, pixman_fixed_t ux, int n)<br> {<br>- uint32_t *bits = image->bits + y * image->rowstride;<br>
+ uint32_t *bits = image->bits + STRIDE_MULT (y, image->rowstride);<br> int i;<br> <br> for (i = 0; i < n; ++i)<br>@@ -2543,7 +2543,7 @@ bits_image_fetch_bilinear_no_repeat_8888 (pixman_iter_t *iter,<br>
}<br> else<br> {<br>- top_row = bits->bits + y1 * bits->rowstride;<br>+ top_row = bits->bits + STRIDE_MULT (y1, bits->rowstride);<br> x_top = x;<br> ux_top = ux;<br> }<br>@@ -2556,7 +2556,7 @@ bits_image_fetch_bilinear_no_repeat_8888 (pixman_iter_t *iter,<br>
}<br> else<br> {<br>- bottom_row = bits->bits + y2 * bits->rowstride;<br>+ bottom_row = bits->bits + STRIDE_MULT (y2, bits->rowstride);<br> x_bottom = x;<br> ux_bottom = ux;<br> }<br>
@@ -2798,7 +2798,7 @@ bits_image_fetch_separable_convolution_affine (pixman_image_t * image,<br> repeat (repeat_mode, &rx, bits->width);<br> repeat (repeat_mode, &ry, bits->height);<br>
<br>- row = (uint8_t *)bits->bits + bits->rowstride * 4 * ry;<br>+ row = (uint8_t *)bits->bits + STRIDE_MULT (bits->rowstride * 4, ry);<br> pixel = convert_pixel (row, rx) | mask;<br>
}<br> else<br>@@ -2809,7 +2809,7 @@ bits_image_fetch_separable_convolution_affine (pixman_image_t * image,<br> }<br> else<br> {<br>- row = (uint8_t *)bits->bits + bits->rowstride * 4 * ry;<br>
+ row = (uint8_t *)bits->bits + STRIDE_MULT (bits->rowstride * 4, ry);<br> pixel = convert_pixel (row, rx) | mask;<br> }<br> }<br>@@ -2911,8 +2911,8 @@ bits_image_fetch_bilinear_affine (pixman_image_t * image,<br>
repeat (repeat_mode, &x2, width);<br> repeat (repeat_mode, &y2, height);<br> <br>- row1 = (uint8_t *)bits->bits + bits->rowstride * 4 * y1;<br>- row2 = (uint8_t *)bits->bits + bits->rowstride * 4 * y2;<br>
+ row1 = (uint8_t *)bits->bits + STRIDE_MULT (bits->rowstride * 4, y1);<br>+ row2 = (uint8_t *)bits->bits + STRIDE_MULT (bits->rowstride * 4, y2);<br> <br> tl = convert_pixel (row1, x1) | mask;<br>
tr = convert_pixel (row1, x2) | mask;<br>@@ -2947,7 +2947,7 @@ bits_image_fetch_bilinear_affine (pixman_image_t * image,<br> }<br> else<br> {<br>- row1 = (uint8_t *)bits->bits + bits->rowstride * 4 * y1;<br>
+ row1 = (uint8_t *)bits->bits + STRIDE_MULT (bits->rowstride * 4, y1);<br> row1 += bpp / 8 * x1;<br> <br> mask1 = PIXMAN_FORMAT_A (format)? 0 : 0xff000000;<br>@@ -2960,7 +2960,7 @@ bits_image_fetch_bilinear_affine (pixman_image_t * image,<br>
}<br> else<br> {<br>- row2 = (uint8_t *)bits->bits + bits->rowstride * 4 * y2;<br>+ row2 = (uint8_t *)bits->bits + STRIDE_MULT (bits->rowstride * 4, y2);<br> row2 += bpp / 8 * x1;<br>
<br> mask2 = PIXMAN_FORMAT_A (format)? 0 : 0xff000000;<br>@@ -3058,7 +3058,7 @@ bits_image_fetch_nearest_affine (pixman_image_t * image,<br> repeat (repeat_mode, &y0, height);<br> }<br> <br>- row = (uint8_t *)bits->bits + bits->rowstride * 4 * y0;<br>
+ row = (uint8_t *)bits->bits + STRIDE_MULT (bits->rowstride * 4, y0);<br> <br> buffer[i] = convert_pixel (row, x0) | mask;<br> }<br>diff --git a/pixman/pixman-mips-dspr2.c b/pixman/pixman-mips-dspr2.c<br>
index e10c9df..e6cb379 100644<br>--- a/pixman/pixman-mips-dspr2.c<br>+++ b/pixman/pixman-mips-dspr2.c<br>@@ -180,7 +180,7 @@ mips_dspr2_fill (pixman_implementation_t *imp,<br> {<br> case 16:<br> stride = stride * (int) sizeof (uint32_t) / 2;<br>
- byte_line = (uint8_t *)(((uint16_t *)bits) + stride * y + x);<br>+ byte_line = (uint8_t *)(((uint16_t *)bits) + STRIDE_MULT (stride, y) + x);<br> byte_width = width * 2;<br> stride *= 2;<br>
<br>@@ -193,7 +193,7 @@ mips_dspr2_fill (pixman_implementation_t *imp,<br> return TRUE;<br> case 32:<br> stride = stride * (int) sizeof (uint32_t) / 4;<br>- byte_line = (uint8_t *)(((uint32_t *)bits) + stride * y + x);<br>
+ byte_line = (uint8_t *)(((uint32_t *)bits) + STRIDE_MULT (stride, y) + x);<br> byte_width = width * 4;<br> stride *= 4;<br> <br>@@ -237,9 +237,9 @@ mips_dspr2_blt (pixman_implementation_t *imp,<br>
src_stride = src_stride * (int) sizeof (uint32_t) / 2;<br> dst_stride = dst_stride * (int) sizeof (uint32_t) / 2;<br> src_bytes =(uint8_t *)(((uint16_t *)src_bits)<br>- + src_stride * (src_y) + (src_x));<br>
+ + STRIDE_MULT (src_stride, src_y) + src_x);<br> dst_bytes = (uint8_t *)(((uint16_t *)dst_bits)<br>- + dst_stride * (dest_y) + (dest_x));<br>
+ + STRIDE_MULT (dst_stride, dest_y) + dest_x);<br> byte_width = width * 2;<br> src_stride *= 2;<br> dst_stride *= 2;<br>@@ -257,9 +257,9 @@ mips_dspr2_blt (pixman_implementation_t *imp,<br>
src_stride = src_stride * (int) sizeof (uint32_t) / 4;<br> dst_stride = dst_stride * (int) sizeof (uint32_t) / 4;<br> src_bytes = (uint8_t *)(((uint32_t *)src_bits)<br>- + src_stride * (src_y) + (src_x));<br>
+ + STRIDE_MULT (src_stride, src_y) + src_x);<br> dst_bytes = (uint8_t *)(((uint32_t *)dst_bits)<br>- + dst_stride * (dest_y) + (dest_x));<br>
+ + STRIDE_MULT (dst_stride, dest_y) + dest_x);<br> byte_width = width * 4;<br> src_stride *= 4;<br> dst_stride *= 4;<br>diff --git a/pixman/pixman-mmx.c b/pixman/pixman-mmx.c<br>
index a0f59ef..09ccf35 100644<br>--- a/pixman/pixman-mmx.c<br>+++ b/pixman/pixman-mmx.c<br>@@ -2102,7 +2102,7 @@ mmx_fill (pixman_implementation_t *imp,<br> if (bpp == 8)<br> {<br> stride = stride * (int) sizeof (uint32_t) / 1;<br>
- byte_line = (uint8_t *)(((uint8_t *)bits) + stride * y + x);<br>+ byte_line = (uint8_t *)(((uint8_t *)bits) + STRIDE_MULT (stride, y) + x);<br> byte_width = width;<br> stride *= 1;<br> filler = (filler & 0xff) * 0x01010101;<br>
@@ -2110,7 +2110,7 @@ mmx_fill (pixman_implementation_t *imp,<br> else if (bpp == 16)<br> {<br> stride = stride * (int) sizeof (uint32_t) / 2;<br>- byte_line = (uint8_t *)(((uint16_t *)bits) + stride * y + x);<br>
+ byte_line = (uint8_t *)(((uint16_t *)bits) + STRIDE_MULT (stride, y) + x);<br> byte_width = 2 * width;<br> stride *= 2;<br> filler = (filler & 0xffff) * 0x00010001;<br>@@ -2118,7 +2118,7 @@ mmx_fill (pixman_implementation_t *imp,<br>
else<br> {<br> stride = stride * (int) sizeof (uint32_t) / 4;<br>- byte_line = (uint8_t *)(((uint32_t *)bits) + stride * y + x);<br>+ byte_line = (uint8_t *)(((uint32_t *)bits) + STRIDE_MULT (stride, y) + x);<br>
byte_width = 4 * width;<br> stride *= 4;<br> }<br>@@ -3287,8 +3287,8 @@ mmx_blt (pixman_implementation_t *imp,<br> {<br> src_stride = src_stride * (int) sizeof (uint32_t) / 2;<br> dst_stride = dst_stride * (int) sizeof (uint32_t) / 2;<br>
- src_bytes = (uint8_t *)(((uint16_t *)src_bits) + src_stride * (src_y) + (src_x));<br>- dst_bytes = (uint8_t *)(((uint16_t *)dst_bits) + dst_stride * (dest_y) + (dest_x));<br>+ src_bytes = (uint8_t *)(((uint16_t *)src_bits) + STRIDE_MULT (src_stride, src_y) + src_x);<br>
+ dst_bytes = (uint8_t *)(((uint16_t *)dst_bits) + STRIDE_MULT (dst_stride, dest_y) + dest_x);<br> byte_width = 2 * width;<br> src_stride *= 2;<br> dst_stride *= 2;<br>@@ -3297,8 +3297,8 @@ mmx_blt (pixman_implementation_t *imp,<br>
{<br> src_stride = src_stride * (int) sizeof (uint32_t) / 4;<br> dst_stride = dst_stride * (int) sizeof (uint32_t) / 4;<br>- src_bytes = (uint8_t *)(((uint32_t *)src_bits) + src_stride * (src_y) + (src_x));<br>
- dst_bytes = (uint8_t *)(((uint32_t *)dst_bits) + dst_stride * (dest_y) + (dest_x));<br>+ src_bytes = (uint8_t *)(((uint32_t *)src_bits) + STRIDE_MULT (src_stride, src_y) + src_x);<br>+ dst_bytes = (uint8_t *)(((uint32_t *)dst_bits) + STRIDE_MULT (dst_stride, dest_y) + dest_x);<br>
byte_width = 4 * width;<br> src_stride *= 4;<br> dst_stride *= 4;<br>diff --git a/pixman/pixman-noop.c b/pixman/pixman-noop.c<br>index e598904..4ac95db 100644<br>--- a/pixman/pixman-noop.c<br>+++ b/pixman/pixman-noop.c<br>
@@ -89,7 +89,7 @@ noop_init_direct_buffer (pixman_iter_t *iter, const pixman_iter_info_t *info)<br> pixman_image_t *image = iter->image;<br> <br> iter->buffer =<br>- image->bits.bits + iter->y * image->bits.rowstride + iter->x;<br>
+ image->bits.bits + STRIDE_MULT (iter->y, image->bits.rowstride) + iter->x;<br> }<br> <br> static void<br>diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h<br>index 6ca13b2..275deaa 100644<br>
--- a/pixman/pixman-private.h<br>+++ b/pixman/pixman-private.h<br>@@ -1148,6 +1148,8 @@ void pixman_timer_register (pixman_timer_t *timer);<br> <br> #endif /* PIXMAN_TIMERS */<br> <br>+#define STRIDE_MULT(stride, height) ((ssize_t)(stride)*(height))<br>
+<br> #endif /* __ASSEMBLER__ */<br> <br> #endif /* PIXMAN_PRIVATE_H */<br>diff --git a/pixman/pixman-sse2.c b/pixman/pixman-sse2.c<br>index 42c7209..544c6bc 100644<br>--- a/pixman/pixman-sse2.c<br>+++ b/pixman/pixman-sse2.c<br>
@@ -3337,7 +3337,7 @@ sse2_fill (pixman_implementation_t *imp,<br> uint16_t w;<br> <br> stride = stride * (int) sizeof (uint32_t) / 1;<br>- byte_line = (uint8_t *)(((uint8_t *)bits) + stride * y + x);<br>+ byte_line = (uint8_t *)(((uint8_t *)bits) + STRIDE_MULT (stride, y) + x);<br>
byte_width = width;<br> stride *= 1;<br> <br>@@ -3348,7 +3348,7 @@ sse2_fill (pixman_implementation_t *imp,<br> else if (bpp == 16)<br> {<br> stride = stride * (int) sizeof (uint32_t) / 2;<br>- byte_line = (uint8_t *)(((uint16_t *)bits) + stride * y + x);<br>
+ byte_line = (uint8_t *)(((uint16_t *)bits) + STRIDE_MULT (stride, y) + x);<br> byte_width = 2 * width;<br> stride *= 2;<br> <br>@@ -3357,7 +3357,7 @@ sse2_fill (pixman_implementation_t *imp,<br> else if (bpp == 32)<br>
{<br> stride = stride * (int) sizeof (uint32_t) / 4;<br>- byte_line = (uint8_t *)(((uint32_t *)bits) + stride * y + x);<br>+ byte_line = (uint8_t *)(((uint32_t *)bits) + STRIDE_MULT (stride, y) + x);<br> byte_width = 4 * width;<br>
stride *= 4;<br> }<br>@@ -4711,8 +4711,8 @@ sse2_blt (pixman_implementation_t *imp,<br> {<br> src_stride = src_stride * (int) sizeof (uint32_t) / 2;<br> dst_stride = dst_stride * (int) sizeof (uint32_t) / 2;<br>
- src_bytes =(uint8_t *)(((uint16_t *)src_bits) + src_stride * (src_y) + (src_x));<br>- dst_bytes = (uint8_t *)(((uint16_t *)dst_bits) + dst_stride * (dest_y) + (dest_x));<br>+ src_bytes =(uint8_t *)(((uint16_t *)src_bits) + STRIDE_MULT (src_stride, src_y) + src_x);<br>
+ dst_bytes = (uint8_t *)(((uint16_t *)dst_bits) + STRIDE_MULT (dst_stride, dest_y) + dest_x);<br> byte_width = 2 * width;<br> src_stride *= 2;<br> dst_stride *= 2;<br>@@ -4721,8 +4721,8 @@ sse2_blt (pixman_implementation_t *imp,<br>
{<br> src_stride = src_stride * (int) sizeof (uint32_t) / 4;<br> dst_stride = dst_stride * (int) sizeof (uint32_t) / 4;<br>- src_bytes = (uint8_t *)(((uint32_t *)src_bits) + src_stride * (src_y) + (src_x));<br>
- dst_bytes = (uint8_t *)(((uint32_t *)dst_bits) + dst_stride * (dest_y) + (dest_x));<br>+ src_bytes = (uint8_t *)(((uint32_t *)src_bits) + STRIDE_MULT (src_stride, src_y) + src_x);<br>+ dst_bytes = (uint8_t *)(((uint32_t *)dst_bits) + STRIDE_MULT (dst_stride, dest_y) + dest_x);<br>
byte_width = 4 * width;<br> src_stride *= 4;<br> dst_stride *= 4;<br>diff --git a/pixman/pixman-ssse3.c b/pixman/pixman-ssse3.c<br>index 680d6b9..ca2dfe8 100644<br>--- a/pixman/pixman-ssse3.c<br>+++ b/pixman/pixman-ssse3.c<br>
@@ -53,7 +53,7 @@ static void<br> ssse3_fetch_horizontal (bits_image_t *image, line_t *line,<br> int y, pixman_fixed_t x, pixman_fixed_t ux, int n)<br> {<br>- uint32_t *bits = image->bits + y * image->rowstride;<br>
+ uint32_t *bits = image->bits + STRIDE_MULT (y, image->rowstride);<br> __m128i vx = _mm_set_epi16 (<br> - (x + 1), x, - (x + 1), x,<br> - (x + ux + 1), x + ux, - (x + ux + 1), x + ux);<br>diff --git a/pixman/pixman-trap.c b/pixman/pixman-trap.c<br>
index 91766fd..e55ddf0 100644<br>--- a/pixman/pixman-trap.c<br>+++ b/pixman/pixman-trap.c<br>@@ -304,7 +304,7 @@ dump_image (pixman_image_t *image,<br> for (i = 0; i < image->bits.height; ++i)<br> {<br> uint8_t *line =<br>
- (uint8_t *)&(image->bits.bits[i * image->bits.rowstride]);<br>+ (uint8_t *)&(image->bits.bits[STRIDE_MULT (i, image->bits.rowstride)]);<br> <br> for (j = 0; j < image->bits.width; ++j)<br>
printf ("%c", line[j] ? '#' : ' ');<br>diff --git a/pixman/pixman-utils.c b/pixman/pixman-utils.c<br>index 4a3a835..3261aa5 100644<br>--- a/pixman/pixman-utils.c<br>+++ b/pixman/pixman-utils.c<br>
@@ -230,7 +230,7 @@ _pixman_iter_init_bits_stride (pixman_iter_t *iter, const pixman_iter_info_t *in<br> uint8_t *b = (uint8_t *)image->bits.bits;<br> int s = image->bits.rowstride * 4;<br> <br>- iter->bits = b + s * iter->y + iter->x * PIXMAN_FORMAT_BPP (info->format) / 8;<br>
+ iter->bits = b + STRIDE_MULT (s, iter->y) + iter->x * PIXMAN_FORMAT_BPP (info->format) / 8;<br> iter->stride = s;<br> }<br> <br>diff --git a/test/affine-test.c b/test/affine-test.c<br>index 8e19023..ef733a0 100644<br>
--- a/test/affine-test.c<br>+++ b/test/affine-test.c<br>@@ -74,21 +74,21 @@ test_composite (int testnum,<br> w = prng_rand_n (dst_width * 3 / 2 - dst_x);<br> h = prng_rand_n (dst_height * 3 / 2 - dst_y);<br>
<br>
- srcbuf = (uint32_t *)malloc (src_stride * src_height);<br>- dstbuf = (uint32_t *)malloc (dst_stride * dst_height);<br>+ srcbuf = (uint32_t *)malloc (STRIDE_MULT (src_stride, src_height));<br>+ dstbuf = (uint32_t *)malloc (STRIDE_MULT (dst_stride, dst_height));<br>
<br>- prng_randmemset (srcbuf, src_stride * src_height, 0);<br>- prng_randmemset (dstbuf, dst_stride * dst_height, 0);<br>+ prng_randmemset (srcbuf, STRIDE_MULT (src_stride, src_height), 0);<br>+ prng_randmemset (dstbuf, STRIDE_MULT (dst_stride, dst_height), 0);<br>
<br> if (prng_rand_n (2) == 0)<br> {<br>- srcbuf += (src_stride / 4) * (src_height - 1);<br>+ srcbuf += STRIDE_MULT (src_stride / 4, (src_height - 1));<br> src_stride = - src_stride;<br> }<br> <br>
if (prng_rand_n (2) == 0)<br>
{<br>- dstbuf += (dst_stride / 4) * (dst_height - 1);<br>+ dstbuf += STRIDE_MULT (dst_stride / 4, (dst_height - 1));<br> dst_stride = - dst_stride;<br> }<br> <br>@@ -294,10 +294,10 @@ test_composite (int testnum,<br>
pixman_image_unref (dst_img);<br> <br> if (src_stride < 0)<br>- srcbuf += (src_stride / 4) * (src_height - 1);<br>+ srcbuf += STRIDE_MULT (src_stride / 4, (src_height - 1));<br> <br> if (dst_stride < 0)<br>
- dstbuf += (dst_stride / 4) * (dst_height - 1);<br>+ dstbuf += STRIDE_MULT (dst_stride / 4, (dst_height - 1));<br> <br> free (srcbuf);<br> free (dstbuf);<br>diff --git a/test/blitters-test.c b/test/blitters-test.c<br>
index af94835..1b272dc 100644<br>--- a/test/blitters-test.c<br>+++ b/test/blitters-test.c<br>@@ -44,23 +44,23 @@ create_random_image (pixman_format_code_t *allowed_formats,<br> stride = (stride + 3) & ~3;<br> <br>
/* do the allocation */<br>- buf = aligned_malloc (64, stride * height);<br>+ buf = aligned_malloc (64, STRIDE_MULT (stride, height));<br> <br> if (prng_rand_n (4) == 0)<br> {<br> /* uniform distribution */<br>
- prng_randmemset (buf, stride * height, 0);<br>+ prng_randmemset (buf, STRIDE_MULT (stride, height), 0);<br> }<br> else<br> {<br> /* significantly increased probability for 0x00 and 0xFF */<br>- prng_randmemset (buf, stride * height, RANDMEMSET_MORE_00_AND_FF);<br>
+ prng_randmemset (buf, STRIDE_MULT (stride, height), RANDMEMSET_MORE_00_AND_FF);<br> }<br> <br> /* test negative stride */<br> if (prng_rand_n (4) == 0)<br> {<br>- buf += (stride / 4) * (height - 1);<br>
+ buf += STRIDE_MULT (stride / 4, (height - 1));<br> stride = - stride;<br> }<br> <br>@@ -97,7 +97,7 @@ free_random_image (uint32_t initcrc,<br> crc32 = compute_crc32_for_image (initcrc, img);<br> <br>
if (img->bits.rowstride < 0)<br>
- data += img->bits.rowstride * (img->bits.height - 1);<br>+ data += STRIDE_MULT (img->bits.rowstride, img->bits.height - 1);<br> <br> pixman_image_unref (img);<br> free (data);<br>@@ -244,7 +244,7 @@ test_composite (int testnum, int verbose)<br>
int w, h;<br> pixman_op_t op;<br> pixman_format_code_t src_fmt, dst_fmt, mask_fmt;<br>- uint32_t *dstbuf, *srcbuf, *maskbuf;<br>+ uint32_t *srcbuf, *maskbuf;<br> uint32_t crc32;<br> int max_width, max_height, max_extra_stride;<br>
FLOAT_REGS_CORRUPTION_DETECTOR_START ();<br>@@ -291,7 +291,6 @@ test_composite (int testnum, int verbose)<br> dst_height = pixman_image_get_height (dst_img);<br> dst_stride = pixman_image_get_stride (dst_img);<br>
<br>- dstbuf = pixman_image_get_data (dst_img);<br> srcbuf = pixman_image_get_data (src_img);<br> <br> src_x = prng_rand_n (src_width);<br>diff --git a/test/composite-traps-test.c b/test/composite-traps-test.c<br>
index 86a0355..33fd20f 100644<br>--- a/test/composite-traps-test.c<br>+++ b/test/composite-traps-test.c<br>@@ -104,11 +104,11 @@ test_composite (int testnum,<br> <br> src_stride = (src_stride + 3) & ~3;<br> <br>
- orig = bits = (uint32_t *)make_random_bytes (src_stride * src_height);<br>+ orig = bits = (uint32_t *)make_random_bytes (STRIDE_MULT (src_stride, src_height));<br> <br> if (prng_rand_n (2) == 0)<br> {<br>
- bits += (src_stride / 4) * (src_height - 1);<br>
+ bits += STRIDE_MULT (src_stride / 4, src_height - 1);<br> src_stride = - src_stride;<br> }<br> <br>@@ -157,11 +157,11 @@ test_composite (int testnum,<br> dst_stride = dst_width * dst_bpp + prng_rand_n (MAX_STRIDE) * dst_bpp;<br>
dst_stride = (dst_stride + 3) & ~3;<br> <br>- dst_bits = (uint32_t *)make_random_bytes (dst_stride * dst_height);<br>+ dst_bits = (uint32_t *)make_random_bytes (STRIDE_MULT (dst_stride, dst_height));<br>
<br> if (prng_rand_n (2) == 0)<br> {<br>- dst_bits += (dst_stride / 4) * (dst_height - 1);<br>+ dst_bits += STRIDE_MULT (dst_stride / 4, dst_height - 1);<br> dst_stride = - dst_stride;<br> }<br>
<br>@@ -232,7 +232,7 @@ test_composite (int testnum,<br> print_image (dst_img);<br> <br> if (dst_stride < 0)<br>- dst_bits += (dst_stride / 4) * (dst_height - 1);<br>+ dst_bits += STRIDE_MULT (dst_stride / 4, dst_height - 1);<br>
<br> fence_free (dst_bits);<br> <br>diff --git a/test/glyph-test.c b/test/glyph-test.c<br>index 1811add..fd740ea 100644<br>--- a/test/glyph-test.c<br>+++ b/test/glyph-test.c<br>@@ -144,7 +144,7 @@ create_image (int max_size, const pixman_format_code_t *formats, uint32_t flags)<br>
<br> if (prng_rand_n (64) == 0)<br> {<br>- if (!(data = (uint32_t *)make_random_bytes (stride * height)))<br>+ if (!(data = (uint32_t *)make_random_bytes (STRIDE_MULT (stride, height))))<br> {<br> fprintf (stderr, "Out of memory\n");<br>
abort ();<br>@@ -153,8 +153,8 @@ create_image (int max_size, const pixman_format_code_t *formats, uint32_t flags)<br> }<br> else<br> {<br>- data = malloc (stride * height);<br>- prng_randmemset (data, height * stride, 0);<br>
+ data = malloc (STRIDE_MULT (stride, height));<br>+ prng_randmemset (data, STRIDE_MULT (height, stride), 0);<br> destroy = destroy_malloced;<br> }<br> <br>diff --git a/test/oob-test.c b/test/oob-test.c<br>
index 0d19b50..a7aa583 100644<br>
--- a/test/oob-test.c<br>+++ b/test/oob-test.c<br>@@ -65,10 +65,10 @@ const composite_info_t info[] =<br> static pixman_image_t *<br> make_image (const image_info_t *info)<br> {<br>- char *data = malloc (info->stride * info->height);<br>
+ char *data = malloc (STRIDE_MULT (info->stride, info->height));<br> int i;<br> <br>- for (i = 0; i < info->height * info->stride; ++i)<br>+ for (i = 0; i < STRIDE_MULT (info->height, info->stride); ++i)<br>
data[i] = (i % 255) ^ (((i % 16) << 4) | (i & 0xf0));<br> <br> return pixman_image_create_bits (info->format, info->width, info->height, (uint32_t *)data, info->stride);<br>diff --git a/test/pixel-test.c b/test/pixel-test.c<br>
index 8c525d2..7c86be2 100644<br>--- a/test/pixel-test.c<br>+++ b/test/pixel-test.c<br>@@ -144,7 +144,7 @@ access (pixman_image_t *image, int x, int y)<br> bytes_per_pixel = PIXMAN_FORMAT_BPP (image->bits.format) / 8;<br>
stride = image->bits.rowstride * 4;<br> <br>- location = (uint8_t *)image->bits.bits + y * stride + x * bytes_per_pixel;<br>+ location = (uint8_t *)image->bits.bits + STRIDE_MULT (y, stride) + x * bytes_per_pixel;<br>
<br> if (bytes_per_pixel == 4)<br> result = *(uint32_t *)location;<br>diff --git a/test/rotate-test.c b/test/rotate-test.c<br>index 18ca60d..5b8481b 100644<br>--- a/test/rotate-test.c<br>+++ b/test/rotate-test.c<br>
@@ -71,7 +71,7 @@ make_image (void)<br> stride = WIDTH * 4;<br> if (prng_rand_n (2) == 0)<br> {<br>- bytes += (stride / 4) * (HEIGHT - 1);<br>+ bytes += STRIDE_MULT (stride / 4, HEIGHT - 1);<br> stride = - stride;<br>
}<br> <br>diff --git a/test/scaling-bench.c b/test/scaling-bench.c<br>index 365e798..d3e0753 100644<br>--- a/test/scaling-bench.c<br>+++ b/test/scaling-bench.c<br>@@ -48,8 +48,8 @@ main ()<br> pixman_transform_t transform;<br>
pixman_image_t *dest;<br> double t1, t2, t = -1;<br>- uint32_t *dest_buf = aligned_malloc (16, dest_byte_stride * dest_height);<br>- memset (dest_buf, 0, dest_byte_stride * dest_height);<br>+ uint32_t *dest_buf = aligned_malloc (16, STRIDE_MULT (dest_byte_stride, dest_height));<br>
+ memset (dest_buf, 0, STRIDE_MULT (dest_byte_stride, dest_height));<br> <br> pixman_transform_init_scale (&transform, s, s);<br> pixman_image_set_transform (src, &transform);<br>diff --git a/test/scaling-test.c b/test/scaling-test.c<br>
index e2f7fa9..182539b 100644<br>--- a/test/scaling-test.c<br>+++ b/test/scaling-test.c<br>@@ -136,32 +136,32 @@ test_composite (int testnum,<br> w = prng_rand_n (dst_width * 3 / 2 - dst_x);<br> h = prng_rand_n (dst_height * 3 / 2 - dst_y);<br>
<br>- srcbuf = (uint32_t *)malloc (src_stride * src_height);<br>- maskbuf = (uint32_t *)malloc (mask_stride * mask_height);<br>- dstbuf = (uint32_t *)malloc (dst_stride * dst_height);<br>+ srcbuf = (uint32_t *)malloc (STRIDE_MULT (src_stride, src_height));<br>
+ maskbuf = (uint32_t *)malloc (STRIDE_MULT (mask_stride, mask_height));<br>+ dstbuf = (uint32_t *)malloc (STRIDE_MULT (dst_stride, dst_height));<br> <br>- prng_randmemset (srcbuf, src_stride * src_height, 0);<br>
- prng_randmemset (maskbuf, mask_stride * mask_height, 0);<br>- prng_randmemset (dstbuf, dst_stride * dst_height, 0);<br>+ prng_randmemset (srcbuf, STRIDE_MULT (src_stride, src_height), 0);<br>+ prng_randmemset (maskbuf, STRIDE_MULT (mask_stride, mask_height), 0);<br>
+ prng_randmemset (dstbuf, STRIDE_MULT (dst_stride, dst_height), 0);<br> <br> src_fmt = get_format (src_bpp);<br> dst_fmt = get_format (dst_bpp);<br> <br> if (prng_rand_n (2))<br> {<br>- srcbuf += (src_stride / 4) * (src_height - 1);<br>
+ srcbuf += STRIDE_MULT (src_stride / 4, src_height - 1);<br> src_stride = - src_stride;<br> }<br> <br> if (prng_rand_n (2))<br> {<br>- maskbuf += (mask_stride / 4) * (mask_height - 1);<br>+ maskbuf += STRIDE_MULT (mask_stride / 4, mask_height - 1);<br>
mask_stride = - mask_stride;<br> }<br> <br> if (prng_rand_n (2))<br> {<br>- dstbuf += (dst_stride / 4) * (dst_height - 1);<br>+ dstbuf += STRIDE_MULT (dst_stride / 4, dst_height - 1);<br> dst_stride = - dst_stride;<br>
}<br> <br>@@ -368,13 +368,13 @@ test_composite (int testnum,<br> pixman_image_unref (dst_img);<br> <br> if (src_stride < 0)<br>- srcbuf += (src_stride / 4) * (src_height - 1);<br>+ srcbuf += STRIDE_MULT (src_stride / 4, src_height - 1);<br>
<br> if (mask_stride < 0)<br>- maskbuf += (mask_stride / 4) * (mask_height - 1);<br>+ maskbuf += STRIDE_MULT (mask_stride / 4, mask_height - 1);<br> <br> if (dst_stride < 0)<br>- dstbuf += (dst_stride / 4) * (dst_height - 1);<br>
+ dstbuf += STRIDE_MULT (dst_stride / 4, dst_height - 1);<br> <br> free (srcbuf);<br> free (maskbuf);<br>diff --git a/test/stress-test.c b/test/stress-test.c<br>index 1f03c75..3581af1 100644<br>--- a/test/stress-test.c<br>
+++ b/test/stress-test.c<br>@@ -112,7 +112,7 @@ destroy (pixman_image_t *image, void *data)<br> bits = image->bits.bits;<br> <br> if (image->bits.rowstride < 0)<br>- bits -= (- image->bits.rowstride * (image->bits.height - 1));<br>
+ bits -= STRIDE_MULT (-image->bits.rowstride, image->bits.height - 1);<br> <br> fence_free (bits);<br> }<br>@@ -293,7 +293,7 @@ create_random_bits_image (alpha_preference_t alpha_preference)<br>
case 0:<br>
stride = width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17);<br> stride = (stride + 3) & (~3);<br>- bits = (uint32_t *)make_random_bytes (height * stride);<br>+ bits = (uint32_t *)make_random_bytes (STRIDE_MULT (height, stride));<br>
break;<br> <br> case 1:<br>@@ -304,19 +304,19 @@ create_random_bits_image (alpha_preference_t alpha_preference)<br> case 2: /* Zero-filled */<br> stride = width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17);<br>
stride = (stride + 3) & (~3);<br>- bits = fence_malloc (height * stride);<br>+ bits = fence_malloc (STRIDE_MULT (height, stride));<br> if (!bits)<br> return NULL;<br>- memset (bits, 0, height * stride);<br>
+ memset (bits, 0, STRIDE_MULT (height, stride));<br> break;<br> <br> case 3: /* Filled with 0xFF */<br> stride = width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17);<br> stride = (stride + 3) & (~3);<br>
- bits = fence_malloc (height * stride);<br>+ bits = fence_malloc (STRIDE_MULT (height, stride));<br> if (!bits)<br> return NULL;<br>- memset (bits, 0xff, height * stride);<br>+ memset (bits, 0xff, STRIDE_MULT (height, stride));<br>
break;<br> <br> case 4: /* bits is a bad pointer, has read/write functions */<br>@@ -329,10 +329,10 @@ create_random_bits_image (alpha_preference_t alpha_preference)<br> case 5: /* bits is a real pointer, has read/write functions */<br>
stride = width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17);<br> stride = (stride + 3) & (~3);<br>- bits = fence_malloc (height * stride);<br>+ bits = fence_malloc (STRIDE_MULT (height, stride));<br>
if (!bits)<br> return NULL;<br>- memset (bits, 0xff, height * stride);<br>+ memset (bits, 0xff, STRIDE_MULT (height, stride));<br> read_func = real_reader;<br> write_func = real_writer;<br> break;<br>
@@ -340,10 +340,10 @@ create_random_bits_image (alpha_preference_t alpha_preference)<br> case 6: /* bits is a real pointer, stride is negative */<br> stride = (width * PIXMAN_FORMAT_BPP (format) + prng_rand_n (17));<br>
stride = (stride + 3) & (~3);<br>- bits = (uint32_t *)make_random_bytes (height * stride);<br>+ bits = (uint32_t *)make_random_bytes (STRIDE_MULT (height, stride));<br> if (!bits)<br> return NULL;<br>
- bits += ((height - 1) * stride) / 4;<br>+ bits += STRIDE_MULT (height - 1, stride / 4);<br> stride = - stride;<br> break;<br> }<br>diff --git a/test/utils.c b/test/utils.c<br>index a83fc06..bc6db30 100644<br>
--- a/test/utils.c<br>+++ b/test/utils.c<br>@@ -152,7 +152,7 @@ compute_crc32_for_image_internal (uint32_t crc32,<br> <br> if (stride < 0)<br> {<br>- data += (stride / 4) * (height - 1);<br>+ data += STRIDE_MULT(stride / 4, height - 1);<br>
stride = - stride;<br> }<br> <br>@@ -215,7 +215,7 @@ compute_crc32_for_image_internal (uint32_t crc32,<br> for (i = 0; i * PIXMAN_FORMAT_BPP (fmt) < 32; i++)<br> mask |= mask << (i * PIXMAN_FORMAT_BPP (fmt));<br>
<br>- for (i = 0; i < stride * height / 4; i++)<br>+ for (i = 0; i < STRIDE_MULT (stride / 4, height); i++)<br> data[i] &= mask;<br> <br> /* swap endiannes in order to provide identical results on both big<br>
@@ -223,7 +223,7 @@ compute_crc32_for_image_internal (uint32_t crc32,<br> */<br> image_endian_swap (img);<br> <br>- return compute_crc32 (crc32, data, stride * height);<br>+ return compute_crc32 (crc32, data, STRIDE_MULT (stride, height));<br>
}<br> <br> uint32_t<br>@@ -269,7 +269,7 @@ print_image (pixman_image_t *image)<br> if (j == (width * PIXMAN_FORMAT_BPP (format) + 7) / 8)<br> printf ("| ");<br> <br>- printf ("%02X ", *((uint8_t *)buffer + i * stride + j));<br>
+ printf ("%02X ", *((uint8_t *)buffer + STRIDE_MULT (i, stride) + j));<br> }<br> printf ("\n");<br> }<br>@@ -296,7 +296,7 @@ image_endian_swap (pixman_image_t *img)<br> <br> for (i = 0; i < height; i++)<br>
{<br>- uint8_t *line_data = (uint8_t *)data + stride * i;<br>+ uint8_t *line_data = (uint8_t *)data + STRIDE_MULT (stride, i);<br> <br> switch (bpp)<br> {<br>@@ -459,7 +459,7 @@ fence_free (void *data)<br>
#endif<br> <br> uint8_t *<br>-make_random_bytes (int n_bytes)<br>+make_random_bytes (size_t n_bytes)<br> {<br> uint8_t *bytes = fence_malloc (n_bytes);<br> <br>@@ -516,7 +516,7 @@ write_png (pixman_image_t *image, const char *filename)<br>
int width = pixman_image_get_width (image);<br> int height = pixman_image_get_height (image);<br> int stride = width * 4;<br>- uint32_t *data = malloc (height * stride);<br>+ uint32_t *data = malloc (STRIDE_MULT (height, stride));<br>
pixman_image_t *copy;<br> png_struct *write_struct;<br> png_info *info_struct;<br>diff --git a/test/utils.h b/test/utils.h<br>index 28b7193..37ee410 100644<br>--- a/test/utils.h<br>+++ b/test/utils.h<br>@@ -92,7 +92,7 @@ fence_free (void *data);<br>
<br> /* Generate n_bytes random bytes in fence_malloced memory */<br> uint8_t *<br>-make_random_bytes (int n_bytes);<br>+make_random_bytes (size_t n_bytes);<br> <br> /* Return current time in seconds */<br> double<br></div>
</div>