From a156e4e097f424722c4f1d03f0cf4bb9370962d4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Tue, 19 May 2009 06:18:00 -0400 Subject: [PATCH] Add fetch_extended() function This function takes a list of coordinates and transforms it into another list of coordinates, according to the repeat method of the picture. --- pixman/pixman-bits-image.c | 11 ++--- pixman/pixman-transformed.c | 98 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 5 deletions(-) diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c index 8851a08..a3642b7 100644 --- a/pixman/pixman-bits-image.c +++ b/pixman/pixman-bits-image.c @@ -249,12 +249,13 @@ _pixman_image_fetch_pixels (bits_image_t *image, uint32_t *buffer, int n_pixels) for (i = 0; i < n_pixels; ++i) { - uint32_t x, y; + uint32_t x = *coords++; + uint32_t y = *coords++; - x = *coords++; - y = *coords++; - - buffer[i] = image->fetch_pixel (image, x, y); + if (x == 0xffffffff || y == 0xffffffff) + buffer[i] = 0; + else + buffer[i] = image->fetch_pixel (image, x, y); } } diff --git a/pixman/pixman-transformed.c b/pixman/pixman-transformed.c index d721b35..a71e11a 100644 --- a/pixman/pixman-transformed.c +++ b/pixman/pixman-transformed.c @@ -84,6 +84,104 @@ do_fetch (bits_image_t *pict, int x, int y, fetchPixelProc32 fetch, } } +static void +fetch_pixels_src_clip (bits_image_t *image, uint32_t *buffer, int n_pixels) +{ + if (image->common.src_clip != &(image->common.full_region)) + { + int32_t *coords = (int32_t *)buffer; + int i; + + for (i = 0; i < n_pixels; ++i) + { + int32_t x = coords[0]; + int32_t y = coords[1]; + + if (!pixman_region32_contains_point (image->common.src_clip, x, y, NULL)) + { + coords[0] = 0xffffffff; + coords[1] = 0xffffffff; + } + + coords += 2; + } + } + + _pixman_image_fetch_pixels (image, buffer, n_pixels); +} + +static void +fetch_extended (bits_image_t *image, uint32_t *buffer, int n_pixels) +{ + int32_t *coords, x, y, width, height; + int i; + + width = image->width; + height = image->height; + + coords = (int32_t *)buffer; + + switch (image->common.repeat) + { + case PIXMAN_REPEAT_NORMAL: + for (i = 0; i < n_pixels; ++i) + { + coords[0] = MOD (coords[0], width); + coords[1] = MOD (coords[1], height); + + coords += 2; + } + break; + + case PIXMAN_REPEAT_PAD: + for (i = 0; i < n_pixels; ++i) + { + coords[0] = CLIP (coords[0], 0, width - 1); + coords[1] = CLIP (coords[1], 0, height - 1); + + coords += 2; + } + break; + + case PIXMAN_REPEAT_REFLECT: + for (i = 0; i < n_pixels; ++i) + { + x = MOD (coords[0], width * 2); + y = MOD (coords[1], height * 2); + + if (x >= width) + x = width * 2 - x - 1; + + if (y >= height) + y = height * 2 - y - 1; + + coords[0] = x; + coords[1] = y; + + coords += 2; + } + break; + + case PIXMAN_REPEAT_NONE: + for (i = 0; i < n_pixels; ++i) + { + x = coords[0]; + y = coords[1]; + + if (x < 0 || x >= width) + coords[0] = 0xffffffff; + + if (y < 0 || y >= height) + coords[1] = 0xffffffff; + + coords += 2; + } + break; + } + + fetch_pixels_src_clip (image, buffer, n_pixels); +} + /* * Fetching Algorithms */ -- 2.7.4