summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2003-04-17 08:48:22 +0000
committerCarl Worth <cworth@cworth.org>2003-04-17 08:48:22 +0000
commitb61b9ffc2322e09873b9e2dfb0c1da56ec1ffd61 (patch)
tree7c520fb071ad33d58c089967aef73cb1fd37d0df
parent2d8dfcec1bb166f8335300bd3850847a5bb1396e (diff)
Removed reliance on server headers. Reowrked IcFormat
-rw-r--r--pixman/ChangeLog.libic50
-rw-r--r--pixman/src/ic.c40
-rw-r--r--pixman/src/ic.h161
-rw-r--r--pixman/src/iccolor.c85
-rw-r--r--pixman/src/iccompose.c26
-rw-r--r--pixman/src/icformat.c67
-rw-r--r--pixman/src/icimage.c115
-rw-r--r--pixman/src/icimage.h86
-rw-r--r--pixman/src/icint.h285
-rw-r--r--pixman/src/icpixels.c22
-rw-r--r--pixman/src/icrect.c107
-rw-r--r--pixman/src/ictrap.c48
-rw-r--r--pixman/src/ictri.c102
13 files changed, 798 insertions, 396 deletions
diff --git a/pixman/ChangeLog.libic b/pixman/ChangeLog.libic
index c2718833..d60eda52 100644
--- a/pixman/ChangeLog.libic
+++ b/pixman/ChangeLog.libic
@@ -1,3 +1,53 @@
+2003-04-17 Carl Worth <cworth@isi.edu>
+
+ * src/icint.h: Removed reliance on some server include files,
+ (this included copy and paste of Xserver/render/picture.h into
+ icint.h)
+
+ * src/icformat.c (IcFormatInit): Replaced public
+ IcFormatCreate/IcFormatDestroy with IcFormatInit and an exposed
+ IcFormat structure.
+ (_IcFormatCreate): Tracked changes now that IcFormat no longer has
+ direct and indexed sub-structure.
+
+ * src/iccompose.c: Commented out all code supporting indexed
+ formats.
+
+ * src/ic.h: Expose IcFormat structure, (with no support for
+ indexed formats).
+
+ * src/ic.c (IcComposite): Track changes in IcImage structure
+ (format vs. format_name)
+
+2003-03-10 Carl Worth <cworth@isi.edu>
+
+ * src/Makefile.am (INCLUDES): Cleaned up to no longer require
+ includes from X server source tree.
+
+2003-03-05 Carl Worth <cworth@isi.edu>
+
+ * src/ictri.c (IcTriangles):
+ (IcTriStrip):
+ (IcTriFan): fixed argument order to match XRender
+
+ * src/icrect.c (IcRectangle): Add IcRectangle convenience function.
+ (IcRectangles): fixed argument order to match XRender
+
+ * src/ictri.c (IcTriangles):
+ (IcTriStrip):
+ (IcTriFan): Removed format argument from IcTri* functions.
+
+ * src/ictrap.c (IcTrapezoids): Removed format argument from
+ IcTrapezoids.
+
+ * src/icrect.c (IcRectangles): Initial (painfully slow)
+ implementation of IcRectangles.
+
+ * src/icimage.c (IcImageCreate): Simplified IcImageCreate, (no
+ longer requires mask/vlist/error/error_value)
+ (IcImageSetRepeat): Added IcImageSetRepeat
+ (IcImageSetClipRegion): Implemented simple IcImageSetClipRegion.
+
2003-02-25 Carl Worth <cworth@isi.edu>
* src/icimage.c (IcImageInit):
diff --git a/pixman/src/ic.c b/pixman/src/ic.c
index e522b777..13fc6b27 100644
--- a/pixman/src/ic.c
+++ b/pixman/src/ic.c
@@ -26,9 +26,8 @@
#include "icint.h"
#include "icimage.h"
-#include "misc.h"
-
/*
+#include "misc.h"
#include "scrnintstr.h"
#include "validate.h"
#include "windowstr.h"
@@ -38,11 +37,10 @@
#include "dixstruct.h"
#include "gcstruct.h"
#include "picturestr.h"
-*/
-
#include "os.h"
#include "resource.h"
#include "servermd.h"
+*/
#ifndef __GNUC__
@@ -140,7 +138,7 @@ IcIn (CARD32 x, CARD8 y)
return; \
} \
/* manage missing src alpha */ \
- if ((image)->image_format->direct.alphaMask == 0) \
+ if ((image)->image_format->alphaMask == 0) \
(bits) |= 0xff000000; \
}
@@ -948,10 +946,10 @@ IcComposite (char op,
iSrc->pixels->height == 1)
{
srcRepeat = FALSE;
- if (PICT_FORMAT_COLOR(iSrc->format)) {
- switch (iMask->format) {
+ if (PICT_FORMAT_COLOR(iSrc->format_name)) {
+ switch (iMask->format_name) {
case PICT_a8:
- switch (iDst->format) {
+ switch (iDst->format_name) {
case PICT_r5g6b5:
case PICT_b5g6r5:
func = IcCompositeSolidMask_nx8x0565;
@@ -970,7 +968,7 @@ IcComposite (char op,
break;
case PICT_a8r8g8b8:
if (iMask->componentAlpha) {
- switch (iDst->format) {
+ switch (iDst->format_name) {
case PICT_a8r8g8b8:
case PICT_x8r8g8b8:
func = IcCompositeSolidMask_nx8888x8888C;
@@ -983,7 +981,7 @@ IcComposite (char op,
break;
case PICT_a8b8g8r8:
if (iMask->componentAlpha) {
- switch (iDst->format) {
+ switch (iDst->format_name) {
case PICT_a8b8g8r8:
case PICT_x8b8g8r8:
func = IcCompositeSolidMask_nx8888x8888C;
@@ -995,7 +993,7 @@ IcComposite (char op,
}
break;
case PICT_a1:
- switch (iDst->format) {
+ switch (iDst->format_name) {
case PICT_r5g6b5:
case PICT_b5g6r5:
case PICT_r8g8b8:
@@ -1013,10 +1011,10 @@ IcComposite (char op,
}
else
{
- switch (iSrc->format) {
+ switch (iSrc->format_name) {
case PICT_a8r8g8b8:
case PICT_x8r8g8b8:
- switch (iDst->format) {
+ switch (iDst->format_name) {
case PICT_a8r8g8b8:
case PICT_x8r8g8b8:
func = IcCompositeSrc_8888x8888;
@@ -1031,7 +1029,7 @@ IcComposite (char op,
break;
case PICT_a8b8g8r8:
case PICT_x8b8g8r8:
- switch (iDst->format) {
+ switch (iDst->format_name) {
case PICT_a8b8g8r8:
case PICT_x8b8g8r8:
func = IcCompositeSrc_8888x8888;
@@ -1045,14 +1043,14 @@ IcComposite (char op,
}
break;
case PICT_r5g6b5:
- switch (iDst->format) {
+ switch (iDst->format_name) {
case PICT_r5g6b5:
func = IcCompositeSrc_0565x0565;
break;
}
break;
case PICT_b5g6r5:
- switch (iDst->format) {
+ switch (iDst->format_name) {
case PICT_b5g6r5:
func = IcCompositeSrc_0565x0565;
break;
@@ -1064,30 +1062,30 @@ IcComposite (char op,
case PictOpAdd:
if (iMask == 0)
{
- switch (iSrc->format) {
+ switch (iSrc->format_name) {
case PICT_a8r8g8b8:
- switch (iDst->format) {
+ switch (iDst->format_name) {
case PICT_a8r8g8b8:
func = IcCompositeSrcAdd_8888x8888;
break;
}
break;
case PICT_a8b8g8r8:
- switch (iDst->format) {
+ switch (iDst->format_name) {
case PICT_a8b8g8r8:
func = IcCompositeSrcAdd_8888x8888;
break;
}
break;
case PICT_a8:
- switch (iDst->format) {
+ switch (iDst->format_name) {
case PICT_a8:
func = IcCompositeSrcAdd_8000x8000;
break;
}
break;
case PICT_a1:
- switch (iDst->format) {
+ switch (iDst->format_name) {
case PICT_a1:
func = IcCompositeSrcAdd_1000x1000;
break;
diff --git a/pixman/src/ic.h b/pixman/src/ic.h
index 2705a67f..0491f9c7 100644
--- a/pixman/src/ic.h
+++ b/pixman/src/ic.h
@@ -31,23 +31,31 @@
/* icformat.c */
-/* XXX: Perhaps we just want an enum for some standard formats? */
+/* XXX: Change from int to enum for IcFormatName */
typedef int IcFormatName;
-typedef struct _IcFormat IcFormat;
-/* XXX: Not sure if this is at all the API we want for IcFormat */
-IcFormat *
-IcFormatCreate (IcFormatName name);
+/* XXX: Is depth redundant here? */
+typedef struct _IcFormat {
+ /* XXX: Should switch from int to an IcFormatName enum */
+ int format_name;
+ int depth;
+ int red, redMask;
+ int green, greenMask;
+ int blue, blueMask;
+ int alpha, alphaMask;
+} IcFormat;
void
-IcFormatDestroy (IcFormat *format);
+IcFormatInit (IcFormat *format, IcFormatName name);
-/* icpixels.c */
+/* icimage.c */
-typedef struct _IcPixels IcPixels;
+typedef struct _IcImage IcImage;
-IcPixels *
-IcPixelsCreate (int width, int height, int depth);
+IcImage *
+IcImageCreate (IcFormat *format,
+ int width,
+ int height);
/*
* This single define controls the basic size of data manipulated
@@ -68,78 +76,105 @@ typedef uint32_t IcBits;
# endif
#endif
-IcPixels *
-IcPixelsCreateForData (IcBits *data, int width, int height, int depth, int bpp, int stride);
+IcImage *
+IcImageCreateForData (IcBits *data, IcFormat *format, int width, int height, int bpp, int stride);
void
-IcPixelsDestroy (IcPixels *pixels);
+IcImageDestroy (IcImage *image);
-/* icimage.c */
+int
+IcImageSetClipRegion (IcImage *image,
+ PixRegion *region);
-typedef struct _IcImage IcImage;
+typedef struct _IcTransform {
+ XFixed matrix[3][3];
+} IcTransform;
-/* XXX: I'd like to drop the mask/list interfaces here, (as well as two error codes) */
-IcImage *
-IcImageCreate (IcFormat *format,
- int width,
- int height,
- Mask vmask,
- XID *vlist,
- int *error,
- int *error_value);
+int
+IcImageSetTransform (IcImage *image,
+ IcTransform *transform);
-IcImage *
-IcImageCreateForPixels (IcPixels *pixels,
- IcFormat *format,
- Mask vmask,
- XID *vlist,
- int *error,
- int *error_value);
+void
+IcImageSetRepeat (IcImage *image,
+ int repeat);
+
+/* iccolor.c */
+
+/* XXX: Do we really need a struct here? Only IcRectangles uses this. */
+typedef struct {
+ unsigned short red;
+ unsigned short green;
+ unsigned short blue;
+ unsigned short alpha;
+} IcColor;
+
+void
+IcColorToPixel (const IcFormat *format,
+ const IcColor *color,
+ IcBits *pixel);
+
+void
+IcPixelToColor (const IcFormat *format,
+ IcBits pixel,
+ IcColor *color);
+
+/* icrect.c */
+
+void IcFillRectangle (char op,
+ IcImage *dst,
+ const IcColor *color,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height);
+void
+IcFillRectangles (char op,
+ IcImage *dst,
+ const IcColor *color,
+ const XRectangle *rects,
+ int nRects);
/* ictrap.c */
/* XXX: Switch to enum for op */
void
-IcTrapezoids (char op,
- IcImage *src,
- IcImage *dst,
- IcFormat *format,
- int xSrc,
- int ySrc,
- int ntrap,
- XTrapezoid *traps);
+IcCompositeTrapezoids (char op,
+ IcImage *src,
+ IcImage *dst,
+ int xSrc,
+ int ySrc,
+ const XTrapezoid *traps,
+ int ntrap);
/* ictri.c */
void
-IcTriangles (char op,
- IcImage *src,
- IcImage *dst,
- IcFormat *format,
- int xSrc,
- int ySrc,
- int ntri,
- XTriangle *tris);
+IcCompositeTriangles (char op,
+ IcImage *src,
+ IcImage *dst,
+ int xSrc,
+ int ySrc,
+ const XTriangle *tris,
+ int ntris);
void
-IcTriStrip (char op,
- IcImage *src,
- IcImage *dst,
- IcFormat *format,
- int xSrc,
- int ySrc,
- int npoint,
- XPointFixed *points);
+IcCompositeTriStrip (char op,
+ IcImage *src,
+ IcImage *dst,
+ int xSrc,
+ int ySrc,
+ const XPointFixed *points,
+ int npoints);
+
void
-IcTriFan (char op,
- IcImage *src,
- IcImage *dst,
- IcFormat *format,
- int xSrc,
- int ySrc,
- int npoint,
- XPointFixed *points);
+IcCompositeTriFan (char op,
+ IcImage *src,
+ IcImage *dst,
+ int xSrc,
+ int ySrc,
+ const XPointFixed *points,
+ int npoints);
/* ic.c */
diff --git a/pixman/src/iccolor.c b/pixman/src/iccolor.c
new file mode 100644
index 00000000..78a9cba1
--- /dev/null
+++ b/pixman/src/iccolor.c
@@ -0,0 +1,85 @@
+/*
+ * $XFree86: $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * 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 SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#include "icint.h"
+
+static int
+Ones(unsigned long mask);
+
+static int
+Ones(unsigned long mask) /* HACKMEM 169 */
+{
+ register unsigned long y;
+
+ y = (mask >> 1) &033333333333;
+ y = mask - y - ((y >>1) & 033333333333);
+ return (((y + (y >> 3)) & 030707070707) % 077);
+}
+
+void
+IcColorToPixel (const IcFormat *format,
+ const IcColor *color,
+ IcBits *pixel)
+{
+ CARD32 r, g, b, a;
+
+ r = color->red >> (16 - Ones (format->redMask));
+ g = color->green >> (16 - Ones (format->greenMask));
+ b = color->blue >> (16 - Ones (format->blueMask));
+ a = color->alpha >> (16 - Ones (format->alphaMask));
+ r = r << format->red;
+ g = g << format->green;
+ b = b << format->blue;
+ a = a << format->alpha;
+ *pixel = r|g|b|a;
+}
+
+static CARD16
+IcFillColor (CARD32 pixel, int bits)
+{
+ while (bits < 16)
+ {
+ pixel |= pixel << bits;
+ bits <<= 1;
+ }
+ return (CARD16) pixel;
+}
+
+void
+IcPixelToColor (const IcFormat *format,
+ const IcBits pixel,
+ IcColor *color)
+{
+ CARD32 r, g, b, a;
+
+ r = (pixel >> format->red) & format->redMask;
+ g = (pixel >> format->green) & format->greenMask;
+ b = (pixel >> format->blue) & format->blueMask;
+ a = (pixel >> format->alpha) & format->alphaMask;
+ color->red = IcFillColor (r, Ones (format->redMask));
+ color->green = IcFillColor (r, Ones (format->greenMask));
+ color->blue = IcFillColor (r, Ones (format->blueMask));
+ color->alpha = IcFillColor (r, Ones (format->alphaMask));
+}
diff --git a/pixman/src/iccompose.c b/pixman/src/iccompose.c
index 9c19c5fd..9ffbfdc3 100644
--- a/pixman/src/iccompose.c
+++ b/pixman/src/iccompose.c
@@ -1892,6 +1892,7 @@ IcFetch_a2b2g2r2 (IcCompositeOperand *op)
return a|r|g|b;
}
+/* XXX: We're not supporting indexed formats, right?
CARD32
IcFetch_c8 (IcCompositeOperand *op)
{
@@ -1900,6 +1901,7 @@ IcFetch_c8 (IcCompositeOperand *op)
return op->indexed->rgba[pixel];
}
+*/
#define Fetch8(l,o) (((CARD8 *) (l))[(o) >> 3])
#if IMAGE_BYTE_ORDER == MSBFirst
@@ -1984,6 +1986,7 @@ IcFetch_a1b1g1r1 (IcCompositeOperand *op)
return a|r|g|b;
}
+/* XXX: We're not supporting indexed formats, right?
CARD32
IcFetch_c4 (IcCompositeOperand *op)
{
@@ -1992,6 +1995,7 @@ IcFetch_c4 (IcCompositeOperand *op)
return op->indexed->rgba[pixel];
}
+*/
CARD32
IcFetcha_a1 (IcCompositeOperand *op)
@@ -2031,6 +2035,7 @@ IcFetch_a1 (IcCompositeOperand *op)
return a << 24;
}
+/* XXX: We're not supporting indexed formats, right?
CARD32
IcFetch_g1 (IcCompositeOperand *op)
{
@@ -2045,6 +2050,7 @@ IcFetch_g1 (IcCompositeOperand *op)
a = a & 1;
return op->indexed->rgba[a];
}
+*/
/*
* All the store functions
@@ -2273,6 +2279,7 @@ IcStore_a2r2g2b2 (IcCompositeOperand *op, CARD32 value)
((b >> 6) ));
}
+/* XXX: We're not supporting indexed formats, right?
void
IcStore_c8 (IcCompositeOperand *op, CARD32 value)
{
@@ -2288,6 +2295,7 @@ IcStore_g8 (IcCompositeOperand *op, CARD32 value)
CARD8 *pixel = ((CARD8 *) line) + (offset >> 3);
*pixel = IcIndexToEntY24(op->indexed,value);
}
+*/
#define Store8(l,o,v) (((CARD8 *) l)[(o) >> 3] = (v))
#if IMAGE_BYTE_ORDER == MSBFirst
@@ -2359,6 +2367,7 @@ IcStore_a1b1g1r1 (IcCompositeOperand *op, CARD32 value)
Store4(line,offset,pixel);
}
+/* XXX: We're not supporting indexed formats, right?
void
IcStore_c4 (IcCompositeOperand *op, CARD32 value)
{
@@ -2378,6 +2387,7 @@ IcStore_g4 (IcCompositeOperand *op, CARD32 value)
pixel = IcIndexToEntY24(op->indexed,value);
Store4(line,offset,pixel);
}
+*/
void
IcStore_a1 (IcCompositeOperand *op, CARD32 value)
@@ -2390,6 +2400,7 @@ IcStore_a1 (IcCompositeOperand *op, CARD32 value)
*pixel = (*pixel & ~mask) | value;
}
+/* XXX: We're not supporting indexed formats, right?
void
IcStore_g1 (IcCompositeOperand *op, CARD32 value)
{
@@ -2400,6 +2411,7 @@ IcStore_g1 (IcCompositeOperand *op, CARD32 value)
value = IcIndexToEntY24(op->indexed,value) ? mask : 0;
*pixel = (*pixel & ~mask) | value;
}
+*/
CARD32
IcFetch_external (IcCompositeOperand *op)
@@ -2623,8 +2635,10 @@ IcAccessMap icAccessMap[] = {
{ PICT_r3g3b2, IcFetch_r3g3b2, IcFetch_r3g3b2, IcStore_r3g3b2 },
{ PICT_b2g3r3, IcFetch_b2g3r3, IcFetch_b2g3r3, IcStore_b2g3r3 },
{ PICT_a2r2g2b2, IcFetch_a2r2g2b2, IcFetch_a2r2g2b2, IcStore_a2r2g2b2 },
+/* XXX: We're not supporting indexed formats, right?
{ PICT_c8, IcFetch_c8, IcFetch_c8, IcStore_c8 },
{ PICT_g8, IcFetch_c8, IcFetch_c8, IcStore_g8 },
+*/
/* 4bpp formats */
{ PICT_a4, IcFetch_a4, IcFetcha_a4, IcStore_a4 },
@@ -2632,12 +2646,16 @@ IcAccessMap icAccessMap[] = {
{ PICT_b1g2r1, IcFetch_b1g2r1, IcFetch_b1g2r1, IcStore_b1g2r1 },
{ PICT_a1r1g1b1, IcFetch_a1r1g1b1, IcFetch_a1r1g1b1, IcStore_a1r1g1b1 },
{ PICT_a1b1g1r1, IcFetch_a1b1g1r1, IcFetch_a1b1g1r1, IcStore_a1b1g1r1 },
+/* XXX: We're not supporting indexed formats, right?
{ PICT_c4, IcFetch_c4, IcFetch_c4, IcStore_c4 },
{ PICT_g4, IcFetch_c4, IcFetch_c4, IcStore_g4 },
+*/
/* 1bpp formats */
{ PICT_a1, IcFetch_a1, IcFetcha_a1, IcStore_a1 },
+/* XXX: We're not supporting indexed formats, right?
{ PICT_g1, IcFetch_g1, IcFetch_g1, IcStore_g1 },
+*/
};
#define NumAccessMap (sizeof icAccessMap / sizeof icAccessMap[0])
@@ -2734,7 +2752,9 @@ IcBuildCompositeOperand (IcImage *image,
op->over = IcStepOver_transform;
op->down = IcStepDown_transform;
op->set = IcSet_transform;
+/* XXX: We're not supporting indexed formats, right?
op->indexed = (IcIndexedPtr) image->image_format->index.devPrivate;
+*/
op->clip = op[1].clip;
return TRUE;
@@ -2758,7 +2778,9 @@ IcBuildCompositeOperand (IcImage *image,
op->over = IcStepOver_external;
op->down = IcStepDown_external;
op->set = IcSet_external;
+/* XXX: We're not supporting indexed formats, right?
op->indexed = (IcIndexedPtr) image->image_format->index.devPrivate;
+*/
op->clip = op[1].clip;
return TRUE;
@@ -2770,7 +2792,7 @@ IcBuildCompositeOperand (IcImage *image,
int xoff, yoff;
for (i = 0; i < NumAccessMap; i++)
- if (icAccessMap[i].format == image->format)
+ if (icAccessMap[i].format == image->format_name)
{
IcBits *bits;
IcStride stride;
@@ -2782,7 +2804,9 @@ IcBuildCompositeOperand (IcImage *image,
op->over = IcStepOver;
op->down = IcStepDown;
op->set = IcSet;
+/* XXX: We're not supporting indexed formats, right?
op->indexed = (IcIndexedPtr) image->image_format->index.devPrivate;
+*/
op->clip = image->pCompositeClip;
IcGetPixels (image->pixels, bits, stride, bpp,
diff --git a/pixman/src/icformat.c b/pixman/src/icformat.c
index 4cf9e9d8..c9d9f67b 100644
--- a/pixman/src/icformat.c
+++ b/pixman/src/icformat.c
@@ -25,13 +25,10 @@
#include "icint.h"
-void
-IcFormatInit (IcFormat *format, IcFormatName name);
-
#define Mask(n) ((n) == 32 ? 0xffffffff : ((1 << (n))-1))
IcFormat *
-IcFormatCreate (IcFormatName name)
+_IcFormatCreate (IcFormatName name)
{
IcFormat *format;
@@ -50,59 +47,57 @@ IcFormatInit (IcFormat *format, IcFormatName name)
/* XXX: What do we want to lodge in here?
format->id = FakeClientID (0);
*/
+ format->format_name = name;
format->depth = PICT_FORMAT_BPP(name);
- format->format = name;
+
switch (PICT_FORMAT_TYPE(name)) {
case PICT_TYPE_ARGB:
- format->type = PictTypeDirect;
- format->direct.alphaMask = Mask(PICT_FORMAT_A(name));
- if (format->direct.alphaMask)
- format->direct.alpha = (PICT_FORMAT_R(name) +
- PICT_FORMAT_G(name) +
- PICT_FORMAT_B(name));
+ format->alphaMask = Mask(PICT_FORMAT_A(name));
+ if (format->alphaMask)
+ format->alpha = (PICT_FORMAT_R(name) +
+ PICT_FORMAT_G(name) +
+ PICT_FORMAT_B(name));
- format->direct.redMask = Mask(PICT_FORMAT_R(name));
- format->direct.red = (PICT_FORMAT_G(name) +
- PICT_FORMAT_B(name));
+ format->redMask = Mask(PICT_FORMAT_R(name));
+ format->red = (PICT_FORMAT_G(name) +
+ PICT_FORMAT_B(name));
- format->direct.greenMask = Mask(PICT_FORMAT_G(name));
- format->direct.green = PICT_FORMAT_B(name);
+ format->greenMask = Mask(PICT_FORMAT_G(name));
+ format->green = PICT_FORMAT_B(name);
- format->direct.blueMask = Mask(PICT_FORMAT_B(name));
- format->direct.blue = 0;
+ format->blueMask = Mask(PICT_FORMAT_B(name));
+ format->blue = 0;
break;
case PICT_TYPE_ABGR:
- format->type = PictTypeDirect;
- format->direct.alphaMask = Mask(PICT_FORMAT_A(name));
- if (format->direct.alphaMask)
- format->direct.alpha = (PICT_FORMAT_B(name) +
- PICT_FORMAT_G(name) +
- PICT_FORMAT_R(name));
+ format->alphaMask = Mask(PICT_FORMAT_A(name));
+ if (format->alphaMask)
+ format->alpha = (PICT_FORMAT_B(name) +
+ PICT_FORMAT_G(name) +
+ PICT_FORMAT_R(name));
- format->direct.blueMask = Mask(PICT_FORMAT_B(name));
- format->direct.blue = (PICT_FORMAT_G(name) +
- PICT_FORMAT_R(name));
+ format->blueMask = Mask(PICT_FORMAT_B(name));
+ format->blue = (PICT_FORMAT_G(name) +
+ PICT_FORMAT_R(name));
- format->direct.greenMask = Mask(PICT_FORMAT_G(name));
- format->direct.green = PICT_FORMAT_R(name);
+ format->greenMask = Mask(PICT_FORMAT_G(name));
+ format->green = PICT_FORMAT_R(name);
- format->direct.redMask = Mask(PICT_FORMAT_R(name));
- format->direct.red = 0;
+ format->redMask = Mask(PICT_FORMAT_R(name));
+ format->red = 0;
break;
case PICT_TYPE_A:
- format->type = PictTypeDirect;
- format->direct.alpha = 0;
- format->direct.alphaMask = Mask(PICT_FORMAT_A(name));
+ format->alpha = 0;
+ format->alphaMask = Mask(PICT_FORMAT_A(name));
/* remaining fields already set to zero */
break;
-/* XXX: Supporting indexed formats requires more, (just pass in the visual?)
+/* XXX: We're not supporting indexed formats, right?
case PICT_TYPE_COLOR:
case PICT_TYPE_GRAY:
format->type = PictTypeIndexed;
@@ -113,7 +108,7 @@ IcFormatInit (IcFormat *format, IcFormatName name)
}
void
-IcFormatDestroy (IcFormat *format)
+_IcFormatDestroy (IcFormat *format)
{
free (format);
}
diff --git a/pixman/src/icimage.c b/pixman/src/icimage.c
index 8591118b..67dff596 100644
--- a/pixman/src/icimage.c
+++ b/pixman/src/icimage.c
@@ -28,23 +28,41 @@
IcImage *
IcImageCreate (IcFormat *format,
int width,
- int height,
- Mask vmask,
- XID *vlist,
- int *error,
- int *error_value)
+ int height)
{
IcImage *image;
IcPixels *pixels;
pixels = IcPixelsCreate (width, height, format->depth);
- if (pixels == NULL) {
- *error = BadAlloc;
- *error_value = 0; /* XXX: What should this be? */
+ if (pixels == NULL)
return NULL;
- }
- image = IcImageCreateForPixels (pixels, format, vmask, vlist, error, error_value);
+ image = IcImageCreateForPixels (pixels, format);
+ if (image == NULL) {
+ IcPixelsDestroy (pixels);
+ return NULL;
+ }
+
+ image->owns_pixels = 1;
+
+ return image;
+}
+
+IcImage *
+IcImageCreateForData (IcBits *data, IcFormat *format, int width, int height, int bpp, int stride)
+{
+ IcImage *image;
+ IcPixels *pixels;
+
+ pixels = IcPixelsCreateForData (data, width, height, format->depth, bpp, stride);
+ if (pixels == NULL)
+ return NULL;
+
+ image = IcImageCreateForPixels (pixels, format);
+ if (image == NULL) {
+ IcPixelsDestroy (pixels);
+ return NULL;
+ }
image->owns_pixels = 1;
@@ -53,25 +71,19 @@ IcImageCreate (IcFormat *format,
IcImage *
IcImageCreateForPixels (IcPixels *pixels,
- IcFormat *format,
- Mask vmask,
- XID *vlist,
- int *error,
- int *error_value)
+ IcFormat *format)
{
IcImage *image;
image = malloc (sizeof (IcImage));
if (!image)
{
- *error = BadAlloc;
- *error_value = 0; /* XXX: What should this be? */
return NULL;
}
image->pixels = pixels;
image->image_format = format;
- image->format = format->format;
+ image->format_name = format->format_name;
/* XXX: What's all this about?
if (pDrawable->type == DRAWABLE_PIXMAP)
{
@@ -86,19 +98,7 @@ IcImageCreateForPixels (IcPixels *pixels,
*/
IcImageInit (image);
-
- if (vmask)
- ;
- /* XXX: Need to finish porting this function
- *error = IcImageChange (image, vmask, vlist, 0, error_value);
- */
- else
- *error = Success;
- if (*error != Success)
- {
- IcImageDestroy (image);
- image = 0;
- }
+
return image;
}
@@ -181,6 +181,14 @@ IcImageSetTransform (IcImage *image,
}
void
+IcImageSetRepeat (IcImage *image,
+ int repeat)
+{
+ if (image)
+ image->repeat = repeat;
+}
+
+void
IcImageDestroy (IcImage *image)
{
if (image->freeCompClip)
@@ -205,49 +213,12 @@ IcImageDestroyClip (IcImage *image)
}
int
-IcImageChangeClip (IcImage *image,
- int type,
- pointer value,
- int n)
+IcImageSetClipRegion (IcImage *image,
+ PixRegion *region)
{
- pointer clientClip;
- int clientClipType;
-
- switch (type) {
- case CT_PIXMAP:
- return Success;
- /* XXX: Still need to figure out how to handle this case
- clientClip = (pointer) BITMAP_TO_REGION(pScreen, (PixmapPtr) value);
- if (!clientClip)
- return BadAlloc;
- clientClipType = CT_REGION;
- (*pScreen->DestroyPixmap) ((PixmapPtr) value);
- break;
- */
- case CT_REGION:
- clientClip = value;
- clientClipType = CT_REGION;
- break;
- case CT_NONE:
- clientClip = 0;
- clientClipType = CT_NONE;
- break;
- default:
- return Success;
- /* XXX: I don't see an Xlib version of RECTS_TO_REGION
- clientClip = (pointer) RECTS_TO_REGION(pScreen, n,
- (xRectangle *) value,
- type);
- if (!clientClip)
- return BadAlloc;
- clientClipType = CT_REGION;
- free(value);
- break;
- */
- }
IcImageDestroyClip (image);
- image->clientClip = clientClip;
- image->clientClipType = clientClipType;
+ image->clientClip = region;
+ image->clientClipType = CT_REGION;
image->stateChanges |= CPClipMask;
return Success;
}
diff --git a/pixman/src/icimage.h b/pixman/src/icimage.h
index b2488c76..dc929e44 100644
--- a/pixman/src/icimage.h
+++ b/pixman/src/icimage.h
@@ -30,12 +30,8 @@
#include "ic.h"
-/* XXX: This is a hack since I don't want to include the server's
- miscstruct with the BoxRec that conflict's with Xlib's. */
-#ifndef MISCSTRUCT_H
-#define MISCSTRUCT_H 1
+#include <X11/Xdefs.h>
-#include "misc.h"
#include "X11/Xprotostr.h"
typedef xPoint DDXPointRec;
@@ -49,13 +45,15 @@ typedef union _DevUnion {
#endif
);
} DevUnion;
-#endif
-#include "glyphstr.h"
+/* #include "glyphstr.h" */
/* #include "scrnintstr.h" */
+
+/* XXX: Hmmm... what's needed from here?
#include "resource.h"
+*/
-#include "Xutil.h"
+#include <X11/Xutil.h>
#define IcIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
#define IcIntDiv(a,b) (((CARD16) (a) * 255) / (b))
@@ -88,42 +86,32 @@ typedef union _DevUnion {
#define IcAdd(x,y,i,t) ((t) = IcGet8(x,i) + IcGet8(y,i), \
(CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
-/* XXX: I'm not sure about several things here:
-
- Do we want data to be IcBits * or unsigned char *?
-*/
-typedef struct _DirectFormat {
- CARD16 red, redMask;
- CARD16 green, greenMask;
- CARD16 blue, blueMask;
- CARD16 alpha, alphaMask;
-} DirectFormatRec;
-
+/*
typedef struct _IndexFormat {
- VisualPtr pVisual;
+ VisualPtr pVisual;
ColormapPtr pColormap;
int nvalues;
xIndexValue *pValues;
void *devPrivate;
} IndexFormatRec;
+*/
+/*
typedef struct _IcFormat {
CARD32 id;
- CARD32 format; /* except bpp */
+ CARD32 format;
unsigned char type;
unsigned char depth;
DirectFormatRec direct;
IndexFormatRec index;
} IcFormatRec;
-
-typedef struct _IcTransform {
- xFixed matrix[3][3];
-} IcTransform, *IcTransformPtr;
+*/
struct _IcImage {
IcPixels *pixels;
IcFormat *image_format;
- CARD32 format;
+ /* XXX: Should switch from int to an IcFormatName enum */
+ int format_name;
int refcnt;
unsigned int repeat : 1;
@@ -152,7 +140,7 @@ struct _IcImage {
IcTransform *transform;
int filter;
- xFixed *filter_params;
+ XFixed *filter_params;
int filter_nparams;
int owns_pixels;
@@ -169,11 +157,13 @@ struct _IcImage {
typedef CARD8 IcIndexType;
#endif
+/* XXX: We're not supporting indexed operations, right?
typedef struct _IcIndexed {
Bool color;
CARD32 rgba[IC_MAX_INDEXED];
IcIndexType ent[32768];
} IcIndexedRec, *IcIndexedPtr;
+*/
#define IcCvtR8G8B8to15(s) ((((s) >> 3) & 0x001f) | \
(((s) >> 6) & 0x03e0) | \
@@ -183,11 +173,10 @@ typedef struct _IcIndexed {
#define IcIndexToEntY24(icf,rgb24) ((icf)->ent[CvtR8G8B8toY15(rgb24)])
+/*
int
IcCreatePicture (PicturePtr pPicture);
-
-void
-IcImageDestroy (IcImage *image);
+*/
void
IcImageInit (IcImage *image);
@@ -199,18 +188,14 @@ IcImageChange (IcImage *image,
DevUnion *ulist,
int *error_value);
-int
-IcImageChangeClip (IcImage *image,
- int type,
- pointer value,
- int n);
-
void
IcImageDestroyClip (IcImage *image);
+/*
void
IcValidatePicture (PicturePtr pPicture,
Mask mask);
+*/
/* XXX: What should this be?
@@ -237,9 +222,12 @@ IcComputeCompositeRegion (PixRegion *region,
CARD16 width,
CARD16 height);
+/*
Bool
IcPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
+*/
+/*
void
IcGlyphs (CARD8 op,
PicturePtr pSrc,
@@ -250,23 +238,16 @@ IcGlyphs (CARD8 op,
int nlist,
GlyphListPtr list,
GlyphPtr *glyphs);
+*/
-void
-IcRenderColorToPixel (PictFormatPtr pPict,
- xRenderColor *color,
- CARD32 *pixel);
-
-void
-IcRenderPixelToColor (PictFormatPtr pPict,
- CARD32 pixel,
- xRenderColor *color);
-
+/*
void
IcCompositeRects (CARD8 op,
PicturePtr pDst,
xRenderColor *color,
int nRect,
xRectangle *rects);
+*/
IcImage *
IcCreateAlphaPicture (IcImage *dst,
@@ -317,7 +298,7 @@ struct _IcCompositeOperand {
int start_x;
int x;
int y;
- IcTransformPtr transform;
+ IcTransform *transform;
int filter;
} transform;
} u;
@@ -327,7 +308,9 @@ struct _IcCompositeOperand {
IcCompositeStep over;
IcCompositeStep down;
IcCompositeSet set;
+/* XXX: We're not supporting indexed operations, right?
IcIndexedPtr indexed;
+*/
PixRegion *clip;
};
@@ -949,11 +932,14 @@ IcFetcha_external (IcCompositeOperand *op);
void
IcStore_external (IcCompositeOperand *op, CARD32 value);
+/*
Bool
IcBuildOneCompositeOperand (PicturePtr pPict,
IcCompositeOperand *op,
INT16 x,
INT16 y);
+*/
+
Bool
IcBuildCompositeOperand (IcImage *image,
IcCompositeOperand op[4],
@@ -1168,10 +1154,4 @@ IcCompositeSolidMask_nx1xn (CARD8 op,
CARD16 width,
CARD16 height);
-/* over in ic.c */
-
-int
-IcImageSetTransform (IcImage *image,
- IcTransform *transform);
-
#endif /* _IC_MIPICT_H_ */
diff --git a/pixman/src/icint.h b/pixman/src/icint.h
index b7627f88..4293852b 100644
--- a/pixman/src/icint.h
+++ b/pixman/src/icint.h
@@ -24,19 +24,33 @@
#ifndef _ICINT_H_
#define _ICINT_H_
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
/* Need definitions for XFixed, etc. */
#include "X11/extensions/Xrender.h"
-/* XXX: Hack: It would be nice to figure out a cleaner way to
- successfully include both Xlib/server header files without having
- major clashes over the definition of BoxRec and BoxPtr. */
-#define EXCLUDE_SERVER_BOXPTR 1
-
#include <X11/X.h>
-#include "servermd.h"
+#include <X11/Xmd.h>
+
+/* These few definitions avoid me needing to include servermd.h and misc.h from Xserver/include */
+#ifndef BITMAP_SCANLINE_PAD
+#define BITMAP_SCANLINE_PAD 32
+#define LOG2_BITMAP_PAD 5
+#define LOG2_BYTES_PER_SCANLINE_PAD 2
+#endif
-#include "misc.h"
+#define FALSE 0
+#define TRUE 1
+
+#define MAXSHORT SHRT_MAX
+#define MINSHORT SHRT_MIN
+
+/* XXX: What do we need from here?
#include "picture.h"
+*/
+
#include "X11/Xprotostr.h"
#include "X11/extensions/Xrender.h"
@@ -51,12 +65,6 @@
#define IC_MASK (IC_UNIT - 1)
#define IC_ALLONES ((IcBits) -1)
-#if GLYPHPADBYTES != 4
-#error "GLYPHPADBYTES must be 4"
-#endif
-#if GETLEFTBITS_ALIGNMENT != 1
-#error "GETLEFTBITS_ALIGNMENT must be 1"
-#endif
/* whether to bother to include 24bpp support */
#ifndef ICNO24BIT
#define IC_24BIT
@@ -86,15 +94,8 @@
#define IcFullMask(n) ((n) == IC_UNIT ? IC_ALLONES : ((((IcBits) 1) << n) - 1))
-/* XXX: What's the significance of this distinction for IcStip? */
-#if LOG2_BITMAP_PAD == IC_SHIFT
-typedef IcBits IcStip;
-#else
-# if LOG2_BITMAP_PAD == 5
-typedef CARD32 IcStip;
-# endif
-#endif
+typedef uint32_t IcStip;
typedef int IcStride;
@@ -697,7 +698,7 @@ IcStipple (IcBits *dst,
int xRot,
int yRot);
-struct _IcPixels {
+typedef struct _IcPixels {
IcBits *data;
unsigned int width;
unsigned int height;
@@ -707,7 +708,7 @@ struct _IcPixels {
int x;
int y;
unsigned int refcnt;
-};
+} IcPixels;
/* XXX: This is to avoid including colormap.h from the server includes */
typedef CARD32 Pixel;
@@ -728,15 +729,245 @@ IcReplicatePixel (Pixel p, int bpp);
#include "icimage.h"
+/* icformat.c */
+
+IcFormat *
+_IcFormatCreate (IcFormatName name);
+
+void
+_IcFormatDestroy (IcFormat *format);
+
+/* icimage.c */
+
+IcImage *
+IcImageCreateForPixels (IcPixels *pixels,
+ IcFormat *format);
+
+/* icpixels.c */
+
+IcPixels *
+IcPixelsCreate (int width, int height, int depth);
+
+IcPixels *
+IcPixelsCreateForData (IcBits *data, int width, int height, int depth, int bpp, int stride);
+
+void
+IcPixelsDestroy (IcPixels *pixels);
+
/* ictrap.c */
void
-IcRasterizeTrapezoid (IcImage *pMask,
- XTrapezoid *pTrap,
- int x_off,
- int y_off);
+IcRasterizeTrapezoid (IcImage *pMask,
+ const XTrapezoid *pTrap,
+ int x_off,
+ int y_off);
#include "icrop.h"
+/* XXX: For now, I'm just wholesale pasting Xserver/render/picture.h here: */
+#ifndef _PICTURE_H_
+#define _PICTURE_H_
+
+typedef struct _DirectFormat *DirectFormatPtr;
+typedef struct _PictFormat *PictFormatPtr;
+typedef struct _Picture *PicturePtr;
+
+/*
+ * While the protocol is generous in format support, the
+ * sample implementation allows only packed RGB and GBR
+ * representations for data to simplify software rendering,
+ */
+#define PICT_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \
+ ((type) << 16) | \
+ ((a) << 12) | \
+ ((r) << 8) | \
+ ((g) << 4) | \
+ ((b)))
+
+/*
+ * gray/color formats use a visual index instead of argb
+ */
+#define PICT_VISFORMAT(bpp,type,vi) (((bpp) << 24) | \
+ ((type) << 16) | \
+ ((vi)))
+
+#define PICT_FORMAT_BPP(f) (((f) >> 24) )
+#define PICT_FORMAT_TYPE(f) (((f) >> 16) & 0xff)
+#define PICT_FORMAT_A(f) (((f) >> 12) & 0x0f)
+#define PICT_FORMAT_R(f) (((f) >> 8) & 0x0f)
+#define PICT_FORMAT_G(f) (((f) >> 4) & 0x0f)
+#define PICT_FORMAT_B(f) (((f) ) & 0x0f)
+#define PICT_FORMAT_RGB(f) (((f) ) & 0xfff)
+#define PICT_FORMAT_VIS(f) (((f) ) & 0xffff)
+
+#define PICT_TYPE_OTHER 0
+#define PICT_TYPE_A 1
+#define PICT_TYPE_ARGB 2
+#define PICT_TYPE_ABGR 3
+#define PICT_TYPE_COLOR 4
+#define PICT_TYPE_GRAY 5
+
+#define PICT_FORMAT_COLOR(f) (PICT_FORMAT_TYPE(f) & 2)
+
+/* 32bpp formats */
+#define PICT_a8r8g8b8 PICT_FORMAT(32,PICT_TYPE_ARGB,8,8,8,8)
+#define PICT_x8r8g8b8 PICT_FORMAT(32,PICT_TYPE_ARGB,0,8,8,8)
+#define PICT_a8b8g8r8 PICT_FORMAT(32,PICT_TYPE_ABGR,8,8,8,8)
+#define PICT_x8b8g8r8 PICT_FORMAT(32,PICT_TYPE_ABGR,0,8,8,8)
+
+/* 24bpp formats */
+#define PICT_r8g8b8 PICT_FORMAT(24,PICT_TYPE_ARGB,0,8,8,8)
+#define PICT_b8g8r8 PICT_FORMAT(24,PICT_TYPE_ABGR,0,8,8,8)
+
+/* 16bpp formats */
+#define PICT_r5g6b5 PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,6,5)
+#define PICT_b5g6r5 PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,6,5)
+
+#define PICT_a1r5g5b5 PICT_FORMAT(16,PICT_TYPE_ARGB,1,5,5,5)
+#define PICT_x1r5g5b5 PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,5,5)
+#define PICT_a1b5g5r5 PICT_FORMAT(16,PICT_TYPE_ABGR,1,5,5,5)
+#define PICT_x1b5g5r5 PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,5,5)
+#define PICT_a4r4g4b4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
+#define PICT_x4r4g4b4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
+#define PICT_a4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
+#define PICT_x4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
+
+/* 8bpp formats */
+#define PICT_a8 PICT_FORMAT(8,PICT_TYPE_A,8,0,0,0)
+#define PICT_r3g3b2 PICT_FORMAT(8,PICT_TYPE_ARGB,0,3,3,2)
+#define PICT_b2g3r3 PICT_FORMAT(8,PICT_TYPE_ABGR,0,3,3,2)
+#define PICT_a2r2g2b2 PICT_FORMAT(8,PICT_TYPE_ARGB,2,2,2,2)
+#define PICT_a2b2g2r2 PICT_FORMAT(8,PICT_TYPE_ABGR,2,2,2,2)
+
+#define PICT_c8 PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0)
+#define PICT_g8 PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0)
+
+/* 4bpp formats */
+#define PICT_a4 PICT_FORMAT(4,PICT_TYPE_A,4,0,0,0)
+#define PICT_r1g2b1 PICT_FORMAT(4,PICT_TYPE_ARGB,0,1,2,1)
+#define PICT_b1g2r1 PICT_FORMAT(4,PICT_TYPE_ABGR,0,1,2,1)
+#define PICT_a1r1g1b1 PICT_FORMAT(4,PICT_TYPE_ARGB,1,1,1,1)
+#define PICT_a1b1g1r1 PICT_FORMAT(4,PICT_TYPE_ABGR,1,1,1,1)
+
+#define PICT_c4 PICT_FORMAT(4,PICT_TYPE_COLOR,0,0,0,0)
+#define PICT_g4 PICT_FORMAT(4,PICT_TYPE_GRAY,0,0,0,0)
+
+/* 1bpp formats */
+#define PICT_a1 PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0)
+
+#define PICT_g1 PICT_FORMAT(1,PICT_TYPE_GRAY,0,0,0,0)
+
+/*
+ * For dynamic indexed visuals (GrayScale and PseudoColor), these control the
+ * selection of colors allocated for drawing to Pictures. The default
+ * policy depends on the size of the colormap:
+ *
+ * Size Default Policy
+ * ----------------------------
+ * < 64 PolicyMono
+ * < 256 PolicyGray
+ * 256 PolicyColor (only on PseudoColor)
+ *
+ * The actual allocation code lives in miindex.c, and so is
+ * austensibly server dependent, but that code does:
+ *
+ * PolicyMono Allocate no additional colors, use black and white
+ * PolicyGray Allocate 13 gray levels (11 cells used)
+ * PolicyColor Allocate a 4x4x4 cube and 13 gray levels (71 cells used)
+ * PolicyAll Allocate as big a cube as possible, fill with gray (all)
+ *
+ * Here's a picture to help understand how many colors are
+ * actually allocated (this is just the gray ramp):
+ *
+ * gray level
+ * all 0000 1555 2aaa 4000 5555 6aaa 8000 9555 aaaa bfff d555 eaaa ffff
+ * b/w 0000 ffff
+ * 4x4x4 5555 aaaa
+ * extra 1555 2aaa 4000 6aaa 8000 9555 bfff d555 eaaa
+ *
+ * The default colormap supplies two gray levels (black/white), the
+ * 4x4x4 cube allocates another two and nine more are allocated to fill
+ * in the 13 levels. When the 4x4x4 cube is not allocated, a total of
+ * 11 cells are allocated.
+ */
+
+#define PictureCmapPolicyInvalid -1
+#define PictureCmapPolicyDefault 0
+#define PictureCmapPolicyMono 1
+#define PictureCmapPolicyGray 2
+#define PictureCmapPolicyColor 3
+#define PictureCmapPolicyAll 4
+
+extern int PictureCmapPolicy;
+
+int PictureParseCmapPolicy (const char *name);
+
+/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
+
+#ifdef WIN32
+typedef __int64 xFixed_32_32;
+#else
+# if defined(__alpha__) || defined(__alpha) || \
+ defined(ia64) || defined(__ia64__) || \
+ defined(__sparc64__) || \
+ defined(__s390x__) || \
+ defined(x86_64) || defined (__x86_64__)
+typedef long xFixed_32_32;
+# else
+# if defined(__GNUC__) && \
+ ((__GNUC__ > 2) || \
+ ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 7)))
+__extension__
+# endif
+typedef long long int xFixed_32_32;
+# endif
+#endif
+
+typedef CARD32 xFixed_1_31;
+typedef CARD32 xFixed_1_16;
+typedef INT32 xFixed_16_16;
+
+/*
+ * An unadorned "xFixed" is the same as xFixed_16_16,
+ * (since it's quite common in the code)
+ */
+typedef xFixed_16_16 xFixed;
+#define XFIXED_BITS 16
+
+#define xFixedToInt(f) (int) ((f) >> XFIXED_BITS)
+#define IntToxFixed(i) ((xFixed) (i) << XFIXED_BITS)
+#define xFixedE ((xFixed) 1)
+#define xFixed1 (IntToxFixed(1))
+#define xFixed1MinusE (xFixed1 - xFixedE)
+#define xFixedFrac(f) ((f) & xFixed1MinusE)
+#define xFixedFloor(f) ((f) & ~xFixed1MinusE)
+#define xFixedCeil(f) xFixedFloor((f) + xFixed1MinusE)
+
+#define xFixedFraction(f) ((f) & xFixed1MinusE)
+#define xFixedMod2(f) ((f) & (xFixed1 | xFixed1MinusE))
+
+/* whether 't' is a well defined not obviously empty trapezoid */
+#define xTrapezoidValid(t) ((t)->left.p1.y != (t)->left.p2.y && \
+ (t)->right.p1.y != (t)->right.p2.y && \
+ (int) ((t)->bottom - (t)->top) > 0)
+
+/*
+ * Standard NTSC luminance conversions:
+ *
+ * y = r * 0.299 + g * 0.587 + b * 0.114
+ *
+ * Approximate this for a bit more speed:
+ *
+ * y = (r * 153 + g * 301 + b * 58) / 512
+ *
+ * This gives 17 bits of luminance; to get 15 bits, lop the low two
+ */
+
+#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \
+ (((s) >> 8) & 0xff) * 301 + \
+ (((s) ) & 0xff) * 58) >> 2)
+
+#endif /* _PICTURE_H_ */
+
#endif
diff --git a/pixman/src/icpixels.c b/pixman/src/icpixels.c
index 66229113..9b1277ea 100644
--- a/pixman/src/icpixels.c
+++ b/pixman/src/icpixels.c
@@ -1,5 +1,5 @@
/*
- * $Id: icpixels.c,v 1.2 2003-02-21 18:07:17 cworth Exp $
+ * $Id: icpixels.c,v 1.3 2003-04-17 15:48:22 cworth Exp $
*
* Copyright © 1998 Keith Packard
*
@@ -26,7 +26,7 @@
#include "icint.h"
static void
-IcPixelsInit (IcPixels *pixels, IcBits *data, int width, int height, int depth, int bpp, int stride);
+IcPixelsInit (IcPixels *pixels, IcBits *buf, int width, int height, int depth, int bpp, int stride);
static unsigned int
IcBitsPerPixel (unsigned int depth);
@@ -52,8 +52,8 @@ IcPixels *
IcPixelsCreate (int width, int height, int depth)
{
IcPixels *pixels;
- IcBits *data;
- unsigned int datasize;
+ IcBits *buf;
+ unsigned int buf_size;
unsigned int bpp;
unsigned int stride;
unsigned int adjust;
@@ -61,20 +61,20 @@ IcPixelsCreate (int width, int height, int depth)
bpp = IcBitsPerPixel (depth);
stride = ((width * bpp + IC_MASK) >> IC_SHIFT) * sizeof (IcBits);
- datasize = height * stride;
+ buf_size = height * stride;
base = sizeof (IcPixels);
adjust = 0;
if (base & 7)
adjust = 8 - (base & 7);
- datasize += adjust;
+ buf_size += adjust;
- pixels = malloc(base + datasize);
+ pixels = malloc(base + buf_size);
if (!pixels)
return NULL;
- data = (IcBits *) ((char *)pixels + base + adjust);
+ buf = (IcBits *) ((char *)pixels + base + adjust);
- IcPixelsInit (pixels, data, width, height, depth, bpp, stride);
+ IcPixelsInit (pixels, buf, width, height, depth, bpp, stride);
return pixels;
}
@@ -94,9 +94,9 @@ IcPixelsCreateForData (IcBits *data, int width, int height, int depth, int bpp,
}
static void
-IcPixelsInit (IcPixels *pixels, IcBits *data, int width, int height, int depth, int bpp, int stride)
+IcPixelsInit (IcPixels *pixels, IcBits *buf, int width, int height, int depth, int bpp, int stride)
{
- pixels->data = data;
+ pixels->data = buf;
pixels->width = width;
pixels->height = height;
pixels->depth = depth;
diff --git a/pixman/src/icrect.c b/pixman/src/icrect.c
index d0740571..48de3acb 100644
--- a/pixman/src/icrect.c
+++ b/pixman/src/icrect.c
@@ -24,6 +24,7 @@
#include "icint.h"
+/* XXX: I haven't ported this yet
static void
IcColorRects (IcImage *dst,
IcImage *clipPict,
@@ -46,9 +47,8 @@ IcColorRects (IcImage *dst,
tmpval[3] = dst->clipOrigin.y - yoff;
mask |= CPClipXOrigin|CPClipYOrigin;
- clip = REGION_CREATE (pScreen, NULL, 1);
- REGION_COPY (pScreen, pClip,
- (RegionPtr) pClipPict->clientClip);
+ clip = PixRegionCreate ();
+ PixRegionCopy (clip, pClipPict->clientClip);
(*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0);
}
@@ -72,80 +72,97 @@ IcColorRects (IcImage *dst,
}
}
}
+*/
+
+void IcFillRectangle (char op,
+ IcImage *dst,
+ const IcColor *color,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height)
+{
+ XRectangle rect;
+
+ rect.x = x;
+ rect.y = y;
+ rect.width = width;
+ rect.height = height;
+
+ IcFillRectangles (op, dst, color, &rect, 1);
+}
void
-IcCompositeRects (CARD8 op,
- IcImage *dst,
- IcColor *color,
- int nRect,
- xRectangle *rects)
+IcFillRectangles (char op,
+ IcImage *dst,
+ const IcColor *color,
+ const XRectangle *rects,
+ int nRects)
{
- if (color->alpha == 0xffff)
+ IcColor color_s = *color;
+
+ if (color_s.alpha == 0xffff)
{
if (op == PictOpOver)
op = PictOpSrc;
}
if (op == PictOpClear)
- color->red = color->green = color->blue = color->alpha = 0;
-
+ color_s.red = color_s.green = color_s.blue = color_s.alpha = 0;
+
+/* XXX: Really need this to optimize solid rectangles
if (op == PictOpSrc || op == PictOpClear)
{
- IcColorRects (dst, dst, color, nRect, rects, 0, 0);
+ IcColorRects (dst, dst, &color_s, nRects, rects, 0, 0);
if (dst->alphaMap)
IcColorRects (dst->alphaMap, dst,
- color, nRect, rects,
+ &color_s, nRects, rects,
dst->alphaOrigin.x,
dst->alphaOrigin.y);
}
else
+*/
{
- IcFormat *rgbaFormat;
+ IcFormat rgbaFormat;
IcPixels *pixels;
IcImage *src;
- xRectangle one;
- int error;
- Pixel pixel;
- CARD32 tmpval[2];
+ IcBits pixel;
- rgbaFormat = IcFormatCreate (PICT_a8r8g8b8);
- if (!rgbaFormat)
- goto bail1;
+ IcFormatInit (&rgbaFormat, PICT_a8r8g8b8);
- pixels = IcPixelsCreate (1, 1, rgbaFormat->depth);
+ pixels = IcPixelsCreate (1, 1, rgbaFormat.depth);
if (!pixels)
- goto bail2;
+ goto bail1;
- IcRenderColorToPixel (rgbaFormat, color, &pixel);
-
- /* XXX: how to do this?
- one.x = 0;
- one.y = 0;
- one.width = 1;
- one.height = 1;
- (*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &one);
+ IcColorToPixel (&rgbaFormat, &color_s, &pixel);
+
+ /* XXX: Originally, fb had the following:
+
+ (*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &one);
+
+ I haven't checked to see what I might be breaking with a
+ trivial assignment instead.
*/
-
- tmpval[0] = xTrue;
- src = IcImageCreateForPixels (pixels, rgbaFormat,
- CPRepeat, tmpval, &error, &error_value);
+ pixels->data[0] = pixel;
+
+ src = IcImageCreateForPixels (pixels, &rgbaFormat);
if (!src)
- goto bail4;
+ goto bail2;
+
+ IcImageSetRepeat (src, 1);
- while (nRect--)
+ while (nRects--)
{
- CompositePicture (op, pSrc, 0, pDst, 0, 0, 0, 0,
- rects->x,
- rects->y,
- rects->width,
- rects->height);
+ IcComposite (op, src, 0, dst, 0, 0, 0, 0,
+ rects->x,
+ rects->y,
+ rects->width,
+ rects->height);
rects++;
}
IcImageDestroy (src);
-bail4:
-bail3:
- IcPixelsDestroy (pixels);
bail2:
+ IcPixelsDestroy (pixels);
bail1:
;
}
diff --git a/pixman/src/ictrap.c b/pixman/src/ictrap.c
index 5850e865..d5f46b73 100644
--- a/pixman/src/ictrap.c
+++ b/pixman/src/ictrap.c
@@ -37,7 +37,6 @@ IcCreateAlphaPicture (IcImage *dst,
CARD16 width,
CARD16 height)
{
- int error, error_value;
IcImage *image;
if (width > 32767 || height > 32767)
@@ -45,15 +44,16 @@ IcCreateAlphaPicture (IcImage *dst,
if (!format)
{
+ /* XXX: Is the memory from this IcFormatCreate leaking? */
if (dst->polyEdge == PolyEdgeSharp)
- format = IcFormatCreate (PICT_a1);
+ format = _IcFormatCreate (PICT_a1);
else
- format = IcFormatCreate (PICT_a8);
+ format = _IcFormatCreate (PICT_a8);
if (!format)
return 0;
}
- image = IcImageCreate (format, width, height, 0, 0, &error, &error_value);
+ image = IcImageCreate (format, width, height);
/* XXX: Is this a reasonable way to clear the image? Would
probably be preferable to use IcImageFillRectangle once such a
@@ -64,7 +64,7 @@ IcCreateAlphaPicture (IcImage *dst,
}
static XFixed
-IcLineFixedX (XLineFixed *l, XFixed y, Bool ceil)
+IcLineFixedX (const XLineFixed *l, XFixed y, Bool ceil)
{
XFixed dx = l->p2.x - l->p1.x;
xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx;
@@ -75,7 +75,7 @@ IcLineFixedX (XLineFixed *l, XFixed y, Bool ceil)
}
static void
-IcTrapezoidBounds (int ntrap, XTrapezoid *traps, PixRegionBox *box)
+IcTrapezoidBounds (int ntrap, const XTrapezoid *traps, PixRegionBox *box)
{
box->y1 = MAXSHORT;
box->y2 = MINSHORT;
@@ -95,12 +95,12 @@ IcTrapezoidBounds (int ntrap, XTrapezoid *traps, PixRegionBox *box)
if (y2 > box->y2)
box->y2 = y2;
- x1 = xFixedToInt (min (IcLineFixedX (&traps->left, traps->top, FALSE),
+ x1 = xFixedToInt (MIN (IcLineFixedX (&traps->left, traps->top, FALSE),
IcLineFixedX (&traps->left, traps->bottom, FALSE)));
if (x1 < box->x1)
box->x1 = x1;
- x2 = xFixedToInt (xFixedCeil (max (IcLineFixedX (&traps->right, traps->top, TRUE),
+ x2 = xFixedToInt (xFixedCeil (MAX (IcLineFixedX (&traps->right, traps->top, TRUE),
IcLineFixedX (&traps->right, traps->bottom, TRUE))));
if (x2 > box->x2)
box->x2 = x2;
@@ -108,26 +108,28 @@ IcTrapezoidBounds (int ntrap, XTrapezoid *traps, PixRegionBox *box)
}
void
-IcTrapezoids (char op,
- IcImage *src,
- IcImage *dst,
- IcFormat *format,
- int xSrc,
- int ySrc,
- int ntrap,
- XTrapezoid *traps)
+IcCompositeTrapezoids (char op,
+ IcImage *src,
+ IcImage *dst,
+ int xSrc,
+ int ySrc,
+ const XTrapezoid *traps,
+ int ntraps)
{
IcImage *image = NULL;
PixRegionBox bounds;
INT16 xDst, yDst;
INT16 xRel, yRel;
+ IcFormat *format;
xDst = traps[0].left.p1.x >> 16;
yDst = traps[0].left.p1.y >> 16;
+ format = _IcFormatCreate (PICT_a8);
+
if (format)
{
- IcTrapezoidBounds (ntrap, traps, &bounds);
+ IcTrapezoidBounds (ntraps, traps, &bounds);
if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
return;
image = IcCreateAlphaPicture (dst, format,
@@ -136,7 +138,7 @@ IcTrapezoids (char op,
if (!image)
return;
}
- for (; ntrap; ntrap--, traps++)
+ for (; ntraps; ntraps--, traps++)
{
if (!xTrapezoidValid(traps))
continue;
@@ -174,6 +176,8 @@ IcTrapezoids (char op,
bounds.y2 - bounds.y1);
IcImageDestroy (image);
}
+
+ _IcFormatDestroy (format);
}
#ifdef DEBUG
@@ -1133,10 +1137,10 @@ PixelAlpha(xFixed pixel_x,
)
void
-IcRasterizeTrapezoid (IcImage *pMask,
- XTrapezoid *pTrap,
- int x_off,
- int y_off)
+IcRasterizeTrapezoid (IcImage *pMask,
+ const XTrapezoid *pTrap,
+ int x_off,
+ int y_off)
{
XTrapezoid trap = *pTrap;
int alpha, temp;
diff --git a/pixman/src/ictri.c b/pixman/src/ictri.c
index d0bde4b5..e369d1c7 100644
--- a/pixman/src/ictri.c
+++ b/pixman/src/ictri.c
@@ -25,13 +25,13 @@
#include "icint.h"
void
-IcRasterizeTriangle (IcImage *image,
- XTriangle *tri,
- int x_off,
- int y_off);
+IcRasterizeTriangle (IcImage *image,
+ const XTriangle *tri,
+ int x_off,
+ int y_off);
static void
-IcPointFixedBounds (int npoint, XPointFixed *points, PixRegionBox *bounds)
+IcPointFixedBounds (int npoint, const XPointFixed *points, PixRegionBox *bounds)
{
bounds->x1 = xFixedToInt (points->x);
bounds->x2 = xFixedToInt (xFixedCeil (points->x));
@@ -59,18 +59,18 @@ IcPointFixedBounds (int npoint, XPointFixed *points, PixRegionBox *bounds)
}
static void
-IcTriangleBounds (int ntri, XTriangle *tris, PixRegionBox *bounds)
+IcTriangleBounds (int ntri, const XTriangle *tris, PixRegionBox *bounds)
{
IcPointFixedBounds (ntri * 3, (XPointFixed *) tris, bounds);
}
void
-IcRasterizeTriangle (IcImage *image,
- XTriangle *tri,
- int x_off,
- int y_off)
+IcRasterizeTriangle (IcImage *image,
+ const XTriangle *tri,
+ int x_off,
+ int y_off)
{
- XPointFixed *top, *left, *right, *t;
+ const XPointFixed *top, *left, *right, *t;
XTrapezoid trap[2];
top = &tri->p1;
@@ -143,26 +143,28 @@ IcRasterizeTriangle (IcImage *image,
}
void
-IcTriangles (char op,
- IcImage *src,
- IcImage *dst,
- IcFormat *format,
- int xSrc,
- int ySrc,
- int ntri,
- XTriangle *tris)
+IcCompositeTriangles (char op,
+ IcImage *src,
+ IcImage *dst,
+ int xSrc,
+ int ySrc,
+ const XTriangle *tris,
+ int ntris)
{
PixRegionBox bounds;
IcImage *image = NULL;
int xDst, yDst;
int xRel, yRel;
+ IcFormat *format;
xDst = tris[0].p1.x >> 16;
yDst = tris[0].p1.y >> 16;
+
+ format = _IcFormatCreate (PICT_a8);
if (format)
{
- IcTriangleBounds (ntri, tris, &bounds);
+ IcTriangleBounds (ntris, tris, &bounds);
if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
return;
image = IcCreateAlphaPicture (dst,
@@ -172,7 +174,7 @@ IcTriangles (char op,
if (!image)
return;
}
- for (; ntri; ntri--, tris++)
+ for (; ntris; ntris--, tris++)
{
if (!format)
{
@@ -207,32 +209,36 @@ IcTriangles (char op,
bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
IcImageDestroy (image);
}
+
+ _IcFormatDestroy (format);
}
void
-IcTriStrip (char op,
- IcImage *src,
- IcImage *dst,
- IcFormat *format,
- int xSrc,
- int ySrc,
- int npoint,
- XPointFixed *points)
+IcCompositeTriStrip (char op,
+ IcImage *src,
+ IcImage *dst,
+ int xSrc,
+ int ySrc,
+ const XPointFixed *points,
+ int npoints)
{
XTriangle tri;
PixRegionBox bounds;
IcImage *image = NULL;
int xDst, yDst;
int xRel, yRel;
+ IcFormat *format;
xDst = points[0].x >> 16;
yDst = points[0].y >> 16;
+
+ format = _IcFormatCreate (PICT_a8);
- if (npoint < 3)
+ if (npoints < 3)
return;
if (format)
{
- IcPointFixedBounds (npoint, points, &bounds);
+ IcPointFixedBounds (npoints, points, &bounds);
if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
return;
image = IcCreateAlphaPicture (dst,
@@ -242,7 +248,7 @@ IcTriStrip (char op,
if (!image)
return;
}
- for (; npoint >= 3; npoint--, points++)
+ for (; npoints >= 3; npoints--, points++)
{
tri.p1 = points[0];
tri.p2 = points[1];
@@ -279,33 +285,37 @@ IcTriStrip (char op,
bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
IcImageDestroy (image);
}
+
+ _IcFormatDestroy (format);
}
void
-IcTriFan (char op,
- IcImage *src,
- IcImage *dst,
- IcFormat *format,
- int xSrc,
- int ySrc,
- int npoint,
- XPointFixed *points)
+IcCompositeTriFan (char op,
+ IcImage *src,
+ IcImage *dst,
+ int xSrc,
+ int ySrc,
+ const XPointFixed *points,
+ int npoints)
{
XTriangle tri;
PixRegionBox bounds;
IcImage *image = NULL;
- XPointFixed *first;
+ const XPointFixed *first;
int xDst, yDst;
int xRel, yRel;
+ IcFormat *format;
xDst = points[0].x >> 16;
yDst = points[0].y >> 16;
+
+ format = _IcFormatCreate (PICT_a8);
- if (npoint < 3)
+ if (npoints < 3)
return;
if (format)
{
- IcPointFixedBounds (npoint, points, &bounds);
+ IcPointFixedBounds (npoints, points, &bounds);
if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
return;
image = IcCreateAlphaPicture (dst,
@@ -316,8 +326,8 @@ IcTriFan (char op,
return;
}
first = points++;
- npoint--;
- for (; npoint >= 2; npoint--, points++)
+ npoints--;
+ for (; npoints >= 2; npoints--, points++)
{
tri.p1 = *first;
tri.p2 = points[0];
@@ -354,5 +364,7 @@ IcTriFan (char op,
bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
IcImageDestroy (image);
}
+
+ _IcFormatDestroy (format);
}