mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-08 02:08:03 +02:00
Fixed transform/filter support
This commit is contained in:
parent
8f10ce3013
commit
7e1f3f1798
7 changed files with 59 additions and 27 deletions
|
|
@ -1,3 +1,7 @@
|
|||
2003-05-14 Carl Worth <cworth@isi.edu>
|
||||
|
||||
* src/ic.h: Add IcImageSetFilter. Fixed transform support.
|
||||
|
||||
2003-05-05 Carl Worth <cworth@isi.edu>
|
||||
|
||||
* src/ictrap.c (IcCompositeTrapezoids): Avoid crash if there's
|
||||
|
|
|
|||
|
|
@ -128,10 +128,22 @@ typedef struct _IcTrapezoid {
|
|||
IcLineFixed left, right;
|
||||
} IcTrapezoid;
|
||||
|
||||
typedef struct _IcVector {
|
||||
IcFixed16_16 vector[3];
|
||||
} IcVector;
|
||||
|
||||
typedef struct _IcTransform {
|
||||
IcFixed16_16 matrix[3][3];
|
||||
} IcTransform;
|
||||
|
||||
typedef enum {
|
||||
IcFilterFast,
|
||||
IcFilterGood,
|
||||
IcFilterBest,
|
||||
IcFilterNearest,
|
||||
IcFilterBilinear
|
||||
} IcFilter;
|
||||
|
||||
int
|
||||
IcImageSetTransform (IcImage *image,
|
||||
IcTransform *transform);
|
||||
|
|
@ -140,6 +152,10 @@ void
|
|||
IcImageSetRepeat (IcImage *image,
|
||||
int repeat);
|
||||
|
||||
void
|
||||
IcImageSetFilter (IcImage *image,
|
||||
IcFilter filter);
|
||||
|
||||
/* iccolor.c */
|
||||
|
||||
/* XXX: Do we really need a struct here? Only IcRectangles uses this. */
|
||||
|
|
|
|||
|
|
@ -2439,26 +2439,26 @@ IcStore_external (IcCompositeOperand *op, CARD32 value)
|
|||
CARD32
|
||||
IcFetch_transform (IcCompositeOperand *op)
|
||||
{
|
||||
return 0;
|
||||
/* XXX: Still need to port this function
|
||||
PictVector v;
|
||||
IcVector v;
|
||||
int x, y;
|
||||
int minx, maxx, miny, maxy;
|
||||
int n;
|
||||
CARD32 rtot, gtot, btot, atot;
|
||||
CARD32 xerr, yerr;
|
||||
CARD32 bits;
|
||||
PixRegionBox box;
|
||||
|
||||
v.vector[0] = IntToxFixed(op->u.transform.x);
|
||||
v.vector[1] = IntToxFixed(op->u.transform.y);
|
||||
v.vector[2] = xFixed1;
|
||||
if (!PictureTransformPoint (op->u.transform.transform, &v))
|
||||
if (!IcTransformPoint (op->u.transform.transform, &v))
|
||||
return 0;
|
||||
switch (op->u.transform.filter) {
|
||||
case PictFilterNearest:
|
||||
case IcFilterFast:
|
||||
case IcFilterNearest:
|
||||
y = xFixedToInt (v.vector[1]) + op->u.transform.top_y;
|
||||
x = xFixedToInt (v.vector[0]) + op->u.transform.left_x;
|
||||
if (PixRegionPointInRegion (op->clip, x, y))
|
||||
if (PixRegionPointInRegion (op->clip, x, y, &box))
|
||||
{
|
||||
(*op[1].set) (&op[1], x, y);
|
||||
bits = (*op[1].fetch) (&op[1]);
|
||||
|
|
@ -2466,7 +2466,9 @@ IcFetch_transform (IcCompositeOperand *op)
|
|||
else
|
||||
bits = 0;
|
||||
break;
|
||||
case PictFilterBilinear:
|
||||
case IcFilterGood:
|
||||
case IcFilterBest:
|
||||
case IcFilterBilinear:
|
||||
rtot = gtot = btot = atot = 0;
|
||||
miny = xFixedToInt (v.vector[1]) + op->u.transform.top_y;
|
||||
maxy = xFixedToInt (xFixedCeil (v.vector[1])) + op->u.transform.top_y;
|
||||
|
|
@ -2482,7 +2484,7 @@ IcFetch_transform (IcCompositeOperand *op)
|
|||
xerr = xFixed1 - xFixedFrac (v.vector[0]);
|
||||
for (x = minx; x <= maxx; x++)
|
||||
{
|
||||
if (PixRegionPointInRegion (op->clip, x, y))
|
||||
if (PixRegionPointInRegion (op->clip, x, y, &box))
|
||||
{
|
||||
(*op[1].set) (&op[1], x, y);
|
||||
bits = (*op[1].fetch) (&op[1]);
|
||||
|
|
@ -2517,32 +2519,31 @@ IcFetch_transform (IcCompositeOperand *op)
|
|||
break;
|
||||
}
|
||||
return bits;
|
||||
*/
|
||||
}
|
||||
|
||||
CARD32
|
||||
IcFetcha_transform (IcCompositeOperand *op)
|
||||
{
|
||||
return 0;
|
||||
/* XXX: Still need to port this function
|
||||
PictVector v;
|
||||
IcVector v;
|
||||
int x, y;
|
||||
int minx, maxx, miny, maxy;
|
||||
int n;
|
||||
CARD32 rtot, gtot, btot, atot;
|
||||
CARD32 xerr, yerr;
|
||||
CARD32 bits;
|
||||
PixRegionBox box;
|
||||
|
||||
v.vector[0] = IntToxFixed(op->u.transform.x);
|
||||
v.vector[1] = IntToxFixed(op->u.transform.y);
|
||||
v.vector[2] = xFixed1;
|
||||
if (!PictureTransformPoint (op->u.transform.transform, &v))
|
||||
if (!IcTransformPoint (op->u.transform.transform, &v))
|
||||
return 0;
|
||||
switch (op->u.transform.filter) {
|
||||
case PictFilterNearest:
|
||||
case IcFilterFast:
|
||||
case IcFilterNearest:
|
||||
y = xFixedToInt (v.vector[1]) + op->u.transform.left_x;
|
||||
x = xFixedToInt (v.vector[0]) + op->u.transform.top_y;
|
||||
if (PixRegionPointInRegion (op->clip, x, y))
|
||||
if (PixRegionPointInRegion (op->clip, x, y, &box))
|
||||
{
|
||||
(*op[1].set) (&op[1], x, y);
|
||||
bits = (*op[1].fetcha) (&op[1]);
|
||||
|
|
@ -2550,7 +2551,9 @@ IcFetcha_transform (IcCompositeOperand *op)
|
|||
else
|
||||
bits = 0;
|
||||
break;
|
||||
case PictFilterBilinear:
|
||||
case IcFilterGood:
|
||||
case IcFilterBest:
|
||||
case IcFilterBilinear:
|
||||
rtot = gtot = btot = atot = 0;
|
||||
|
||||
miny = xFixedToInt (v.vector[1]) + op->u.transform.top_y;
|
||||
|
|
@ -2566,7 +2569,7 @@ IcFetcha_transform (IcCompositeOperand *op)
|
|||
xerr = xFixed1 - xFixedFrac (v.vector[0]);
|
||||
for (x = minx; x <= maxx; x++)
|
||||
{
|
||||
if (PixRegionPointInRegion (op->clip, x, y))
|
||||
if (PixRegionPointInRegion (op->clip, x, y, &box))
|
||||
{
|
||||
(*op[1].set) (&op[1], x, y);
|
||||
bits = (*op[1].fetcha) (&op[1]);
|
||||
|
|
@ -2603,7 +2606,6 @@ IcFetcha_transform (IcCompositeOperand *op)
|
|||
break;
|
||||
}
|
||||
return bits;
|
||||
*/
|
||||
}
|
||||
|
||||
IcAccessMap icAccessMap[] = {
|
||||
|
|
|
|||
|
|
@ -137,9 +137,7 @@ IcImageInit (IcImage *image)
|
|||
|
||||
image->transform = NULL;
|
||||
|
||||
/* XXX: Need to track down and include this function
|
||||
image->filter = PictureGetFilterId (FilterNearest, -1, TRUE);
|
||||
*/
|
||||
image->filter = IcFilterNearest;
|
||||
image->filter_params = 0;
|
||||
image->filter_nparams = 0;
|
||||
|
||||
|
|
@ -189,6 +187,14 @@ IcImageSetRepeat (IcImage *image,
|
|||
image->repeat = repeat;
|
||||
}
|
||||
|
||||
void
|
||||
IcImageSetFilter (IcImage *image,
|
||||
IcFilter filter)
|
||||
{
|
||||
if (image)
|
||||
image->filter = filter;
|
||||
}
|
||||
|
||||
void
|
||||
IcImageDestroy (IcImage *image)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ struct _IcImage {
|
|||
|
||||
IcTransform *transform;
|
||||
|
||||
int filter;
|
||||
IcFilter filter;
|
||||
IcFixed16_16 *filter_params;
|
||||
int filter_nparams;
|
||||
|
||||
|
|
@ -300,7 +300,7 @@ struct _IcCompositeOperand {
|
|||
int x;
|
||||
int y;
|
||||
IcTransform *transform;
|
||||
int filter;
|
||||
IcFilter filter;
|
||||
} transform;
|
||||
} u;
|
||||
IcCompositeFetch fetch;
|
||||
|
|
|
|||
|
|
@ -753,6 +753,12 @@ IcPixelsCreateForData (IcBits *data, int width, int height, int depth, int bpp,
|
|||
void
|
||||
IcPixelsDestroy (IcPixels *pixels);
|
||||
|
||||
/* ictransform.c */
|
||||
|
||||
Bool
|
||||
IcTransformPoint (IcTransform *transform,
|
||||
IcVector *vector);
|
||||
|
||||
/* ictrap.c */
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -30,12 +30,11 @@ typedef xFixed_32_32 xFixed_48_16;
|
|||
#define MAX_FIXED_48_16 ((xFixed_48_16) 0x7fffffff)
|
||||
#define MIN_FIXED_48_16 (-((xFixed_48_16) 1 << 31))
|
||||
|
||||
/* XXX: Still need to port this
|
||||
Bool
|
||||
IcTransformPoint (IcTransform *transform,
|
||||
PictVectorPtr vector)
|
||||
IcVector *vector)
|
||||
{
|
||||
PictVector result;
|
||||
IcVector result;
|
||||
int i, j;
|
||||
xFixed_32_32 partial;
|
||||
xFixed_48_16 v;
|
||||
|
|
@ -67,4 +66,3 @@ IcTransformPoint (IcTransform *transform,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue