pixman: Branch 'wide-composite' - 18 commits
Aaron Plattner
aplattner at kemper.freedesktop.org
Mon Oct 22 18:08:06 PDT 2007
.gitignore | 5
README | 26
configure.ac | 43 +
pixman/Makefile.am | 17
pixman/Makefile.win32 | 31 +
pixman/gen.pl | 2
pixman/pixman-access-accessors.c | 4
pixman/pixman-access-handcode.c | 28
pixman/pixman-compose.c | 961 +++++++++++---------------------
pixman/pixman-compose32.c | 323 +++++++++++
pixman/pixman-compose64.c | 1138 ---------------------------------------
pixman/pixman-compute-region.c | 3
pixman/pixman-edge-accessors.c | 4
pixman/pixman-edge.c | 4
pixman/pixman-image.c | 36 +
pixman/pixman-mmx.c | 7
pixman/pixman-pict.c | 4
pixman/pixman-private.h | 31 +
pixman/pixman-region.c | 14
pixman/pixman-timer.c | 7
pixman/pixman-trap.c | 3
pixman/pixman-utils.c | 17
pixman/pixman.h | 4
23 files changed, 927 insertions(+), 1785 deletions(-)
New commits:
commit cfabdf041f13d53d747c1e7417437f10aafbf31d
Merge: 4bd67df... 2853243...
Author: Aaron Plattner <aplattner at nvidia.com>
Date: Mon Oct 22 18:05:42 2007 -0700
Merge branch 'master' into wide-composite
Conflicts:
pixman/pixman-compose.c
diff --cc pixman/pixman-access-handcode.c
index 2049836,0000000..82e8bae
mode 100644,000000..100644
--- a/pixman/pixman-access-handcode.c
+++ b/pixman/pixman-access-handcode.c
@@@ -1,2788 -1,0 +1,2788 @@@
+/*
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ * 2005 Lars Knoll & Zack Rusin, Trolltech
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <assert.h>
+#include <limits.h>
+
+#include "pixman-private.h"
+
+
+/*
+ * FIXME:
+ * The stuff here is added just to get it to compile. Something sensible needs to
+ * be done before this can be used.
+ *
+ * we should go through this code and clean up some of the weird stuff that have
+ * resulted from unmacro-ifying it.
+ *
+ */
+#define INLINE inline
+
+/* End of stuff added to get it to compile
+ */
+
+static unsigned int
+SourcePictureClassify (source_image_t *pict,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ if (pict->common.type == SOLID)
+ {
+ pict->class = SOURCE_IMAGE_CLASS_HORIZONTAL;
+ }
+ else if (pict->common.type == LINEAR)
+ {
+ linear_gradient_t *linear = (linear_gradient_t *)pict;
+ pixman_vector_t v;
+ pixman_fixed_32_32_t l;
+ pixman_fixed_48_16_t dx, dy, a, b, off;
+ pixman_fixed_48_16_t factors[4];
+ int i;
+
+ dx = linear->p2.x - linear->p1.x;
+ dy = linear->p2.y - linear->p1.y;
+ l = dx * dx + dy * dy;
+ if (l)
+ {
+ a = (dx << 32) / l;
+ b = (dy << 32) / l;
+ }
+ else
+ {
+ a = b = 0;
+ }
+
+ off = (-a * linear->p1.x
+ -b * linear->p1.y) >> 16;
+
+ for (i = 0; i < 3; i++)
+ {
+ v.vector[0] = pixman_int_to_fixed ((i % 2) * (width - 1) + x);
+ v.vector[1] = pixman_int_to_fixed ((i / 2) * (height - 1) + y);
+ v.vector[2] = pixman_fixed_1;
+
+ if (pict->common.transform)
+ {
+ if (!pixman_transform_point_3d (pict->common.transform, &v))
+ return SOURCE_IMAGE_CLASS_UNKNOWN;
+ }
+
+ factors[i] = ((a * v.vector[0] + b * v.vector[1]) >> 16) + off;
+ }
+
+ if (factors[2] == factors[0])
+ pict->class = SOURCE_IMAGE_CLASS_HORIZONTAL;
+ else if (factors[1] == factors[0])
+ pict->class = SOURCE_IMAGE_CLASS_VERTICAL;
+ }
+
+ return pict->class;
+}
+
+#define SCANLINE_BUFFER_LENGTH 2048
+
+typedef FASTCALL void (*fetchProc_32)(pixman_image_t *image,
+ const uint32_t *bits,
+ int x, int width,
+ uint32_t *buffer,
+ const pixman_indexed_t * indexed);
+
+static fetchProc_32 fetchProcForPicture_32 (bits_image_t * pict);
+
+
+typedef FASTCALL uint32_t (*fetchPixelProc_32)(pixman_image_t *image,
+ const uint32_t *bits, int offset,
+ const pixman_indexed_t * indexed);
+
+static fetchPixelProc_32 fetchPixelProcForPicture_32 (bits_image_t * pict);
+
+typedef FASTCALL void (*storeProc_32) (pixman_image_t *image,
+ uint32_t *bits, const uint32_t *values,
+ int x, int width,
+ const pixman_indexed_t * indexed);
+
+static storeProc_32 storeProcForPicture_32 (bits_image_t * pict);
+
+typedef FASTCALL void (*fetchProc_64)(pixman_image_t *image,
+ const uint32_t *bits,
+ int x, int width,
+ uint64_t *buffer,
+ const pixman_indexed_t * indexed);
+
+static fetchProc_64 fetchProcForPicture_64 (bits_image_t * pict);
+
+
+typedef FASTCALL uint64_t (*fetchPixelProc_64)(pixman_image_t *image,
+ const uint32_t *bits, int offset,
+ const pixman_indexed_t * indexed);
+
+static fetchPixelProc_64 fetchPixelProcForPicture_64 (bits_image_t * pict);
+
+typedef FASTCALL void (*storeProc_64) (pixman_image_t *image,
+ uint32_t *bits, const uint64_t *values,
+ int x, int width,
+ const pixman_indexed_t * indexed);
+
+static storeProc_64 storeProcForPicture_64 (bits_image_t * pict);
+
+/* handcoded fetch/store functions. */
+#define fbFetch_g8_32 fbFetch_c8_32
+#define fbFetchPixel_g8_32 fbFetchPixel_c8_32
+#define fbStore_g8_32 fbStore_c8_32
+
+#define fbFetch_g4_32 fbFetch_c4_32
+#define fbFetchPixel_g4_32 fbFetchPixel_c4_32
+#define fbStore_g4_32 fbStore_c4_32
+
+#define fbFetch_g8_64 fbFetch_c8_64
+#define fbFetchPixel_g8_64 fbFetchPixel_c8_64
+#define fbStore_g8_64 fbStore_c8_64
+
+#define fbFetch_g4_64 fbFetch_c4_64
+#define fbFetchPixel_g4_64 fbFetchPixel_c4_64
+#define fbStore_g4_64 fbStore_c4_64
+
+
+static FASTCALL void
+fbFetch_r8g8b8_32 (pixman_image_t *image,
+ const uint32_t *bits, int x, int width, uint32_t *buffer, const pixman_indexed_t * indexed)
+{
+ const uint8_t *pixel = (const uint8_t *)bits + 3*x;
+ const uint8_t *end = pixel + 3*width;
+ while (pixel < end) {
+ uint32_t b = Fetch24(pixel) | 0xff000000;
+ pixel += 3;
+ *buffer++ = b;
+ }
+}
+
+static FASTCALL void
+fbFetch_r8g8b8_64 (pixman_image_t *image,
+ const uint32_t *bits, int x, int width, uint64_t *buffer, const pixman_indexed_t * indexed)
+{
+ const uint8_t *pixel = (const uint8_t *)bits + 3*x;
+ const uint8_t *end = pixel + 3*width;
+ while (pixel < end) {
+ uint64_t r = (uint64_t)READ(pixel) << 32;
+ uint64_t g = (uint64_t)READ(pixel + 1) << 16;
+ uint64_t b = (uint64_t)READ(pixel + 2);
+ uint64_t p = r | g | b;
+
+ pixel += 3;
+ *buffer++ = (p << 16) | p;
+ }
+}
+
+static FASTCALL void
+fbFetch_b8g8r8_32 (pixman_image_t *image,
+ const uint32_t *bits, int x, int width, uint32_t *buffer, const pixman_indexed_t * indexed)
+{
+ const uint8_t *pixel = (const uint8_t *)bits + 3*x;
+ const uint8_t *end = pixel + 3*width;
+ while (pixel < end) {
+ uint32_t b = 0xff000000;
+#if IMAGE_BYTE_ORDER == MSBFirst
+ b |= (READ(pixel++));
+ b |= (READ(pixel++) << 8);
+ b |= (READ(pixel++) << 16);
+#else
+ b |= (READ(pixel++) << 16);
+ b |= (READ(pixel++) << 8);
+ b |= (READ(pixel++));
+#endif
+ *buffer++ = b;
+ }
+}
+
+static FASTCALL void
+fbFetch_b8g8r8_64 (pixman_image_t *image,
+ const uint32_t *bits, int x, int width, uint64_t *buffer, const pixman_indexed_t * indexed)
+{
+ const uint8_t *pixel = (const uint8_t *)bits + 3*x;
+ const uint8_t *end = pixel + 3*width;
+ while (pixel < end) {
+ uint64_t b = 0xffff000000000000LL;
+#if IMAGE_BYTE_ORDER == MSBFirst
+ b |= ((uint64_t)READ(pixel++));
+ b |= ((uint64_t)READ(pixel++) << 16);
+ b |= ((uint64_t)READ(pixel++) << 32);
+#else
+ b |= ((uint64_t)READ(pixel++) << 32);
+ b |= ((uint64_t)READ(pixel++) << 16);
+ b |= ((uint64_t)READ(pixel++));
+#endif
+ *buffer++ = b | (b << 8);
+ }
+}
+
+static FASTCALL uint32_t
+fbFetchPixel_r8g8b8_32 (pixman_image_t *image,
+ const uint32_t *bits, int offset, const pixman_indexed_t * indexed)
+{
+ uint8_t *pixel = ((uint8_t *) bits) + (offset*3);
+#if IMAGE_BYTE_ORDER == MSBFirst
+ return (0xff000000 |
+ (READ(pixel + 0) << 16) |
+ (READ(pixel + 1) << 8) |
+ (READ(pixel + 2)));
+#else
+ return (0xff000000 |
+ (READ(pixel + 2) << 16) |
+ (READ(pixel + 1) << 8) |
+ (READ(pixel + 0)));
+#endif
+}
+
+static FASTCALL uint64_t
+fbFetchPixel_r8g8b8_64 (pixman_image_t *image,
+ const uint32_t *bits, int offset, const pixman_indexed_t * indexed)
+{
+ uint8_t *pixel = ((uint8_t *) bits) + (offset*3);
+#if IMAGE_BYTE_ORDER == MSBFirst
+ uint64_t p = (0xffff000000000000LL |
+ ((uint64_t)READ(pixel + 0) << 32) |
+ ((uint64_t)READ(pixel + 1) << 16) |
+ ((uint64_t)READ(pixel + 2)));
+#else
+ uint64_t p = (0xffff000000000000LL |
+ ((uint64_t)READ(pixel + 2) << 32) |
+ ((uint64_t)READ(pixel + 1) << 16) |
+ ((uint64_t)READ(pixel + 0)));
+#endif
+ return p | (p << 8);
+}
+
+static FASTCALL uint32_t
+fbFetchPixel_b8g8r8_32 (pixman_image_t *image,
+ const uint32_t *bits, int offset, const pixman_indexed_t * indexed)
+{
+ uint8_t *pixel = ((uint8_t *) bits) + (offset*3);
+#if IMAGE_BYTE_ORDER == MSBFirst
+ return (0xff000000 |
+ (READ(pixel + 2) << 16) |
+ (READ(pixel + 1) << 8) |
+ (READ(pixel + 0)));
+#else
+ return (0xff000000 |
+ (READ(pixel + 0) << 16) |
+ (READ(pixel + 1) << 8) |
+ (READ(pixel + 2)));
+#endif
+}
+
+static FASTCALL uint64_t
+fbFetchPixel_b8g8r8_64 (pixman_image_t *image,
+ const uint32_t *bits, int offset, const pixman_indexed_t * indexed)
+{
+ uint8_t *pixel = ((uint8_t *) bits) + (offset*3);
+#if IMAGE_BYTE_ORDER == MSBFirst
+ uint64_t p = (0xffff000000000000LL |
+ ((uint64_t)READ(pixel + 2) << 32) |
+ ((uint64_t)READ(pixel + 1) << 16) |
+ ((uint64_t)READ(pixel + 0)));
+#else
+ uint64_t p = (0xffff000000000000LL |
+ ((uint64_t)READ(pixel + 0) << 32) |
+ ((uint64_t)READ(pixel + 1) << 16) |
+ ((uint64_t)READ(pixel + 2)));
+#endif
+ return p | (p << 8);
+}
+
+static FASTCALL void
+fbStore_r8g8b8_32 (pixman_image_t *image,
+ uint32_t *bits, const uint32_t *values, int x, int width,
+ const pixman_indexed_t * indexed)
+{
+ int i;
+ uint8_t *pixel = ((uint8_t *) bits) + 3*x;
+ for (i = 0; i < width; ++i) {
+ Store24(pixel, values[i]);
+ pixel += 3;
+ }
+}
+
+static FASTCALL void
+fbStore_r8g8b8_64 (pixman_image_t *image,
+ uint32_t *bits, const uint64_t *values, int x, int width,
+ const pixman_indexed_t * indexed)
+{
+ int i;
+ uint8_t *pixel = ((uint8_t *) bits) + 3*x;
+ for (i = 0; i < width; ++i) {
+ uint32_t r = (values[i] >> 40) & 0xff;
+ uint32_t g = (values[i] >> 24) & 0xff;
+ uint32_t b = (values[i] >> 8) & 0xff;
+ Store24(pixel, (r|g|b));
+ pixel += 3;
+ }
+}
+
+static FASTCALL void
+fbStore_b8g8r8_32 (pixman_image_t *image,
+ uint32_t *bits, const uint32_t *values, int x, int width, const pixman_indexed_t * indexed)
+{
+ int i;
+ uint8_t *pixel = ((uint8_t *) bits) + 3*x;
+ for (i = 0; i < width; ++i) {
+ uint32_t val = values[i];
+#if IMAGE_BYTE_ORDER == MSBFirst
+ WRITE(pixel++, Blue(val));
+ WRITE(pixel++, Green(val));
+ WRITE(pixel++, Red(val));
+#else
+ WRITE(pixel++, Red(val));
+ WRITE(pixel++, Green(val));
+ WRITE(pixel++, Blue(val));
+#endif
+ }
+}
+
+static FASTCALL void
+fbStore_b8g8r8_64 (pixman_image_t *image,
+ uint32_t *bits, const uint64_t *values, int x, int width, const pixman_indexed_t * indexed)
+{
+ int i;
+ uint8_t *pixel = ((uint8_t *) bits) + 3*x;
+ for (i = 0; i < width; ++i) {
+ uint32_t r = (values[i] >> 40) & 0xff;
+ uint32_t g = (values[i] >> 24) & 0xff;
+ uint32_t b = (values[i] >> 8) & 0xff;
+#if IMAGE_BYTE_ORDER == MSBFirst
+ WRITE(pixel++, b);
+ WRITE(pixel++, g);
+ WRITE(pixel++, r);
+#else
+ WRITE(pixel++, r);
+ WRITE(pixel++, g);
+ WRITE(pixel++, b);
+#endif
+ }
+}
+
+static FASTCALL void
+fbFetch_c8_32 (pixman_image_t *image,
+ const uint32_t *bits, int x, int width, uint32_t *buffer, const pixman_indexed_t * indexed)
+{
+ const uint8_t *pixel = (const uint8_t *)bits + x;
+ const uint8_t *end = pixel + width;
+ while (pixel < end) {
+ uint32_t p = READ(pixel++);
+ *buffer++ = indexed->rgba[p];
+ }
+}
+
+static FASTCALL void
+fbFetch_c8_64 (pixman_image_t *image,
+ const uint32_t *bits, int x, int width, uint64_t *buffer, const pixman_indexed_t * indexed)
+{
+ const uint8_t *pixel = (const uint8_t *)bits + x;
+ const uint8_t *end = pixel + width;
+ while (pixel < end) {
+ uint64_t p = READ(pixel++);
+ uint64_t px = (p & 0xff) | ((p & 0xff00) << 8) | ((p & 0xff0000) << 16) | ((p & 0xff000000) << 24);
+
+ *buffer++ = px | (px << 8);
+ }
+}
+
+#define Fetch8(l,o) (READ((uint8_t *)(l) + ((o) >> 2)))
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) & 0xf : Fetch8(l,o) >> 4)
+#else
+#define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) >> 4 : Fetch8(l,o) & 0xf)
+#endif
+
+static FASTCALL void
+fbFetch_c4_32 (pixman_image_t *image,
+ const uint32_t *bits, int x, int width, uint32_t *buffer, const pixman_indexed_t * indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ uint32_t p = Fetch4(bits, i + x);
+
+ *buffer++ = indexed->rgba[p];
+ }
+}
+
+static FASTCALL void
+fbFetch_c4_64 (pixman_image_t *image,
+ const uint32_t *bits, int x, int width, uint64_t *buffer, const pixman_indexed_t * indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ uint64_t p = indexed->rgba[Fetch4(bits, i + x)];
+ uint64_t px = (p & 0xff) | ((p & 0xff00) << 8) | ((p & 0xff0000) << 16) | ((p & 0xff000000) << 24);
+
+ *buffer++ = px | (px << 8);
+ }
+}
+
+static FASTCALL void
+fbFetch_a1_32 (pixman_image_t *image,
+ const uint32_t *bits, int x, int width, uint32_t *buffer, const pixman_indexed_t * indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ uint32_t p = READ(bits + ((i + x) >> 5));
+ uint32_t a;
+#if BITMAP_BIT_ORDER == MSBFirst
+ a = p >> (0x1f - ((i+x) & 0x1f));
+#else
+ a = p >> ((i+x) & 0x1f);
+#endif
+ a = a & 1;
+ a |= a << 1;
+ a |= a << 2;
+ a |= a << 4;
+ *buffer++ = a << 24;
+ }
+}
+
+static FASTCALL void
+fbFetch_a1_64 (pixman_image_t *image,
+ const uint32_t *bits, int x, int width, uint64_t *buffer, const pixman_indexed_t * indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ uint32_t p = READ(bits + ((i + x) >> 5));
+ uint64_t a;
+#if BITMAP_BIT_ORDER == MSBFirst
+ a = p >> (0x1f - ((i+x) & 0x1f));
+#else
+ a = p >> ((i+x) & 0x1f);
+#endif
+ a = a & 1;
+ a |= a << 1;
+ a |= a << 2;
+ a |= a << 4;
+ a |= a << 8;
+ *buffer++ = a << 48;
+ }
+}
+
+static FASTCALL void
+fbFetch_g1_32 (pixman_image_t *image,
+ const uint32_t *bits, int x, int width, uint32_t *buffer, const pixman_indexed_t * indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ uint32_t p = READ(bits + ((i+x) >> 5));
+ uint32_t a;
+#if BITMAP_BIT_ORDER == MSBFirst
+ a = p >> (0x1f - ((i+x) & 0x1f));
+#else
+ a = p >> ((i+x) & 0x1f);
+#endif
+ a = a & 1;
+ *buffer++ = indexed->rgba[a];
+ }
+}
+
+static FASTCALL void
+fbFetch_g1_64 (pixman_image_t *image,
+ const uint32_t *bits, int x, int width, uint64_t *buffer, const pixman_indexed_t * indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ uint32_t t = READ(bits + ((i+x) >> 5));
+ uint32_t a;
+#if BITMAP_BIT_ORDER == MSBFirst
+ a = t >> (0x1f - ((i+x) & 0x1f));
+#else
+ a = t >> ((i+x) & 0x1f);
+#endif
+ a = a & 1;
+
+ uint64_t p = indexed->rgba[Fetch4(bits, i + x)];
+ uint64_t px = (p & 0xff) | ((p & 0xff00) << 8) | ((p & 0xff0000) << 16) | ((p & 0xff000000) << 24);
+ *buffer++ = px | (px << 8);
+ }
+}
+
+static FASTCALL uint32_t
+fbFetchPixel_c8_32 (pixman_image_t *image,
+ const uint32_t *bits, int offset, const pixman_indexed_t * indexed)
+{
+ uint32_t pixel = READ((uint8_t *) bits + offset);
+ return indexed->rgba[pixel];
+}
+
+static FASTCALL uint64_t
+fbFetchPixel_c8_64 (pixman_image_t *image,
+ const uint32_t *bits, int offset, const pixman_indexed_t * indexed)
+{
+ uint64_t p = indexed->rgba[READ((uint8_t *) bits + offset)];
+ uint64_t px = (p & 0xff) | ((p & 0xff00) << 8) | ((p & 0xff0000) << 16) | ((p & 0xff000000) << 24);
+
+ return px | (px << 8);
+}
+
+
+static FASTCALL uint32_t
+fbFetchPixel_c4_32 (pixman_image_t *image,
+ const uint32_t *bits, int offset, const pixman_indexed_t * indexed)
+{
+ uint32_t pixel = Fetch4(bits, offset);
+
+ return indexed->rgba[pixel];
+}
+
+static FASTCALL uint64_t
+fbFetchPixel_c4_64 (pixman_image_t *image,
+ const uint32_t *bits, int offset, const pixman_indexed_t * indexed)
+{
+ uint64_t p = indexed->rgba[Fetch4(bits, offset)];
+ uint64_t px = (p & 0xff) | ((p & 0xff00) << 8) | ((p & 0xff0000) << 16) | ((p & 0xff000000) << 24);
+
+ return px | (px << 8);
+}
+
+static FASTCALL uint32_t
+fbFetchPixel_a1_32 (pixman_image_t *image,
+ const uint32_t *bits, int offset, const pixman_indexed_t * indexed)
+{
+ uint32_t pixel = READ(bits + (offset >> 5));
+ uint32_t a;
+#if BITMAP_BIT_ORDER == MSBFirst
+ a = pixel >> (0x1f - (offset & 0x1f));
+#else
+ a = pixel >> (offset & 0x1f);
+#endif
+ a = a & 1;
+ a |= a << 1;
+ a |= a << 2;
+ a |= a << 4;
+ return a << 24;
+}
+
+static FASTCALL uint64_t
+fbFetchPixel_a1_64 (pixman_image_t *image,
+ const uint32_t *bits, int offset, const pixman_indexed_t * indexed)
+{
+ uint32_t pixel = READ(bits + (offset >> 5));
+ uint64_t a;
+#if BITMAP_BIT_ORDER == MSBFirst
+ a = pixel >> (0x1f - (offset & 0x1f));
+#else
+ a = pixel >> (offset & 0x1f);
+#endif
+ a = a & 1;
+ a |= a << 1;
+ a |= a << 2;
+ a |= a << 4;
+ a |= a << 8;
+ return a << 48;
+}
+
+static FASTCALL uint32_t
+fbFetchPixel_g1_32 (pixman_image_t *image,
+ const uint32_t *bits, int offset, const pixman_indexed_t * indexed)
+{
+ uint32_t pixel = READ(bits + (offset >> 5));
+ uint32_t a;
+#if BITMAP_BIT_ORDER == MSBFirst
+ a = pixel >> (0x1f - (offset & 0x1f));
+#else
+ a = pixel >> (offset & 0x1f);
+#endif
+ a = a & 1;
+ return indexed->rgba[a];
+}
+
+static FASTCALL uint64_t
+fbFetchPixel_g1_64 (pixman_image_t *image,
+ const uint32_t *bits, int offset, const pixman_indexed_t * indexed)
+{
+ uint32_t pixel = READ(bits + (offset >> 5));
+ uint32_t a;
+#if BITMAP_BIT_ORDER == MSBFirst
+ a = pixel >> (0x1f - (offset & 0x1f));
+#else
+ a = pixel >> (offset & 0x1f);
+#endif
+ a = a & 1;
+ uint64_t p = indexed->rgba[a];
+ uint64_t px = (p & 0xff) | ((p & 0xff00) << 8) | ((p & 0xff0000) << 16) | ((p & 0xff000000) << 24);
+ return px | (px << 8);
+}
+
+static FASTCALL void
+fbStore_c8_32 (pixman_image_t *image,
+ uint32_t *bits, const uint32_t *values, int x, int width, const pixman_indexed_t * indexed)
+{
+ int i;
+ uint8_t *pixel = ((uint8_t *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ WRITE(pixel++, miIndexToEnt24(indexed,values[i]));
+ }
+}
+
+static FASTCALL void
+fbStore_c8_64 (pixman_image_t *image,
+ uint32_t *bits, const uint64_t *values, int x, int width, const pixman_indexed_t * indexed)
+{
+ int i;
+ uint8_t *pixel = ((uint8_t *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ WRITE(pixel++, miIndexToEnt48(indexed,values[i]));
+ }
+}
+
+#define Store8(l,o,v) (WRITE((uint8_t *)(l) + ((o) >> 3), (v)))
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define Store4(l,o,v) Store8(l,o,((o) & 4 ? \
+ (Fetch8(l,o) & 0xf0) | (v) : \
+ (Fetch8(l,o) & 0x0f) | ((v) << 4)))
+#else
+#define Store4(l,o,v) Store8(l,o,((o) & 4 ? \
+ (Fetch8(l,o) & 0x0f) | ((v) << 4) : \
+ (Fetch8(l,o) & 0xf0) | (v)))
+#endif
+
+static FASTCALL void
+fbStore_c4_32 (pixman_image_t *image,
+ uint32_t *bits, const uint32_t *values, int x, int width, const pixman_indexed_t * indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ uint32_t pixel;
+
+ pixel = miIndexToEnt24(indexed, values[i]);
+ Store4(bits, i + x, pixel);
+ }
+}
+
+static FASTCALL void
+fbStore_c4_64 (pixman_image_t *image,
+ uint32_t *bits, const uint64_t *values, int x, int width, const pixman_indexed_t * indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ uint32_t pixel;
+
+ pixel = miIndexToEnt48(indexed, values[i]);
+ Store4(bits, i + x, pixel);
+ }
+}
+
+static FASTCALL void
+fbStore_a1_32 (pixman_image_t *image,
+ uint32_t *bits, const uint32_t *values, int x, int width, const pixman_indexed_t * indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ uint32_t *pixel = ((uint32_t *) bits) + ((i+x) >> 5);
+ uint32_t mask = FbStipMask((i+x) & 0x1f, 1);
+
+ uint32_t v = values[i] & 0x80000000 ? mask : 0;
+ WRITE(pixel, (READ(pixel) & ~mask) | v);
+ }
+}
+
+static FASTCALL void
+fbStore_a1_64 (pixman_image_t *image,
+ uint32_t *bits, const uint64_t *values, int x, int width, const pixman_indexed_t * indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ uint32_t *pixel = ((uint32_t *) bits) + ((i+x) >> 5);
+ uint32_t mask = FbStipMask((i+x) & 0x1f, 1);
+
+ uint64_t v = values[i] & 0x8000000000000000LL ? mask : 0;
+ WRITE(pixel, (READ(pixel) & ~mask) | v);
+ }
+}
+
+static FASTCALL void
+fbStore_g1_32 (pixman_image_t *image,
+ uint32_t *bits, const uint32_t *values, int x, int width, const pixman_indexed_t * indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ uint32_t *pixel = ((uint32_t *) bits) + ((i+x) >> 5);
+ uint32_t mask = FbStipMask((i+x) & 0x1f, 1);
+
+ uint32_t v = miIndexToEntY24(indexed,values[i]) ? mask : 0;
+ WRITE(pixel, (READ(pixel) & ~mask) | v);
+ }
+}
+
+static FASTCALL void
+fbStore_g1_64 (pixman_image_t *image,
+ uint32_t *bits, const uint64_t *values, int x, int width, const pixman_indexed_t * indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ uint32_t *pixel = ((uint32_t *) bits) + ((i+x) >> 5);
+ uint32_t mask = FbStipMask((i+x) & 0x1f, 1);
+
+ uint32_t v = miIndexToEntY48(indexed,values[i]) ? mask : 0;
+ WRITE(pixel, (READ(pixel) & ~mask) | v);
+ }
+}
+
+/* end of handcoded fetch/store functions */
+
+
+#ifdef PIXMAN_FB_ACCESSORS
+static
+#endif
+void fbFetchSolid(bits_image_t * pict, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits)
+{
+ uint32_t *bits;
+ uint32_t color;
+ uint32_t *end;
+ fetchPixelProc_32 fetch = fetchPixelProcForPicture_32(pict);
+ const pixman_indexed_t * indexed = pict->indexed;
+
+ bits = pict->bits;
+
+ color = fetch((pixman_image_t *)pict, bits, 0, indexed);
+
+ end = buffer + width;
+ while (buffer < end)
+ *(buffer++) = color;
+ fbFinishAccess (pict->pDrawable);
+}
+
+#ifdef PIXMAN_FB_ACCESSORS
+static
+#endif
+void fbFetchSolid64(bits_image_t * pict, int x, int y, int width, uint64_t *buffer, uint64_t *mask, uint64_t maskBits)
+{
+ uint32_t *bits;
+ uint64_t color;
+ uint64_t *end;
+ fetchPixelProc_64 fetch = fetchPixelProcForPicture_64(pict);
+ const pixman_indexed_t * indexed = pict->indexed;
+
+ bits = pict->bits;
+
+ color = fetch((pixman_image_t *)pict, bits, 0, indexed);
+
+ end = buffer + width;
+ while (buffer < end)
+ *(buffer++) = color;
+ fbFinishAccess (pict->pDrawable);
+}
+
+static void fbFetch(bits_image_t * pict, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits)
+{
+ uint32_t *bits;
- uint32_t stride;
++ int32_t stride;
+ fetchProc_32 fetch = fetchProcForPicture_32(pict);
+ const pixman_indexed_t * indexed = pict->indexed;
+
+ bits = pict->bits;
+ stride = pict->rowstride;
+
+ bits += y*stride;
+
+ fetch((pixman_image_t *)pict, bits, x, width, buffer, indexed);
+}
+
+static void fbFetch64(bits_image_t * pict, int x, int y, int width, uint64_t *buffer, uint64_t *mask, uint64_t maskBits)
+{
+ uint32_t *bits;
- uint32_t stride;
++ int32_t stride;
+ fetchProc_64 fetch = fetchProcForPicture_64(pict);
+ const pixman_indexed_t * indexed = pict->indexed;
+
+ bits = pict->bits;
+ stride = pict->rowstride;
+
+ bits += y*stride;
+
+ fetch((pixman_image_t *)pict, bits, x, width, buffer, indexed);
+}
+
+#ifdef PIXMAN_FB_ACCESSORS
+#define PIXMAN_COMPOSITE_RECT_GENERAL pixman_composite_rect_general_accessors
+#define PIXMAN_COMPOSITE_RECT_GENERAL_WIDE pixman_composite_rect_general_wide_accessors
+#else
+#define PIXMAN_COMPOSITE_RECT_GENERAL pixman_composite_rect_general_no_accessors
+#define PIXMAN_COMPOSITE_RECT_GENERAL_WIDE pixman_composite_rect_general_wide_no_accessors
+#endif
+
+typedef struct
+{
+ uint32_t left_ag;
+ uint32_t left_rb;
+ uint32_t right_ag;
+ uint32_t right_rb;
+ int32_t left_x;
+ int32_t right_x;
+ int32_t stepper;
+
+ pixman_gradient_stop_t *stops;
+ int num_stops;
+ unsigned int spread;
+
+ int need_reset;
+} GradientWalker;
+
+static void
+_gradient_walker_init (GradientWalker *walker,
+ gradient_t *gradient,
+ unsigned int spread)
+{
+ walker->num_stops = gradient->n_stops;
+ walker->stops = gradient->stops;
+ walker->left_x = 0;
+ walker->right_x = 0x10000;
+ walker->stepper = 0;
+ walker->left_ag = 0;
+ walker->left_rb = 0;
+ walker->right_ag = 0;
+ walker->right_rb = 0;
+ walker->spread = spread;
+
+ walker->need_reset = TRUE;
+}
+
+static void
+_gradient_walker_reset (GradientWalker *walker,
+ pixman_fixed_32_32_t pos)
+{
+ int32_t x, left_x, right_x;
+ pixman_color_t *left_c, *right_c;
+ int n, count = walker->num_stops;
+ pixman_gradient_stop_t * stops = walker->stops;
+
+ static const pixman_color_t transparent_black = { 0, 0, 0, 0 };
+
+ switch (walker->spread)
+ {
+ case PIXMAN_REPEAT_NORMAL:
+ x = (int32_t)pos & 0xFFFF;
+ for (n = 0; n < count; n++)
+ if (x < stops[n].x)
+ break;
+ if (n == 0) {
+ left_x = stops[count-1].x - 0x10000;
+ left_c = &stops[count-1].color;
+ } else {
+ left_x = stops[n-1].x;
+ left_c = &stops[n-1].color;
+ }
+
+ if (n == count) {
+ right_x = stops[0].x + 0x10000;
+ right_c = &stops[0].color;
+ } else {
+ right_x = stops[n].x;
+ right_c = &stops[n].color;
+ }
+ left_x += (pos - x);
+ right_x += (pos - x);
+ break;
+
+ case PIXMAN_REPEAT_PAD:
+ for (n = 0; n < count; n++)
+ if (pos < stops[n].x)
+ break;
+
+ if (n == 0) {
+ left_x = INT32_MIN;
+ left_c = &stops[0].color;
+ } else {
+ left_x = stops[n-1].x;
+ left_c = &stops[n-1].color;
+ }
+
+ if (n == count) {
+ right_x = INT32_MAX;
+ right_c = &stops[n-1].color;
+ } else {
+ right_x = stops[n].x;
+ right_c = &stops[n].color;
+ }
+ break;
+
+ case PIXMAN_REPEAT_REFLECT:
+ x = (int32_t)pos & 0xFFFF;
+ if ((int32_t)pos & 0x10000)
+ x = 0x10000 - x;
+ for (n = 0; n < count; n++)
+ if (x < stops[n].x)
+ break;
+
+ if (n == 0) {
+ left_x = -stops[0].x;
+ left_c = &stops[0].color;
+ } else {
+ left_x = stops[n-1].x;
+ left_c = &stops[n-1].color;
+ }
+
+ if (n == count) {
+ right_x = 0x20000 - stops[n-1].x;
+ right_c = &stops[n-1].color;
+ } else {
+ right_x = stops[n].x;
+ right_c = &stops[n].color;
+ }
+
+ if ((int32_t)pos & 0x10000) {
+ pixman_color_t *tmp_c;
+ int32_t tmp_x;
+
+ tmp_x = 0x10000 - right_x;
+ right_x = 0x10000 - left_x;
+ left_x = tmp_x;
+
+ tmp_c = right_c;
+ right_c = left_c;
+ left_c = tmp_c;
+
+ x = 0x10000 - x;
+ }
+ left_x += (pos - x);
+ right_x += (pos - x);
+ break;
+
+ default: /* RepeatNone */
+ for (n = 0; n < count; n++)
+ if (pos < stops[n].x)
+ break;
+
+ if (n == 0)
+ {
+ left_x = INT32_MIN;
+ right_x = stops[0].x;
+ left_c = right_c = (pixman_color_t*) &transparent_black;
+ }
+ else if (n == count)
+ {
+ left_x = stops[n-1].x;
+ right_x = INT32_MAX;
+ left_c = right_c = (pixman_color_t*) &transparent_black;
+ }
+ else
+ {
+ left_x = stops[n-1].x;
+ right_x = stops[n].x;
+ left_c = &stops[n-1].color;
+ right_c = &stops[n].color;
+ }
+ }
+
+ walker->left_x = left_x;
+ walker->right_x = right_x;
+ walker->left_ag = ((left_c->alpha >> 8) << 16) | (left_c->green >> 8);
+ walker->left_rb = ((left_c->red & 0xff00) << 8) | (left_c->blue >> 8);
+ walker->right_ag = ((right_c->alpha >> 8) << 16) | (right_c->green >> 8);
+ walker->right_rb = ((right_c->red & 0xff00) << 8) | (right_c->blue >> 8);
+
+ if ( walker->left_x == walker->right_x ||
+ ( walker->left_ag == walker->right_ag &&
+ walker->left_rb == walker->right_rb ) )
+ {
+ walker->stepper = 0;
+ }
+ else
+ {
+ int32_t width = right_x - left_x;
+ walker->stepper = ((1 << 24) + width/2)/width;
+ }
+
+ walker->need_reset = FALSE;
+}
+
+#define GRADIENT_WALKER_NEED_RESET(w,x) \
+ ( (w)->need_reset || (x) < (w)->left_x || (x) >= (w)->right_x)
+
+
+/* the following assumes that GRADIENT_WALKER_NEED_RESET(w,x) is FALSE */
+static uint32_t
+_gradient_walker_pixel (GradientWalker *walker,
+ pixman_fixed_32_32_t x)
+{
+ int dist, idist;
+ uint32_t t1, t2, a, color;
+
+ if (GRADIENT_WALKER_NEED_RESET (walker, x))
+ _gradient_walker_reset (walker, x);
+
+ dist = ((int)(x - walker->left_x)*walker->stepper) >> 16;
+ idist = 256 - dist;
+
+ /* combined INTERPOLATE and premultiply */
+ t1 = walker->left_rb*idist + walker->right_rb*dist;
+ t1 = (t1 >> 8) & 0xff00ff;
+
+ t2 = walker->left_ag*idist + walker->right_ag*dist;
+ t2 &= 0xff00ff00;
+
+ color = t2 & 0xff000000;
+ a = t2 >> 24;
+
+ t1 = t1*a + 0x800080;
+ t1 = (t1 + ((t1 >> 8) & 0xff00ff)) >> 8;
+
+ t2 = (t2 >> 8)*a + 0x800080;
+ t2 = (t2 + ((t2 >> 8) & 0xff00ff));
+
+ return (color | (t1 & 0xff00ff) | (t2 & 0xff00));
+}
+
+static void pixmanFetchSourcePict(source_image_t * pict, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits)
+{
+#if 0
+ SourcePictPtr pGradient = pict->pSourcePict;
+#endif
+ GradientWalker walker;
+ uint32_t *end = buffer + width;
+ gradient_t *gradient;
+
+ if (pict->common.type == SOLID)
+ {
+ register uint32_t color = ((solid_fill_t *)pict)->color;
+
+ while (buffer < end)
+ *(buffer++) = color;
+
+ return;
+ }
+
+ gradient = (gradient_t *)pict;
+
+ _gradient_walker_init (&walker, gradient, pict->common.repeat);
+
+ if (pict->common.type == LINEAR) {
+ pixman_vector_t v, unit;
+ pixman_fixed_32_32_t l;
+ pixman_fixed_48_16_t dx, dy, a, b, off;
+ linear_gradient_t *linear = (linear_gradient_t *)pict;
+
+ /* reference point is the center of the pixel */
+ v.vector[0] = pixman_int_to_fixed(x) + pixman_fixed_1/2;
+ v.vector[1] = pixman_int_to_fixed(y) + pixman_fixed_1/2;
+ v.vector[2] = pixman_fixed_1;
+ if (pict->common.transform) {
+ if (!pixman_transform_point_3d (pict->common.transform, &v))
+ return;
+ unit.vector[0] = pict->common.transform->matrix[0][0];
+ unit.vector[1] = pict->common.transform->matrix[1][0];
+ unit.vector[2] = pict->common.transform->matrix[2][0];
+ } else {
+ unit.vector[0] = pixman_fixed_1;
+ unit.vector[1] = 0;
+ unit.vector[2] = 0;
+ }
+
+ dx = linear->p2.x - linear->p1.x;
+ dy = linear->p2.y - linear->p1.y;
+ l = dx*dx + dy*dy;
+ if (l != 0) {
+ a = (dx << 32) / l;
+ b = (dy << 32) / l;
+ off = (-a*linear->p1.x - b*linear->p1.y)>>16;
+ }
+ if (l == 0 || (unit.vector[2] == 0 && v.vector[2] == pixman_fixed_1)) {
+ pixman_fixed_48_16_t inc, t;
+ /* affine transformation only */
+ if (l == 0) {
+ t = 0;
+ inc = 0;
+ } else {
+ t = ((a*v.vector[0] + b*v.vector[1]) >> 16) + off;
+ inc = (a * unit.vector[0] + b * unit.vector[1]) >> 16;
+ }
+
+ if (pict->class == SOURCE_IMAGE_CLASS_VERTICAL)
+ {
+ register uint32_t color;
+
+ color = _gradient_walker_pixel( &walker, t );
+ while (buffer < end)
+ *(buffer++) = color;
+ }
+ else
+ {
+ if (!mask) {
+ while (buffer < end)
+ {
+ *(buffer) = _gradient_walker_pixel (&walker, t);
+ buffer += 1;
+ t += inc;
+ }
+ } else {
+ while (buffer < end) {
+ if (*mask++ & maskBits)
+ {
+ *(buffer) = _gradient_walker_pixel (&walker, t);
+ }
+ buffer += 1;
+ t += inc;
+ }
+ }
+ }
+ }
+ else /* projective transformation */
+ {
+ pixman_fixed_48_16_t t;
+
+ if (pict->class == SOURCE_IMAGE_CLASS_VERTICAL)
+ {
+ register uint32_t color;
+
+ if (v.vector[2] == 0)
+ {
+ t = 0;
+ }
+ else
+ {
+ pixman_fixed_48_16_t x, y;
+
+ x = ((pixman_fixed_48_16_t) v.vector[0] << 16) / v.vector[2];
+ y = ((pixman_fixed_48_16_t) v.vector[1] << 16) / v.vector[2];
+ t = ((a * x + b * y) >> 16) + off;
+ }
+
+ color = _gradient_walker_pixel( &walker, t );
+ while (buffer < end)
+ *(buffer++) = color;
+ }
+ else
+ {
+ while (buffer < end)
+ {
+ if (!mask || *mask++ & maskBits)
+ {
+ if (v.vector[2] == 0) {
+ t = 0;
+ } else {
+ pixman_fixed_48_16_t x, y;
+ x = ((pixman_fixed_48_16_t)v.vector[0] << 16) / v.vector[2];
+ y = ((pixman_fixed_48_16_t)v.vector[1] << 16) / v.vector[2];
+ t = ((a*x + b*y) >> 16) + off;
+ }
+ *(buffer) = _gradient_walker_pixel (&walker, t);
+ }
+ ++buffer;
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ }
+ }
+ } else {
+
+/*
+ * In the radial gradient problem we are given two circles (câ,râ) and
+ * (câ,râ) that define the gradient itself. Then, for any point p, we
+ * must compute the value(s) of t within [0.0, 1.0] representing the
+ * circle(s) that would color the point.
+ *
+ * There are potentially two values of t since the point p can be
+ * colored by both sides of the circle, (which happens whenever one
+ * circle is not entirely contained within the other).
+ *
+ * If we solve for a value of t that is outside of [0.0, 1.0] then we
+ * use the extend mode (NONE, REPEAT, REFLECT, or PAD) to map to a
+ * value within [0.0, 1.0].
+ *
+ * Here is an illustration of the problem:
+ *
+ * pâ
+ * p â¢
+ * ⢠â²
+ * · â²râ
+ * pâ · â²
+ * ⢠θâ²
+ * â² âââ¢
+ * â²râ · câ
+ * θⲠ·
+ * âââ¢
+ * câ
+ *
+ * Given (câ,râ), (câ,râ) and p, we must find an angle θ such that two
+ * points pâ and pâ on the two circles are collinear with p. Then, the
+ * desired value of t is the ratio of the length of pâp to the length
+ * of pâpâ.
+ *
+ * So, we have six unknown values: (pâx, pây), (pâx, pây), θ and t.
+ * We can also write six equations that constrain the problem:
+ *
+ * Point pâ is a distance râ from câ at an angle of θ:
+ *
+ * 1. pâx = câx + râ·cos θ
+ * 2. pây = cây + râ·sin θ
+ *
+ * Point pâ is a distance râ from câ at an angle of θ:
+ *
+ * 3. pâx = câx + r2·cos θ
+ * 4. pây = cây + r2·sin θ
+ *
+ * Point p lies at a fraction t along the line segment pâpâ:
+ *
+ * 5. px = t·pâx + (1-t)·pâx
+ * 6. py = t·pây + (1-t)·pây
+ *
+ * To solve, first subtitute 1-4 into 5 and 6:
+ *
+ * px = t·(câx + râ·cos θ) + (1-t)·(câx + râ·cos θ)
+ * py = t·(cây + râ·sin θ) + (1-t)·(cây + râ·sin θ)
+ *
+ * Then solve each for cos θ and sin θ expressed as a function of t:
+ *
+ * cos θ = (-(câx - câx)·t + (px - câx)) / ((râ-râ)·t + râ)
+ * sin θ = (-(cây - cây)·t + (py - cây)) / ((râ-râ)·t + râ)
+ *
+ * To simplify this a bit, we define new variables for several of the
+ * common terms as shown below:
+ *
+ * pâ
+ * p â¢
+ * ⢠â²
+ * · â â²râ
+ * pâ · â â²
+ * ⢠pdyâ â²
+ * â² â â¢câ
+ * â²râ â · â
+ * Ⲡ·â âcdy
+ * â¢âââââ´ââââââââ
+ * câ pdx cdx
+ *
+ * cdx = (câx - câx)
+ * cdy = (cây - cây)
+ * dr = râ-râ
+ * pdx = px - câx
+ * pdy = py - cây
+ *
+ * Note that cdx, cdy, and dr do not depend on point p at all, so can
+ * be pre-computed for the entire gradient. The simplifed equations
+ * are now:
+ *
+ * cos θ = (-cdx·t + pdx) / (dr·t + râ)
+ * sin θ = (-cdy·t + pdy) / (dr·t + râ)
+ *
+ * Finally, to get a single function of t and eliminate the last
+ * unknown θ, we use the identity sin²θ + cos²θ = 1. First, square
+ * each equation, (we knew a quadratic was coming since it must be
+ * possible to obtain two solutions in some cases):
+ *
+ * cos²θ = (cdx²t² - 2·cdx·pdx·t + pdx²) / (dr²·t² + 2·râ·dr·t + râ²)
+ * sin²θ = (cdy²t² - 2·cdy·pdy·t + pdy²) / (dr²·t² + 2·râ·dr·t + râ²)
+ *
+ * Then add both together, set the result equal to 1, and express as a
+ * standard quadratic equation in t of the form At² + Bt + C = 0
+ *
+ * (cdx² + cdy² - dr²)·t² - 2·(cdx·pdx + cdy·pdy + râ·dr)·t + (pdx² + pdy² - râ²) = 0
+ *
+ * In other words:
+ *
+ * A = cdx² + cdy² - dr²
+ * B = -2·(pdx·cdx + pdy·cdy + râ·dr)
+ * C = pdx² + pdy² - râ²
+ *
+ * And again, notice that A does not depend on p, so can be
+ * precomputed. From here we just use the quadratic formula to solve
+ * for t:
+ *
+ * t = (-2·B ± â·(B² - 4·A·C)) / 2·A
+ */
+ /* radial or conical */
+ pixman_bool_t affine = TRUE;
+ double cx = 1.;
+ double cy = 0.;
+ double cz = 0.;
+ double rx = x + 0.5;
+ double ry = y + 0.5;
+ double rz = 1.;
+
+ if (pict->common.transform) {
+ pixman_vector_t v;
+ /* reference point is the center of the pixel */
+ v.vector[0] = pixman_int_to_fixed(x) + pixman_fixed_1/2;
+ v.vector[1] = pixman_int_to_fixed(y) + pixman_fixed_1/2;
+ v.vector[2] = pixman_fixed_1;
+ if (!pixman_transform_point_3d (pict->common.transform, &v))
+ return;
+
+ cx = pict->common.transform->matrix[0][0]/65536.;
+ cy = pict->common.transform->matrix[1][0]/65536.;
+ cz = pict->common.transform->matrix[2][0]/65536.;
+ rx = v.vector[0]/65536.;
+ ry = v.vector[1]/65536.;
+ rz = v.vector[2]/65536.;
+ affine = pict->common.transform->matrix[2][0] == 0 && v.vector[2] == pixman_fixed_1;
+ }
+
+ if (pict->common.type == RADIAL) {
+ radial_gradient_t *radial = (radial_gradient_t *)pict;
+ if (affine) {
+ while (buffer < end) {
+ if (!mask || *mask++ & maskBits)
+ {
+ double pdx, pdy;
+ double B, C;
+ double det;
+ double c1x = radial->c1.x / 65536.0;
+ double c1y = radial->c1.y / 65536.0;
+ double r1 = radial->c1.radius / 65536.0;
+ pixman_fixed_48_16_t t;
+
+ pdx = rx - c1x;
+ pdy = ry - c1y;
+
+ B = -2 * ( pdx * radial->cdx
+ + pdy * radial->cdy
+ + r1 * radial->dr);
+ C = (pdx * pdx + pdy * pdy - r1 * r1);
+
+ det = (B * B) - (4 * radial->A * C);
+ if (det < 0.0)
+ det = 0.0;
+
+ if (radial->A < 0)
+ t = (pixman_fixed_48_16_t) ((- B - sqrt(det)) / (2.0 * radial->A) * 65536);
+ else
+ t = (pixman_fixed_48_16_t) ((- B + sqrt(det)) / (2.0 * radial->A) * 65536);
+
+ *(buffer) = _gradient_walker_pixel (&walker, t);
+ }
+ ++buffer;
+
+ rx += cx;
+ ry += cy;
+ }
+ } else {
+ /* projective */
+ while (buffer < end) {
+ if (!mask || *mask++ & maskBits)
+ {
+ double pdx, pdy;
+ double B, C;
+ double det;
+ double c1x = radial->c1.x / 65536.0;
+ double c1y = radial->c1.y / 65536.0;
+ double r1 = radial->c1.radius / 65536.0;
+ pixman_fixed_48_16_t t;
+ double x, y;
+
+ if (rz != 0) {
+ x = rx/rz;
+ y = ry/rz;
+ } else {
+ x = y = 0.;
+ }
+
+ pdx = x - c1x;
+ pdy = y - c1y;
+
+ B = -2 * ( pdx * radial->cdx
+ + pdy * radial->cdy
+ + r1 * radial->dr);
+ C = (pdx * pdx + pdy * pdy - r1 * r1);
+
+ det = (B * B) - (4 * radial->A * C);
+ if (det < 0.0)
+ det = 0.0;
+
+ if (radial->A < 0)
+ t = (pixman_fixed_48_16_t) ((- B - sqrt(det)) / (2.0 * radial->A) * 65536);
+ else
+ t = (pixman_fixed_48_16_t) ((- B + sqrt(det)) / (2.0 * radial->A) * 65536);
+
+ *(buffer) = _gradient_walker_pixel (&walker, t);
+ }
+ ++buffer;
+
+ rx += cx;
+ ry += cy;
+ rz += cz;
+ }
+ }
+ } else /* SourcePictTypeConical */ {
+ conical_gradient_t *conical = (conical_gradient_t *)pict;
+ double a = conical->angle/(180.*65536);
+ if (affine) {
+ rx -= conical->center.x/65536.;
+ ry -= conical->center.y/65536.;
+
+ while (buffer < end) {
+ double angle;
+
+ if (!mask || *mask++ & maskBits)
+ {
+ pixman_fixed_48_16_t t;
+
+ angle = atan2(ry, rx) + a;
+ t = (pixman_fixed_48_16_t) (angle * (65536. / (2*M_PI)));
+
+ *(buffer) = _gradient_walker_pixel (&walker, t);
+ }
+
+ ++buffer;
+ rx += cx;
+ ry += cy;
+ }
+ } else {
+ while (buffer < end) {
+ double x, y;
+ double angle;
+
+ if (!mask || *mask++ & maskBits)
+ {
+ pixman_fixed_48_16_t t;
+
+ if (rz != 0) {
+ x = rx/rz;
+ y = ry/rz;
+ } else {
+ x = y = 0.;
+ }
+ x -= conical->center.x/65536.;
+ y -= conical->center.y/65536.;
+ angle = atan2(y, x) + a;
+ t = (pixman_fixed_48_16_t) (angle * (65536. / (2*M_PI)));
+
+ *(buffer) = _gradient_walker_pixel (&walker, t);
+ }
+
+ ++buffer;
+ rx += cx;
+ ry += cy;
+ rz += cz;
+ }
+ }
+ }
+ }
+}
+
+static void fbFetchTransformed(bits_image_t * pict, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits)
+{
+ uint32_t *bits;
- uint32_t stride;
++ int32_t stride;
+ fetchPixelProc_32 fetch;
+ pixman_vector_t v;
+ pixman_vector_t unit;
+ int i;
+ pixman_box16_t box;
+ const pixman_indexed_t * indexed = pict->indexed;
+ pixman_bool_t affine = TRUE;
+
+ fetch = fetchPixelProcForPicture_32(pict);
+
+ bits = pict->bits;
+ stride = pict->rowstride;
+
+ /* reference point is the center of the pixel */
+ v.vector[0] = pixman_int_to_fixed(x) + pixman_fixed_1 / 2;
+ v.vector[1] = pixman_int_to_fixed(y) + pixman_fixed_1 / 2;
+ v.vector[2] = pixman_fixed_1;
+
+ /* when using convolution filters one might get here without a transform */
+ if (pict->common.transform)
+ {
+ if (!pixman_transform_point_3d (pict->common.transform, &v))
+ {
+ fbFinishAccess (pict->pDrawable);
+ return;
+ }
+ unit.vector[0] = pict->common.transform->matrix[0][0];
+ unit.vector[1] = pict->common.transform->matrix[1][0];
+ unit.vector[2] = pict->common.transform->matrix[2][0];
+ affine = v.vector[2] == pixman_fixed_1 && unit.vector[2] == 0;
+ }
+ else
+ {
+ unit.vector[0] = pixman_fixed_1;
+ unit.vector[1] = 0;
+ unit.vector[2] = 0;
+ }
+
+ if (pict->common.filter == PIXMAN_FILTER_NEAREST || pict->common.filter == PIXMAN_FILTER_FAST)
+ {
+ if (pict->common.repeat == PIXMAN_REPEAT_NORMAL) {
+ if (pixman_region_n_rects (pict->common.src_clip) == 1) {
+ for (i = 0; i < width; ++i) {
+ if (!mask || mask[i] & maskBits)
+ {
+ if (!v.vector[2]) {
+ *(buffer + i) = 0;
+ } else {
+ if (!affine) {
+ y = MOD(DIV(v.vector[1],v.vector[2]), pict->height);
+ x = MOD(DIV(v.vector[0],v.vector[2]), pict->width);
+ } else {
+ y = MOD(v.vector[1]>>16, pict->height);
+ x = MOD(v.vector[0]>>16, pict->width);
+ }
+ *(buffer + i) = fetch((pixman_image_t *)pict, bits + y * stride, x, indexed);
+ }
+ }
+
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ } else {
+ for (i = 0; i < width; ++i) {
+ if (!mask || mask[i] & maskBits)
+ {
+ if (!v.vector[2]) {
+ *(buffer + i) = 0;
+ } else {
+ if (!affine) {
+ y = MOD(DIV(v.vector[1],v.vector[2]), pict->height);
+ x = MOD(DIV(v.vector[0],v.vector[2]), pict->width);
+ } else {
+ y = MOD(v.vector[1]>>16, pict->height);
+ x = MOD(v.vector[0]>>16, pict->width);
+ }
+ if (pixman_region_contains_point (pict->common.src_clip, x, y, &box))
+ *(buffer + i) = fetch ((pixman_image_t *)pict, bits + y*stride, x, indexed);
+ else
+ *(buffer + i) = 0;
+ }
+ }
+
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ }
+ } else {
+ if (pixman_region_n_rects(pict->common.src_clip) == 1) {
+ box = pict->common.src_clip->extents;
+ for (i = 0; i < width; ++i) {
+ if (!mask || mask[i] & maskBits)
+ {
+ if (!v.vector[2]) {
+ *(buffer + i) = 0;
+ } else {
+ if (!affine) {
+ y = DIV(v.vector[1],v.vector[2]);
+ x = DIV(v.vector[0],v.vector[2]);
+ } else {
+ y = v.vector[1]>>16;
+ x = v.vector[0]>>16;
+ }
+ *(buffer + i) = ((x < box.x1) | (x >= box.x2) | (y < box.y1) | (y >= box.y2)) ?
+ 0 : fetch((pixman_image_t *)pict, bits + (y)*stride, x, indexed);
+ }
+ }
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ } else {
+ for (i = 0; i < width; ++i) {
+ if (!mask || mask[i] & maskBits)
+ {
+ if (!v.vector[2]) {
+ *(buffer + i) = 0;
+ } else {
+ if (!affine) {
+ y = DIV(v.vector[1],v.vector[2]);
+ x = DIV(v.vector[0],v.vector[2]);
+ } else {
+ y = v.vector[1]>>16;
+ x = v.vector[0]>>16;
+ }
+ if (pixman_region_contains_point (pict->common.src_clip, x, y, &box))
+ *(buffer + i) = fetch((pixman_image_t *)pict, bits + y*stride, x, indexed);
+ else
+ *(buffer + i) = 0;
+ }
+ }
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ }
+ }
+ } else if (pict->common.filter == PIXMAN_FILTER_BILINEAR ||
+ pict->common.filter == PIXMAN_FILTER_GOOD ||
+ pict->common.filter == PIXMAN_FILTER_BEST)
+ {
+ /* adjust vector for maximum contribution at 0.5, 0.5 of each texel. */
+ v.vector[0] -= v.vector[2] / 2;
+ v.vector[1] -= v.vector[2] / 2;
+ unit.vector[0] -= unit.vector[2] / 2;
+ unit.vector[1] -= unit.vector[2] / 2;
+
+ if (pict->common.repeat == PIXMAN_REPEAT_NORMAL) {
+ if (pixman_region_n_rects(pict->common.src_clip) == 1) {
+ for (i = 0; i < width; ++i) {
+ if (!mask || mask[i] & maskBits)
+ {
+ if (!v.vector[2]) {
+ *(buffer + i) = 0;
+ } else {
+ int x1, x2, y1, y2, distx, idistx, disty, idisty;
+ uint32_t *b;
+ uint32_t tl, tr, bl, br, r;
+ uint32_t ft, fb;
+
+ if (!affine) {
+ pixman_fixed_48_16_t div;
+ div = ((pixman_fixed_48_16_t)v.vector[0] << 16)/v.vector[2];
+ x1 = div >> 16;
+ distx = ((pixman_fixed_t)div >> 8) & 0xff;
+ div = ((pixman_fixed_48_16_t)v.vector[1] << 16)/v.vector[2];
+ y1 = div >> 16;
+ disty = ((pixman_fixed_t)div >> 8) & 0xff;
+ } else {
+ x1 = v.vector[0] >> 16;
+ distx = (v.vector[0] >> 8) & 0xff;
+ y1 = v.vector[1] >> 16;
+ disty = (v.vector[1] >> 8) & 0xff;
+ }
+ x2 = x1 + 1;
+ y2 = y1 + 1;
+
+ idistx = 256 - distx;
+ idisty = 256 - disty;
+
+ x1 = MOD (x1, pict->width);
+ x2 = MOD (x2, pict->width);
+ y1 = MOD (y1, pict->height);
+ y2 = MOD (y2, pict->height);
+
+ b = bits + y1*stride;
+
+ tl = fetch((pixman_image_t *)pict, b, x1, indexed);
+ tr = fetch((pixman_image_t *)pict, b, x2, indexed);
+ b = bits + y2*stride;
+ bl = fetch((pixman_image_t *)pict, b, x1, indexed);
+ br = fetch((pixman_image_t *)pict, b, x2, indexed);
+
+ ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+ fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+ r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+ ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+ fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+ r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+ ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+ fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+ r |= (((ft * idisty + fb * disty)) & 0xff0000);
+ ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+ fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+ r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
+ *(buffer + i) = r;
+ }
+ }
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ } else {
+ for (i = 0; i < width; ++i) {
+ if (!mask || mask[i] & maskBits)
+ {
+ if (!v.vector[2]) {
+ *(buffer + i) = 0;
+ } else {
+ int x1, x2, y1, y2, distx, idistx, disty, idisty;
+ uint32_t *b;
+ uint32_t tl, tr, bl, br, r;
+ uint32_t ft, fb;
+
+ if (!affine) {
+ pixman_fixed_48_16_t div;
+ div = ((pixman_fixed_48_16_t)v.vector[0] << 16)/v.vector[2];
+ x1 = div >> 16;
+ distx = ((pixman_fixed_t)div >> 8) & 0xff;
+ div = ((pixman_fixed_48_16_t)v.vector[1] << 16)/v.vector[2];
+ y1 = div >> 16;
+ disty = ((pixman_fixed_t)div >> 8) & 0xff;
+ } else {
+ x1 = v.vector[0] >> 16;
+ distx = (v.vector[0] >> 8) & 0xff;
+ y1 = v.vector[1] >> 16;
+ disty = (v.vector[1] >> 8) & 0xff;
+ }
+ x2 = x1 + 1;
+ y2 = y1 + 1;
+
+ idistx = 256 - distx;
+ idisty = 256 - disty;
+
+ x1 = MOD (x1, pict->width);
+ x2 = MOD (x2, pict->width);
+ y1 = MOD (y1, pict->height);
+ y2 = MOD (y2, pict->height);
+
+ b = bits + y1*stride;
+
+ tl = pixman_region_contains_point(pict->common.src_clip, x1, y1, &box)
+ ? fetch((pixman_image_t *)pict, b, x1, indexed) : 0;
+ tr = pixman_region_contains_point(pict->common.src_clip, x2, y1, &box)
+ ? fetch((pixman_image_t *)pict, b, x2, indexed) : 0;
+ b = bits + (y2)*stride;
+ bl = pixman_region_contains_point(pict->common.src_clip, x1, y2, &box)
+ ? fetch((pixman_image_t *)pict, b, x1, indexed) : 0;
+ br = pixman_region_contains_point(pict->common.src_clip, x2, y2, &box)
+ ? fetch((pixman_image_t *)pict, b, x2, indexed) : 0;
+
+ ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+ fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+ r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+ ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+ fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+ r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+ ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+ fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+ r |= (((ft * idisty + fb * disty)) & 0xff0000);
+ ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+ fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+ r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
+ *(buffer + i) = r;
+ }
+ }
+
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ }
+ } else {
+ if (pixman_region_n_rects(pict->common.src_clip) == 1) {
+ box = pict->common.src_clip->extents;
+ for (i = 0; i < width; ++i) {
+ if (!mask || mask[i] & maskBits)
+ {
+ if (!v.vector[2]) {
+ *(buffer + i) = 0;
+ } else {
+ int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
+ uint32_t *b;
+ uint32_t tl, tr, bl, br, r;
+ pixman_bool_t x1_out, x2_out, y1_out, y2_out;
+ uint32_t ft, fb;
+
+ if (!affine) {
+ pixman_fixed_48_16_t div;
+ div = ((pixman_fixed_48_16_t)v.vector[0] << 16)/v.vector[2];
+ x1 = div >> 16;
+ distx = ((pixman_fixed_t)div >> 8) & 0xff;
+ div = ((pixman_fixed_48_16_t)v.vector[1] << 16)/v.vector[2];
+ y1 = div >> 16;
+ disty = ((pixman_fixed_t)div >> 8) & 0xff;
+ } else {
+ x1 = v.vector[0] >> 16;
+ distx = (v.vector[0] >> 8) & 0xff;
+ y1 = v.vector[1] >> 16;
+ disty = (v.vector[1] >> 8) & 0xff;
+ }
+ x2 = x1 + 1;
+ y2 = y1 + 1;
+
+ idistx = 256 - distx;
+ idisty = 256 - disty;
+
+ b = bits + (y1)*stride;
+ x_off = x1;
+
+ x1_out = (x1 < box.x1) | (x1 >= box.x2);
+ x2_out = (x2 < box.x1) | (x2 >= box.x2);
+ y1_out = (y1 < box.y1) | (y1 >= box.y2);
+ y2_out = (y2 < box.y1) | (y2 >= box.y2);
+
+ tl = x1_out|y1_out ? 0 : fetch((pixman_image_t *)pict, b, x_off, indexed);
+ tr = x2_out|y1_out ? 0 : fetch((pixman_image_t *)pict, b, x_off + 1, indexed);
+ b += stride;
+ bl = x1_out|y2_out ? 0 : fetch((pixman_image_t *)pict, b, x_off, indexed);
+ br = x2_out|y2_out ? 0 : fetch((pixman_image_t *)pict, b, x_off + 1, indexed);
+
+ ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+ fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+ r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+ ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+ fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+ r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+ ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+ fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+ r |= (((ft * idisty + fb * disty)) & 0xff0000);
+ ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+ fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+ r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
+ *(buffer + i) = r;
+ }
+ }
+
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ } else {
+ for (i = 0; i < width; ++i) {
+ if (!mask || mask[i] & maskBits)
+ {
+ if (!v.vector[2]) {
+ *(buffer + i) = 0;
+ } else {
+ int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
+ uint32_t *b;
+ uint32_t tl, tr, bl, br, r;
+ uint32_t ft, fb;
+
+ if (!affine) {
+ pixman_fixed_48_16_t div;
+ div = ((pixman_fixed_48_16_t)v.vector[0] << 16)/v.vector[2];
+ x1 = div >> 16;
+ distx = ((pixman_fixed_t)div >> 8) & 0xff;
+ div = ((pixman_fixed_48_16_t)v.vector[1] << 16)/v.vector[2];
+ y1 = div >> 16;
+ disty = ((pixman_fixed_t)div >> 8) & 0xff;
+ } else {
+ x1 = v.vector[0] >> 16;
+ distx = (v.vector[0] >> 8) & 0xff;
+ y1 = v.vector[1] >> 16;
+ disty = (v.vector[1] >> 8) & 0xff;
+ }
+ x2 = x1 + 1;
+ y2 = y1 + 1;
+
+ idistx = 256 - distx;
+ idisty = 256 - disty;
+
+ b = bits + (y1)*stride;
+ x_off = x1;
+
+ tl = pixman_region_contains_point(pict->common.src_clip, x1, y1, &box)
+ ? fetch((pixman_image_t *)pict, b, x_off, indexed) : 0;
+ tr = pixman_region_contains_point(pict->common.src_clip, x2, y1, &box)
+ ? fetch((pixman_image_t *)pict, b, x_off + 1, indexed) : 0;
+ b += stride;
+ bl = pixman_region_contains_point(pict->common.src_clip, x1, y2, &box)
+ ? fetch((pixman_image_t *)pict, b, x_off, indexed) : 0;
+ br = pixman_region_contains_point(pict->common.src_clip, x2, y2, &box)
+ ? fetch((pixman_image_t *)pict, b, x_off + 1, indexed) : 0;
+
+ ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+ fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+ r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+ ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+ fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+ r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+ ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+ fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+ r |= (((ft * idisty + fb * disty)) & 0xff0000);
+ ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+ fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+ r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
+ *(buffer + i) = r;
+ }
+ }
+
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ }
+ }
+ } else if (pict->common.filter == PIXMAN_FILTER_CONVOLUTION) {
+ pixman_fixed_t *params = pict->common.filter_params;
+ int32_t cwidth = pixman_fixed_to_int(params[0]);
+ int32_t cheight = pixman_fixed_to_int(params[1]);
+ int xoff = (params[0] - pixman_fixed_1) >> 1;
+ int yoff = (params[1] - pixman_fixed_1) >> 1;
+ params += 2;
+ for (i = 0; i < width; ++i) {
+ if (!mask || mask[i] & maskBits)
+ {
+ if (!v.vector[2]) {
+ *(buffer + i) = 0;
+ } else {
+ int x1, x2, y1, y2, x, y;
+ int32_t srtot, sgtot, sbtot, satot;
+ pixman_fixed_t *p = params;
+
+ if (!affine) {
+ pixman_fixed_48_16_t tmp;
+ tmp = ((pixman_fixed_48_16_t)v.vector[0] << 16)/v.vector[2] - xoff;
+ x1 = pixman_fixed_to_int(tmp);
+ tmp = ((pixman_fixed_48_16_t)v.vector[1] << 16)/v.vector[2] - yoff;
+ y1 = pixman_fixed_to_int(tmp);
+ } else {
+ x1 = pixman_fixed_to_int(v.vector[0] - xoff);
+ y1 = pixman_fixed_to_int(v.vector[1] - yoff);
+ }
+ x2 = x1 + cwidth;
+ y2 = y1 + cheight;
+
+ srtot = sgtot = sbtot = satot = 0;
+
+ for (y = y1; y < y2; y++) {
+ int ty = (pict->common.repeat == PIXMAN_REPEAT_NORMAL) ? MOD (y, pict->height) : y;
+ for (x = x1; x < x2; x++) {
+ if (*p) {
+ int tx = (pict->common.repeat == PIXMAN_REPEAT_NORMAL) ? MOD (x, pict->width) : x;
+ if (pixman_region_contains_point (pict->common.src_clip, tx, ty, &box)) {
+ uint32_t *b = bits + (ty)*stride;
+ uint32_t c = fetch((pixman_image_t *)pict, b, tx, indexed);
+
+ srtot += Red(c) * *p;
+ sgtot += Green(c) * *p;
+ sbtot += Blue(c) * *p;
+ satot += Alpha(c) * *p;
+ }
+ }
+ p++;
+ }
+ }
+
+ satot >>= 16;
+ srtot >>= 16;
+ sgtot >>= 16;
+ sbtot >>= 16;
+
+ if (satot < 0) satot = 0; else if (satot > 0xff) satot = 0xff;
+ if (srtot < 0) srtot = 0; else if (srtot > 0xff) srtot = 0xff;
+ if (sgtot < 0) sgtot = 0; else if (sgtot > 0xff) sgtot = 0xff;
+ if (sbtot < 0) sbtot = 0; else if (sbtot > 0xff) sbtot = 0xff;
+
+ *(buffer + i) = ((satot << 24) |
+ (srtot << 16) |
+ (sgtot << 8) |
+ (sbtot ));
+ }
+ }
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ }
+
+ fbFinishAccess (pict->pDrawable);
+}
+
+
+static void fbFetchExternalAlpha(bits_image_t * pict, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits)
+{
+ int i;
+ uint32_t _alpha_buffer[SCANLINE_BUFFER_LENGTH];
+ uint32_t *alpha_buffer = _alpha_buffer;
+
+ if (!pict->common.alpha_map) {
+ fbFetchTransformed (pict, x, y, width, buffer, mask, maskBits);
+ return;
+ }
+ if (width > SCANLINE_BUFFER_LENGTH)
+ alpha_buffer = (uint32_t *) pixman_malloc_ab (width, sizeof(uint32_t));
+
+ fbFetchTransformed(pict, x, y, width, buffer, mask, maskBits);
+ fbFetchTransformed((bits_image_t *)pict->common.alpha_map, x - pict->common.alpha_origin.x,
+ y - pict->common.alpha_origin.y, width, alpha_buffer,
+ mask, maskBits);
+ for (i = 0; i < width; ++i) {
+ if (!mask || mask[i] & maskBits)
+ {
+ int a = alpha_buffer[i]>>24;
+ *(buffer + i) = (a << 24)
+ | (div_255(Red(*(buffer + i)) * a) << 16)
+ | (div_255(Green(*(buffer + i)) * a) << 8)
+ | (div_255(Blue(*(buffer + i)) * a));
+ }
+ }
+
+ if (alpha_buffer != _alpha_buffer)
+ free(alpha_buffer);
+}
+
+static void fbStore(bits_image_t * pict, int x, int y, int width, uint32_t *buffer)
+{
+ uint32_t *bits;
- uint32_t stride;
++ int32_t stride;
+ storeProc_32 store = storeProcForPicture_32(pict);
+ const pixman_indexed_t * indexed = pict->indexed;
+
+ bits = pict->bits;
+ stride = pict->rowstride;
+ bits += y*stride;
+ store((pixman_image_t *)pict, bits, buffer, x, width, indexed);
+ fbFinishAccess (pict->pDrawable);
+}
+
+static void fbStore64(bits_image_t * pict, int x, int y, int width, uint64_t *buffer)
+{
+ uint32_t *bits;
- uint32_t stride;
++ int32_t stride;
+ storeProc_64 store = storeProcForPicture_64(pict);
+ const pixman_indexed_t * indexed = pict->indexed;
+
+ bits = pict->bits;
+ stride = pict->rowstride;
+ bits += y*stride;
+ store((pixman_image_t *)pict, bits, buffer, x, width, indexed);
+ fbFinishAccess (pict->pDrawable);
+}
+
+static void fbStoreExternalAlpha(bits_image_t * pict, int x, int y, int width, uint32_t *buffer)
+{
+ uint32_t *bits, *alpha_bits;
- uint32_t stride, astride;
++ int32_t stride, astride;
+ int ax, ay;
+ storeProc_32 store;
+ storeProc_32 astore;
+ const pixman_indexed_t * indexed = pict->indexed;
+ const pixman_indexed_t * aindexed;
+
+ if (!pict->common.alpha_map) {
+ fbStore(pict, x, y, width, buffer);
+ return;
+ }
+
+ store = storeProcForPicture_32(pict);
+ astore = storeProcForPicture_32(pict->common.alpha_map);
+ aindexed = pict->common.alpha_map->indexed;
+
+ ax = x;
+ ay = y;
+
+ bits = pict->bits;
+ stride = pict->rowstride;
+
+ alpha_bits = pict->common.alpha_map->bits;
+ astride = pict->common.alpha_map->rowstride;
+
+ bits += y*stride;
+ alpha_bits += (ay - pict->common.alpha_origin.y)*astride;
+
+
+ store((pixman_image_t *)pict, bits, buffer, x, width, indexed);
+ astore((pixman_image_t *)pict->common.alpha_map,
+ alpha_bits, buffer, ax - pict->common.alpha_origin.x, width, aindexed);
+
+ fbFinishAccess (pict->alpha_map->pDrawable);
+ fbFinishAccess (pict->pDrawable);
+}
+
+static void fbStoreExternalAlpha64(bits_image_t * pict, int x, int y, int width, uint64_t *buffer)
+{
+ uint32_t *bits, *alpha_bits;
- uint32_t stride, astride;
++ int32_t stride, astride;
+ int ax, ay;
+ storeProc_64 store;
+ storeProc_64 astore;
+ const pixman_indexed_t * indexed = pict->indexed;
+ const pixman_indexed_t * aindexed;
+
+ if (!pict->common.alpha_map) {
+ fbStore64(pict, x, y, width, buffer);
+ return;
+ }
+
+ store = storeProcForPicture_64(pict);
+ astore = storeProcForPicture_64(pict->common.alpha_map);
+ aindexed = pict->common.alpha_map->indexed;
+
+ ax = x;
+ ay = y;
+
+ bits = pict->bits;
+ stride = pict->rowstride;
+
+ alpha_bits = pict->common.alpha_map->bits;
+ astride = pict->common.alpha_map->rowstride;
+
+ bits += y*stride;
+ alpha_bits += (ay - pict->common.alpha_origin.y)*astride;
+
+
+ store((pixman_image_t *)pict, bits, buffer, x, width, indexed);
+ astore((pixman_image_t *)pict->common.alpha_map,
+ alpha_bits, buffer, ax - pict->common.alpha_origin.x, width, aindexed);
+
+ fbFinishAccess (pict->alpha_map->pDrawable);
+ fbFinishAccess (pict->pDrawable);
+}
+
+static void
+fbExpand(uint32_t * source, uint64_t * dest, int width)
+{
+ int i;
+ for(i = 0; i < width; i++) {
+ uint32_t p = source[i];
+ uint64_t r = (uint64_t)(p & 0x00ff0000) << 24;
+ uint64_t g = (uint64_t)(p & 0x0000ff00) << 16;
+ uint64_t b = (uint64_t)(p & 0x000000ff) << 8;
+ uint64_t a = (uint64_t)(p & 0xff000000) << 32;
+
+ dest[i] = r | g | b | a;
+ }
+}
+
+static void
+fbContract(uint64_t * source, uint32_t * dest, int width)
+{
+ int i;
+ for(i = 0; i < width; i++) {
+ uint64_t p = source[i];
+ uint64_t r = (p >> 24) & 0x00ff0000;
+ uint64_t g = (p >> 16) & 0x0000ff00;
+ uint64_t b = (p >> 8) & 0x000000ff;
+ uint64_t a = (p >> 32) & 0xff000000;
+
+ dest[i] = r | g | b | a;
+ }
+}
+
+static uint32_t
+fbContractPixel(uint64_t p)
+{
+ uint64_t r = (p >> 24) & 0x00ff0000;
+ uint64_t g = (p >> 16) & 0x0000ff00;
+ uint64_t b = (p >> 8) & 0x000000ff;
+ uint64_t a = (p >> 32) & 0xff000000;
+
+ return r | g | b | a;
+}
+
+static void
+pixmanFetchSourcePict64(source_image_t * pict, int x, int y, int width, uint64_t *buffer, uint64_t *mask, uint64_t maskBits)
+{
+ // use the space in the existing buffer for the 32-bit mask and result
+ uint32_t * mask32 = (uint32_t *) buffer;
+ uint32_t * buffer32 = ((uint32_t *) buffer) + width;
+ uint32_t maskBits32 = fbContractPixel(maskBits);
+
+ if(mask)
+ fbContract(mask, mask32, width);
+ else
+ mask32 = NULL;
+ pixmanFetchSourcePict(pict, x, y, width, buffer32, mask32, maskBits32);
+ fbExpand(buffer32, buffer, width);
+}
+
+static void
+fbFetchExternalAlpha64(bits_image_t * pict, int x, int y, int width, uint64_t *buffer, uint64_t *mask, uint64_t maskBits)
+{
+ uint32_t * mask32 = (uint32_t *) buffer;
+ uint32_t * buffer32 = ((uint32_t *) buffer) + width;
+ uint32_t maskBits32 = fbContractPixel(maskBits);
+
+ if (mask)
+ fbContract(mask, mask32, width);
+ else
+ mask32 = NULL;
+ fbFetchExternalAlpha(pict, x, y, width, buffer32, mask32, maskBits32);
+ fbExpand(buffer32, buffer, width);
+}
+
+static void
+fbFetchTransformed64(bits_image_t * pict, int x, int y, int width, uint64_t *buffer, uint64_t *mask, uint64_t maskBits)
+{
+ uint32_t * mask32 = (uint32_t *) buffer;
+ uint32_t * buffer32 = ((uint32_t *) buffer) + width;
+ uint32_t maskBits32 = fbContractPixel(maskBits);
+
+ if (mask)
+ fbContract(mask, mask32, width);
+ else
+ mask32 = NULL;
+ fbFetchTransformed(pict, x, y, width, buffer32, mask32, maskBits32);
+ fbExpand(buffer32, buffer, width);
+}
+
+typedef void (*scanStoreProc)(pixman_image_t *, int, int, int, uint32_t *);
+typedef void (*scanFetchProc)(pixman_image_t *, int, int, int, uint32_t *,
+ uint32_t *, uint32_t);
+
+typedef void (*scanStoreProc64)(pixman_image_t *, int, int, int, uint64_t *);
+typedef void (*scanFetchProc64)(pixman_image_t *, int, int, int, uint64_t *,
+ uint64_t *, uint64_t);
+
+//#ifndef PIXMAN_FB_ACCESSORS
+//static
+//#endif
+void
+PIXMAN_COMPOSITE_RECT_GENERAL (const FbComposeData *data,
+ uint32_t *scanline_buffer)
+{
+ uint32_t *src_buffer = scanline_buffer;
+ uint32_t *dest_buffer = src_buffer + data->width;
+ int i;
+ scanStoreProc store;
+ scanFetchProc fetchSrc = NULL, fetchMask = NULL, fetchDest = NULL;
+ unsigned int srcClass = SOURCE_IMAGE_CLASS_UNKNOWN;
+ unsigned int maskClass = SOURCE_IMAGE_CLASS_UNKNOWN;
+ uint32_t *bits;
- uint32_t stride;
++ int32_t stride;
+ int xoff, yoff;
+
+ if (data->op == PIXMAN_OP_CLEAR)
+ fetchSrc = NULL;
+ else if (IS_SOURCE_IMAGE (data->src))
+ {
+ fetchSrc = (scanFetchProc)pixmanFetchSourcePict;
+ srcClass = SourcePictureClassify ((source_image_t *)data->src,
+ data->xSrc, data->ySrc,
+ data->width, data->height);
+ }
+ else
+ {
+ bits_image_t *bits = (bits_image_t *)data->src;
+
+ if (bits->common.alpha_map)
+ {
+ fetchSrc = (scanFetchProc)fbFetchExternalAlpha;
+ }
+ else if (bits->common.repeat == PIXMAN_REPEAT_NORMAL &&
+ bits->width == 1 &&
+ bits->height == 1)
+ {
+ fetchSrc = (scanFetchProc)fbFetchSolid;
+ srcClass = SOURCE_IMAGE_CLASS_HORIZONTAL;
+ }
+ else if (!bits->common.transform && bits->common.filter != PIXMAN_FILTER_CONVOLUTION)
+ {
+ fetchSrc = (scanFetchProc)fbFetch;
+ }
+ else
+ {
+ fetchSrc = (scanFetchProc)fbFetchTransformed;
+ }
+ }
+
+ if (!data->mask || data->op == PIXMAN_OP_CLEAR)
+ {
+ fetchMask = NULL;
+ }
+ else
+ {
+ if (IS_SOURCE_IMAGE (data->mask))
+ {
+ fetchMask = (scanFetchProc)pixmanFetchSourcePict;
+ maskClass = SourcePictureClassify ((source_image_t *)data->mask,
+ data->xMask, data->yMask,
+ data->width, data->height);
+ }
+ else
+ {
+ bits_image_t *bits = (bits_image_t *)data->mask;
+
+ if (bits->common.alpha_map)
+ {
+ fetchMask = (scanFetchProc)fbFetchExternalAlpha;
+ }
+ else if (bits->common.repeat == PIXMAN_REPEAT_NORMAL &&
+ bits->width == 1 && bits->height == 1)
+ {
+ fetchMask = (scanFetchProc)fbFetchSolid;
+ maskClass = SOURCE_IMAGE_CLASS_HORIZONTAL;
+ }
+ else if (!bits->common.transform && bits->common.filter != PIXMAN_FILTER_CONVOLUTION)
+ fetchMask = (scanFetchProc)fbFetch;
+ else
+ fetchMask = (scanFetchProc)fbFetchTransformed;
+ }
+ }
+
+ if (data->dest->common.alpha_map)
+ {
+ fetchDest = (scanFetchProc)fbFetchExternalAlpha;
+ store = (scanStoreProc)fbStoreExternalAlpha;
+
+ if (data->op == PIXMAN_OP_CLEAR || data->op == PIXMAN_OP_SRC)
+ fetchDest = NULL;
+ }
+ else
+ {
+ fetchDest = (scanFetchProc)fbFetch;
+ store = (scanStoreProc)fbStore;
+
+ switch (data->op)
+ {
+ case PIXMAN_OP_CLEAR:
+ case PIXMAN_OP_SRC:
+ fetchDest = NULL;
+#ifndef PIXMAN_FB_ACCESSORS
+ /* fall-through */
+ case PIXMAN_OP_ADD:
+ case PIXMAN_OP_OVER:
+ switch (data->dest->bits.format) {
+ case PIXMAN_a8r8g8b8:
+ case PIXMAN_x8r8g8b8:
+ store = NULL;
+ break;
+ default:
+ break;
+ }
+#endif
+ break;
+ }
+ }
+
+ if (!store)
+ {
+ bits = data->dest->bits.bits;
+ stride = data->dest->bits.rowstride;
+ xoff = yoff = 0;
+ }
+ else
+ {
+ bits = NULL;
+ stride = 0;
+ xoff = yoff = 0;
+ }
+
+ if (fetchSrc &&
+ fetchMask &&
+ data->mask &&
+ data->mask->common.type == BITS &&
+ data->mask->common.component_alpha &&
+ PIXMAN_FORMAT_RGB (data->mask->bits.format))
+ {
+ uint32_t *mask_buffer = dest_buffer + data->width;
+ CombineFuncC compose = pixman_composeFunctions.combineC[data->op];
+ if (!compose)
+ return;
+
+ for (i = 0; i < data->height; ++i) {
+ /* fill first half of scanline with source */
+ if (fetchSrc)
+ {
+ if (fetchMask)
+ {
+ /* fetch mask before source so that fetching of
+ source can be optimized */
+ fetchMask (data->mask, data->xMask, data->yMask + i,
+ data->width, mask_buffer, 0, 0);
+
+ if (maskClass == SOURCE_IMAGE_CLASS_HORIZONTAL)
+ fetchMask = NULL;
+ }
+
+ if (srcClass == SOURCE_IMAGE_CLASS_HORIZONTAL)
+ {
+ fetchSrc (data->src, data->xSrc, data->ySrc + i,
+ data->width, src_buffer, 0, 0);
+ fetchSrc = NULL;
+ }
+ else
+ {
+ fetchSrc (data->src, data->xSrc, data->ySrc + i,
+ data->width, src_buffer, mask_buffer,
+ 0xffffffff);
+ }
+ }
+ else if (fetchMask)
+ {
+ fetchMask (data->mask, data->xMask, data->yMask + i,
+ data->width, mask_buffer, 0, 0);
+ }
+
+ if (store)
+ {
+ /* fill dest into second half of scanline */
+ if (fetchDest)
+ fetchDest (data->dest, data->xDest, data->yDest + i,
+ data->width, dest_buffer, 0, 0);
+
+ /* blend */
+ compose (dest_buffer, src_buffer, mask_buffer, data->width);
+
+ /* write back */
+ store (data->dest, data->xDest, data->yDest + i, data->width,
+ dest_buffer);
+ }
+ else
+ {
+ /* blend */
+ compose (bits + (data->yDest + i+ yoff) * stride +
+ data->xDest + xoff,
+ src_buffer, mask_buffer, data->width);
+ }
+ }
+ }
+ else
+ {
+ uint32_t *src_mask_buffer = 0, *mask_buffer = 0;
+ CombineFuncU compose = pixman_composeFunctions.combineU[data->op];
+ if (!compose)
+ return;
+
+ if (fetchMask)
+ mask_buffer = dest_buffer + data->width;
+
+ for (i = 0; i < data->height; ++i) {
+ /* fill first half of scanline with source */
+ if (fetchSrc)
+ {
+ if (fetchMask)
+ {
+ /* fetch mask before source so that fetching of
+ source can be optimized */
+ fetchMask (data->mask, data->xMask, data->yMask + i,
+ data->width, mask_buffer, 0, 0);
+
+ if (maskClass == SOURCE_IMAGE_CLASS_HORIZONTAL)
+ fetchMask = NULL;
+ }
+
+ if (srcClass == SOURCE_IMAGE_CLASS_HORIZONTAL)
+ {
+ fetchSrc (data->src, data->xSrc, data->ySrc + i,
+ data->width, src_buffer, 0, 0);
+
+ if (mask_buffer)
+ {
+ pixman_composeFunctions.combineU[PIXMAN_OP_IN] (mask_buffer, src_buffer, data->width);
+ src_mask_buffer = mask_buffer;
+ }
+ else
+ src_mask_buffer = src_buffer;
+
+ fetchSrc = NULL;
+ }
+ else
+ {
+ fetchSrc (data->src, data->xSrc, data->ySrc + i,
+ data->width, src_buffer, mask_buffer,
+ 0xff000000);
+
+ if (mask_buffer)
+ pixman_composeFunctions.combineMaskU (src_buffer,
+ mask_buffer,
+ data->width);
+
+ src_mask_buffer = src_buffer;
+ }
+ }
+ else if (fetchMask)
+ {
+ fetchMask (data->mask, data->xMask, data->yMask + i,
+ data->width, mask_buffer, 0, 0);
+
+ pixman_composeFunctions.combineU[PIXMAN_OP_IN] (mask_buffer, src_buffer, data->width);
+
+ src_mask_buffer = mask_buffer;
+ }
+
+ if (store)
+ {
+ /* fill dest into second half of scanline */
+ if (fetchDest)
+ fetchDest (data->dest, data->xDest, data->yDest + i,
+ data->width, dest_buffer, 0, 0);
+
+ /* blend */
+ compose (dest_buffer, src_mask_buffer, data->width);
+
+ /* write back */
+ store (data->dest, data->xDest, data->yDest + i, data->width,
+ dest_buffer);
+ }
+ else
+ {
+ /* blend */
+ compose (bits + (data->yDest + i+ yoff) * stride +
+ data->xDest + xoff,
+ src_mask_buffer, data->width);
+ }
+ }
+ }
+
+ if (!store)
+ fbFinishAccess (data->dest->pDrawable);
+}
+
+
+void
+PIXMAN_COMPOSITE_RECT_GENERAL_WIDE (const FbComposeData *data,
+ uint64_t *scanline_buffer)
+{
+ uint64_t *src_buffer = scanline_buffer;
+ uint64_t *dest_buffer = src_buffer + data->width;
+ int i;
+ scanStoreProc64 store;
+ scanFetchProc64 fetchSrc = NULL, fetchMask = NULL, fetchDest = NULL;
+ unsigned int srcClass = SOURCE_IMAGE_CLASS_UNKNOWN;
+ unsigned int maskClass = SOURCE_IMAGE_CLASS_UNKNOWN;
+ uint32_t *bits;
- uint32_t stride;
++ int32_t stride;
+ int xoff, yoff;
+
+ if (data->op == PIXMAN_OP_CLEAR)
+ fetchSrc = NULL;
+ else if (IS_SOURCE_IMAGE (data->src))
+ {
+ fetchSrc = (scanFetchProc64)pixmanFetchSourcePict64;
+ srcClass = SourcePictureClassify ((source_image_t *)data->src,
+ data->xSrc, data->ySrc,
+ data->width, data->height);
+ }
+ else
+ {
+ bits_image_t *bits = (bits_image_t *)data->src;
+
+ if (bits->common.alpha_map)
+ {
+ fetchSrc = (scanFetchProc64)fbFetchExternalAlpha64;
+ }
+ else if (bits->common.repeat == PIXMAN_REPEAT_NORMAL &&
+ bits->width == 1 &&
+ bits->height == 1)
+ {
+ fetchSrc = (scanFetchProc64)fbFetchSolid64;
+ srcClass = SOURCE_IMAGE_CLASS_HORIZONTAL;
+ }
+ else if (!bits->common.transform && bits->common.filter != PIXMAN_FILTER_CONVOLUTION)
+ {
+ fetchSrc = (scanFetchProc64)fbFetch64;
+ }
+ else
+ {
+ fetchSrc = (scanFetchProc64)fbFetchTransformed64;
+ }
+ }
+
+ if (!data->mask || data->op == PIXMAN_OP_CLEAR)
+ {
+ fetchMask = NULL;
+ }
+ else
+ {
+ if (IS_SOURCE_IMAGE (data->mask))
+ {
+ fetchMask = (scanFetchProc64)pixmanFetchSourcePict64;
+ maskClass = SourcePictureClassify ((source_image_t *)data->mask,
+ data->xMask, data->yMask,
+ data->width, data->height);
+ }
+ else
+ {
+ bits_image_t *bits = (bits_image_t *)data->mask;
+
+ if (bits->common.alpha_map)
+ {
+ fetchMask = (scanFetchProc64)fbFetchExternalAlpha64;
+ }
+ else if (bits->common.repeat == PIXMAN_REPEAT_NORMAL &&
+ bits->width == 1 && bits->height == 1)
+ {
+ fetchMask = (scanFetchProc64)fbFetchSolid64;
+ maskClass = SOURCE_IMAGE_CLASS_HORIZONTAL;
+ }
+ else if (!bits->common.transform && bits->common.filter != PIXMAN_FILTER_CONVOLUTION)
+ fetchMask = (scanFetchProc64)fbFetch64;
+ else
+ fetchMask = (scanFetchProc64)fbFetchTransformed64;
+ }
+ }
+
+ if (data->dest->common.alpha_map)
+ {
+ fetchDest = (scanFetchProc64)fbFetchExternalAlpha64;
+ store = (scanStoreProc64)fbStoreExternalAlpha64;
+
+ if (data->op == PIXMAN_OP_CLEAR || data->op == PIXMAN_OP_SRC)
+ fetchDest = NULL;
+ }
+ else
+ {
+ fetchDest = (scanFetchProc64)fbFetch64;
+ store = (scanStoreProc64)fbStore64;
+
+ switch (data->op)
+ {
+ case PIXMAN_OP_CLEAR:
+ case PIXMAN_OP_SRC:
+ fetchDest = NULL;
+ break;
+ }
+ }
+
+ if (!store)
+ {
+ bits = data->dest->bits.bits;
+ stride = data->dest->bits.rowstride;
+ xoff = yoff = 0;
+ }
+ else
+ {
+ bits = NULL;
+ stride = 0;
+ xoff = yoff = 0;
+ }
+
+ if (fetchSrc &&
+ fetchMask &&
+ data->mask &&
+ data->mask->common.type == BITS &&
+ data->mask->common.component_alpha &&
+ PIXMAN_FORMAT_RGB (data->mask->bits.format))
+ {
+ uint64_t *mask_buffer = dest_buffer + data->width;
+ CombineFuncC64 compose = pixman_composeFunctions_wide.combineC[data->op];
+ if (!compose)
+ return;
+
+ for (i = 0; i < data->height; ++i) {
+ /* fill first half of scanline with source */
+ if (fetchSrc)
+ {
+ if (fetchMask)
+ {
+ /* fetch mask before source so that fetching of
+ source can be optimized */
+ fetchMask (data->mask, data->xMask, data->yMask + i,
+ data->width, mask_buffer, 0, 0);
+
+ if (maskClass == SOURCE_IMAGE_CLASS_HORIZONTAL)
+ fetchMask = NULL;
+ }
+
+ if (srcClass == SOURCE_IMAGE_CLASS_HORIZONTAL)
+ {
+ fetchSrc (data->src, data->xSrc, data->ySrc + i,
+ data->width, src_buffer, 0, 0);
+ fetchSrc = NULL;
+ }
+ else
+ {
+ fetchSrc (data->src, data->xSrc, data->ySrc + i,
+ data->width, src_buffer, mask_buffer,
+ 0xffffffffffffffffLL);
+ }
+ }
+ else if (fetchMask)
+ {
+ fetchMask (data->mask, data->xMask, data->yMask + i,
+ data->width, mask_buffer, 0, 0);
+ }
+
+ if (store)
+ {
+ /* fill dest into second half of scanline */
+ if (fetchDest)
+ fetchDest (data->dest, data->xDest, data->yDest + i,
+ data->width, dest_buffer, 0, 0);
+
+ /* blend */
+ compose (dest_buffer, src_buffer, mask_buffer, data->width);
+
+ /* write back */
+ store (data->dest, data->xDest, data->yDest + i, data->width,
+ dest_buffer);
+ }
+ else
+ {
+ assert(!"need to have a storeproc with 64-bit internal format");
+ }
+ }
+ }
+ else
+ {
+ uint64_t *src_mask_buffer = 0, *mask_buffer = 0;
+ CombineFuncU64 compose = pixman_composeFunctions_wide.combineU[data->op];
+ if (!compose)
+ return;
+
+ if (fetchMask)
+ mask_buffer = dest_buffer + data->width;
+
+ for (i = 0; i < data->height; ++i) {
+ /* fill first half of scanline with source */
+ if (fetchSrc)
+ {
+ if (fetchMask)
+ {
+ /* fetch mask before source so that fetching of
+ source can be optimized */
+ fetchMask (data->mask, data->xMask, data->yMask + i,
+ data->width, mask_buffer, 0, 0);
+
+ if (maskClass == SOURCE_IMAGE_CLASS_HORIZONTAL)
+ fetchMask = NULL;
+ }
+
+ if (srcClass == SOURCE_IMAGE_CLASS_HORIZONTAL)
+ {
+ fetchSrc (data->src, data->xSrc, data->ySrc + i,
+ data->width, src_buffer, 0, 0);
+
+ if (mask_buffer)
+ {
+ pixman_composeFunctions_wide.combineU[PIXMAN_OP_IN] (mask_buffer, src_buffer, data->width);
+ src_mask_buffer = mask_buffer;
+ }
+ else
+ src_mask_buffer = src_buffer;
+
+ fetchSrc = NULL;
+ }
+ else
+ {
+ fetchSrc (data->src, data->xSrc, data->ySrc + i,
+ data->width, src_buffer, mask_buffer,
+ 0xffff000000000000LL);
+
+ if (mask_buffer)
+ pixman_composeFunctions_wide.combineMaskU (src_buffer,
+ mask_buffer,
+ data->width);
+
+ src_mask_buffer = src_buffer;
+ }
+ }
+ else if (fetchMask)
+ {
+ fetchMask (data->mask, data->xMask, data->yMask + i,
+ data->width, mask_buffer, 0, 0);
+
+ pixman_composeFunctions_wide.combineU[PIXMAN_OP_IN] (mask_buffer, src_buffer, data->width);
+
+ src_mask_buffer = mask_buffer;
+ }
+
+ if (store)
+ {
+ /* fill dest into second half of scanline */
+ if (fetchDest)
+ fetchDest (data->dest, data->xDest, data->yDest + i,
+ data->width, dest_buffer, 0, 0);
+
+ /* blend */
+ compose (dest_buffer, src_mask_buffer, data->width);
+
+ /* write back */
+ store (data->dest, data->xDest, data->yDest + i, data->width,
+ dest_buffer);
+ }
+ else
+ {
+ assert(!"need to have a storeproc with 64-bit internal format");
+ }
+ }
+ }
+
+ if (!store)
+ fbFinishAccess (data->dest->pDrawable);
+}
commit 4bd67df1ef73a4e604de68310314d6b4f25f1247
Author: Aaron Plattner <aplattner at nvidia.com>
Date: Mon Oct 22 17:54:42 2007 -0700
Don't crash in fbFetch*64 if mask is NULL.
diff --git a/pixman/pixman-access-handcode.c b/pixman/pixman-access-handcode.c
index aacf85a..2049836 100644
--- a/pixman/pixman-access-handcode.c
+++ b/pixman/pixman-access-handcode.c
@@ -2187,7 +2187,10 @@ fbFetchExternalAlpha64(bits_image_t * pict, int x, int y, int width, uint64_t *b
uint32_t * buffer32 = ((uint32_t *) buffer) + width;
uint32_t maskBits32 = fbContractPixel(maskBits);
- fbContract(mask, mask32, width);
+ if (mask)
+ fbContract(mask, mask32, width);
+ else
+ mask32 = NULL;
fbFetchExternalAlpha(pict, x, y, width, buffer32, mask32, maskBits32);
fbExpand(buffer32, buffer, width);
}
@@ -2199,7 +2202,10 @@ fbFetchTransformed64(bits_image_t * pict, int x, int y, int width, uint64_t *buf
uint32_t * buffer32 = ((uint32_t *) buffer) + width;
uint32_t maskBits32 = fbContractPixel(maskBits);
- fbContract(mask, mask32, width);
+ if (mask)
+ fbContract(mask, mask32, width);
+ else
+ mask32 = NULL;
fbFetchTransformed(pict, x, y, width, buffer32, mask32, maskBits32);
fbExpand(buffer32, buffer, width);
}
commit 8916b43c4e14099beeea77f8a27179dc281ba25b
Author: Aaron Plattner <aplattner at nvidia.com>
Date: Mon Oct 22 17:42:28 2007 -0700
Include pixman-access-handcode.c with the preprocessor instead of dumping it wholesale into pixman-access.c.
This allows the compiler to generate useful debugging symbols.
diff --git a/pixman/gen.pl b/pixman/gen.pl
index 9420c0f..dfb73b6 100644
--- a/pixman/gen.pl
+++ b/pixman/gen.pl
@@ -412,6 +412,6 @@ sub gen_functions($@)
our @formats;
require "formats.pl";
-print `cat pixman-access-handcode.c`, "\n\n";
+print "#include \"pixman-access-handcode.c\"\n\n";
print gen_functions(32, @formats);
print gen_functions(64, @formats);
commit a0e7d143b8f9f88fcf8cf8e95de30b7c08464b11
Author: Aaron Plattner <aplattner at nvidia.com>
Date: Mon Oct 22 16:53:16 2007 -0700
Unify the 32-bit and 64-bit versions of pixman-compose.c.
Switch everything over from using types like uint32_t to new types full_t,
half_t, and quart_t. For pixman-compose32.c, these are uint32_t, uint16_t, and
uint8_t respectively. For pixman-compose64.c, they are double those sizes.
diff --git a/pixman/Makefile.am b/pixman/Makefile.am
index 73dc691..0cee103 100644
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@ -13,7 +13,7 @@ libpixman_1_la_SOURCES = \
pixman-image.c \
pixman-access.c \
pixman-access-accessors.c \
- pixman-compose.c \
+ pixman-compose32.c \
pixman-compose64.c \
pixman-pict.c \
pixman-utils.c \
diff --git a/pixman/pixman-compose.c b/pixman/pixman-compose.c
index 7dc86f3..2f465d5 100644
--- a/pixman/pixman-compose.c
+++ b/pixman/pixman-compose.c
@@ -23,18 +23,10 @@
* SOFTWARE.
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
+#ifndef FULL_MASK
+#error This file should not be compiled directly.
#endif
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <assert.h>
-#include <limits.h>
-
-#include "pixman-private.h"
-
/*
* FIXME:
* The stuff here is added just to get it to compile. Something sensible needs to
@@ -48,200 +40,16 @@
/*
- The methods below use some tricks to be able to do two color
- components at the same time.
-*/
-
-/*
- x_c = (x_c * a) / 255
-*/
-static inline uint32_t FbByteMul(uint32_t x, uint32_t a)
-{
- uint32_t t = ((x & 0xff00ff) * a) + 0x800080;
- t = (t + ((t >> 8) & 0xff00ff)) >> 8;
- t &= 0xff00ff;
-
- x = (((x >> 8) & 0xff00ff) * a) + 0x800080;
- x = (x + ((x >> 8) & 0xff00ff));
- x &= 0xff00ff00;
- return x + t;
-}
-
-/*
- x_c = (x_c * a) / 255 + y
-*/
-static inline uint32_t FbByteMulAdd(uint32_t x, uint32_t a, uint32_t y)
-{
- uint32_t t = ((x & 0xff00ff) * a) + 0x800080;
- t = (t + ((t >> 8) & 0xff00ff)) >> 8;
- t &= 0xff00ff;
- t += y & 0xff00ff;
- t |= 0x1000100 - ((t >> 8) & 0xff00ff);
- t &= 0xff00ff;
-
- x = (((x >> 8) & 0xff00ff) * a) + 0x800080;
- x = (x + ((x >> 8) & 0xff00ff)) >> 8;
- x &= 0xff00ff;
- x += (y >> 8) & 0xff00ff;
- x |= 0x1000100 - ((x >> 8) & 0xff00ff);
- x &= 0xff00ff;
- x <<= 8;
- return x + t;
-}
-
-/*
- x_c = (x_c * a + y_c * b) / 255
-*/
-static inline uint32_t FbByteAddMul(uint32_t x, uint32_t a, uint32_t y, uint32_t b)
-{
- uint32_t t;
- uint32_t r = (x >> 24) * a + (y >> 24) * b + 0x80;
- r += (r >> 8);
- r >>= 8;
-
- t = (x & 0xff00) * a + (y & 0xff00) * b;
- t += (t >> 8) + 0x8000;
- t >>= 16;
-
- t |= r << 16;
- t |= 0x1000100 - ((t >> 8) & 0xff00ff);
- t &= 0xff00ff;
- t <<= 8;
-
- r = ((x >> 16) & 0xff) * a + ((y >> 16) & 0xff) * b + 0x80;
- r += (r >> 8);
- r >>= 8;
-
- x = (x & 0xff) * a + (y & 0xff) * b + 0x80;
- x += (x >> 8);
- x >>= 8;
- x |= r << 16;
- x |= 0x1000100 - ((x >> 8) & 0xff00ff);
- x &= 0xff00ff;
- return x | t;
-}
-
-/*
- x_c = (x_c * a + y_c *b) / 256
-*/
-static inline uint32_t FbByteAddMul_256(uint32_t x, uint32_t a, uint32_t y, uint32_t b)
-{
- uint32_t t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
- t >>= 8;
- t &= 0xff00ff;
-
- x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
- x &= 0xff00ff00;
- return x + t;
-}
-
-/*
- x_c = (x_c * a_c) / 255
-*/
-static inline uint32_t FbByteMulC(uint32_t x, uint32_t a)
-{
- uint32_t t;
- uint32_t r = (x & 0xff) * (a & 0xff);
- r |= (x & 0xff0000) * ((a >> 16) & 0xff);
- r += 0x800080;
- r = (r + ((r >> 8) & 0xff00ff)) >> 8;
- r &= 0xff00ff;
-
- x >>= 8;
- t = (x & 0xff) * ((a >> 8) & 0xff);
- t |= (x & 0xff0000) * (a >> 24);
- t += 0x800080;
- t = t + ((t >> 8) & 0xff00ff);
- return r | (t & 0xff00ff00);
-}
-
-/*
- x_c = (x_c * a) / 255 + y
-*/
-static inline uint32_t FbByteMulAddC(uint32_t x, uint32_t a, uint32_t y)
-{
- uint32_t t;
- uint32_t r = (x & 0xff) * (a & 0xff);
- r |= (x & 0xff0000) * ((a >> 16) & 0xff);
- r += 0x800080;
- r = (r + ((r >> 8) & 0xff00ff)) >> 8;
- r &= 0xff00ff;
- r += y & 0xff00ff;
- r |= 0x1000100 - ((r >> 8) & 0xff00ff);
- r &= 0xff00ff;
-
- x >>= 8;
- t = (x & 0xff) * ((a >> 8) & 0xff);
- t |= (x & 0xff0000) * (a >> 24);
- t += 0x800080;
- t = (t + ((t >> 8) & 0xff00ff)) >> 8;
- t &= 0xff00ff;
- t += (y >> 8) & 0xff00ff;
- t |= 0x1000100 - ((t >> 8) & 0xff00ff);
- t &= 0xff00ff;
- return r | (t << 8);
-}
-
-
-/*
- x_c = (x_c * a_c + y_c * b) / 255
-*/
-static inline uint32_t FbByteAddMulC(uint32_t x, uint32_t a, uint32_t y, uint32_t b)
-{
- uint32_t t;
- uint32_t r = (x >> 24) * (a >> 24) + (y >> 24) * b;
- r += (r >> 8) + 0x80;
- r >>= 8;
-
- t = (x & 0xff00) * ((a >> 8) & 0xff) + (y & 0xff00) * b;
- t += (t >> 8) + 0x8000;
- t >>= 16;
-
- t |= r << 16;
- t |= 0x1000100 - ((t >> 8) & 0xff00ff);
- t &= 0xff00ff;
- t <<= 8;
-
- r = ((x >> 16) & 0xff) * ((a >> 16) & 0xff) + ((y >> 16) & 0xff) * b + 0x80;
- r += (r >> 8);
- r >>= 8;
-
- x = (x & 0xff) * (a & 0xff) + (y & 0xff) * b + 0x80;
- x += (x >> 8);
- x >>= 8;
- x |= r << 16;
- x |= 0x1000100 - ((x >> 8) & 0xff00ff);
- x &= 0xff00ff;
- return x | t;
-}
-
-/*
- x_c = min(x_c + y_c, 255)
-*/
-static inline uint32_t FbByteAdd(uint32_t x, uint32_t y)
-{
- uint32_t t;
- uint32_t r = (x & 0xff00ff) + (y & 0xff00ff);
- r |= 0x1000100 - ((r >> 8) & 0xff00ff);
- r &= 0xff00ff;
-
- t = ((x >> 8) & 0xff00ff) + ((y >> 8) & 0xff00ff);
- t |= 0x1000100 - ((t >> 8) & 0xff00ff);
- r |= (t & 0xff00ff) << 8;
- return r;
-}
-
-/*
* Combine src and mask
*/
static FASTCALL void
-pixman_fbCombineMaskU (uint32_t *src, const uint32_t *mask, int width)
+pixman_fbCombineMaskU (full_t *src, const full_t *mask, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t a = *(mask + i) >> 24;
- uint32_t s = *(src + i);
- s = FbByteMul(s, a);
+ full_t a = *(mask + i) >> (SHIFT * 3);
+ full_t s = *(src + i);
+ s = FullMul(s, a);
*(src + i) = s;
}
}
@@ -251,156 +59,156 @@ pixman_fbCombineMaskU (uint32_t *src, const uint32_t *mask, int width)
*/
static FASTCALL void
-fbCombineClear (uint32_t *dest, const uint32_t *src, int width)
+fbCombineClear (full_t *dest, const full_t *src, int width)
{
- memset(dest, 0, width*sizeof(uint32_t));
+ memset(dest, 0, width*sizeof(full_t));
}
static FASTCALL void
-fbCombineSrcU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineSrcU (full_t *dest, const full_t *src, int width)
{
- memcpy(dest, src, width*sizeof(uint32_t));
+ memcpy(dest, src, width*sizeof(full_t));
}
static FASTCALL void
-fbCombineOverU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineOverU (full_t *dest, const full_t *src, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t d = *(dest + i);
- uint32_t ia = Alpha(~s);
- *(dest + i) = FbByteMulAdd(d, ia, s);
+ full_t s = *(src + i);
+ full_t d = *(dest + i);
+ full_t ia = Alpha(~s);
+ *(dest + i) = FullMulAdd(d, ia, s);
}
}
static FASTCALL void
-fbCombineOverReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineOverReverseU (full_t *dest, const full_t *src, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t d = *(dest + i);
- uint32_t ia = Alpha(~*(dest + i));
- *(dest + i) = FbByteMulAdd(s, ia, d);
+ full_t s = *(src + i);
+ full_t d = *(dest + i);
+ full_t ia = Alpha(~*(dest + i));
+ *(dest + i) = FullMulAdd(s, ia, d);
}
}
static FASTCALL void
-fbCombineInU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineInU (full_t *dest, const full_t *src, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t a = Alpha(*(dest + i));
- *(dest + i) = FbByteMul(s, a);
+ full_t s = *(src + i);
+ full_t a = Alpha(*(dest + i));
+ *(dest + i) = FullMul(s, a);
}
}
static FASTCALL void
-fbCombineInReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineInReverseU (full_t *dest, const full_t *src, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t d = *(dest + i);
- uint32_t a = Alpha(*(src + i));
- *(dest + i) = FbByteMul(d, a);
+ full_t d = *(dest + i);
+ full_t a = Alpha(*(src + i));
+ *(dest + i) = FullMul(d, a);
}
}
static FASTCALL void
-fbCombineOutU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineOutU (full_t *dest, const full_t *src, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t a = Alpha(~*(dest + i));
- *(dest + i) = FbByteMul(s, a);
+ full_t s = *(src + i);
+ full_t a = Alpha(~*(dest + i));
+ *(dest + i) = FullMul(s, a);
}
}
static FASTCALL void
-fbCombineOutReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineOutReverseU (full_t *dest, const full_t *src, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t d = *(dest + i);
- uint32_t a = Alpha(~*(src + i));
- *(dest + i) = FbByteMul(d, a);
+ full_t d = *(dest + i);
+ full_t a = Alpha(~*(src + i));
+ *(dest + i) = FullMul(d, a);
}
}
static FASTCALL void
-fbCombineAtopU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineAtopU (full_t *dest, const full_t *src, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t d = *(dest + i);
- uint32_t dest_a = Alpha(d);
- uint32_t src_ia = Alpha(~s);
+ full_t s = *(src + i);
+ full_t d = *(dest + i);
+ full_t dest_a = Alpha(d);
+ full_t src_ia = Alpha(~s);
- *(dest + i) = FbByteAddMul(s, dest_a, d, src_ia);
+ *(dest + i) = FullAddMul(s, dest_a, d, src_ia);
}
}
static FASTCALL void
-fbCombineAtopReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineAtopReverseU (full_t *dest, const full_t *src, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t d = *(dest + i);
- uint32_t src_a = Alpha(s);
- uint32_t dest_ia = Alpha(~d);
+ full_t s = *(src + i);
+ full_t d = *(dest + i);
+ full_t src_a = Alpha(s);
+ full_t dest_ia = Alpha(~d);
- *(dest + i) = FbByteAddMul(s, dest_ia, d, src_a);
+ *(dest + i) = FullAddMul(s, dest_ia, d, src_a);
}
}
static FASTCALL void
-fbCombineXorU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineXorU (full_t *dest, const full_t *src, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t d = *(dest + i);
- uint32_t src_ia = Alpha(~s);
- uint32_t dest_ia = Alpha(~d);
+ full_t s = *(src + i);
+ full_t d = *(dest + i);
+ full_t src_ia = Alpha(~s);
+ full_t dest_ia = Alpha(~d);
- *(dest + i) = FbByteAddMul(s, dest_ia, d, src_ia);
+ *(dest + i) = FullAddMul(s, dest_ia, d, src_ia);
}
}
static FASTCALL void
-fbCombineAddU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineAddU (full_t *dest, const full_t *src, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t d = *(dest + i);
- *(dest + i) = FbByteAdd(d, s);
+ full_t s = *(src + i);
+ full_t d = *(dest + i);
+ *(dest + i) = FullAdd(d, s);
}
}
static FASTCALL void
-fbCombineSaturateU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineSaturateU (full_t *dest, const full_t *src, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t d = *(dest + i);
- uint16_t sa, da;
+ full_t s = *(src + i);
+ full_t d = *(dest + i);
+ half_t sa, da;
- sa = s >> 24;
- da = ~d >> 24;
+ sa = s >> (SHIFT * 3);
+ da = ~d >> (SHIFT * 3);
if (sa > da)
{
- sa = FbIntDiv(da, sa);
- s = FbByteMul(s, sa);
+ sa = IntDiv(da, sa);
+ s = FullMul(s, sa);
};
- *(dest + i) = FbByteAdd(d, s);
+ *(dest + i) = FullAdd(d, s);
}
}
@@ -432,7 +240,7 @@ fbCombineSaturateU (uint32_t *dest, const uint32_t *src, int width)
#define CombineAOut 1
#define CombineAIn 2
#define CombineBOut 4
-#define CombineBIn 8
+#define CombineBIn SHIFT
#define CombineClear 0
#define CombineA (CombineAOut|CombineAIn)
@@ -444,20 +252,20 @@ fbCombineSaturateU (uint32_t *dest, const uint32_t *src, int width)
#define CombineXor (CombineAOut|CombineBOut)
/* portion covered by a but not b */
-static INLINE uint8_t
-fbCombineDisjointOutPart (uint8_t a, uint8_t b)
+static INLINE quart_t
+fbCombineDisjointOutPart (quart_t a, quart_t b)
{
/* min (1, (1-b) / a) */
b = ~b; /* 1 - b */
if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */
- return 0xff; /* 1 */
- return FbIntDiv(b,a); /* (1-b) / a */
+ return QUARTER_MASK;/* 1 */
+ return IntDiv(b,a); /* (1-b) / a */
}
/* portion covered by both a and b */
-static INLINE uint8_t
-fbCombineDisjointInPart (uint8_t a, uint8_t b)
+static INLINE quart_t
+fbCombineDisjointInPart (quart_t a, quart_t b)
{
/* max (1-(1-b)/a,0) */
/* = - min ((1-b)/a - 1, 0) */
@@ -466,20 +274,20 @@ fbCombineDisjointInPart (uint8_t a, uint8_t b)
b = ~b; /* 1 - b */
if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */
return 0; /* 1 - 1 */
- return ~FbIntDiv(b,a); /* 1 - (1-b) / a */
+ return ~IntDiv(b,a); /* 1 - (1-b) / a */
}
static FASTCALL void
-fbCombineDisjointGeneralU (uint32_t *dest, const uint32_t *src, int width, uint8_t combine)
+fbCombineDisjointGeneralU (full_t *dest, const full_t *src, int width, quart_t combine)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t d = *(dest + i);
- uint32_t m,n,o,p;
- uint16_t Fa, Fb, t, u, v;
- uint8_t sa = s >> 24;
- uint8_t da = d >> 24;
+ full_t s = *(src + i);
+ full_t d = *(dest + i);
+ full_t m,n,o,p;
+ half_t Fa, Fb, t, u, v;
+ quart_t sa = s >> (SHIFT * 3);
+ quart_t da = d >> (SHIFT * 3);
switch (combine & CombineA) {
default:
@@ -492,7 +300,7 @@ fbCombineDisjointGeneralU (uint32_t *dest, const uint32_t *src, int width, uint8
Fa = fbCombineDisjointInPart (sa, da);
break;
case CombineA:
- Fa = 0xff;
+ Fa = QUARTER_MASK;
break;
}
@@ -507,33 +315,33 @@ fbCombineDisjointGeneralU (uint32_t *dest, const uint32_t *src, int width, uint8
Fb = fbCombineDisjointInPart (da, sa);
break;
case CombineB:
- Fb = 0xff;
+ Fb = QUARTER_MASK;
break;
}
- m = FbGen (s,d,0,Fa,Fb,t, u, v);
- n = FbGen (s,d,8,Fa,Fb,t, u, v);
- o = FbGen (s,d,16,Fa,Fb,t, u, v);
- p = FbGen (s,d,24,Fa,Fb,t, u, v);
+ m = Gen (s,d,0,Fa,Fb,t, u, v);
+ n = Gen (s,d,SHIFT,Fa,Fb,t, u, v);
+ o = Gen (s,d,(SHIFT * 2),Fa,Fb,t, u, v);
+ p = Gen (s,d,(SHIFT * 3),Fa,Fb,t, u, v);
s = m|n|o|p;
*(dest + i) = s;
}
}
static FASTCALL void
-fbCombineDisjointOverU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointOverU (full_t *dest, const full_t *src, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint16_t a = s >> 24;
+ full_t s = *(src + i);
+ half_t a = s >> (SHIFT * 3);
if (a != 0x00)
{
- if (a != 0xff)
+ if (a != QUARTER_MASK)
{
- uint32_t d = *(dest + i);
- a = fbCombineDisjointOutPart (d >> 24, a);
- s = FbByteMulAdd(d, a, s);
+ full_t d = *(dest + i);
+ a = fbCombineDisjointOutPart (d >> (SHIFT * 3), a);
+ s = FullMulAdd(d, a, s);
}
*(dest + i) = s;
}
@@ -541,50 +349,50 @@ fbCombineDisjointOverU (uint32_t *dest, const uint32_t *src, int width)
}
static FASTCALL void
-fbCombineDisjointInU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointInU (full_t *dest, const full_t *src, int width)
{
fbCombineDisjointGeneralU (dest, src, width, CombineAIn);
}
static FASTCALL void
-fbCombineDisjointInReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointInReverseU (full_t *dest, const full_t *src, int width)
{
fbCombineDisjointGeneralU (dest, src, width, CombineBIn);
}
static FASTCALL void
-fbCombineDisjointOutU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointOutU (full_t *dest, const full_t *src, int width)
{
fbCombineDisjointGeneralU (dest, src, width, CombineAOut);
}
static FASTCALL void
-fbCombineDisjointOutReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointOutReverseU (full_t *dest, const full_t *src, int width)
{
fbCombineDisjointGeneralU (dest, src, width, CombineBOut);
}
static FASTCALL void
-fbCombineDisjointAtopU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointAtopU (full_t *dest, const full_t *src, int width)
{
fbCombineDisjointGeneralU (dest, src, width, CombineAAtop);
}
static FASTCALL void
-fbCombineDisjointAtopReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointAtopReverseU (full_t *dest, const full_t *src, int width)
{
fbCombineDisjointGeneralU (dest, src, width, CombineBAtop);
}
static FASTCALL void
-fbCombineDisjointXorU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointXorU (full_t *dest, const full_t *src, int width)
{
fbCombineDisjointGeneralU (dest, src, width, CombineXor);
}
/* portion covered by a but not b */
-static INLINE uint8_t
-fbCombineConjointOutPart (uint8_t a, uint8_t b)
+static INLINE quart_t
+fbCombineConjointOutPart (quart_t a, quart_t b)
{
/* max (1-b/a,0) */
/* = 1-min(b/a,1) */
@@ -593,31 +401,31 @@ fbCombineConjointOutPart (uint8_t a, uint8_t b)
if (b >= a) /* b >= a -> b/a >= 1 */
return 0x00; /* 0 */
- return ~FbIntDiv(b,a); /* 1 - b/a */
+ return ~IntDiv(b,a); /* 1 - b/a */
}
/* portion covered by both a and b */
-static INLINE uint8_t
-fbCombineConjointInPart (uint8_t a, uint8_t b)
+static INLINE quart_t
+fbCombineConjointInPart (quart_t a, quart_t b)
{
/* min (1,b/a) */
if (b >= a) /* b >= a -> b/a >= 1 */
- return 0xff; /* 1 */
- return FbIntDiv(b,a); /* b/a */
+ return QUARTER_MASK; /* 1 */
+ return IntDiv(b,a); /* b/a */
}
static FASTCALL void
-fbCombineConjointGeneralU (uint32_t *dest, const uint32_t *src, int width, uint8_t combine)
+fbCombineConjointGeneralU (full_t *dest, const full_t *src, int width, quart_t combine)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t d = *(dest + i);
- uint32_t m,n,o,p;
- uint16_t Fa, Fb, t, u, v;
- uint8_t sa = s >> 24;
- uint8_t da = d >> 24;
+ full_t s = *(src + i);
+ full_t d = *(dest + i);
+ full_t m,n,o,p;
+ half_t Fa, Fb, t, u, v;
+ quart_t sa = s >> (SHIFT * 3);
+ quart_t da = d >> (SHIFT * 3);
switch (combine & CombineA) {
default:
@@ -630,7 +438,7 @@ fbCombineConjointGeneralU (uint32_t *dest, const uint32_t *src, int width, uint8
Fa = fbCombineConjointInPart (sa, da);
break;
case CombineA:
- Fa = 0xff;
+ Fa = QUARTER_MASK;
break;
}
@@ -645,129 +453,84 @@ fbCombineConjointGeneralU (uint32_t *dest, const uint32_t *src, int width, uint8
Fb = fbCombineConjointInPart (da, sa);
break;
case CombineB:
- Fb = 0xff;
+ Fb = QUARTER_MASK;
break;
}
- m = FbGen (s,d,0,Fa,Fb,t, u, v);
- n = FbGen (s,d,8,Fa,Fb,t, u, v);
- o = FbGen (s,d,16,Fa,Fb,t, u, v);
- p = FbGen (s,d,24,Fa,Fb,t, u, v);
+ m = Gen (s,d,0,Fa,Fb,t, u, v);
+ n = Gen (s,d,SHIFT,Fa,Fb,t, u, v);
+ o = Gen (s,d,(SHIFT * 2),Fa,Fb,t, u, v);
+ p = Gen (s,d,(SHIFT * 3),Fa,Fb,t, u, v);
s = m|n|o|p;
*(dest + i) = s;
}
}
static FASTCALL void
-fbCombineConjointOverU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointOverU (full_t *dest, const full_t *src, int width)
{
fbCombineConjointGeneralU (dest, src, width, CombineAOver);
}
static FASTCALL void
-fbCombineConjointOverReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointOverReverseU (full_t *dest, const full_t *src, int width)
{
fbCombineConjointGeneralU (dest, src, width, CombineBOver);
}
static FASTCALL void
-fbCombineConjointInU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointInU (full_t *dest, const full_t *src, int width)
{
fbCombineConjointGeneralU (dest, src, width, CombineAIn);
}
static FASTCALL void
-fbCombineConjointInReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointInReverseU (full_t *dest, const full_t *src, int width)
{
fbCombineConjointGeneralU (dest, src, width, CombineBIn);
}
static FASTCALL void
-fbCombineConjointOutU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointOutU (full_t *dest, const full_t *src, int width)
{
fbCombineConjointGeneralU (dest, src, width, CombineAOut);
}
static FASTCALL void
-fbCombineConjointOutReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointOutReverseU (full_t *dest, const full_t *src, int width)
{
fbCombineConjointGeneralU (dest, src, width, CombineBOut);
}
static FASTCALL void
-fbCombineConjointAtopU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointAtopU (full_t *dest, const full_t *src, int width)
{
fbCombineConjointGeneralU (dest, src, width, CombineAAtop);
}
static FASTCALL void
-fbCombineConjointAtopReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointAtopReverseU (full_t *dest, const full_t *src, int width)
{
fbCombineConjointGeneralU (dest, src, width, CombineBAtop);
}
static FASTCALL void
-fbCombineConjointXorU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointXorU (full_t *dest, const full_t *src, int width)
{
fbCombineConjointGeneralU (dest, src, width, CombineXor);
}
-static CombineFuncU pixman_fbCombineFuncU[] = {
- fbCombineClear,
- fbCombineSrcU,
- NULL, /* CombineDst */
- fbCombineOverU,
- fbCombineOverReverseU,
- fbCombineInU,
- fbCombineInReverseU,
- fbCombineOutU,
- fbCombineOutReverseU,
- fbCombineAtopU,
- fbCombineAtopReverseU,
- fbCombineXorU,
- fbCombineAddU,
- fbCombineSaturateU,
- NULL,
- NULL,
- fbCombineClear,
- fbCombineSrcU,
- NULL, /* CombineDst */
- fbCombineDisjointOverU,
- fbCombineSaturateU, /* DisjointOverReverse */
- fbCombineDisjointInU,
- fbCombineDisjointInReverseU,
- fbCombineDisjointOutU,
- fbCombineDisjointOutReverseU,
- fbCombineDisjointAtopU,
- fbCombineDisjointAtopReverseU,
- fbCombineDisjointXorU,
- NULL,
- NULL,
- NULL,
- NULL,
- fbCombineClear,
- fbCombineSrcU,
- NULL, /* CombineDst */
- fbCombineConjointOverU,
- fbCombineConjointOverReverseU,
- fbCombineConjointInU,
- fbCombineConjointInReverseU,
- fbCombineConjointOutU,
- fbCombineConjointOutReverseU,
- fbCombineConjointAtopU,
- fbCombineConjointAtopReverseU,
- fbCombineConjointXorU,
-};
+/******************************************************************************/
static INLINE void
-fbCombineMaskC (uint32_t *src, uint32_t *mask)
+fbCombineMaskC (full_t *src, full_t *mask)
{
- uint32_t a = *mask;
+ full_t a = *mask;
- uint32_t x;
- uint16_t xa;
+ full_t x;
+ half_t xa;
if (!a)
{
@@ -776,24 +539,24 @@ fbCombineMaskC (uint32_t *src, uint32_t *mask)
}
x = *(src);
- if (a == 0xffffffff)
+ if (a == FULL_MASK)
{
- x = x >> 24;
- x |= x << 8;
- x |= x << 16;
+ x = x >> (SHIFT * 3);
+ x |= x << SHIFT;
+ x |= x << (SHIFT * 2);
*(mask) = x;
return;
}
- xa = x >> 24;
- *(src) = FbByteMulC(x, a);
- *(mask) = FbByteMul(a, xa);
+ xa = x >> (SHIFT * 3);
+ *(src) = FullMulC(x, a);
+ *(mask) = FullMul(a, xa);
}
static INLINE void
-fbCombineMaskValueC (uint32_t *src, const uint32_t *mask)
+fbCombineMaskValueC (full_t *src, const full_t *mask)
{
- uint32_t a = *mask;
+ full_t a = *mask;
if (!a)
{
@@ -801,50 +564,50 @@ fbCombineMaskValueC (uint32_t *src, const uint32_t *mask)
return;
}
- if (a == 0xffffffff)
+ if (a == FULL_MASK)
return;
- *(src) = FbByteMulC(*(src), a);
+ *(src) = FullMulC(*(src), a);
}
static INLINE void
-fbCombineMaskAlphaC (const uint32_t *src, uint32_t *mask)
+fbCombineMaskAlphaC (const full_t *src, full_t *mask)
{
- uint32_t a = *(mask);
- uint32_t x;
+ full_t a = *(mask);
+ full_t x;
if (!a)
return;
- x = *(src) >> 24;
- if (x == 0xff)
+ x = *(src) >> (SHIFT * 3);
+ if (x == QUARTER_MASK)
return;
- if (a == 0xffffffff)
+ if (a == FULL_MASK)
{
- x = x >> 24;
- x |= x << 8;
- x |= x << 16;
+ x = x >> (SHIFT * 3);
+ x |= x << SHIFT;
+ x |= x << (SHIFT * 2);
*(mask) = x;
return;
}
- *(mask) = FbByteMul(a, x);
+ *(mask) = FullMul(a, x);
}
static FASTCALL void
-fbCombineClearC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineClearC (full_t *dest, full_t *src, full_t *mask, int width)
{
- memset(dest, 0, width*sizeof(uint32_t));
+ memset(dest, 0, width*sizeof(full_t));
}
static FASTCALL void
-fbCombineSrcC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineSrcC (full_t *dest, full_t *src, full_t *mask, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t m = *(mask + i);
+ full_t s = *(src + i);
+ full_t m = *(mask + i);
fbCombineMaskValueC (&s, &m);
@@ -853,24 +616,24 @@ fbCombineSrcC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
}
static FASTCALL void
-fbCombineOverC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineOverC (full_t *dest, full_t *src, full_t *mask, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t m = *(mask + i);
- uint32_t a;
+ full_t s = *(src + i);
+ full_t m = *(mask + i);
+ full_t a;
fbCombineMaskC (&s, &m);
a = ~m;
- if (a != 0xffffffff)
+ if (a != FULL_MASK)
{
if (a)
{
- uint32_t d = *(dest + i);
- s = FbByteMulAddC(d, a, s);
+ full_t d = *(dest + i);
+ s = FullMulAddC(d, a, s);
}
*(dest + i) = s;
}
@@ -878,24 +641,24 @@ fbCombineOverC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
}
static FASTCALL void
-fbCombineOverReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineOverReverseC (full_t *dest, full_t *src, full_t *mask, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t d = *(dest + i);
- uint32_t a = ~d >> 24;
+ full_t d = *(dest + i);
+ full_t a = ~d >> (SHIFT * 3);
if (a)
{
- uint32_t s = *(src + i);
- uint32_t m = *(mask + i);
+ full_t s = *(src + i);
+ full_t m = *(mask + i);
fbCombineMaskValueC (&s, &m);
- if (a != 0xff)
+ if (a != QUARTER_MASK)
{
- s = FbByteMulAdd(s, a, d);
+ s = FullMulAdd(s, a, d);
}
*(dest + i) = s;
}
@@ -903,23 +666,23 @@ fbCombineOverReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
}
static FASTCALL void
-fbCombineInC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineInC (full_t *dest, full_t *src, full_t *mask, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t d = *(dest + i);
- uint16_t a = d >> 24;
- uint32_t s = 0;
+ full_t d = *(dest + i);
+ half_t a = d >> (SHIFT * 3);
+ full_t s = 0;
if (a)
{
- uint32_t m = *(mask + i);
+ full_t m = *(mask + i);
s = *(src + i);
fbCombineMaskValueC (&s, &m);
- if (a != 0xff)
+ if (a != QUARTER_MASK)
{
- s = FbByteMul(s, a);
+ s = FullMul(s, a);
}
}
*(dest + i) = s;
@@ -927,25 +690,25 @@ fbCombineInC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
}
static FASTCALL void
-fbCombineInReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineInReverseC (full_t *dest, full_t *src, full_t *mask, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t m = *(mask + i);
- uint32_t a;
+ full_t s = *(src + i);
+ full_t m = *(mask + i);
+ full_t a;
fbCombineMaskAlphaC (&s, &m);
a = m;
- if (a != 0xffffffff)
+ if (a != FULL_MASK)
{
- uint32_t d = 0;
+ full_t d = 0;
if (a)
{
d = *(dest + i);
- d = FbByteMulC(d, a);
+ d = FullMulC(d, a);
}
*(dest + i) = d;
}
@@ -953,24 +716,24 @@ fbCombineInReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
}
static FASTCALL void
-fbCombineOutC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineOutC (full_t *dest, full_t *src, full_t *mask, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t d = *(dest + i);
- uint16_t a = ~d >> 24;
- uint32_t s = 0;
+ full_t d = *(dest + i);
+ half_t a = ~d >> (SHIFT * 3);
+ full_t s = 0;
if (a)
{
- uint32_t m = *(mask + i);
+ full_t m = *(mask + i);
s = *(src + i);
fbCombineMaskValueC (&s, &m);
- if (a != 0xff)
+ if (a != QUARTER_MASK)
{
- s = FbByteMul(s, a);
+ s = FullMul(s, a);
}
}
*(dest + i) = s;
@@ -978,25 +741,25 @@ fbCombineOutC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
}
static FASTCALL void
-fbCombineOutReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineOutReverseC (full_t *dest, full_t *src, full_t *mask, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t m = *(mask + i);
- uint32_t a;
+ full_t s = *(src + i);
+ full_t m = *(mask + i);
+ full_t a;
fbCombineMaskAlphaC (&s, &m);
a = ~m;
- if (a != 0xffffffff)
+ if (a != FULL_MASK)
{
- uint32_t d = 0;
+ full_t d = 0;
if (a)
{
d = *(dest + i);
- d = FbByteMulC(d, a);
+ d = FullMulC(d, a);
}
*(dest + i) = d;
}
@@ -1004,92 +767,92 @@ fbCombineOutReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
}
static FASTCALL void
-fbCombineAtopC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineAtopC (full_t *dest, full_t *src, full_t *mask, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t d = *(dest + i);
- uint32_t s = *(src + i);
- uint32_t m = *(mask + i);
- uint32_t ad;
- uint16_t as = d >> 24;
+ full_t d = *(dest + i);
+ full_t s = *(src + i);
+ full_t m = *(mask + i);
+ full_t ad;
+ half_t as = d >> (SHIFT * 3);
fbCombineMaskC (&s, &m);
ad = ~m;
- *(dest + i) = FbByteAddMulC(d, ad, s, as);
+ *(dest + i) = FullAddMulC(d, ad, s, as);
}
}
static FASTCALL void
-fbCombineAtopReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineAtopReverseC (full_t *dest, full_t *src, full_t *mask, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t d = *(dest + i);
- uint32_t s = *(src + i);
- uint32_t m = *(mask + i);
- uint32_t ad;
- uint16_t as = ~d >> 24;
+ full_t d = *(dest + i);
+ full_t s = *(src + i);
+ full_t m = *(mask + i);
+ full_t ad;
+ half_t as = ~d >> (SHIFT * 3);
fbCombineMaskC (&s, &m);
ad = m;
- *(dest + i) = FbByteAddMulC(d, ad, s, as);
+ *(dest + i) = FullAddMulC(d, ad, s, as);
}
}
static FASTCALL void
-fbCombineXorC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineXorC (full_t *dest, full_t *src, full_t *mask, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t d = *(dest + i);
- uint32_t s = *(src + i);
- uint32_t m = *(mask + i);
- uint32_t ad;
- uint16_t as = ~d >> 24;
+ full_t d = *(dest + i);
+ full_t s = *(src + i);
+ full_t m = *(mask + i);
+ full_t ad;
+ half_t as = ~d >> (SHIFT * 3);
fbCombineMaskC (&s, &m);
ad = ~m;
- *(dest + i) = FbByteAddMulC(d, ad, s, as);
+ *(dest + i) = FullAddMulC(d, ad, s, as);
}
}
static FASTCALL void
-fbCombineAddC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineAddC (full_t *dest, full_t *src, full_t *mask, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s = *(src + i);
- uint32_t m = *(mask + i);
- uint32_t d = *(dest + i);
+ full_t s = *(src + i);
+ full_t m = *(mask + i);
+ full_t d = *(dest + i);
fbCombineMaskValueC (&s, &m);
- *(dest + i) = FbByteAdd(d, s);;
+ *(dest + i) = FullAdd(d, s);
}
}
static FASTCALL void
-fbCombineSaturateC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineSaturateC (full_t *dest, full_t *src, full_t *mask, int width)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s, d;
- uint16_t sa, sr, sg, sb, da;
- uint16_t t, u, v;
- uint32_t m,n,o,p;
+ full_t s, d;
+ half_t sa, sr, sg, sb, da;
+ half_t t, u, v;
+ full_t m,n,o,p;
d = *(dest + i);
s = *(src + i);
@@ -1097,53 +860,53 @@ fbCombineSaturateC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
fbCombineMaskC (&s, &m);
- sa = (m >> 24);
- sr = (m >> 16) & 0xff;
- sg = (m >> 8) & 0xff;
- sb = (m ) & 0xff;
- da = ~d >> 24;
+ sa = (m >> (SHIFT * 3));
+ sr = (m >> (SHIFT * 2)) & QUARTER_MASK;
+ sg = (m >> SHIFT ) & QUARTER_MASK;
+ sb = (m ) & QUARTER_MASK;
+ da = ~d >> (SHIFT * 3);
if (sb <= da)
- m = FbAdd(s,d,0,t);
+ m = Add(s,d,0,t);
else
- m = FbGen (s, d, 0, (da << 8) / sb, 0xff, t, u, v);
+ m = Gen (s, d, 0, (da << SHIFT) / sb, QUARTER_MASK, t, u, v);
if (sg <= da)
- n = FbAdd(s,d,8,t);
+ n = Add(s,d,SHIFT,t);
else
- n = FbGen (s, d, 8, (da << 8) / sg, 0xff, t, u, v);
+ n = Gen (s, d, SHIFT, (da << SHIFT) / sg, QUARTER_MASK, t, u, v);
if (sr <= da)
- o = FbAdd(s,d,16,t);
+ o = Add(s,d,(SHIFT * 2),t);
else
- o = FbGen (s, d, 16, (da << 8) / sr, 0xff, t, u, v);
+ o = Gen (s, d, (SHIFT * 2), (da << SHIFT) / sr, QUARTER_MASK, t, u, v);
if (sa <= da)
- p = FbAdd(s,d,24,t);
+ p = Add(s,d,(SHIFT * 3),t);
else
- p = FbGen (s, d, 24, (da << 8) / sa, 0xff, t, u, v);
+ p = Gen (s, d, (SHIFT * 3), (da << SHIFT) / sa, QUARTER_MASK, t, u, v);
*(dest + i) = m|n|o|p;
}
}
static FASTCALL void
-fbCombineDisjointGeneralC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width, uint8_t combine)
+fbCombineDisjointGeneralC (full_t *dest, full_t *src, full_t *mask, int width, quart_t combine)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s, d;
- uint32_t m,n,o,p;
- uint32_t Fa, Fb;
- uint16_t t, u, v;
- uint32_t sa;
- uint8_t da;
+ full_t s, d;
+ full_t m,n,o,p;
+ full_t Fa, Fb;
+ half_t t, u, v;
+ full_t sa;
+ quart_t da;
s = *(src + i);
m = *(mask + i);
d = *(dest + i);
- da = d >> 24;
+ da = d >> (SHIFT * 3);
fbCombineMaskC (&s, &m);
@@ -1154,21 +917,21 @@ fbCombineDisjointGeneralC (uint32_t *dest, uint32_t *src, uint32_t *mask, int wi
Fa = 0;
break;
case CombineAOut:
- m = fbCombineDisjointOutPart ((uint8_t) (sa >> 0), da);
- n = fbCombineDisjointOutPart ((uint8_t) (sa >> 8), da) << 8;
- o = fbCombineDisjointOutPart ((uint8_t) (sa >> 16), da) << 16;
- p = fbCombineDisjointOutPart ((uint8_t) (sa >> 24), da) << 24;
+ m = (full_t)fbCombineDisjointOutPart ((quart_t) (sa >> 0), da);
+ n = (full_t)fbCombineDisjointOutPart ((quart_t) (sa >> SHIFT), da) << SHIFT;
+ o = (full_t)fbCombineDisjointOutPart ((quart_t) (sa >> (SHIFT * 2)), da) << (SHIFT * 2);
+ p = (full_t)fbCombineDisjointOutPart ((quart_t) (sa >> (SHIFT * 3)), da) << (SHIFT * 3);
Fa = m|n|o|p;
break;
case CombineAIn:
- m = fbCombineDisjointInPart ((uint8_t) (sa >> 0), da);
- n = fbCombineDisjointInPart ((uint8_t) (sa >> 8), da) << 8;
- o = fbCombineDisjointInPart ((uint8_t) (sa >> 16), da) << 16;
- p = fbCombineDisjointInPart ((uint8_t) (sa >> 24), da) << 24;
+ m = (full_t)fbCombineDisjointInPart ((quart_t) (sa >> 0), da);
+ n = (full_t)fbCombineDisjointInPart ((quart_t) (sa >> SHIFT), da) << SHIFT;
+ o = (full_t)fbCombineDisjointInPart ((quart_t) (sa >> (SHIFT * 2)), da) << (SHIFT * 2);
+ p = (full_t)fbCombineDisjointInPart ((quart_t) (sa >> (SHIFT * 3)), da) << (SHIFT * 3);
Fa = m|n|o|p;
break;
case CombineA:
- Fa = 0xffffffff;
+ Fa = FULL_MASK;
break;
}
@@ -1177,97 +940,97 @@ fbCombineDisjointGeneralC (uint32_t *dest, uint32_t *src, uint32_t *mask, int wi
Fb = 0;
break;
case CombineBOut:
- m = fbCombineDisjointOutPart (da, (uint8_t) (sa >> 0));
- n = fbCombineDisjointOutPart (da, (uint8_t) (sa >> 8)) << 8;
- o = fbCombineDisjointOutPart (da, (uint8_t) (sa >> 16)) << 16;
- p = fbCombineDisjointOutPart (da, (uint8_t) (sa >> 24)) << 24;
+ m = (full_t)fbCombineDisjointOutPart (da, (quart_t) (sa >> 0));
+ n = (full_t)fbCombineDisjointOutPart (da, (quart_t) (sa >> SHIFT)) << SHIFT;
+ o = (full_t)fbCombineDisjointOutPart (da, (quart_t) (sa >> (SHIFT * 2))) << (SHIFT * 2);
+ p = (full_t)fbCombineDisjointOutPart (da, (quart_t) (sa >> (SHIFT * 3))) << (SHIFT * 3);
Fb = m|n|o|p;
break;
case CombineBIn:
- m = fbCombineDisjointInPart (da, (uint8_t) (sa >> 0));
- n = fbCombineDisjointInPart (da, (uint8_t) (sa >> 8)) << 8;
- o = fbCombineDisjointInPart (da, (uint8_t) (sa >> 16)) << 16;
- p = fbCombineDisjointInPart (da, (uint8_t) (sa >> 24)) << 24;
+ m = (full_t)fbCombineDisjointInPart (da, (quart_t) (sa >> 0));
+ n = (full_t)fbCombineDisjointInPart (da, (quart_t) (sa >> SHIFT)) << SHIFT;
+ o = (full_t)fbCombineDisjointInPart (da, (quart_t) (sa >> (SHIFT * 2))) << (SHIFT * 2);
+ p = (full_t)fbCombineDisjointInPart (da, (quart_t) (sa >> (SHIFT * 3))) << (SHIFT * 3);
Fb = m|n|o|p;
break;
case CombineB:
- Fb = 0xffffffff;
+ Fb = FULL_MASK;
break;
}
- m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t, u, v);
- n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t, u, v);
- o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t, u, v);
- p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t, u, v);
+ m = Gen (s,d,0, GetQuart(Fa,0), GetQuart(Fb,0),t, u, v);
+ n = Gen (s,d,SHIFT, GetQuart(Fa,SHIFT), GetQuart(Fb,SHIFT),t, u, v);
+ o = Gen (s,d,SHIFT * 2, GetQuart(Fa,SHIFT * 2), GetQuart(Fb,SHIFT * 2),t, u, v);
+ p = Gen (s,d,SHIFT * 3, GetQuart(Fa,SHIFT * 3), GetQuart(Fb,SHIFT * 3),t, u, v);
s = m|n|o|p;
*(dest + i) = s;
}
}
static FASTCALL void
-fbCombineDisjointOverC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointOverC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineDisjointGeneralC (dest, src, mask, width, CombineAOver);
}
static FASTCALL void
-fbCombineDisjointInC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointInC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineDisjointGeneralC (dest, src, mask, width, CombineAIn);
}
static FASTCALL void
-fbCombineDisjointInReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointInReverseC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineDisjointGeneralC (dest, src, mask, width, CombineBIn);
}
static FASTCALL void
-fbCombineDisjointOutC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointOutC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineDisjointGeneralC (dest, src, mask, width, CombineAOut);
}
static FASTCALL void
-fbCombineDisjointOutReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointOutReverseC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineDisjointGeneralC (dest, src, mask, width, CombineBOut);
}
static FASTCALL void
-fbCombineDisjointAtopC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointAtopC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineDisjointGeneralC (dest, src, mask, width, CombineAAtop);
}
static FASTCALL void
-fbCombineDisjointAtopReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointAtopReverseC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineDisjointGeneralC (dest, src, mask, width, CombineBAtop);
}
static FASTCALL void
-fbCombineDisjointXorC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointXorC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineDisjointGeneralC (dest, src, mask, width, CombineXor);
}
static FASTCALL void
-fbCombineConjointGeneralC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width, uint8_t combine)
+fbCombineConjointGeneralC (full_t *dest, full_t *src, full_t *mask, int width, quart_t combine)
{
int i;
for (i = 0; i < width; ++i) {
- uint32_t s, d;
- uint32_t m,n,o,p;
- uint32_t Fa, Fb;
- uint16_t t, u, v;
- uint32_t sa;
- uint8_t da;
+ full_t s, d;
+ full_t m,n,o,p;
+ full_t Fa, Fb;
+ half_t t, u, v;
+ full_t sa;
+ quart_t da;
s = *(src + i);
m = *(mask + i);
d = *(dest + i);
- da = d >> 24;
+ da = d >> (SHIFT * 3);
fbCombineMaskC (&s, &m);
@@ -1278,21 +1041,21 @@ fbCombineConjointGeneralC (uint32_t *dest, uint32_t *src, uint32_t *mask, int wi
Fa = 0;
break;
case CombineAOut:
- m = fbCombineConjointOutPart ((uint8_t) (sa >> 0), da);
- n = fbCombineConjointOutPart ((uint8_t) (sa >> 8), da) << 8;
- o = fbCombineConjointOutPart ((uint8_t) (sa >> 16), da) << 16;
- p = fbCombineConjointOutPart ((uint8_t) (sa >> 24), da) << 24;
+ m = (full_t)fbCombineConjointOutPart ((quart_t) (sa >> 0), da);
+ n = (full_t)fbCombineConjointOutPart ((quart_t) (sa >> SHIFT), da) << SHIFT;
+ o = (full_t)fbCombineConjointOutPart ((quart_t) (sa >> (SHIFT * 2)), da) << (SHIFT * 2);
+ p = (full_t)fbCombineConjointOutPart ((quart_t) (sa >> (SHIFT * 3)), da) << (SHIFT * 3);
Fa = m|n|o|p;
break;
case CombineAIn:
- m = fbCombineConjointInPart ((uint8_t) (sa >> 0), da);
- n = fbCombineConjointInPart ((uint8_t) (sa >> 8), da) << 8;
- o = fbCombineConjointInPart ((uint8_t) (sa >> 16), da) << 16;
- p = fbCombineConjointInPart ((uint8_t) (sa >> 24), da) << 24;
+ m = (full_t)fbCombineConjointInPart ((quart_t) (sa >> 0), da);
+ n = (full_t)fbCombineConjointInPart ((quart_t) (sa >> SHIFT), da) << SHIFT;
+ o = (full_t)fbCombineConjointInPart ((quart_t) (sa >> (SHIFT * 2)), da) << (SHIFT * 2);
+ p = (full_t)fbCombineConjointInPart ((quart_t) (sa >> (SHIFT * 3)), da) << (SHIFT * 3);
Fa = m|n|o|p;
break;
case CombineA:
- Fa = 0xffffffff;
+ Fa = FULL_MASK;
break;
}
@@ -1301,156 +1064,82 @@ fbCombineConjointGeneralC (uint32_t *dest, uint32_t *src, uint32_t *mask, int wi
Fb = 0;
break;
case CombineBOut:
- m = fbCombineConjointOutPart (da, (uint8_t) (sa >> 0));
- n = fbCombineConjointOutPart (da, (uint8_t) (sa >> 8)) << 8;
- o = fbCombineConjointOutPart (da, (uint8_t) (sa >> 16)) << 16;
- p = fbCombineConjointOutPart (da, (uint8_t) (sa >> 24)) << 24;
+ m = (full_t)fbCombineConjointOutPart (da, (quart_t) (sa >> 0));
+ n = (full_t)fbCombineConjointOutPart (da, (quart_t) (sa >> SHIFT)) << SHIFT;
+ o = (full_t)fbCombineConjointOutPart (da, (quart_t) (sa >> (SHIFT * 2))) << (SHIFT * 2);
+ p = (full_t)fbCombineConjointOutPart (da, (quart_t) (sa >> (SHIFT * 3))) << (SHIFT * 3);
Fb = m|n|o|p;
break;
case CombineBIn:
- m = fbCombineConjointInPart (da, (uint8_t) (sa >> 0));
- n = fbCombineConjointInPart (da, (uint8_t) (sa >> 8)) << 8;
- o = fbCombineConjointInPart (da, (uint8_t) (sa >> 16)) << 16;
- p = fbCombineConjointInPart (da, (uint8_t) (sa >> 24)) << 24;
+ m = (full_t)fbCombineConjointInPart (da, (quart_t) (sa >> 0));
+ n = (full_t)fbCombineConjointInPart (da, (quart_t) (sa >> SHIFT)) << SHIFT;
+ o = (full_t)fbCombineConjointInPart (da, (quart_t) (sa >> (SHIFT * 2))) << (SHIFT * 2);
+ p = (full_t)fbCombineConjointInPart (da, (quart_t) (sa >> (SHIFT * 3))) << (SHIFT * 3);
Fb = m|n|o|p;
break;
case CombineB:
- Fb = 0xffffffff;
+ Fb = FULL_MASK;
break;
}
- m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t, u, v);
- n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t, u, v);
- o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t, u, v);
- p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t, u, v);
+ m = Gen (s,d,0, GetQuart(Fa,0), GetQuart(Fb,0), t, u, v);
+ n = Gen (s,d,SHIFT, GetQuart(Fa,SHIFT), GetQuart(Fb,SHIFT), t, u, v);
+ o = Gen (s,d,SHIFT * 2, GetQuart(Fa,SHIFT * 2), GetQuart(Fb,SHIFT * 2), t, u, v);
+ p = Gen (s,d,SHIFT * 3, GetQuart(Fa,SHIFT * 3), GetQuart(Fb,SHIFT * 3), t, u, v);
s = m|n|o|p;
*(dest + i) = s;
}
}
static FASTCALL void
-fbCombineConjointOverC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointOverC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineConjointGeneralC (dest, src, mask, width, CombineAOver);
}
static FASTCALL void
-fbCombineConjointOverReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointOverReverseC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineConjointGeneralC (dest, src, mask, width, CombineBOver);
}
static FASTCALL void
-fbCombineConjointInC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointInC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineConjointGeneralC (dest, src, mask, width, CombineAIn);
}
static FASTCALL void
-fbCombineConjointInReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointInReverseC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineConjointGeneralC (dest, src, mask, width, CombineBIn);
}
static FASTCALL void
-fbCombineConjointOutC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointOutC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineConjointGeneralC (dest, src, mask, width, CombineAOut);
}
static FASTCALL void
-fbCombineConjointOutReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointOutReverseC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineConjointGeneralC (dest, src, mask, width, CombineBOut);
}
static FASTCALL void
-fbCombineConjointAtopC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointAtopC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineConjointGeneralC (dest, src, mask, width, CombineAAtop);
}
static FASTCALL void
-fbCombineConjointAtopReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointAtopReverseC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineConjointGeneralC (dest, src, mask, width, CombineBAtop);
}
static FASTCALL void
-fbCombineConjointXorC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointXorC (full_t *dest, full_t *src, full_t *mask, int width)
{
fbCombineConjointGeneralC (dest, src, mask, width, CombineXor);
}
-
-static CombineFuncC pixman_fbCombineFuncC[] = {
- fbCombineClearC,
- fbCombineSrcC,
- NULL, /* Dest */
- fbCombineOverC,
- fbCombineOverReverseC,
- fbCombineInC,
- fbCombineInReverseC,
- fbCombineOutC,
- fbCombineOutReverseC,
- fbCombineAtopC,
- fbCombineAtopReverseC,
- fbCombineXorC,
- fbCombineAddC,
- fbCombineSaturateC,
- NULL,
- NULL,
- fbCombineClearC, /* 0x10 */
- fbCombineSrcC,
- NULL, /* Dest */
- fbCombineDisjointOverC,
- fbCombineSaturateC, /* DisjointOverReverse */
- fbCombineDisjointInC,
- fbCombineDisjointInReverseC,
- fbCombineDisjointOutC,
- fbCombineDisjointOutReverseC,
- fbCombineDisjointAtopC,
- fbCombineDisjointAtopReverseC,
- fbCombineDisjointXorC, /* 0x1b */
- NULL,
- NULL,
- NULL,
- NULL,
- fbCombineClearC,
- fbCombineSrcC,
- NULL, /* Dest */
- fbCombineConjointOverC,
- fbCombineConjointOverReverseC,
- fbCombineConjointInC,
- fbCombineConjointInReverseC,
- fbCombineConjointOutC,
- fbCombineConjointOutReverseC,
- fbCombineConjointAtopC,
- fbCombineConjointAtopReverseC,
- fbCombineConjointXorC,
-};
-
-
-FbComposeFunctions pixman_composeFunctions = {
- pixman_fbCombineFuncU,
- pixman_fbCombineFuncC,
- pixman_fbCombineMaskU
-};
-
-void
-pixman_composite_rect_general (const FbComposeData *data,
- uint32_t *scanline_buffer)
-{
- if (data->src->common.read_func ||
- data->src->common.write_func ||
- (data->mask && data->mask->common.read_func) ||
- (data->mask && data->mask->common.write_func) ||
- data->dest->common.read_func ||
- data->dest->common.write_func)
- {
- pixman_composite_rect_general_accessors (data, scanline_buffer);
- }
- else
- {
- pixman_composite_rect_general_no_accessors (data, scanline_buffer);
- }
-}
-
diff --git a/pixman/pixman-compose32.c b/pixman/pixman-compose32.c
new file mode 100644
index 0000000..019b0ba
--- /dev/null
+++ b/pixman/pixman-compose32.c
@@ -0,0 +1,323 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <assert.h>
+#include <limits.h>
+
+#include "pixman-private.h"
+
+/******************************************************************************/
+/* Helper functions */
+/*
+ The methods below use some tricks to be able to do two color
+ components at the same time.
+*/
+
+/*
+ x_c = (x_c * a) / 255
+*/
+static inline uint32_t FullMul(uint32_t x, uint32_t a)
+{
+ uint32_t t = ((x & 0xff00ff) * a) + 0x800080;
+ t = (t + ((t >> 8) & 0xff00ff)) >> 8;
+ t &= 0xff00ff;
+
+ x = (((x >> 8) & 0xff00ff) * a) + 0x800080;
+ x = (x + ((x >> 8) & 0xff00ff));
+ x &= 0xff00ff00;
+ return x + t;
+}
+
+/*
+ x_c = (x_c * a) / 255 + y
+*/
+static inline uint32_t FullMulAdd(uint32_t x, uint32_t a, uint32_t y)
+{
+ uint32_t t = ((x & 0xff00ff) * a) + 0x800080;
+ t = (t + ((t >> 8) & 0xff00ff)) >> 8;
+ t &= 0xff00ff;
+ t += y & 0xff00ff;
+ t |= 0x1000100 - ((t >> 8) & 0xff00ff);
+ t &= 0xff00ff;
+
+ x = (((x >> 8) & 0xff00ff) * a) + 0x800080;
+ x = (x + ((x >> 8) & 0xff00ff)) >> 8;
+ x &= 0xff00ff;
+ x += (y >> 8) & 0xff00ff;
+ x |= 0x1000100 - ((x >> 8) & 0xff00ff);
+ x &= 0xff00ff;
+ x <<= 8;
+ return x + t;
+}
+
+/*
+ x_c = (x_c * a + y_c * b) / 255
+*/
+static inline uint32_t FullAddMul(uint32_t x, uint32_t a, uint32_t y, uint32_t b)
+{
+ uint32_t t;
+ uint32_t r = (x >> 24) * a + (y >> 24) * b + 0x80;
+ r += (r >> 8);
+ r >>= 8;
+
+ t = (x & 0xff00) * a + (y & 0xff00) * b;
+ t += (t >> 8) + 0x8000;
+ t >>= 16;
+
+ t |= r << 16;
+ t |= 0x1000100 - ((t >> 8) & 0xff00ff);
+ t &= 0xff00ff;
+ t <<= 8;
+
+ r = ((x >> 16) & 0xff) * a + ((y >> 16) & 0xff) * b + 0x80;
+ r += (r >> 8);
+ r >>= 8;
+
+ x = (x & 0xff) * a + (y & 0xff) * b + 0x80;
+ x += (x >> 8);
+ x >>= 8;
+ x |= r << 16;
+ x |= 0x1000100 - ((x >> 8) & 0xff00ff);
+ x &= 0xff00ff;
+ return x | t;
+}
+
+/*
+ x_c = (x_c * a_c) / 255
+*/
+static inline uint32_t FullMulC(uint32_t x, uint32_t a)
+{
+ uint32_t t;
+ uint32_t r = (x & 0xff) * (a & 0xff);
+ r |= (x & 0xff0000) * ((a >> 16) & 0xff);
+ r += 0x800080;
+ r = (r + ((r >> 8) & 0xff00ff)) >> 8;
+ r &= 0xff00ff;
+
+ x >>= 8;
+ t = (x & 0xff) * ((a >> 8) & 0xff);
+ t |= (x & 0xff0000) * (a >> 24);
+ t += 0x800080;
+ t = t + ((t >> 8) & 0xff00ff);
+ return r | (t & 0xff00ff00);
+}
+
+/*
+ x_c = (x_c * a) / 255 + y
+*/
+static inline uint32_t FullMulAddC(uint32_t x, uint32_t a, uint32_t y)
+{
+ uint32_t t;
+ uint32_t r = (x & 0xff) * (a & 0xff);
+ r |= (x & 0xff0000) * ((a >> 16) & 0xff);
+ r += 0x800080;
+ r = (r + ((r >> 8) & 0xff00ff)) >> 8;
+ r &= 0xff00ff;
+ r += y & 0xff00ff;
+ r |= 0x1000100 - ((r >> 8) & 0xff00ff);
+ r &= 0xff00ff;
+
+ x >>= 8;
+ t = (x & 0xff) * ((a >> 8) & 0xff);
+ t |= (x & 0xff0000) * (a >> 24);
+ t += 0x800080;
+ t = (t + ((t >> 8) & 0xff00ff)) >> 8;
+ t &= 0xff00ff;
+ t += (y >> 8) & 0xff00ff;
+ t |= 0x1000100 - ((t >> 8) & 0xff00ff);
+ t &= 0xff00ff;
+ return r | (t << 8);
+}
+
+
+/*
+ x_c = (x_c * a_c + y_c * b) / 255
+*/
+static inline uint32_t FullAddMulC(uint32_t x, uint32_t a, uint32_t y, uint32_t b)
+{
+ uint32_t t;
+ uint32_t r = (x >> 24) * (a >> 24) + (y >> 24) * b;
+ r += (r >> 8) + 0x80;
+ r >>= 8;
+
+ t = (x & 0xff00) * ((a >> 8) & 0xff) + (y & 0xff00) * b;
+ t += (t >> 8) + 0x8000;
+ t >>= 16;
+
+ t |= r << 16;
+ t |= 0x1000100 - ((t >> 8) & 0xff00ff);
+ t &= 0xff00ff;
+ t <<= 8;
+
+ r = ((x >> 16) & 0xff) * ((a >> 16) & 0xff) + ((y >> 16) & 0xff) * b + 0x80;
+ r += (r >> 8);
+ r >>= 8;
+
+ x = (x & 0xff) * (a & 0xff) + (y & 0xff) * b + 0x80;
+ x += (x >> 8);
+ x >>= 8;
+ x |= r << 16;
+ x |= 0x1000100 - ((x >> 8) & 0xff00ff);
+ x &= 0xff00ff;
+ return x | t;
+}
+
+/*
+ x_c = min(x_c + y_c, 255)
+*/
+static inline uint32_t FullAdd(uint32_t x, uint32_t y)
+{
+ uint32_t t;
+ uint32_t r = (x & 0xff00ff) + (y & 0xff00ff);
+ r |= 0x1000100 - ((r >> 8) & 0xff00ff);
+ r &= 0xff00ff;
+
+ t = ((x >> 8) & 0xff00ff) + ((y >> 8) & 0xff00ff);
+ t |= 0x1000100 - ((t >> 8) & 0xff00ff);
+ r |= (t & 0xff00ff) << 8;
+ return r;
+}
+
+
+/******************************************************************************/
+typedef uint32_t full_t;
+#define FULL_MASK 0xffffffff
+
+typedef uint16_t half_t;
+#define HALF_MASK 0xffff
+
+typedef uint8_t quart_t;
+#define QUARTER_MASK 0xff
+
+#define SHIFT 8
+
+#define Add FbAdd
+#define IntDiv FbIntDiv
+#define Gen FbGen
+#define GetQuart FbGet8
+
+#include "pixman-compose.c"
+/******************************************************************************/
+
+static CombineFuncU pixman_fbCombineFuncU[] = {
+ fbCombineClear,
+ fbCombineSrcU,
+ NULL, /* CombineDst */
+ fbCombineOverU,
+ fbCombineOverReverseU,
+ fbCombineInU,
+ fbCombineInReverseU,
+ fbCombineOutU,
+ fbCombineOutReverseU,
+ fbCombineAtopU,
+ fbCombineAtopReverseU,
+ fbCombineXorU,
+ fbCombineAddU,
+ fbCombineSaturateU,
+ NULL,
+ NULL,
+ fbCombineClear,
+ fbCombineSrcU,
+ NULL, /* CombineDst */
+ fbCombineDisjointOverU,
+ fbCombineSaturateU, /* DisjointOverReverse */
+ fbCombineDisjointInU,
+ fbCombineDisjointInReverseU,
+ fbCombineDisjointOutU,
+ fbCombineDisjointOutReverseU,
+ fbCombineDisjointAtopU,
+ fbCombineDisjointAtopReverseU,
+ fbCombineDisjointXorU,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ fbCombineClear,
+ fbCombineSrcU,
+ NULL, /* CombineDst */
+ fbCombineConjointOverU,
+ fbCombineConjointOverReverseU,
+ fbCombineConjointInU,
+ fbCombineConjointInReverseU,
+ fbCombineConjointOutU,
+ fbCombineConjointOutReverseU,
+ fbCombineConjointAtopU,
+ fbCombineConjointAtopReverseU,
+ fbCombineConjointXorU,
+};
+
+static CombineFuncC pixman_fbCombineFuncC[] = {
+ fbCombineClearC,
+ fbCombineSrcC,
+ NULL, /* Dest */
+ fbCombineOverC,
+ fbCombineOverReverseC,
+ fbCombineInC,
+ fbCombineInReverseC,
+ fbCombineOutC,
+ fbCombineOutReverseC,
+ fbCombineAtopC,
+ fbCombineAtopReverseC,
+ fbCombineXorC,
+ fbCombineAddC,
+ fbCombineSaturateC,
+ NULL,
+ NULL,
+ fbCombineClearC, /* 0x10 */
+ fbCombineSrcC,
+ NULL, /* Dest */
+ fbCombineDisjointOverC,
+ fbCombineSaturateC, /* DisjointOverReverse */
+ fbCombineDisjointInC,
+ fbCombineDisjointInReverseC,
+ fbCombineDisjointOutC,
+ fbCombineDisjointOutReverseC,
+ fbCombineDisjointAtopC,
+ fbCombineDisjointAtopReverseC,
+ fbCombineDisjointXorC, /* 0x1b */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ fbCombineClearC,
+ fbCombineSrcC,
+ NULL, /* Dest */
+ fbCombineConjointOverC,
+ fbCombineConjointOverReverseC,
+ fbCombineConjointInC,
+ fbCombineConjointInReverseC,
+ fbCombineConjointOutC,
+ fbCombineConjointOutReverseC,
+ fbCombineConjointAtopC,
+ fbCombineConjointAtopReverseC,
+ fbCombineConjointXorC,
+};
+
+FbComposeFunctions pixman_composeFunctions = {
+ pixman_fbCombineFuncU,
+ pixman_fbCombineFuncC,
+ pixman_fbCombineMaskU
+};
+
+void
+pixman_composite_rect_general (const FbComposeData *data,
+ full_t *scanline_buffer)
+{
+ if (data->src->common.read_func ||
+ data->src->common.write_func ||
+ (data->mask && data->mask->common.read_func) ||
+ (data->mask && data->mask->common.write_func) ||
+ data->dest->common.read_func ||
+ data->dest->common.write_func)
+ {
+ pixman_composite_rect_general_accessors (data, scanline_buffer);
+ }
+ else
+ {
+ pixman_composite_rect_general_no_accessors (data, scanline_buffer);
+ }
+}
diff --git a/pixman/pixman-compose64.c b/pixman/pixman-compose64.c
index d29c09e..6bcefe4 100644
--- a/pixman/pixman-compose64.c
+++ b/pixman/pixman-compose64.c
@@ -47,7 +47,7 @@
/*
x_c = (x_c * a) / 65535
*/
-static inline uint64_t FbWordMul(uint64_t x, uint64_t a)
+static inline uint64_t FullMul(uint64_t x, uint64_t a)
{
uint64_t xa = (((x >> 48) & 0xffff) * a) / 65535;
uint64_t xr = (((x >> 32) & 0xffff) * a) / 65535;
@@ -59,7 +59,7 @@ static inline uint64_t FbWordMul(uint64_t x, uint64_t a)
/*
x_c = min(x_c + y_c, 65535)
*/
-static inline uint64_t FbWordAdd(uint64_t x, uint64_t y)
+static inline uint64_t FullAdd(uint64_t x, uint64_t y)
{
uint64_t xa = ((x >> 48) & 0xffff) + ((y >> 48) & 0xffff);
uint64_t xr = ((x >> 32) & 0xffff) + ((y >> 32) & 0xffff);
@@ -77,23 +77,23 @@ static inline uint64_t FbWordAdd(uint64_t x, uint64_t y)
/*
x_c = (x_c * a) / 65535 + y
*/
-static inline uint64_t FbWordMulAdd(uint64_t x, uint64_t a, uint64_t y)
+static inline uint64_t FullMulAdd(uint64_t x, uint64_t a, uint64_t y)
{
- return FbWordAdd(FbWordMul(x, a), y);
+ return FullAdd(FullMul(x, a), y);
}
/*
x_c = (x_c * a + y_c * b) / 65535
*/
-static inline uint64_t FbWordAddMul(uint64_t x, uint64_t a, uint64_t y, uint64_t b)
+static inline uint64_t FullAddMul(uint64_t x, uint64_t a, uint64_t y, uint64_t b)
{
- return FbWordAdd(FbWordMul(x, a), FbWordMul(y, b));
+ return FullAdd(FullMul(x, a), FullMul(y, b));
}
/*
x_c = (x_c * a_c) / 65535
*/
-static inline uint64_t FbWordMulC(uint64_t x, uint64_t a)
+static inline uint64_t FullMulC(uint64_t x, uint64_t a)
{
uint64_t xa = (((x >> 48) & 0xffff) * ((a >> 48) & 0xffff)) / 65535;
uint64_t xr = (((x >> 32) & 0xffff) * ((a >> 32) & 0xffff)) / 65535;
@@ -106,503 +106,41 @@ static inline uint64_t FbWordMulC(uint64_t x, uint64_t a)
/*
x_c = (x_c * a_c) / 65535 + y
*/
-static inline uint64_t FbWordMulAddC(uint64_t x, uint64_t a, uint64_t y)
+static inline uint64_t FullMulAddC(uint64_t x, uint64_t a, uint64_t y)
{
- return FbWordAdd(FbWordMulC(x, a), y);
+ return FullAdd(FullMulC(x, a), y);
}
/*
x_c = (x_c * a_c + y_c * b) / 65535
*/
-static inline uint64_t FbWordAddMulC(uint64_t x, uint64_t a, uint64_t y, uint64_t b)
+static inline uint64_t FullAddMulC(uint64_t x, uint64_t a, uint64_t y, uint64_t b)
{
- return FbWordAdd(FbWordMulC(x, y), FbWordMul(y, b));
-
-}
-
-/*
- * Combine src and mask
- */
-static FASTCALL void
-pixman_fbCombineMaskU (uint64_t *src, const uint64_t *mask, int width)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t a = *(mask + i) >> 48;
- uint64_t s = *(src + i);
- s = FbWordMul(s, a);
- *(src + i) = s;
- }
-}
-
-/*
- * All of the composing functions
- */
-
-static FASTCALL void
-fbCombineClear (uint64_t *dest, const uint64_t *src, int width)
-{
- memset(dest, 0, width*sizeof(uint64_t));
-}
-
-static FASTCALL void
-fbCombineSrcU (uint64_t *dest, const uint64_t *src, int width)
-{
- memcpy(dest, src, width*sizeof(uint64_t));
-}
-
-
-static FASTCALL void
-fbCombineOverU (uint64_t *dest, const uint64_t *src, int width)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t d = *(dest + i);
- uint64_t ia = ~s >> 48;
- *(dest + i) = FbWordMulAdd(d, ia, s);
- }
-}
-
-static FASTCALL void
-fbCombineOverReverseU (uint64_t *dest, const uint64_t *src, int width)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t d = *(dest + i);
- uint64_t ia = ~*(dest + i) >> 48;
- *(dest + i) = FbWordMulAdd(s, ia, d);
- }
-}
-
-FASTCALL void
-fbCombineInU (uint64_t *dest, const uint64_t *src, int width)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t a = *(dest + i) >>48;
- *(dest + i) = FbWordMul(s, a);
- }
-}
-
-static FASTCALL void
-fbCombineInReverseU (uint64_t *dest, const uint64_t *src, int width)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t d = *(dest + i);
- uint64_t a = *(src + i) >> 48;
- *(dest + i) = FbWordMul(d, a);
- }
-}
-
-static FASTCALL void
-fbCombineOutU (uint64_t *dest, const uint64_t *src, int width)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t a = ~*(dest + i) >> 48;
- *(dest + i) = FbWordMul(s, a);
- }
+ return FullAdd(FullMulC(x, y), FullMul(y, b));
}
-static FASTCALL void
-fbCombineOutReverseU (uint64_t *dest, const uint64_t *src, int width)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t d = *(dest + i);
- uint64_t a = ~*(src + i) >> 48;
- *(dest + i) = FbWordMul(d, a);
- }
-}
+/******************************************************************************/
+typedef uint64_t full_t;
+#define FULL_MASK 0xffffffffffffULL
-static FASTCALL void
-fbCombineAtopU (uint64_t *dest, const uint64_t *src, int width)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t d = *(dest + i);
- uint64_t dest_a = d >> 48;
- uint64_t src_ia = ~s >> 48;
-
- *(dest + i) = FbWordAddMul(s, dest_a, d, src_ia);
- }
-}
+typedef uint32_t half_t;
+#define HALF_MASK 0xffffffULL
-static FASTCALL void
-fbCombineAtopReverseU (uint64_t *dest, const uint64_t *src, int width)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t d = *(dest + i);
- uint64_t src_a = s >> 48;
- uint64_t dest_ia = ~d >> 48;
-
- *(dest + i) = FbWordAddMul(s, dest_ia, d, src_a);
- }
-}
+typedef uint16_t quart_t;
+#define QUARTER_MASK 0xffffULL
-static FASTCALL void
-fbCombineXorU (uint64_t *dest, const uint64_t *src, int width)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t d = *(dest + i);
- uint64_t src_ia = ~s >> 48;
- uint64_t dest_ia = ~d >> 48;
-
- *(dest + i) = FbWordAddMul(s, dest_ia, d, src_ia);
- }
-}
+#define SHIFT 16
-static FASTCALL void
-fbCombineAddU (uint64_t *dest, const uint64_t *src, int width)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t d = *(dest + i);
- *(dest + i) = FbWordAdd(d, s);
- }
-}
+#define Add FbAdd16
+#define IntDiv FbIntDiv16
+#define Gen FbGen16
+#define GetQuart FbGet16
+#undef Alpha
+#define Alpha(x) ((x) >> 48)
-static FASTCALL void
-fbCombineSaturateU (uint64_t *dest, const uint64_t *src, int width)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t d = *(dest + i);
- uint32_t sa, da;
-
- sa = s >> 48;
- da = ~d >> 48;
- if (sa > da)
- {
- sa = FbIntDiv16(da, sa);
- s = FbWordMul(s, sa);
- };
- *(dest + i) = FbWordAdd(d, s);
- }
-}
-
-/*
- * All of the disjoint composing functions
-
- The four entries in the first column indicate what source contributions
- come from each of the four areas of the picture -- areas covered by neither
- A nor B, areas covered only by A, areas covered only by B and finally
- areas covered by both A and B.
-
- Disjoint Conjoint
- Fa Fb Fa Fb
- (0,0,0,0) 0 0 0 0
- (0,A,0,A) 1 0 1 0
- (0,0,B,B) 0 1 0 1
- (0,A,B,A) 1 min((1-a)/b,1) 1 max(1-a/b,0)
- (0,A,B,B) min((1-b)/a,1) 1 max(1-b/a,0) 1
- (0,0,0,A) max(1-(1-b)/a,0) 0 min(1,b/a) 0
- (0,0,0,B) 0 max(1-(1-a)/b,0) 0 min(a/b,1)
- (0,A,0,0) min(1,(1-b)/a) 0 max(1-b/a,0) 0
- (0,0,B,0) 0 min(1,(1-a)/b) 0 max(1-a/b,0)
- (0,0,B,A) max(1-(1-b)/a,0) min(1,(1-a)/b) min(1,b/a) max(1-a/b,0)
- (0,A,0,B) min(1,(1-b)/a) max(1-(1-a)/b,0) max(1-b/a,0) min(1,a/b)
- (0,A,B,0) min(1,(1-b)/a) min(1,(1-a)/b) max(1-b/a,0) max(1-a/b,0)
-
-*/
-
-#define CombineAOut 1
-#define CombineAIn 2
-#define CombineBOut 4
-#define CombineBIn 8
-
-#define CombineClear 0
-#define CombineA (CombineAOut|CombineAIn)
-#define CombineB (CombineBOut|CombineBIn)
-#define CombineAOver (CombineAOut|CombineBOut|CombineAIn)
-#define CombineBOver (CombineAOut|CombineBOut|CombineBIn)
-#define CombineAAtop (CombineBOut|CombineAIn)
-#define CombineBAtop (CombineAOut|CombineBIn)
-#define CombineXor (CombineAOut|CombineBOut)
-
-/* portion covered by a but not b */
-static INLINE uint16_t
-fbCombineDisjointOutPart (uint16_t a, uint16_t b)
-{
- /* min (1, (1-b) / a) */
-
- b = ~b; /* 1 - b */
- if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */
- return 0xffff; /* 1 */
- return FbIntDiv16(b,a); /* (1-b) / a */
-}
-
-/* portion covered by both a and b */
-static INLINE uint16_t
-fbCombineDisjointInPart (uint16_t a, uint16_t b)
-{
- /* max (1-(1-b)/a,0) */
- /* = - min ((1-b)/a - 1, 0) */
- /* = 1 - min (1, (1-b)/a) */
-
- b = ~b; /* 1 - b */
- if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */
- return 0; /* 1 - 1 */
- return ~FbIntDiv16(b,a); /* 1 - (1-b) / a */
-}
-
-static FASTCALL void
-fbCombineDisjointGeneralU (uint64_t *dest, const uint64_t *src, int width, uint16_t combine)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t d = *(dest + i);
- uint64_t m,n,o,p;
- uint32_t Fa, Fb, t, u, v;
- uint16_t sa = s >> 48;
- uint16_t da = d >> 48;
-
- switch (combine & CombineA) {
- default:
- Fa = 0;
- break;
- case CombineAOut:
- Fa = fbCombineDisjointOutPart (sa, da);
- break;
- case CombineAIn:
- Fa = fbCombineDisjointInPart (sa, da);
- break;
- case CombineA:
- Fa = 0xffff;
- break;
- }
-
- switch (combine & CombineB) {
- default:
- Fb = 0;
- break;
- case CombineBOut:
- Fb = fbCombineDisjointOutPart (da, sa);
- break;
- case CombineBIn:
- Fb = fbCombineDisjointInPart (da, sa);
- break;
- case CombineB:
- Fb = 0xffff;
- break;
- }
- m = FbGen16 (s,d,0,Fa,Fb,t, u, v);
- n = FbGen16 (s,d,16,Fa,Fb,t, u, v);
- o = FbGen16 (s,d,32,Fa,Fb,t, u, v);
- p = FbGen16 (s,d,48,Fa,Fb,t, u, v);
- s = m|n|o|p;
- *(dest + i) = s;
- }
-}
-
-static FASTCALL void
-fbCombineDisjointOverU (uint64_t *dest, const uint64_t *src, int width)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint32_t a = s >> 48;
-
- if (a != 0x0000)
- {
- if (a != 0xffff)
- {
- uint64_t d = *(dest + i);
- a = fbCombineDisjointOutPart (d >> 48, a);
- s = FbWordMulAdd(d, a, s);
- }
- *(dest + i) = s;
- }
- }
-}
-
-static FASTCALL void
-fbCombineDisjointInU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineDisjointGeneralU (dest, src, width, CombineAIn);
-}
-
-static FASTCALL void
-fbCombineDisjointInReverseU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineDisjointGeneralU (dest, src, width, CombineBIn);
-}
-
-static FASTCALL void
-fbCombineDisjointOutU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineDisjointGeneralU (dest, src, width, CombineAOut);
-}
-
-static FASTCALL void
-fbCombineDisjointOutReverseU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineDisjointGeneralU (dest, src, width, CombineBOut);
-}
-
-static FASTCALL void
-fbCombineDisjointAtopU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineDisjointGeneralU (dest, src, width, CombineAAtop);
-}
-
-static FASTCALL void
-fbCombineDisjointAtopReverseU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineDisjointGeneralU (dest, src, width, CombineBAtop);
-}
-
-static FASTCALL void
-fbCombineDisjointXorU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineDisjointGeneralU (dest, src, width, CombineXor);
-}
-
-/* portion covered by a but not b */
-static INLINE uint16_t
-fbCombineConjointOutPart (uint16_t a, uint16_t b)
-{
- /* max (1-b/a,0) */
- /* = 1-min(b/a,1) */
-
- /* min (1, (1-b) / a) */
-
- if (b >= a) /* b >= a -> b/a >= 1 */
- return 0x0000; /* 0 */
- return ~FbIntDiv16(b,a); /* 1 - b/a */
-}
-
-/* portion covered by both a and b */
-static INLINE uint16_t
-fbCombineConjointInPart (uint16_t a, uint16_t b)
-{
- /* min (1,b/a) */
-
- if (b >= a) /* b >= a -> b/a >= 1 */
- return 0xffff; /* 1 */
- return FbIntDiv16(b,a); /* b/a */
-}
-
-static FASTCALL void
-fbCombineConjointGeneralU (uint64_t *dest, const uint64_t *src, int width, uint16_t combine)
-{
- int i;
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t d = *(dest + i);
- uint64_t m,n,o,p;
- uint32_t Fa, Fb, t, u, v;
- uint16_t sa = s >> 48;
- uint16_t da = d >> 48;
-
- switch (combine & CombineA) {
- default:
- Fa = 0;
- break;
- case CombineAOut:
- Fa = fbCombineConjointOutPart (sa, da);
- break;
- case CombineAIn:
- Fa = fbCombineConjointInPart (sa, da);
- break;
- case CombineA:
- Fa = 0xffff;
- break;
- }
-
- switch (combine & CombineB) {
- default:
- Fb = 0;
- break;
- case CombineBOut:
- Fb = fbCombineConjointOutPart (da, sa);
- break;
- case CombineBIn:
- Fb = fbCombineConjointInPart (da, sa);
- break;
- case CombineB:
- Fb = 0xffff;
- break;
- }
- m = FbGen16 (s,d,0,Fa,Fb,t, u, v);
- n = FbGen16 (s,d,16,Fa,Fb,t, u, v);
- o = FbGen16 (s,d,32,Fa,Fb,t, u, v);
- p = FbGen16 (s,d,48,Fa,Fb,t, u, v);
- s = m|n|o|p;
- *(dest + i) = s;
- }
-}
-
-static FASTCALL void
-fbCombineConjointOverU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineConjointGeneralU (dest, src, width, CombineAOver);
-}
-
-
-static FASTCALL void
-fbCombineConjointOverReverseU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineConjointGeneralU (dest, src, width, CombineBOver);
-}
-
-
-static FASTCALL void
-fbCombineConjointInU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineConjointGeneralU (dest, src, width, CombineAIn);
-}
-
-
-static FASTCALL void
-fbCombineConjointInReverseU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineConjointGeneralU (dest, src, width, CombineBIn);
-}
-
-static FASTCALL void
-fbCombineConjointOutU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineConjointGeneralU (dest, src, width, CombineAOut);
-}
-
-static FASTCALL void
-fbCombineConjointOutReverseU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineConjointGeneralU (dest, src, width, CombineBOut);
-}
-
-static FASTCALL void
-fbCombineConjointAtopU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineConjointGeneralU (dest, src, width, CombineAAtop);
-}
-
-static FASTCALL void
-fbCombineConjointAtopReverseU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineConjointGeneralU (dest, src, width, CombineBAtop);
-}
-
-static FASTCALL void
-fbCombineConjointXorU (uint64_t *dest, const uint64_t *src, int width)
-{
- fbCombineConjointGeneralU (dest, src, width, CombineXor);
-}
+#include "pixman-compose.c"
+/******************************************************************************/
static CombineFuncU64 pixman_fbCombineFuncU[] = {
fbCombineClear,
@@ -651,626 +189,6 @@ static CombineFuncU64 pixman_fbCombineFuncU[] = {
fbCombineConjointXorU,
};
-static INLINE void
-fbCombineMaskC (uint64_t *src, uint64_t *mask)
-{
- uint64_t a = *mask;
-
- uint64_t x;
- uint32_t xa;
-
- if (!a)
- {
- *(src) = 0;
- return;
- }
-
- x = *(src);
- if (a == 0xffffffffffffffffLL)
- {
- x = x >> 48;
- x |= x << 16;
- x |= x << 32;
- *(mask) = x;
- return;
- }
-
- xa = x >> 48;
- *(src) = FbWordMulC(x, a);
- *(mask) = FbWordMul(a, xa);
-}
-
-static INLINE void
-fbCombineMaskValueC (uint64_t *src, const uint64_t *mask)
-{
- uint64_t a = *mask;
-
- if (!a)
- {
- *src = 0;
- return;
- }
-
- if (a == 0xffffffffffffffffLL)
- return;
-
- *src = FbWordMulC(*src, a);
-}
-
-static INLINE void
-fbCombineMaskAlphaC (const uint64_t *src, uint64_t *mask)
-{
- uint64_t a = *(mask);
- uint64_t x;
-
- if (!a)
- return;
-
- x = *(src) >> 48;
- if (x == 0xffff)
- return;
- if (a == 0xffffffffffffffffLL)
- {
- x = x >> 48;
- x |= x << 16;
- x |= x << 32;
- *(mask) = x;
- return;
- }
-
- *(mask) = FbWordMul(a, x);
-}
-
-static FASTCALL void
-fbCombineClearC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- memset(dest, 0, width*sizeof(uint64_t));
-}
-
-static FASTCALL void
-fbCombineSrcC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- int i;
-
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t m = *(mask + i);
-
- fbCombineMaskValueC (&s, &m);
-
- *(dest) = s;
- }
-}
-
-static FASTCALL void
-fbCombineOverC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- int i;
-
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t m = *(mask + i);
- uint64_t a;
-
- fbCombineMaskC (&s, &m);
-
- a = ~m;
- if (a != 0xffffffffffffffffLL)
- {
- if (a)
- {
- uint64_t d = *(dest + i);
- s = FbWordMulAddC(d, a, s);
- }
- *(dest + i) = s;
- }
- }
-}
-
-static FASTCALL void
-fbCombineOverReverseC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- int i;
-
- for (i = 0; i < width; ++i) {
- uint64_t d = *(dest + i);
- uint64_t a = ~d >> 48;
-
- if (a)
- {
- uint64_t s = *(src + i);
- uint64_t m = *(mask + i);
-
- fbCombineMaskValueC (&s, &m);
-
- if (a != 0xffff)
- {
- s = FbWordMulAdd(s, a, d);
- }
- *(dest + i) = s;
- }
- }
-}
-
-static FASTCALL void
-fbCombineInC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- int i;
-
- for (i = 0; i < width; ++i) {
- uint64_t d = *(dest + i);
- uint32_t a = d >> 48;
- uint64_t s = 0;
- if (a)
- {
- uint64_t m = *(mask + i);
-
- s = *(src + i);
- fbCombineMaskValueC (&s, &m);
- if (a != 0xffff)
- {
- s = FbWordMul(s, a);
- }
- }
- *(dest + i) = s;
- }
-}
-
-static FASTCALL void
-fbCombineInReverseC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- int i;
-
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t m = *(mask + i);
- uint64_t a;
-
- fbCombineMaskAlphaC (&s, &m);
-
- a = m;
- if (a != 0xffffffffffffffffLL)
- {
- uint64_t d = 0;
- if (a)
- {
- d = *(dest + i);
- d = FbWordMulC(d, a);
- }
- *(dest + i) = d;
- }
- }
-}
-
-static FASTCALL void
-fbCombineOutC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- int i;
-
- for (i = 0; i < width; ++i) {
- uint64_t d = *(dest + i);
- uint32_t a = ~d >> 48;
- uint64_t s = 0;
- if (a)
- {
- uint64_t m = *(mask + i);
-
- s = *(src + i);
- fbCombineMaskValueC (&s, &m);
-
- if (a != 0xffff)
- {
- s = FbWordMul(s, a);
- }
- }
- *(dest + i) = s;
- }
-}
-
-static FASTCALL void
-fbCombineOutReverseC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- int i;
-
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t m = *(mask + i);
- uint64_t a;
-
- fbCombineMaskAlphaC (&s, &m);
-
- a = ~m;
- if (a != 0xffffffffffffffffLL)
- {
- uint64_t d = 0;
- if (a)
- {
- d = *(dest + i);
- d = FbWordMulC(d, a);
- }
- *(dest + i) = d;
- }
- }
-}
-
-static FASTCALL void
-fbCombineAtopC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- int i;
-
- for (i = 0; i < width; ++i) {
- uint64_t d = *(dest + i);
- uint64_t s = *(src + i);
- uint64_t m = *(mask + i);
- uint64_t ad;
- uint32_t as = d >> 48;
-
- fbCombineMaskC (&s, &m);
-
- ad = ~m;
-
- *(dest + i) = FbWordAddMulC(d, ad, s, as);
- }
-}
-
-static FASTCALL void
-fbCombineAtopReverseC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- int i;
-
- for (i = 0; i < width; ++i) {
-
- uint64_t d = *(dest + i);
- uint64_t s = *(src + i);
- uint64_t m = *(mask + i);
- uint64_t ad;
- uint32_t as = ~d >> 48;
-
- fbCombineMaskC (&s, &m);
-
- ad = m;
-
- *(dest + i) = FbWordAddMulC(d, ad, s, as);
- }
-}
-
-static FASTCALL void
-fbCombineXorC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- int i;
-
- for (i = 0; i < width; ++i) {
- uint64_t d = *(dest + i);
- uint64_t s = *(src + i);
- uint64_t m = *(mask + i);
- uint64_t ad;
- uint32_t as = ~d >> 48;
-
- fbCombineMaskC (&s, &m);
-
- ad = ~m;
-
- *(dest + i) = FbWordAddMulC(d, ad, s, as);
- }
-}
-
-static FASTCALL void
-fbCombineAddC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- int i;
-
- for (i = 0; i < width; ++i) {
- uint64_t s = *(src + i);
- uint64_t m = *(mask + i);
- uint64_t d = *(dest + i);
-
- fbCombineMaskValueC (&s, &m);
-
- *(dest + i) = FbWordAdd(d, s);;
- }
-}
-
-static FASTCALL void
-fbCombineSaturateC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- int i;
-
- for (i = 0; i < width; ++i) {
- uint64_t s, d;
- uint32_t sa, sr, sg, sb, da;
- uint32_t t, u, v;
- uint64_t m,n,o,p;
-
- d = *(dest + i);
- s = *(src + i);
- m = *(mask + i);
-
- fbCombineMaskC (&s, &m);
-
- sa = (m >> 48);
- sr = (m >> 32) & 0xffff;
- sg = (m >> 16) & 0xffff;
- sb = (m ) & 0xffff;
- da = ~d >> 48;
-
- if (sb <= da)
- m = FbAdd16(s,d,0,t);
- else
- m = FbGen16 (s, d, 0, (da << 16) / sb, 0xffff, t, u, v);
-
- if (sg <= da)
- n = FbAdd16(s,d,16,t);
- else
- n = FbGen16 (s, d, 16, (da << 16) / sg, 0xffff, t, u, v);
-
- if (sr <= da)
- o = FbAdd16(s,d,32,t);
- else
- o = FbGen16 (s, d, 32, (da << 16) / sr, 0xffff, t, u, v);
-
- if (sa <= da)
- p = FbAdd16(s,d,48,t);
- else
- p = FbGen16 (s, d, 48, (da << 16) / sa, 0xffff, t, u, v);
-
- *(dest + i) = m|n|o|p;
- }
-}
-
-static FASTCALL void
-fbCombineDisjointGeneralC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width, uint16_t combine)
-{
- int i;
-
- for (i = 0; i < width; ++i) {
- uint64_t s, d;
- uint64_t m,n,o,p;
- uint64_t Fa, Fb;
- uint32_t t, u, v;
- uint64_t sa;
- uint16_t da;
-
- s = *(src + i);
- m = *(mask + i);
- d = *(dest + i);
- da = d >> 48;
-
- fbCombineMaskC (&s, &m);
-
- sa = m;
-
- switch (combine & CombineA) {
- default:
- Fa = 0;
- break;
- case CombineAOut:
- m = (uint64_t)fbCombineDisjointOutPart ((uint16_t) (sa >> 0), da);
- n = (uint64_t)fbCombineDisjointOutPart ((uint16_t) (sa >> 16), da) << 16;
- o = (uint64_t)fbCombineDisjointOutPart ((uint16_t) (sa >> 32), da) << 32;
- p = (uint64_t)fbCombineDisjointOutPart ((uint16_t) (sa >> 48), da) << 48;
- Fa = m|n|o|p;
- break;
- case CombineAIn:
- m = (uint64_t)fbCombineDisjointInPart ((uint16_t) (sa >> 0), da);
- n = (uint64_t)fbCombineDisjointInPart ((uint16_t) (sa >> 16), da) << 16;
- o = (uint64_t)fbCombineDisjointInPart ((uint16_t) (sa >> 32), da) << 32;
- p = (uint64_t)fbCombineDisjointInPart ((uint16_t) (sa >> 48), da) << 48;
- Fa = m|n|o|p;
- break;
- case CombineA:
- Fa = 0xffffffffffffffffLL;
- break;
- }
-
- switch (combine & CombineB) {
- default:
- Fb = 0;
- break;
- case CombineBOut:
- m = (uint64_t)fbCombineDisjointOutPart (da, (uint16_t) (sa >> 0));
- n = (uint64_t)fbCombineDisjointOutPart (da, (uint16_t) (sa >> 16)) << 16;
- o = (uint64_t)fbCombineDisjointOutPart (da, (uint16_t) (sa >> 32)) << 32;
- p = (uint64_t)fbCombineDisjointOutPart (da, (uint16_t) (sa >> 48)) << 48;
- Fb = m|n|o|p;
- break;
- case CombineBIn:
- m = (uint64_t)fbCombineDisjointInPart (da, (uint16_t) (sa >> 0));
- n = (uint64_t)fbCombineDisjointInPart (da, (uint16_t) (sa >> 16)) << 16;
- o = (uint64_t)fbCombineDisjointInPart (da, (uint16_t) (sa >> 32)) << 32;
- p = (uint64_t)fbCombineDisjointInPart (da, (uint16_t) (sa >> 48)) << 48;
- Fb = m|n|o|p;
- break;
- case CombineB:
- Fb = 0xffffffffffffffffLL;
- break;
- }
- m = FbGen16 (s,d,0,FbGet16(Fa,0),FbGet16(Fb,0),t, u, v);
- n = FbGen16 (s,d,16,FbGet16(Fa,16),FbGet16(Fb,16),t, u, v);
- o = FbGen16 (s,d,32,FbGet16(Fa,32),FbGet16(Fb,32),t, u, v);
- p = FbGen16 (s,d,48,FbGet16(Fa,48),FbGet16(Fb,48),t, u, v);
- s = m|n|o|p;
- *(dest + i) = s;
- }
-}
-
-static FASTCALL void
-fbCombineDisjointOverC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineDisjointGeneralC (dest, src, mask, width, CombineAOver);
-}
-
-static FASTCALL void
-fbCombineDisjointInC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineDisjointGeneralC (dest, src, mask, width, CombineAIn);
-}
-
-static FASTCALL void
-fbCombineDisjointInReverseC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineDisjointGeneralC (dest, src, mask, width, CombineBIn);
-}
-
-static FASTCALL void
-fbCombineDisjointOutC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineDisjointGeneralC (dest, src, mask, width, CombineAOut);
-}
-
-static FASTCALL void
-fbCombineDisjointOutReverseC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineDisjointGeneralC (dest, src, mask, width, CombineBOut);
-}
-
-static FASTCALL void
-fbCombineDisjointAtopC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineDisjointGeneralC (dest, src, mask, width, CombineAAtop);
-}
-
-static FASTCALL void
-fbCombineDisjointAtopReverseC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineDisjointGeneralC (dest, src, mask, width, CombineBAtop);
-}
-
-static FASTCALL void
-fbCombineDisjointXorC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineDisjointGeneralC (dest, src, mask, width, CombineXor);
-}
-
-static FASTCALL void
-fbCombineConjointGeneralC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width, uint16_t combine)
-{
- int i;
-
- for (i = 0; i < width; ++i) {
- uint64_t s, d;
- uint64_t m,n,o,p;
- uint64_t Fa, Fb;
- uint32_t t, u, v;
- uint64_t sa;
- uint16_t da;
-
- s = *(src + i);
- m = *(mask + i);
- d = *(dest + i);
- da = d >> 48;
-
- fbCombineMaskC (&s, &m);
-
- sa = m;
-
- switch (combine & CombineA) {
- default:
- Fa = 0;
- break;
- case CombineAOut:
- m = (uint64_t)fbCombineConjointOutPart ((uint16_t) (sa >> 0), da);
- n = (uint64_t)fbCombineConjointOutPart ((uint16_t) (sa >> 16), da) << 16;
- o = (uint64_t)fbCombineConjointOutPart ((uint16_t) (sa >> 32), da) << 32;
- p = (uint64_t)fbCombineConjointOutPart ((uint16_t) (sa >> 48), da) << 48;
- Fa = m|n|o|p;
- break;
- case CombineAIn:
- m = (uint64_t)fbCombineConjointInPart ((uint16_t) (sa >> 0), da);
- n = (uint64_t)fbCombineConjointInPart ((uint16_t) (sa >> 16), da) << 16;
- o = (uint64_t)fbCombineConjointInPart ((uint16_t) (sa >> 32), da) << 32;
- p = (uint64_t)fbCombineConjointInPart ((uint16_t) (sa >> 48), da) << 48;
- Fa = m|n|o|p;
- break;
- case CombineA:
- Fa = 0xffffffffffffffffLL;
- break;
- }
-
- switch (combine & CombineB) {
- default:
- Fb = 0;
- break;
- case CombineBOut:
- m = (uint64_t)fbCombineConjointOutPart (da, (uint16_t) (sa >> 0));
- n = (uint64_t)fbCombineConjointOutPart (da, (uint16_t) (sa >> 16)) << 16;
- o = (uint64_t)fbCombineConjointOutPart (da, (uint16_t) (sa >> 32)) << 32;
- p = (uint64_t)fbCombineConjointOutPart (da, (uint16_t) (sa >> 48)) << 48;
- Fb = m|n|o|p;
- break;
- case CombineBIn:
- m = (uint64_t)fbCombineConjointInPart (da, (uint16_t) (sa >> 0));
- n = (uint64_t)fbCombineConjointInPart (da, (uint16_t) (sa >> 16)) << 16;
- o = (uint64_t)fbCombineConjointInPart (da, (uint16_t) (sa >> 32)) << 32;
- p = (uint64_t)fbCombineConjointInPart (da, (uint16_t) (sa >> 48)) << 48;
- Fb = m|n|o|p;
- break;
- case CombineB:
- Fb = 0xfffffffffffffffLL;
- break;
- }
- m = FbGen16 (s,d,0,FbGet16(Fa,0),FbGet16(Fb,0),t, u, v);
- n = FbGen16 (s,d,16,FbGet16(Fa,16),FbGet16(Fb,16),t, u, v);
- o = FbGen16 (s,d,32,FbGet16(Fa,32),FbGet16(Fb,32),t, u, v);
- p = FbGen16 (s,d,48,FbGet16(Fa,48),FbGet16(Fb,48),t, u, v);
- s = m|n|o|p;
- *(dest + i) = s;
- }
-}
-
-static FASTCALL void
-fbCombineConjointOverC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineConjointGeneralC (dest, src, mask, width, CombineAOver);
-}
-
-static FASTCALL void
-fbCombineConjointOverReverseC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineConjointGeneralC (dest, src, mask, width, CombineBOver);
-}
-
-static FASTCALL void
-fbCombineConjointInC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineConjointGeneralC (dest, src, mask, width, CombineAIn);
-}
-
-static FASTCALL void
-fbCombineConjointInReverseC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineConjointGeneralC (dest, src, mask, width, CombineBIn);
-}
-
-static FASTCALL void
-fbCombineConjointOutC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineConjointGeneralC (dest, src, mask, width, CombineAOut);
-}
-
-static FASTCALL void
-fbCombineConjointOutReverseC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineConjointGeneralC (dest, src, mask, width, CombineBOut);
-}
-
-static FASTCALL void
-fbCombineConjointAtopC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineConjointGeneralC (dest, src, mask, width, CombineAAtop);
-}
-
-static FASTCALL void
-fbCombineConjointAtopReverseC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineConjointGeneralC (dest, src, mask, width, CombineBAtop);
-}
-
-static FASTCALL void
-fbCombineConjointXorC (uint64_t *dest, uint64_t *src, uint64_t *mask, int width)
-{
- fbCombineConjointGeneralC (dest, src, mask, width, CombineXor);
-}
-
static CombineFuncC64 pixman_fbCombineFuncC[] = {
fbCombineClearC,
fbCombineSrcC,
@@ -1318,7 +236,6 @@ static CombineFuncC64 pixman_fbCombineFuncC[] = {
fbCombineConjointXorC,
};
-
FbComposeFunctions64 pixman_composeFunctions_wide = {
pixman_fbCombineFuncU,
pixman_fbCombineFuncC,
@@ -1343,4 +260,3 @@ pixman_composite_rect_general_wide (const FbComposeData *data,
pixman_composite_rect_general_wide_no_accessors (data, scanline_buffer);
}
}
-
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 094b91b..3c805fc 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -174,10 +174,14 @@ extern FbComposeFunctions64 pixman_composeFunctions_wide;
void pixman_composite_rect_general_accessors (const FbComposeData *data,
uint32_t *scanline_buffer);
+void pixman_composite_rect_general_no_accessors (const FbComposeData *data,
+ uint32_t *scanline_buffer);
void pixman_composite_rect_general (const FbComposeData *data,
uint32_t *scanline_buffer);
void pixman_composite_rect_general_wide_accessors (const FbComposeData *data,
uint64_t *scanline_buffer);
+void pixman_composite_rect_general_wide_no_accessors (const FbComposeData *data,
+ uint64_t *scanline_buffer);
void pixman_composite_rect_general_wide (const FbComposeData *data,
uint64_t *scanline_buffer);
commit e4990cc0755b2c8a14367e6c7431889806ac6641
Merge: 06426f5... 39a67d3...
Author: Aaron Plattner <aplattner at nvidia.com>
Date: Mon Oct 22 13:11:49 2007 -0700
Merge branch 'master' into wide-composite
Conflicts:
.gitignore
pixman/Makefile.am
diff --cc .gitignore
index 5394d12,7f08f61..a9b914a
--- a/.gitignore
+++ b/.gitignore
@@@ -28,4 -28,8 +28,9 @@@ config.h.i
.*.swp
test/composite-test
test/gradient-test
+ *.pdb
+ *.dll
+ *.lib
+ *.ilk
+ *.obj
+pixman/pixman-access.c
diff --cc pixman/Makefile.am
index 9d92f27,66283a2..73dc691
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@@ -1,19 -1,13 +1,20 @@@
+EXTRA_DIST = gen.pl formats.pl pixman-access-handcode.c
+pixman-access.c: gen.pl formats.pl pixman-access-handcode.c
+ cd $(srcdir) && \
+ perl ./gen.pl > $(CURDIR)/$@
+
lib_LTLIBRARIES = libpixman-1.la
libpixman_1_la_LDFLAGS = -version-info $(LT_VERSION_INFO)
- libpixman_1_la_LIBADD = @DEP_LIBS@ -lm libpixmanwrapper.la
+ libpixman_1_la_LIBADD = @DEP_LIBS@ -lm
libpixman_1_la_SOURCES = \
pixman.h \
pixman-region.c \
pixman-private.h \
pixman-image.c \
+ pixman-access.c \
++ pixman-access-accessors.c \
pixman-compose.c \
- pixman-compose-accessors.c \
+ pixman-compose64.c \
pixman-pict.c \
pixman-utils.c \
pixman-edge.c \
diff --cc pixman/pixman-access-accessors.c
index 0000000,0000000..3757b41
new file mode 100644
--- /dev/null
+++ b/pixman/pixman-access-accessors.c
@@@ -1,0 -1,0 +1,4 @@@
++
++#define PIXMAN_FB_ACCESSORS
++
++#include "pixman-access.c"
commit 28532430efeb4a1aba8f3e30a790531d2a9e1472
Author: Søren Sandmann <sandmann at redhat.com>
Date: Wed Oct 17 20:01:27 2007 -0400
Only compile with -msse on x86-64.
diff --git a/configure.ac b/configure.ac
index 5bb6c27..fded892 100644
--- a/configure.ac
+++ b/configure.ac
@@ -86,10 +86,10 @@ if test "x$GCC" = "xyes"; then
dnl ===========================================================================
dnl Check for MMX
-MMX_CFLAGS="-mmmx -msse -Winline --param inline-unit-growth=10000 --param large-function-growth=10000"
+MMX_CFLAGS="-mmmx -Winline --param inline-unit-growth=10000 --param large-function-growth=10000"
have_mmx_intrinsics=no
-AC_MSG_CHECKING(For MMX/SSE intrinsics in the compiler)
+AC_MSG_CHECKING(whether to use MMX intrinsics)
xserver_save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $MMX_CFLAGS"
AC_COMPILE_IFELSE([
@@ -97,10 +97,8 @@ AC_COMPILE_IFELSE([
#error "Need GCC >= 3.4 for MMX intrinsics"
#endif
#include <mmintrin.h>
-#include <xmmintrin.h>
int main () {
__m64 v = _mm_cvtsi32_si64 (1);
- v = _mm_shuffle_pi16 (v, _MM_SHUFFLE(3, 3, 3, 3));
return _mm_cvtsi64_si32 (v);
}], have_mmx_intrinsics=yes)
CFLAGS=$xserver_save_CFLAGS
@@ -111,11 +109,46 @@ if test $have_mmx_intrinsics = yes ; then
else
MMX_CFLAGS=
fi
-AC_SUBST(MMX_CFLAGS)
AM_CONDITIONAL(USE_MMX, test $have_mmx_intrinsics = yes)
+dnl =======================================================
+
+dnl GCC 4.2 when compiling with -msse will generate SSE instructions
+dnl on its own. This means anything compiled with -mss can only be
+dnl run after a runtime check for SSE. Unfortunately, since we still
+dnl need to support MMX-but-not-SSE (such as the OLPC), this means we
+dnl can only use SSE when compiling for x86-64 (where SSE is always
+dnl supported).
+
+have_sse_intrinsics=no
+AC_MSG_CHECKING(whether to use SSE intrinsics)
+xserver_save_CFLAGS=$CFLAGS
+CFLAGS="$CFLAGS -msse $MMX_CFLAGS"
+
+AC_COMPILE_IFELSE([
+#if !defined(__amd64__) && !defined(__x86_64__)
+#error "Need x86-64 for SSE"
+#endif
+#include <mmintrin.h>
+#include <xmmintrin.h>
+int main () {
+ __m64 v = _mm_cvtsi32_si64 (1);
+ v = _mm_shuffle_pi16 (v, _MM_SHUFFLE(3, 3, 3, 3));
+ return _mm_cvtsi64_si32 (v);
+}], have_sse_intrinsics=yes)
+CFLAGS=$xserver_save_CFLAGS
+AC_MSG_RESULT($have_sse_intrinsics)
+
+if test $have_sse_intrinsics = yes ; then
+ AC_DEFINE(USE_SSE, 1, [use SSE compiler intrinsics])
+ MMX_CFLAGS="-msse $MMX_CFLAGS"
+fi
+
+AM_CONDITIONAL(USE_SSE, test $have_sse_intrinsics = yes)
+
dnl ========================================================
+AC_SUBST(MMX_CFLAGS)
PKG_CHECK_MODULES(GTK, [gtk+-2.0], [HAVE_GTK=yes], [HAVE_GTK=no])
AM_CONDITIONAL(HAVE_GTK, [test "x$HAVE_GTK" = xyes])
diff --git a/pixman/pixman-mmx.c b/pixman/pixman-mmx.c
index be79124..52061c7 100644
--- a/pixman/pixman-mmx.c
+++ b/pixman/pixman-mmx.c
@@ -35,10 +35,6 @@
#ifdef USE_MMX
-#if defined(__amd64__) || defined(__x86_64__)
-#define USE_SSE
-#endif
-
#include <mmintrin.h>
#ifdef USE_SSE
#include <xmmintrin.h> /* for _mm_shuffle_pi16 and _MM_SHUFFLE */
commit ab6743b17074dfedffb0ee32fe2e37cad03769bf
Author: Søren Sandmann <sandmann at redhat.com>
Date: Wed Oct 17 19:20:55 2007 -0400
Make stride signed in various places. This should fix some the
crashers that people have reported in bug 12398.
diff --git a/pixman/pixman-compose.c b/pixman/pixman-compose.c
index 1e91864..4c73822 100644
--- a/pixman/pixman-compose.c
+++ b/pixman/pixman-compose.c
@@ -2880,7 +2880,7 @@ static void fbFetchSolid(bits_image_t * pict, int x, int y, int width, uint32_t
static void fbFetch(bits_image_t * pict, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits)
{
uint32_t *bits;
- uint32_t stride;
+ int32_t stride;
fetchProc fetch = fetchProcForPicture(pict);
const pixman_indexed_t * indexed = pict->indexed;
@@ -3560,7 +3560,7 @@ static void pixmanFetchSourcePict(source_image_t * pict, int x, int y, int width
static void fbFetchTransformed(bits_image_t * pict, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits)
{
uint32_t *bits;
- uint32_t stride;
+ int32_t stride;
fetchPixelProc fetch;
pixman_vector_t v;
pixman_vector_t unit;
@@ -4093,7 +4093,7 @@ static void fbFetchExternalAlpha(bits_image_t * pict, int x, int y, int width, u
static void fbStore(bits_image_t * pict, int x, int y, int width, uint32_t *buffer)
{
uint32_t *bits;
- uint32_t stride;
+ int32_t stride;
storeProc store = storeProcForPicture(pict);
const pixman_indexed_t * indexed = pict->indexed;
@@ -4107,7 +4107,7 @@ static void fbStore(bits_image_t * pict, int x, int y, int width, uint32_t *buff
static void fbStoreExternalAlpha(bits_image_t * pict, int x, int y, int width, uint32_t *buffer)
{
uint32_t *bits, *alpha_bits;
- uint32_t stride, astride;
+ int32_t stride, astride;
int ax, ay;
storeProc store;
storeProc astore;
@@ -4163,7 +4163,7 @@ PIXMAN_COMPOSITE_RECT_GENERAL (const FbComposeData *data,
unsigned int srcClass = SOURCE_IMAGE_CLASS_UNKNOWN;
unsigned int maskClass = SOURCE_IMAGE_CLASS_UNKNOWN;
uint32_t *bits;
- uint32_t stride;
+ int32_t stride;
int xoff, yoff;
if (data->op == PIXMAN_OP_CLEAR)
commit aca8b610d9ab178fcbcfa4a44d87e52aa7918ea4
Author: Søren Sandmann <sandmann at redhat.com>
Date: Wed Oct 17 18:43:13 2007 -0400
Remove comma from enumerator list. Bug 12621, reported by Matt Kraai.
diff --git a/pixman/pixman.h b/pixman/pixman.h
index a22dfd9..7b93214 100644
--- a/pixman/pixman.h
+++ b/pixman/pixman.h
@@ -452,7 +452,7 @@ typedef enum {
/* 1bpp formats */
PIXMAN_a1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_A,1,0,0,0),
- PIXMAN_g1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0),
+ PIXMAN_g1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0)
} pixman_format_code_t;
/* Constructors */
commit 089c3e6ad00105b2f9a1118d15b4f381653ea6ff
Author: Søren Sandmann <sandmann at redhat.com>
Date: Wed Oct 17 18:40:28 2007 -0400
Add README file based on text from Bjorn Lindquist
diff --git a/README b/README
index e69de29..94b830c 100644
--- a/README
+++ b/README
@@ -0,0 +1,26 @@
+pixman is a library that provides low-level pixel manipulation
+features such as image compositing and trapezoid rasterization.
+
+Please submit bugs & patches to the libpixman bugzilla:
+
+ https://bugs.freedesktop.org/enter_bug.cgi?product=libpixman
+
+All questions regarding this software should be directed to either the
+Xorg mailing list:
+
+ http://lists.freedesktop.org/mailman/listinfo/xorg
+
+or the cairo mailing list:
+
+ http://lists.freedesktop.org/mailman/listinfo/cairo
+
+The master development code repository can be found at:
+
+ git://anongit.freedesktop.org/git/pixman
+
+ http://gitweb.freedesktop.org/?p=pixman;a=summary
+
+For more information on the git code manager, see:
+
+ http://wiki.x.org/wiki/GitPage
+
commit 39a67d35f05aa47cf50191e0837a2125593a7bbc
Author: Tilman Sauerbeck <tilman at code-monkey.de>
Date: Sat Sep 29 22:45:42 2007 +0200
Fixed the declaration of pixman_image_set_source_clipping().
diff --git a/pixman/pixman.h b/pixman/pixman.h
index d76cc12..a22dfd9 100644
--- a/pixman/pixman.h
+++ b/pixman/pixman.h
@@ -498,7 +498,7 @@ pixman_bool_t pixman_image_set_filter (pixman_image_t
void pixman_image_set_filter_params (pixman_image_t *image,
pixman_fixed_t *params,
int n_params);
-void pixman_image_set_source_cliping (pixman_image_t *image,
+void pixman_image_set_source_clipping (pixman_image_t *image,
pixman_bool_t source_clipping);
void pixman_image_set_alpha_map (pixman_image_t *image,
pixman_image_t *alpha_map,
commit 7f820e15070c9b9618d78425b8cb1a4df722eb22
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Sep 27 12:46:46 2007 +0100
[pixman-image] [mlk] Free the locally allocated bits.
If we fail to allocate the image, remember to free the bits if we have
created the buffer on behalf of the caller.
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index de799b1..d40234d 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -359,8 +359,11 @@ pixman_image_create_bits (pixman_format_code_t format,
image = allocate_image();
- if (!image)
+ if (!image) {
+ if (free_me)
+ free (free_me);
return NULL;
+ }
image->type = BITS;
image->bits.format = format;
commit b4f0cc6eeaff8d5ea114734fcfa293fce1904ce4
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Sep 27 12:44:44 2007 +0100
[pixman-image] Avoid a potential malloc(0).
Do not attempt to allocate bits if either the image width or height is
0 - Cairo has a habit of attempting to create such surfaces when
generating glyphs. The malloc(0) may return a NULL pointer and be treated
as an out-of-memory error.
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 986f8ab..de799b1 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -350,7 +350,7 @@ pixman_image_create_bits (pixman_format_code_t format,
return_val_if_fail (bits == NULL ||
(rowstride_bytes % sizeof (uint32_t)) == 0, NULL);
- if (!bits)
+ if (!bits && width && height)
{
free_me = bits = create_bits (format, width, height, &rowstride_bytes);
if (!bits)
commit 958a650b8eb1b61143122c3ad1f9b637b6467984
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Sep 27 12:40:59 2007 +0100
[pixman-image] Avoid integer overflow when allocating bits.
Check for potential overflows at every step of the calculation of the
buffer size required for the pixels.
(Fixes https://bugs.freedesktop.org/show_bug.cgi?id=11627)
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index fa32208..986f8ab 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -285,9 +285,32 @@ create_bits (pixman_format_code_t format,
int stride;
int buf_size;
int bpp;
-
+
+ /* what follows is a long-winded way, avoiding any possibility of integer
+ * overflows, of saying:
+ * stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (uint32_t);
+ */
+
bpp = PIXMAN_FORMAT_BPP (format);
- stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (uint32_t);
+ if (pixman_multiply_overflows_int (width, bpp))
+ return NULL;
+
+ stride = width * bpp;
+ if (pixman_addition_overflows_int (stride, FB_MASK))
+ return NULL;
+
+ stride += FB_MASK;
+ stride >>= FB_SHIFT;
+
+#if FB_SHIFT < 2
+ if (pixman_multiply_overflows_int (stride, sizeof (uint32_t)))
+ return NULL;
+#endif
+ stride *= sizeof (uint32_t);
+
+ if (pixman_multiply_overflows_int (height, stride))
+ return NULL;
+
buf_size = height * stride;
if (rowstride_bytes)
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 6487bfd..0c5942f 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -69,6 +69,8 @@
/* Memory allocation helpers */
void *pixman_malloc_ab (unsigned int n, unsigned int b);
void *pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c);
+pixman_bool_t pixman_multiply_overflows_int (unsigned int a, unsigned int b);
+pixman_bool_t pixman_addition_overflows_int (unsigned int a, unsigned int b);
#if DEBUG
diff --git a/pixman/pixman-utils.c b/pixman/pixman-utils.c
index fc93608..1d1dec9 100644
--- a/pixman/pixman-utils.c
+++ b/pixman/pixman-utils.c
@@ -371,6 +371,20 @@ pixman_line_fixed_edge_init (pixman_edge_t *e,
bot->y + y_off_fixed);
}
+pixman_bool_t
+pixman_multiply_overflows_int (unsigned int a,
+ unsigned int b)
+{
+ return a >= INT32_MAX / b;
+}
+
+pixman_bool_t
+pixman_addition_overflows_int (unsigned int a,
+ unsigned int b)
+{
+ return a > INT32_MAX - b;
+}
+
void *
pixman_malloc_ab(unsigned int a,
unsigned int b)
commit 5b60c91fd6865021aa6027ee65fa8371a4e2d297
Author: Jeff Muizelaar <jeff at freiheit.infidigm.net>
Date: Thu Sep 20 15:40:17 2007 -0400
Fix special case selection when the mask has a transform
http://gitweb.freedesktop.org/?p=xorg/xserver.git;a=commitdiff;h=c19ece1d8c32dc81740a4036a642661f54064e75
was a mismerge that avoided setting the maskTransform condition when the mask
has a transform. This allowed a special case routine to be chosen when the
mask had a transform, which is not expected by the special case routines.
diff --git a/pixman/pixman-pict.c b/pixman/pixman-pict.c
index 3bc5267..d6564ff 100644
--- a/pixman/pixman-pict.c
+++ b/pixman/pixman-pict.c
@@ -1429,6 +1429,7 @@ pixman_image_composite (pixman_op_t op,
{
maskRepeat = pMask->common.repeat == PIXMAN_REPEAT_NORMAL;
+ maskTransform = pMask->common.transform != 0;
if (pMask->common.filter == PIXMAN_FILTER_CONVOLUTION)
maskTransform = TRUE;
commit 3be35594c99b7abd2af43b66349ca53bfa1462d6
Author: Carl Worth <cworth at cworth.org>
Date: Tue Sep 11 16:29:06 2007 +0100
Fix build breakage when under the influence of USE_MMX
This was recently broken (dc7c047d1c68f343b66e81d9e79084e4171e2634) when
removing an assignment to noinst_LTLIBRARIES.
diff --git a/pixman/Makefile.am b/pixman/Makefile.am
index b7138e4..66283a2 100644
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@ -22,7 +22,7 @@ libpixmaninclude_HEADERS = pixman.h
# mmx code
if USE_MMX
-noinst_LTLIBRARIES += libpixman-mmx.la
+noinst_LTLIBRARIES = libpixman-mmx.la
libpixman_mmx_la_SOURCES = \
pixman-mmx.c \
pixman-mmx.h
commit dc7c047d1c68f343b66e81d9e79084e4171e2634
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date: Mon Sep 10 15:20:44 2007 -0700
[memlk] don't try to allocate new data for 0-rectangle regions
diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c
index fff49e7..ac23806 100644
--- a/pixman/pixman-region.c
+++ b/pixman/pixman-region.c
@@ -2518,6 +2518,8 @@ pixman_region_init_rects (pixman_region16_t *region,
{
int overlap;
+ /* if it's 1, then we just want to set the extents, so call
+ * the existing method. */
if (count == 1) {
pixman_region_init_rect(region,
boxes[0].x1,
@@ -2528,6 +2530,15 @@ pixman_region_init_rects (pixman_region16_t *region,
}
pixman_region_init(region);
+
+ /* if it's 0, don't call pixman_rect_alloc -- 0 rectangles is
+ * a special case, and causing pixman_rect_alloc would cause
+ * us to leak memory (because the 0-rect case should be the
+ * static pixman_region_emptyData data).
+ */
+ if (count == 0)
+ return TRUE;
+
if (!pixman_rect_alloc(region, count))
return FALSE;
commit 1b098ede1938d1225c32cf5639e4c7a891859897
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date: Tue Sep 4 11:19:33 2007 -0700
[win32] Makefile and compilation fixes for win32
diff --git a/.gitignore b/.gitignore
index ee2f0a3..7f08f61 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,3 +28,8 @@ config.h.in
.*.swp
test/composite-test
test/gradient-test
+*.pdb
+*.dll
+*.lib
+*.ilk
+*.obj
diff --git a/pixman/Makefile.win32 b/pixman/Makefile.win32
new file mode 100644
index 0000000..e0a1828
--- /dev/null
+++ b/pixman/Makefile.win32
@@ -0,0 +1,31 @@
+LIBRARY = pixman-1
+
+CC = cl
+LINK = link
+
+CFLAGS = -MD -Zi -nologo -O2 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -I../pixman/src -I. -DPACKAGE=$(LIBRARY) -DPACKAGE_VERSION="" -DPACKAGE_BUGREPORT=""
+
+SOURCES = \
+ pixman-region.c \
+ pixman-image.c \
+ pixman-compose.c \
+ pixman-compose-accessors.c \
+ pixman-pict.c \
+ pixman-utils.c \
+ pixman-edge.c \
+ pixman-edge-accessors.c \
+ pixman-trap.c \
+ pixman-compute-region.c \
+ pixman-timer.c \
+ $(NULL)
+
+OBJECTS = $(subst .c,.obj,$(SOURCES))
+
+%.obj: %.c
+ @$(CC) -c $(CFLAGS) -Fo"$@" $<
+
+$(LIBRARY).lib: $(OBJECTS)
+ lib -NOLOGO -OUT:$@ $(OBJECTS)
+
+clean:
+ @rm -f *.obj *.lib *.pdb *.ilk || exit 0
diff --git a/pixman/pixman-compose.c b/pixman/pixman-compose.c
index b48251d..1e91864 100644
--- a/pixman/pixman-compose.c
+++ b/pixman/pixman-compose.c
@@ -23,7 +23,9 @@
* SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
#include <stdlib.h>
#include <string.h>
diff --git a/pixman/pixman-compute-region.c b/pixman/pixman-compute-region.c
index f9b9de7..1e566a9 100644
--- a/pixman/pixman-compute-region.c
+++ b/pixman/pixman-compute-region.c
@@ -21,7 +21,10 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
#include "pixman-private.h"
diff --git a/pixman/pixman-edge.c b/pixman/pixman-edge.c
index 24758c3..12c1967 100644
--- a/pixman/pixman-edge.c
+++ b/pixman/pixman-edge.c
@@ -21,7 +21,11 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
+
#include <string.h>
#include "pixman.h"
#include "pixman-private.h"
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index c39ee9b..fa32208 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -20,7 +20,9 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
#include <stdlib.h>
#include <stdio.h>
diff --git a/pixman/pixman-mmx.c b/pixman/pixman-mmx.c
index 8c7be6d..be79124 100644
--- a/pixman/pixman-mmx.c
+++ b/pixman/pixman-mmx.c
@@ -28,7 +28,10 @@
*
* Based on work by Owen Taylor
*/
+
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
#ifdef USE_MMX
diff --git a/pixman/pixman-pict.c b/pixman/pixman-pict.c
index c7d73fc..3bc5267 100644
--- a/pixman/pixman-pict.c
+++ b/pixman/pixman-pict.c
@@ -22,7 +22,10 @@
* Author: Keith Packard, SuSE, Inc.
*/
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 775f7a7..6487bfd 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -37,6 +37,28 @@
# define FUNC ((const char*) ("???"))
#endif
+#ifndef INT16_MIN
+# define INT16_MIN (-32767-1)
+# define INT16_MAX (32767)
+#endif
+
+#ifndef INT32_MIN
+# define INT32_MIN (-2147483647-1)
+# define INT32_MAX (2147483647)
+#endif
+
+#ifndef UINT32_MIN
+# define UINT32_MIN (0)
+# define UINT32_MAX (4294967295U)
+#endif
+
+#ifndef M_PI
+# define M_PI 3.14159265358979323846
+#endif
+
+#ifdef _MSC_VER
+#define inline __inline
+#endif
#define FB_SHIFT 5
#define FB_UNIT (1 << FB_SHIFT)
@@ -774,6 +796,8 @@ pixman_rasterize_edges_accessors (pixman_image_t *image,
pixman_fixed_t b);
+#ifdef PIXMAN_TIMING
+
/* Timing */
static inline uint64_t
oil_profile_stamp_rdtsc (void)
@@ -817,5 +841,6 @@ void pixman_timer_register (PixmanTimer *timer);
timer##tname.total += OIL_STAMP() - begin##tname; \
}
+#endif /* PIXMAN_TIMING */
#endif /* PIXMAN_PRIVATE_H */
diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c
index 94b6dcc..fff49e7 100644
--- a/pixman/pixman-region.c
+++ b/pixman/pixman-region.c
@@ -45,7 +45,10 @@ SOFTWARE.
******************************************************************/
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
+
#include <stdlib.h>
#include <limits.h>
#include <string.h>
diff --git a/pixman/pixman-timer.c b/pixman/pixman-timer.c
index c762644..ce54e74 100644
--- a/pixman/pixman-timer.c
+++ b/pixman/pixman-timer.c
@@ -19,11 +19,16 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
#include "pixman-private.h"
+#ifdef PIXMAN_TIMER
+
static PixmanTimer *timers;
static void
@@ -57,3 +62,5 @@ pixman_timer_register (PixmanTimer *timer)
timer->next = timers;
timers = timer;
}
+
+#endif
diff --git a/pixman/pixman-trap.c b/pixman/pixman-trap.c
index 204ca04..ed32e92 100644
--- a/pixman/pixman-trap.c
+++ b/pixman/pixman-trap.c
@@ -22,7 +22,10 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
+
#include <stdio.h>
#include "pixman-private.h"
diff --git a/pixman/pixman-utils.c b/pixman/pixman-utils.c
index cdf115d..fc93608 100644
--- a/pixman/pixman-utils.c
+++ b/pixman/pixman-utils.c
@@ -21,7 +21,10 @@
* Author: Keith Packard, SuSE, Inc.
*/
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
+
#include <stdlib.h>
#include "pixman.h"
#include "pixman-private.h"
commit 5fc4d5ab1fae8677f5a95f5eb0e4fad3a9e0bf82
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date: Tue Sep 4 11:18:40 2007 -0700
compilation: build edge/compose with accessors separately
Simplify the build by creating a new file for pixman-compose and
pixman-edge built with accessor functions.
diff --git a/pixman/Makefile.am b/pixman/Makefile.am
index 708e0dd..b7138e4 100644
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@ -1,15 +1,17 @@
lib_LTLIBRARIES = libpixman-1.la
libpixman_1_la_LDFLAGS = -version-info $(LT_VERSION_INFO)
-libpixman_1_la_LIBADD = @DEP_LIBS@ -lm libpixmanwrapper.la
+libpixman_1_la_LIBADD = @DEP_LIBS@ -lm
libpixman_1_la_SOURCES = \
pixman.h \
pixman-region.c \
pixman-private.h \
pixman-image.c \
pixman-compose.c \
+ pixman-compose-accessors.c \
pixman-pict.c \
pixman-utils.c \
pixman-edge.c \
+ pixman-edge-accessors.c \
pixman-edge-imp.h \
pixman-trap.c \
pixman-compute-region.c \
@@ -18,15 +20,6 @@ libpixman_1_la_SOURCES = \
libpixmanincludedir = $(includedir)/pixman-1/
libpixmaninclude_HEADERS = pixman.h
-# wrapper library
-noinst_LTLIBRARIES = libpixmanwrapper.la
-libpixmanwrapper_la_SOURCES = \
- pixman-compose.c \
- pixman-edge.c
-libpixmanwrapper_la_CFLAGS = $(DEP_CFLAGS) -DPIXMAN_FB_ACCESSORS
-
-
-
# mmx code
if USE_MMX
noinst_LTLIBRARIES += libpixman-mmx.la
diff --git a/pixman/pixman-compose-accessors.c b/pixman/pixman-compose-accessors.c
new file mode 100644
index 0000000..5393cf4
--- /dev/null
+++ b/pixman/pixman-compose-accessors.c
@@ -0,0 +1,4 @@
+
+#define PIXMAN_FB_ACCESSORS
+
+#include "pixman-compose.c"
diff --git a/pixman/pixman-edge-accessors.c b/pixman/pixman-edge-accessors.c
new file mode 100644
index 0000000..ea3a31e
--- /dev/null
+++ b/pixman/pixman-edge-accessors.c
@@ -0,0 +1,4 @@
+
+#define PIXMAN_FB_ACCESSORS
+
+#include "pixman-edge.c"
More information about the xorg-commit
mailing list