summaryrefslogtreecommitdiff
path: root/cd/src/xrender
diff options
context:
space:
mode:
Diffstat (limited to 'cd/src/xrender')
-rwxr-xr-xcd/src/xrender/cdxrender.c117
1 files changed, 38 insertions, 79 deletions
diff --git a/cd/src/xrender/cdxrender.c b/cd/src/xrender/cdxrender.c
index 4dc69e2..2f99da3 100755
--- a/cd/src/xrender/cdxrender.c
+++ b/cd/src/xrender/cdxrender.c
@@ -17,7 +17,7 @@
#include "cddbuf.h"
#include "cdimage.h"
#include "cdnative.h"
-#include "truetype.h"
+#include "cd_truetype.h"
#include "sim.h"
#include <X11/Xproto.h>
@@ -196,52 +196,6 @@ static void cdbox(cdCtxCanvas *ctxcanvas, int xmin, int xmax, int ymin, int ymax
cdfSimBox(ctxcanvas, (double)xmin, (double)xmax, (double)ymin, (double)ymax);
}
-static void xrFixAngles(cdCtxCanvas *ctxcanvas, double *angle1, double *angle2)
-{
- if (ctxcanvas->canvas->invert_yaxis)
- {
- double temp = 360 - *angle1;
- *angle1 = 360 - *angle2;
- *angle2 = temp;
- }
-}
-
-static void cdarc(cdCtxCanvas *ctxcanvas, int xc, int yc, int w, int h, double a1, double a2)
-{
- xrFixAngles(ctxcanvas, &a1, &a2);
- cdfSimArc(ctxcanvas, (double)xc, (double)yc, (double)w, (double)h, a1, a2);
-}
-
-static void cdfarc(cdCtxCanvas *ctxcanvas, double xc, double yc, double w, double h, double a1, double a2)
-{
- xrFixAngles(ctxcanvas, &a1, &a2);
- cdfSimArc(ctxcanvas, xc, yc, w, h, a1, a2);
-}
-
-static void cdfsector(cdCtxCanvas *ctxcanvas, double xc, double yc, double w, double h, double a1, double a2)
-{
- xrFixAngles(ctxcanvas, &a1, &a2);
- cdfSimElipse(ctxcanvas, xc, yc, w, h, a1, a2, 1);
-}
-
-static void cdsector(cdCtxCanvas *ctxcanvas, int xc, int yc, int w, int h, double a1, double a2)
-{
- xrFixAngles(ctxcanvas, &a1, &a2);
- cdfSimElipse(ctxcanvas, (double)xc, (double)yc, (double)w, (double)h, a1, a2, 1);
-}
-
-static void cdfchord(cdCtxCanvas *ctxcanvas, double xc, double yc, double w, double h, double a1, double a2)
-{
- xrFixAngles(ctxcanvas, &a1, &a2);
- cdfSimElipse(ctxcanvas, xc, yc, w, h, a1, a2, 0);
-}
-
-static void cdchord(cdCtxCanvas *ctxcanvas, int xc, int yc, int w, int h, double a1, double a2)
-{
- xrFixAngles(ctxcanvas, &a1, &a2);
- cdfSimElipse(ctxcanvas, (double)xc, (double)yc, (double)w, (double)h, a1, a2, 0);
-}
-
static void cdfpoly(cdCtxCanvas* ctxcanvas, int mode, cdfPoint* fpoly, int n)
{
int i;
@@ -254,11 +208,17 @@ static void cdfpoly(cdCtxCanvas* ctxcanvas, int mode, cdfPoint* fpoly, int n)
/* continue */
case CD_OPEN_LINES:
for (i = 0; i< n - 1; i++)
+ {
+ /* because line styles are not supported, this is not a problem */
cdfline(ctxcanvas, fpoly[i].x, fpoly[i].y, fpoly[i+1].x, fpoly[i+1].y);
+ }
break;
case CD_BEZIER:
cdfSimPolyBezier(ctxcanvas->canvas, fpoly, n);
break;
+ case CD_PATH:
+ cdfSimPolyPath(ctxcanvas->canvas, fpoly, n);
+ break;
case CD_FILL:
{
if (ctxcanvas->canvas->new_region)
@@ -327,23 +287,17 @@ static void cdpoly(cdCtxCanvas* ctxcanvas, int mode, cdPoint* poly, int n)
/* continue */
case CD_OPEN_LINES:
for (i = 0; i<n-1; i++)
- cdfline(ctxcanvas, (int)poly[i].x, (int)poly[i].y, (int)poly[i+1].x, (int)poly[i+1].y);
- break;
- case CD_BEZIER:
{
- cdfPoint* fpoly = malloc(sizeof(cdfPoint)*n);
-
- for (i = 0; i<n; i++)
- {
- fpoly[i].x = (double)poly[i].x;
- fpoly[i].y = (double)poly[i].y;
- }
-
- cdfSimPolyBezier(ctxcanvas->canvas, fpoly, n);
-
- free(fpoly);
+ /* because line styles are not supported, this is not a problem */
+ cdfline(ctxcanvas, (double)poly[i].x, (double)poly[i].y, (double)poly[i+1].x, (double)poly[i+1].y);
}
break;
+ case CD_PATH:
+ cdSimPolyPath(ctxcanvas->canvas, poly, n);
+ break;
+ case CD_BEZIER:
+ cdSimPolyBezier(ctxcanvas->canvas, poly, n);
+ break;
case CD_FILL:
{
if (ctxcanvas->canvas->new_region)
@@ -953,11 +907,11 @@ static void cdkillcanvas(cdCtxCanvas *ctxcanvas)
if (ctxcanvas->ctxplus->font)
XftFontClose(ctxcanvas->dpy, ctxcanvas->ctxplus->font);
- XftDrawDestroy(ctxcanvas->ctxplus->draw);
- free(ctxcanvas->ctxplus);
-
/* call original method */
ctxcanvas->ctxplus->cxKillCanvas(ctxcanvas);
+
+ XftDrawDestroy(ctxcanvas->ctxplus->draw);
+ free(ctxcanvas->ctxplus);
}
static void xrInitTable(cdCanvas* canvas)
@@ -978,19 +932,21 @@ static void xrInitTable(cdCanvas* canvas)
canvas->cxPixel = cdpixel;
canvas->cxClear = cdclear;
+
canvas->cxLine = cdline;
- canvas->cxFLine = cdfline;
canvas->cxRect = cdrect;
- canvas->cxFRect = cdfSimRect;
canvas->cxBox = cdbox;
- canvas->cxFBox = cdfSimBox;
- canvas->cxArc = cdarc;
- canvas->cxFArc = cdfarc;
- canvas->cxSector = cdsector;
- canvas->cxFSector = cdfsector;
- canvas->cxChord = cdchord;
- canvas->cxFChord = cdfchord;
+ canvas->cxArc = cdSimArc;
+ canvas->cxSector = cdSimSector;
+ canvas->cxChord = cdSimChord;
canvas->cxPoly = cdpoly;
+
+ canvas->cxFLine = cdfline;
+ canvas->cxFRect = cdfSimRect;
+ canvas->cxFBox = cdfSimBox;
+ canvas->cxFArc = cdfSimArc;
+ canvas->cxFSector = cdfSimSector;
+ canvas->cxFChord = cdfSimChord;
canvas->cxFPoly = cdfpoly;
/* TODO: canvas->cxPutImageRectRGBA = cdputimagerectrgba; */
@@ -1045,13 +1001,13 @@ static void xrCreateCanvasDBUFFER(cdCanvas* canvas, void *data)
{
cdcreatecanvasDBUFFER(canvas, data); /* call original first */
xrCreateContextPlus(canvas->ctxcanvas);
- canvas->ctxcanvas->ctxplus->cxKillCanvas = cdkillcanvasDBUFFER; /* must set it here since CreateContext clears the structure */
}
static void xrInitTableDBUFFER(cdCanvas* canvas)
{
- if (!cdkillcanvasDBUFFER) cdkillcanvasDBUFFER = canvas->cxKillCanvas; /* save original method */
cdinittableDBUFFER(canvas);
+ if (!cdkillcanvasDBUFFER) cdkillcanvasDBUFFER = canvas->cxKillCanvas;
+ canvas->ctxcanvas->ctxplus->cxKillCanvas = cdkillcanvasDBUFFER;
xrInitTable(canvas);
}
@@ -1062,6 +1018,7 @@ cdContext* cdContextDBufferPlus(void)
int old_plus = cdUseContextPlus(0); /* disable context plus */
cdDBufferContext = *cdContextDBuffer(); /* copy original context */
cdDBufferContext.plus = 1; /* mark as plus */
+ cdDBufferContext.caps |= CD_CAP_FPRIMTIVES;
/* save original methods */
cdcreatecanvasDBUFFER = cdDBufferContext.cxCreateCanvas;
@@ -1080,13 +1037,13 @@ static void xrCreateCanvasNATIVE(cdCanvas* canvas, void *data)
{
cdcreatecanvasNATIVE(canvas, data);
xrCreateContextPlus(canvas->ctxcanvas);
- canvas->ctxcanvas->ctxplus->cxKillCanvas = cdkillcanvasNATIVE;
}
static void xrInitTableNATIVE(cdCanvas* canvas)
{
- if (!cdkillcanvasNATIVE) cdkillcanvasNATIVE = canvas->cxKillCanvas;
cdinittableNATIVE(canvas);
+ if (!cdkillcanvasNATIVE) cdkillcanvasNATIVE = canvas->cxKillCanvas;
+ canvas->ctxcanvas->ctxplus->cxKillCanvas = cdkillcanvasNATIVE;
xrInitTable(canvas);
}
@@ -1101,6 +1058,7 @@ cdContext* cdContextNativeWindowPlus(void)
cdNativeWindowContext.cxCreateCanvas = xrCreateCanvasNATIVE;
cdNativeWindowContext.cxInitTable = xrInitTableNATIVE;
cdNativeWindowContext.plus = 1;
+ cdNativeWindowContext.caps |= CD_CAP_FPRIMTIVES;
cdUseContextPlus(old_plus);
}
return &cdNativeWindowContext;
@@ -1110,13 +1068,13 @@ static void xrCreateCanvasIMAGE(cdCanvas* canvas, void *data)
{
cdcreatecanvasIMAGE(canvas, data);
xrCreateContextPlus(canvas->ctxcanvas);
- canvas->ctxcanvas->ctxplus->cxKillCanvas = cdkillcanvasIMAGE;
}
static void xrInitTableIMAGE(cdCanvas* canvas)
{
- if (!cdkillcanvasIMAGE) cdkillcanvasIMAGE = canvas->cxKillCanvas;
cdinittableIMAGE(canvas);
+ if (!cdkillcanvasIMAGE) cdkillcanvasIMAGE = canvas->cxKillCanvas;
+ canvas->ctxcanvas->ctxplus->cxKillCanvas = cdkillcanvasIMAGE;
xrInitTable(canvas);
}
@@ -1131,6 +1089,7 @@ cdContext* cdContextImagePlus(void)
cdImageContext.cxCreateCanvas = xrCreateCanvasIMAGE;
cdImageContext.cxInitTable = xrInitTableIMAGE;
cdImageContext.plus = 1;
+ cdImageContext.caps |= CD_CAP_FPRIMTIVES;
cdUseContextPlus(old_plus);
}
return &cdImageContext;