Window frame/coordinate handling cleanups

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@23461 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2006-09-12 09:50:14 +00:00
parent e11c20b9ed
commit c1cdc25750
13 changed files with 148 additions and 94 deletions

View file

@ -196,8 +196,8 @@ very expensive
numarray[0] = ax; numarray[1] = ay;
x = p.x;
y = wi->sy - p.y;
x = p.x - offset.x;
y = offset.y - p.y;
[(id<FTFontInfo>)font
drawString: s
at: x:y
@ -229,8 +229,8 @@ very expensive
numarray[0] = ax; numarray[1] = ay;
numarray[2] = cx; numarray[3] = cy;
x = p.x;
y = wi->sy - p.y;
x = p.x - offset.x;
y = offset.y - p.y;
[(id<FTFontInfo>)font
drawString: s
at: x:y
@ -270,8 +270,8 @@ very expensive
if ([path isEmpty]) return;
p = [path currentPoint];
x = p.x;
y = wi->sy - p.y;
x = p.x - offset.x;
y = offset.y - p.y;
[(id<FTFontInfo>)font
drawString: s
at: x:y
@ -300,8 +300,8 @@ very expensive
numarray[0] = cx; numarray[1] = cy;
x = p.x;
y = wi->sy - p.y;
x = p.x - offset.x;
y = offset.y - p.y;
[(id<FTFontInfo>)font
drawString: s
at: x:y
@ -327,8 +327,8 @@ very expensive
if ([path isEmpty]) return;
p = [path currentPoint];
x = p.x;
y = wi->sy - p.y;
x = p.x - offset.x;
y = offset.y - p.y;
[(id<FTFontInfo>)font
drawString: s
at: x:y
@ -354,8 +354,8 @@ very expensive
if ([path isEmpty]) return;
p = [path currentPoint];
x = p.x;
y = wi->sy - p.y;
x = p.x - offset.x;
y = offset.y - p.y;
[(id<FTFontInfo>)font
drawString: s
at: x:y
@ -381,8 +381,8 @@ very expensive
if (!path || [path isEmpty]) return;
p = [path currentPoint];
x = p.x;
y = wi->sy - p.y;
x = p.x - offset.x;
y = offset.y - p.y;
[(id<FTFontInfo>)font
drawString: s
at: x:y
@ -409,8 +409,8 @@ very expensive
if (!path || [path isEmpty]) return;
p = [path currentPoint];
x = p.x;
y = wi->sy - p.y;
x = p.x - offset.x;
y = offset.y - p.y;
if (wi->has_alpha)
{
[(id<FTFontInfo>)font

View file

@ -259,7 +259,7 @@ typedef struct
} rect_trace_t;
static void _rect_setup(rect_trace_t *t, NSRect r, int cx0, int cx1,
NSAffineTransform *ctm, int up, int *y0, int wi_sy)
NSAffineTransform *ctm, int up, int *y0, NSPoint offset)
{
float fx[4], fy[4];
NSPoint p;
@ -289,10 +289,10 @@ static void _rect_setup(rect_trace_t *t, NSRect r, int cx0, int cx1,
if (fabs(fy[2] - floor(fy[2] + .5)) < 0.001) fy[2] = floor(fy[2] + .5);
if (fabs(fy[3] - floor(fy[3] + .5)) < 0.001) fy[3] = floor(fy[3] + .5);
t->x[0] = floor(fx[0]); t->y[0] = wi_sy - floor(fy[0]);
t->x[1] = floor(fx[1]); t->y[1] = wi_sy - floor(fy[1]);
t->x[2] = floor(fx[2]); t->y[2] = wi_sy - floor(fy[2]);
t->x[3] = floor(fx[3]); t->y[3] = wi_sy - floor(fy[3]);
t->x[0] = floor(fx[0]) - offset.x; t->y[0] = offset.y - floor(fy[0]);
t->x[1] = floor(fx[1]) - offset.x; t->y[1] = offset.y - floor(fy[1]);
t->x[2] = floor(fx[2]) - offset.x; t->y[2] = offset.y - floor(fy[2]);
t->x[3] = floor(fx[3]) - offset.x; t->y[3] = offset.y - floor(fy[3]);
/* If we're tracing the 'other way', we just flip the y-coordinates
and unflip when returning them */
@ -493,11 +493,11 @@ static BOOL _rect_advance(rect_trace_t *t, int *x0, int *x1)
cy1 = clip_y1;
sp = [ags->ctm pointInMatrixSpace: aRect.origin];
sp.x = floor(sp.x);
sp.y = floor(ags->wi->sy - sp.y);
sp.x = floor(sp.x - ags->offset.x);
sp.y = floor(ags->offset.y - sp.y);
dp = [ctm pointInMatrixSpace: aPoint];
dp.x = floor(dp.x);
dp.y = floor(wi->sy - dp.y);
dp.x = floor(dp.x - offset.x);
dp.y = floor(offset.y - dp.y);
if (dp.x - cx0 > sp.x)
cx0 = dp.x - sp.x;
@ -613,7 +613,7 @@ static BOOL _rect_advance(rect_trace_t *t, int *x0, int *x1)
{
int ry;
int x0, x1;
_rect_setup(&state, aRect, sx0, sx0 + cx1, ags->ctm, order, &ry, ags->wi->sy);
_rect_setup(&state, aRect, sx0, sx0 + cx1, ags->ctm, order, &ry, ags->offset);
if (order)
{
if (ry < sy0)
@ -875,11 +875,11 @@ static BOOL _rect_advance(rect_trace_t *t, int *x0, int *x1)
cy1 = clip_y1;
sp = [ags->ctm pointInMatrixSpace: aRect.origin];
sp.x = floor(sp.x);
sp.y = floor(ags->wi->sy - sp.y);
sp.x = floor(sp.x - ags->offset.x);
sp.y = floor(ags->offset.y - sp.y);
dp = [ctm pointInMatrixSpace: aPoint];
dp.x = floor(dp.x);
dp.y = floor(wi->sy - dp.y);
dp.x = floor(dp.x - offset.x);
dp.y = floor(offset.y - dp.y);
if (dp.x - cx0 > sp.x)
cx0 = dp.x - sp.x;
@ -987,7 +987,7 @@ static BOOL _rect_advance(rect_trace_t *t, int *x0, int *x1)
{
int ry;
int x0, x1;
_rect_setup(&state, aRect, sx0, sx0 + cx1, ags->ctm, order, &ry, ags->wi->sy);
_rect_setup(&state, aRect, sx0, sx0 + cx1, ags->ctm, order, &ry, ags->offset);
if (order)
{
if (ry < sy0)
@ -1254,7 +1254,7 @@ static BOOL _rect_advance(rect_trace_t *t, int *x0, int *x1)
{
int ry;
int x0, x1;
_rect_setup(&state, aRect, cx0, cx0 + cx1, ctm, 0, &ry, wi->sy);
_rect_setup(&state, aRect, cx0, cx0 + cx1, ctm, 0, &ry, offset);
if (ry >= cy0 + cy1)
return;
delta = ry - cy0;

View file

@ -248,10 +248,10 @@ seem to cause edges to be off by a pixel
if (fabs(fy[2] - floor(fy[2] + .5)) < 0.001) fy[2] = floor(fy[2] + .5);
if (fabs(fy[3] - floor(fy[3] + .5)) < 0.001) fy[3] = floor(fy[3] + .5);
x[0] = floor(fx[0]); y[0] = wi->sy - floor(fy[0]);
x[1] = floor(fx[1]); y[1] = wi->sy - floor(fy[1]);
x[2] = floor(fx[2]); y[2] = wi->sy - floor(fy[2]);
x[3] = floor(fx[3]); y[3] = wi->sy - floor(fy[3]);
x[0] = floor(fx[0]) - offset.x; y[0] = offset.y - floor(fy[0]);
x[1] = floor(fx[1]) - offset.x; y[1] = offset.y - floor(fy[1]);
x[2] = floor(fx[2]) - offset.x; y[2] = offset.y - floor(fy[2]);
x[3] = floor(fx[3]) - offset.x; y[3] = offset.y - floor(fy[3]);
tx[0] = 0; ty[0] = ii->height;
tx[1] = ii->width; ty[1] = ii->height;
@ -626,8 +626,8 @@ seem to cause edges to be off by a pixel
else
alpha_dest = NULL;
ox = [matrix transformPoint: NSMakePoint(0, 0)].x;
oy = wi->sy - [matrix transformPoint: NSMakePoint(0, 0)].y - pixelsHigh;
ox = [matrix transformPoint: NSMakePoint(0, 0)].x - offset.x;
oy = offset.y - [matrix transformPoint: NSMakePoint(0, 0)].y - pixelsHigh;
for (y = 0; y < pixelsHigh; y++)
{

View file

@ -413,8 +413,8 @@ within one pixel.) */
matrix[1]=-ctm->matrix.m12;
matrix[2]= ctm->matrix.m21;
matrix[3]=-ctm->matrix.m22;
matrix[4]= ctm->matrix.tX;
matrix[5]=-ctm->matrix.tY + wi->sy;
matrix[4]= ctm->matrix.tX - offset.x;
matrix[5]=-ctm->matrix.tY + offset.y;
/* If the matrix is 'inverted', ie. if the determinant is negative,
we need to flip the order of the vertices. Since it's a rectangle
@ -622,8 +622,8 @@ within one pixel.) */
matrix[1]= 0;
matrix[2]= 0;
matrix[3]=-1;
matrix[4]= 0;
matrix[5]= wi->sy;
matrix[4]= 0 - offset.x;
matrix[5]= offset.y;
bp2 = art_bpath_affine_transform(bpath, matrix);
art_free(bpath);
@ -1295,8 +1295,8 @@ static void clip_svp_callback(void *data, int y, int start,
matrix[1] =-ctm->matrix.m12;
matrix[2] = ctm->matrix.m21;
matrix[3] =-ctm->matrix.m22;
matrix[4] = ctm->matrix.tX;
matrix[5] =-ctm->matrix.tY + wi->sy;
matrix[4] = ctm->matrix.tX - offset.x;
matrix[5] =-ctm->matrix.tY + offset.y;
vp2 = art_vpath_affine_transform(vp, matrix);
art_free(vp);

View file

@ -61,7 +61,7 @@ typedef struct
} rect_trace_t;
static void _rect_setup(rect_trace_t *t, NSRect r, int cx0, int cx1,
NSAffineTransform *ctm, int up, int *y0, int wi_sy)
NSAffineTransform *ctm, int up, int *y0, NSPoint offset)
{
float fx[4], fy[4];
NSPoint p;
@ -91,10 +91,10 @@ static void _rect_setup(rect_trace_t *t, NSRect r, int cx0, int cx1,
if (fabs(fy[2] - floor(fy[2] + .5)) < 0.001) fy[2] = floor(fy[2] + .5);
if (fabs(fy[3] - floor(fy[3] + .5)) < 0.001) fy[3] = floor(fy[3] + .5);
t->x[0] = floor(fx[0]); t->y[0] = wi_sy - floor(fy[0]);
t->x[1] = floor(fx[1]); t->y[1] = wi_sy - floor(fy[1]);
t->x[2] = floor(fx[2]); t->y[2] = wi_sy - floor(fy[2]);
t->x[3] = floor(fx[3]); t->y[3] = wi_sy - floor(fy[3]);
t->x[0] = floor(fx[0]) - offset.x; t->y[0] = offset.y - floor(fy[0]);
t->x[1] = floor(fx[1]) - offset.x; t->y[1] = offset.y - floor(fy[1]);
t->x[2] = floor(fx[2]) - offset.x; t->y[2] = offset.y - floor(fy[2]);
t->x[3] = floor(fx[3]) - offset.x; t->y[3] = offset.y - floor(fy[3]);
/* If we're tracing the 'other way', we just flip the y-coordinates
and unflip when returning them */
@ -628,7 +628,7 @@ static void function_free(function_t *f)
dst=wi->data+wi->bytes_per_line*clip_y0+clip_x0*DI.bytes_per_pixel;
dsta=wi->alpha+wi->sx*clip_y0+clip_x0;
_rect_setup(&rt,rect,clip_x0,clip_x1,matrix,0,&y,wi->sy);
_rect_setup(&rt,rect,clip_x0,clip_x1,matrix,0,&y,offset);
while (y<clip_y0)
{
@ -652,7 +652,7 @@ static void function_free(function_t *f)
r.dst=dst+x0*DI.bytes_per_pixel;
r.dsta=dsta+x0;
p=[inverse transformPoint: NSMakePoint(clip_x0+x0,wi->sy-y)];
p=[inverse transformPoint: NSMakePoint(clip_x0+x0-offset.x,offset.y-y)];
in[0]=p.x;
in[1]=p.y;
@ -695,7 +695,7 @@ static void function_free(function_t *f)
{
if (state)
{
p=[inverse transformPoint: NSMakePoint(clip_x0+x0,wi->sy-y)];
p=[inverse transformPoint: NSMakePoint(clip_x0+x0-offset.x,offset.y-y)];
in[0]=p.x;
in[1]=p.y;
@ -728,7 +728,7 @@ static void function_free(function_t *f)
}
if (state)
{
p=[inverse transformPoint: NSMakePoint(clip_x0+x0,wi->sy-y)];
p=[inverse transformPoint: NSMakePoint(clip_x0+x0-offset.y,offset.y-y)];
in[0]=p.x;
in[1]=p.y;