summaryrefslogtreecommitdiff
path: root/src/drv
diff options
context:
space:
mode:
authorscuri <scuri>2010-05-21 21:54:49 +0000
committerscuri <scuri>2010-05-21 21:54:49 +0000
commit95a0b9f784c2c4eddd86e51eac3a1ae9394cdf49 (patch)
tree2153b840982d2ccdc621a387e0d5110baa5267e0 /src/drv
parentcc487d4de29a48d8e20a9a8492957a5950d5c181 (diff)
*** empty log message ***
Diffstat (limited to 'src/drv')
-rw-r--r--src/drv/cdcgm.c14
-rw-r--r--src/drv/cddebug.c118
-rw-r--r--src/drv/cddgn.c13
-rw-r--r--src/drv/cddxf.c24
-rw-r--r--src/drv/cdirgb.c8
-rw-r--r--src/drv/cdmf.c93
-rw-r--r--src/drv/cdpdf.c3
-rw-r--r--src/drv/cdpicture.c201
8 files changed, 452 insertions, 22 deletions
diff --git a/src/drv/cdcgm.c b/src/drv/cdcgm.c
index ab47c1e..94b1619 100644
--- a/src/drv/cdcgm.c
+++ b/src/drv/cdcgm.c
@@ -566,6 +566,12 @@ static void cdpoly(cdCtxCanvas *ctxcanvas, int mode, cdPoint* poly, int n)
case CD_FILL:
cgm_polygon( ctxcanvas->cgm, n, fpoly);
break;
+ case CD_BEZIER:
+ cdfSimPolyBezier(ctxcanvas->canvas, fpoly, n);
+ break;
+ case CD_PATH:
+ cdfSimPolyPath(ctxcanvas->canvas, fpoly, n);
+ break;
}
free(fpoly);
@@ -595,6 +601,12 @@ static void cdfpoly(cdCtxCanvas *ctxcanvas, int mode, cdfPoint* poly, int n)
case CD_FILL:
cgm_polygon( ctxcanvas->cgm, n, fpoly);
break;
+ case CD_BEZIER:
+ cdfSimPolyBezier(ctxcanvas->canvas, fpoly, n);
+ break;
+ case CD_PATH:
+ cdfSimPolyPath(ctxcanvas->canvas, fpoly, n);
+ break;
}
}
@@ -1122,7 +1134,7 @@ static cdContext cdCGMContext =
CD_CAP_LINECAP | CD_CAP_LINEJOIN | CD_CAP_REGION | CD_CAP_CHORD |
CD_CAP_FONTDIM | CD_CAP_TEXTSIZE |
CD_CAP_IMAGERGBA | CD_CAP_GETIMAGERGB |
- CD_CAP_TEXTORIENTATION),
+ CD_CAP_TEXTORIENTATION | CD_CAP_PATH | CD_CAP_BEZIER),
0,
cdcreatecanvas,
cdinittable,
diff --git a/src/drv/cddebug.c b/src/drv/cddebug.c
index 0c5fd0d..bd91209 100644
--- a/src/drv/cddebug.c
+++ b/src/drv/cddebug.c
@@ -27,6 +27,7 @@
#define CDDBG_BEGIN "Begin"
#define CDDBG_VERTEX "Vertex"
#define CDDBG_END "End"
+#define CDDBG_PATHSET "PathSet"
#define CDDBG_MARK "Mark"
#define CDDBG_BACKOPACITY "BackOpacity"
#define CDDBG_WRITEMODE "WriteMode"
@@ -236,7 +237,8 @@ static void cdpoly(cdCtxCanvas *ctxcanvas, int mode, cdPoint* poly, int n)
"CD_CLOSED_LINES",
"CD_CLIP",
"CD_BEZIER",
- "CD_REGION"
+ "CD_REGION",
+ "CD_PATH"
};
if (mode == CD_FILL && ctxcanvas->canvas->fill_mode != ctxcanvas->last_fill_mode)
@@ -254,8 +256,61 @@ static void cdpoly(cdCtxCanvas *ctxcanvas, int mode, cdPoint* poly, int n)
else
fprintf(ctxcanvas->file, "%s(%s)\n", CDDBG_BEGIN, enum2str[mode]);
- for(i = 0; i<n; i++)
- fprintf(ctxcanvas->file, "%s(%d, %d)\n", CDDBG_VERTEX, poly[i].x, poly[i].y);
+ if (mode == CD_PATH)
+ {
+ const char* path2str[] = {
+ "CD_PATH_NEW",
+ "CD_PATH_MOVETO",
+ "CD_PATH_LINETO",
+ "CD_PATH_ARC",
+ "CD_PATH_CURVETO",
+ "CD_PATH_CLOSE",
+ "CD_PATH_FILL",
+ "CD_PATH_STROKE",
+ "CD_PATH_FILLSTROKE",
+ "CD_PATH_CLIP"
+ };
+ int p;
+
+ i = 0;
+ for (p=0; p<ctxcanvas->canvas->path_n; p++)
+ {
+ fprintf(ctxcanvas->file, "%s(%s)\n", CDDBG_PATHSET, path2str[ctxcanvas->canvas->path[p]]);
+
+ switch(ctxcanvas->canvas->path[p])
+ {
+ case CD_PATH_MOVETO:
+ case CD_PATH_LINETO:
+ if (i+1 > n)
+ {
+ fprintf(ctxcanvas->file, "ERROR: not enough points in path\n");
+ return;
+ }
+ fprintf(ctxcanvas->file, "%s(%d, %d)\n", CDDBG_VERTEX, poly[i].x, poly[i].y);
+ i++;
+ break;
+ case CD_PATH_CURVETO:
+ case CD_PATH_ARC:
+ {
+ if (i+3 > n)
+ {
+ fprintf(ctxcanvas->file, "ERROR: not enough points in path\n");
+ return;
+ }
+ fprintf(ctxcanvas->file, "%s(%d, %d)\n", CDDBG_VERTEX, poly[i].x, poly[i].y);
+ fprintf(ctxcanvas->file, "%s(%d, %d)\n", CDDBG_VERTEX, poly[i+1].x, poly[i+1].y);
+ fprintf(ctxcanvas->file, "%s(%d, %d)\n", CDDBG_VERTEX, poly[i+2].x, poly[i+2].y);
+ i += 3;
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ for(i = 0; i<n; i++)
+ fprintf(ctxcanvas->file, "%s(%d, %d)\n", CDDBG_VERTEX, poly[i].x, poly[i].y);
+ }
fprintf(ctxcanvas->file, "%s()\n", CDDBG_END);
}
@@ -284,8 +339,61 @@ static void cdfpoly(cdCtxCanvas *ctxcanvas, int mode, cdfPoint* poly, int n)
fprintf(ctxcanvas->file, "%s(%s)\n", CDDBG_BEGIN, enum2str[mode]);
- for(i = 0; i<n; i++)
- fprintf(ctxcanvas->file, "%s(%g, %g)\n", CDDBG_FVERTEX, poly[i].x, poly[i].y);
+ if (mode == CD_PATH)
+ {
+ const char* path2str[] = {
+ "CD_PATH_NEW",
+ "CD_PATH_MOVETO",
+ "CD_PATH_LINETO",
+ "CD_PATH_ARC",
+ "CD_PATH_CURVETO",
+ "CD_PATH_CLOSE",
+ "CD_PATH_FILL",
+ "CD_PATH_STROKE",
+ "CD_PATH_FILLSTROKE",
+ "CD_PATH_CLIP"
+ };
+ int p;
+
+ i = 0;
+ for (p=0; p<ctxcanvas->canvas->path_n; p++)
+ {
+ fprintf(ctxcanvas->file, "%s(%s)\n", CDDBG_PATHSET, path2str[ctxcanvas->canvas->path[p]]);
+
+ switch(ctxcanvas->canvas->path[p])
+ {
+ case CD_PATH_MOVETO:
+ case CD_PATH_LINETO:
+ if (i+1 > n)
+ {
+ fprintf(ctxcanvas->file, "ERROR: not enough points in path\n");
+ return;
+ }
+ fprintf(ctxcanvas->file, "%s(%g, %g)\n", CDDBG_VERTEX, poly[i].x, poly[i].y);
+ i++;
+ break;
+ case CD_PATH_CURVETO:
+ case CD_PATH_ARC:
+ {
+ if (i+3 > n)
+ {
+ fprintf(ctxcanvas->file, "ERROR: not enough points in path\n");
+ return;
+ }
+ fprintf(ctxcanvas->file, "%s(%g, %g)\n", CDDBG_VERTEX, poly[i].x, poly[i].y);
+ fprintf(ctxcanvas->file, "%s(%g, %g)\n", CDDBG_VERTEX, poly[i+1].x, poly[i+1].y);
+ fprintf(ctxcanvas->file, "%s(%g, %g)\n", CDDBG_VERTEX, poly[i+2].x, poly[i+2].y);
+ i += 3;
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ for(i = 0; i<n; i++)
+ fprintf(ctxcanvas->file, "%s(%g, %g)\n", CDDBG_FVERTEX, poly[i].x, poly[i].y);
+ }
fprintf(ctxcanvas->file, "%s()\n", CDDBG_END);
}
diff --git a/src/drv/cddgn.c b/src/drv/cddgn.c
index d7dd5f9..dd049fd 100644
--- a/src/drv/cddgn.c
+++ b/src/drv/cddgn.c
@@ -1066,6 +1066,17 @@ static void cdpoly(cdCtxCanvas* ctxcanvas, int mode, cdPoint* poly, int n)
{
short is_fill=0;
+ if (mode == CD_BEZIER)
+ {
+ cdSimPolyBezier(ctxcanvas->canvas, poly, n);
+ return;
+ }
+ if (mode == CD_PATH)
+ {
+ cdSimPolyPath(ctxcanvas->canvas, poly, n);
+ return;
+ }
+
if(mode == CD_FILL && ctxcanvas->fill_type == NOFILL)
mode = CD_CLOSED_LINES;
@@ -1667,7 +1678,7 @@ static void cdinittable(cdCanvas* canvas)
static cdContext cdDGNContext =
{
- CD_CAP_ALL & ~(CD_CAP_CLEAR | CD_CAP_PLAY |
+ CD_CAP_ALL & ~(CD_CAP_CLEAR | CD_CAP_PLAY | CD_CAP_PATH | CD_CAP_BEZIER |
CD_CAP_IMAGERGBA | CD_CAP_GETIMAGERGB |
CD_CAP_CLIPAREA | CD_CAP_CLIPPOLY | CD_CAP_RECT |
CD_CAP_LINECAP | CD_CAP_LINEJOIN | CD_CAP_REGION | CD_CAP_CHORD |
diff --git a/src/drv/cddxf.c b/src/drv/cddxf.c
index 9f67ef4..f8c9a28 100644
--- a/src/drv/cddxf.c
+++ b/src/drv/cddxf.c
@@ -441,6 +441,17 @@ static void cdflush (cdCtxCanvas *ctxcanvas)
/*==========================================================================*/
static void cdpoly(cdCtxCanvas *ctxcanvas, int mode, cdPoint* poly, int n)
{
+ if (mode == CD_BEZIER)
+ {
+ cdSimPolyBezier(ctxcanvas->canvas, poly, n);
+ return;
+ }
+ if (mode == CD_PATH)
+ {
+ cdSimPolyPath(ctxcanvas->canvas, poly, n);
+ return;
+ }
+
if (mode == CD_CLOSED_LINES || mode == CD_FILL)
{
poly[n].x = poly[0].x;
@@ -501,6 +512,17 @@ static void cdbox(cdCtxCanvas *ctxcanvas, int xmin, int xmax, int ymin, int ymax
static void cdfpoly(cdCtxCanvas *ctxcanvas, int mode, cdfPoint* poly, int n)
{
+ if (mode == CD_BEZIER)
+ {
+ cdfSimPolyBezier(ctxcanvas->canvas, poly, n);
+ return;
+ }
+ if (mode == CD_PATH)
+ {
+ cdfSimPolyPath(ctxcanvas->canvas, poly, n);
+ return;
+ }
+
if (mode == CD_CLOSED_LINES || mode == CD_FILL)
{
poly[n].x = poly[0].x;
@@ -1331,7 +1353,7 @@ static void cdinittable(cdCanvas* canvas)
static cdContext cdDXFContext =
{
CD_CAP_ALL & ~(CD_CAP_CLEAR | CD_CAP_PLAY | CD_CAP_PALETTE |
- CD_CAP_CLIPAREA | CD_CAP_CLIPPOLY |
+ CD_CAP_CLIPAREA | CD_CAP_CLIPPOLY | CD_CAP_PATH | CD_CAP_BEZIER |
CD_CAP_LINECAP | CD_CAP_LINEJOIN | CD_CAP_REGION | CD_CAP_CHORD |
CD_CAP_IMAGERGB | CD_CAP_IMAGEMAP | CD_CAP_IMAGESRV |
CD_CAP_BACKGROUND | CD_CAP_BACKOPACITY | CD_CAP_WRITEMODE |
diff --git a/src/drv/cdirgb.c b/src/drv/cdirgb.c
index f0eb98e..3caeb3c 100644
--- a/src/drv/cdirgb.c
+++ b/src/drv/cdirgb.c
@@ -1956,8 +1956,8 @@ static void cdinittable(cdCanvas* canvas)
static cdContext cdImageRGBContext =
{
CD_CAP_ALL & ~(CD_CAP_FLUSH | CD_CAP_PLAY | CD_CAP_FPRIMTIVES |
- CD_CAP_LINECAP | CD_CAP_LINEJOIN | CD_CAP_REGION |
- CD_CAP_PALETTE | CD_CAP_TEXTORIENTATION),
+ CD_CAP_LINECAP | CD_CAP_LINEJOIN |
+ CD_CAP_PALETTE ),
0,
cdcreatecanvas,
cdinittable,
@@ -2074,8 +2074,8 @@ static void cdinittableDB(cdCanvas* canvas)
static cdContext cdDBufferRGBContext =
{
CD_CAP_ALL & ~(CD_CAP_PLAY | CD_CAP_FPRIMTIVES |
- CD_CAP_LINECAP | CD_CAP_LINEJOIN | CD_CAP_REGION |
- CD_CAP_PALETTE | CD_CAP_TEXTORIENTATION),
+ CD_CAP_LINECAP | CD_CAP_LINEJOIN |
+ CD_CAP_PALETTE ),
0,
cdcreatecanvasDB,
cdinittableDB,
diff --git a/src/drv/cdmf.c b/src/drv/cdmf.c
index 727fcac..ddb109c 100644
--- a/src/drv/cdmf.c
+++ b/src/drv/cdmf.c
@@ -96,7 +96,8 @@ enum
CDMF_FCHORD, /* 72 */
CDMF_FCLIPAREA, /* 73 */
CDMF_FONT, /* 74 */
- CDMF_RESETMATRIX /* 75 */
+ CDMF_RESETMATRIX, /* 75 */
+ CDMF_PATHSET /* 76 */
};
struct _cdCtxCanvas
@@ -242,8 +243,49 @@ static void cdpoly(cdCtxCanvas *ctxcanvas, int mode, cdPoint* poly, int n)
fprintf(ctxcanvas->file, "%d %d\n", CDMF_BEGIN, mode);
- for(i = 0; i<n; i++)
- fprintf(ctxcanvas->file, "%d %d %d\n", CDMF_VERTEX, poly[i].x, poly[i].y);
+ if (mode == CD_PATH)
+ {
+ int p;
+
+ i = 0;
+ for (p=0; p<ctxcanvas->canvas->path_n; p++)
+ {
+ fprintf(ctxcanvas->file, "%d %d\n", CDMF_PATHSET, ctxcanvas->canvas->path[p]);
+
+ switch(ctxcanvas->canvas->path[p])
+ {
+ case CD_PATH_MOVETO:
+ case CD_PATH_LINETO:
+ if (i+1 > n)
+ {
+ fprintf(ctxcanvas->file, "ERROR: not enough points in path\n");
+ return;
+ }
+ fprintf(ctxcanvas->file, "%d %d %d\n", CDMF_VERTEX, poly[i].x, poly[i].y);
+ i++;
+ break;
+ case CD_PATH_CURVETO:
+ case CD_PATH_ARC:
+ {
+ if (i+3 > n)
+ {
+ fprintf(ctxcanvas->file, "ERROR: not enough points in path\n");
+ return;
+ }
+ fprintf(ctxcanvas->file, "%d %d %d\n", CDMF_VERTEX, poly[i].x, poly[i].y);
+ fprintf(ctxcanvas->file, "%d %d %d\n", CDMF_VERTEX, poly[i+1].x, poly[i+1].y);
+ fprintf(ctxcanvas->file, "%d %d %d\n", CDMF_VERTEX, poly[i+2].x, poly[i+2].y);
+ i += 3;
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ for(i = 0; i<n; i++)
+ fprintf(ctxcanvas->file, "%d %d %d\n", CDMF_VERTEX, poly[i].x, poly[i].y);
+ }
fprintf(ctxcanvas->file, "%d\n", CDMF_END);
}
@@ -260,8 +302,49 @@ static void cdfpoly(cdCtxCanvas *ctxcanvas, int mode, cdfPoint* poly, int n)
fprintf(ctxcanvas->file, "%d %d\n", CDMF_BEGIN, mode);
- for(i = 0; i<n; i++)
- fprintf(ctxcanvas->file, "%d %g %g\n", CDMF_FVERTEX, poly[i].x, poly[i].y);
+ if (mode == CD_PATH)
+ {
+ int p;
+
+ i = 0;
+ for (p=0; p<ctxcanvas->canvas->path_n; p++)
+ {
+ fprintf(ctxcanvas->file, "%d %d\n", CDMF_PATHSET, ctxcanvas->canvas->path[p]);
+
+ switch(ctxcanvas->canvas->path[p])
+ {
+ case CD_PATH_MOVETO:
+ case CD_PATH_LINETO:
+ if (i+1 > n)
+ {
+ fprintf(ctxcanvas->file, "ERROR: not enough points in path\n");
+ return;
+ }
+ fprintf(ctxcanvas->file, "%d %g %g\n", CDMF_FVERTEX, poly[i].x, poly[i].y);
+ i++;
+ break;
+ case CD_PATH_CURVETO:
+ case CD_PATH_ARC:
+ {
+ if (i+3 > n)
+ {
+ fprintf(ctxcanvas->file, "ERROR: not enough points in path\n");
+ return;
+ }
+ fprintf(ctxcanvas->file, "%d %g %g\n", CDMF_FVERTEX, poly[i].x, poly[i].y);
+ fprintf(ctxcanvas->file, "%d %g %g\n", CDMF_FVERTEX, poly[i+1].x, poly[i+1].y);
+ fprintf(ctxcanvas->file, "%d %g %g\n", CDMF_FVERTEX, poly[i+2].x, poly[i+2].y);
+ i += 3;
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ for(i = 0; i<n; i++)
+ fprintf(ctxcanvas->file, "%d %g %g\n", CDMF_FVERTEX, poly[i].x, poly[i].y);
+ }
fprintf(ctxcanvas->file, "%d\n", CDMF_END);
}
diff --git a/src/drv/cdpdf.c b/src/drv/cdpdf.c
index eb9371f..4614568 100644
--- a/src/drv/cdpdf.c
+++ b/src/drv/cdpdf.c
@@ -1684,8 +1684,7 @@ static cdContext cdPDFContext =
{
CD_CAP_ALL & ~(CD_CAP_CLEAR | CD_CAP_PLAY | CD_CAP_PALETTE |
CD_CAP_REGION | CD_CAP_IMAGESRV | CD_CAP_TEXTSIZE |
- CD_CAP_BACKGROUND | CD_CAP_BACKOPACITY | CD_CAP_WRITEMODE |
- CD_CAP_GETIMAGERGB),
+ CD_CAP_WRITEMODE | CD_CAP_GETIMAGERGB),
0,
cdcreatecanvas,
cdinittable,
diff --git a/src/drv/cdpicture.c b/src/drv/cdpicture.c
index a5533b2..c77f042 100644
--- a/src/drv/cdpicture.c
+++ b/src/drv/cdpicture.c
@@ -27,6 +27,7 @@ typedef enum _tPrim
CDPIC_CHORD,
CDPIC_TEXT,
CDPIC_POLY,
+ CDPIC_PATH,
CDPIC_FLINE,
CDPIC_FRECT,
CDPIC_FBOX,
@@ -35,6 +36,7 @@ typedef enum _tPrim
CDPIC_FCHORD,
CDPIC_FTEXT,
CDPIC_FPOLY,
+ CDPIC_FPATH,
CDPIC_PIXEL,
CDPIC_IMAGEMAP,
CDPIC_IMAGERGB,
@@ -109,6 +111,24 @@ typedef struct _tfPoly
cdfPoint* points;
} tfPoly; /* Begin, Vertex and End */
+typedef struct _tPath
+{
+ int fill;
+ int n;
+ cdPoint* points;
+ int path_n;
+ int *path;
+} tPath; /* Begin, PathSet, Vertex and End */
+
+typedef struct _tfPath
+{
+ int fill;
+ int n;
+ cdfPoint* points;
+ int path_n;
+ int *path;
+} tfPath; /* Begin, PathSet, Vertex and End */
+
typedef struct _tText
{
int x, y;
@@ -156,6 +176,8 @@ typedef struct _tPrimNode
tfASC arcsectorchordf;
tPoly poly;
tfPoly polyf;
+ tPath path;
+ tfPath pathf;
tText text;
tfText textf;
tPixel pixel;
@@ -608,16 +630,72 @@ static void cdftext(cdCtxCanvas *ctxcanvas, double x, double y, const char *text
picUpdateBBox(ctxcanvas, xmax, ymax, 0);
}
+static void cdpath(cdCtxCanvas *ctxcanvas, cdPoint* poly, int n)
+{
+ int i, p, fill = -1;
+ tPrimNode *prim;
+
+ for (p=0; p<ctxcanvas->canvas->path_n; p++)
+ {
+ if (ctxcanvas->canvas->path[p] == CD_PATH_CLIP)
+ return;
+ else if (ctxcanvas->canvas->path[p] == CD_PATH_FILL ||
+ ctxcanvas->canvas->path[p] == CD_PATH_FILLSTROKE) /* no support for both in cdPicture */
+ {
+ fill = 1;
+ break;
+ }
+ else if (ctxcanvas->canvas->path[p] == CD_PATH_STROKE)
+ {
+ fill = -1;
+ break;
+ }
+ }
+
+ if (fill == -1)
+ return;
+
+ prim = primCreate(CDPIC_PATH);
+ prim->param.path.fill = fill;
+
+ if (fill)
+ primAddAttrib_Fill(prim, ctxcanvas->canvas);
+ else
+ primAddAttrib_Line(prim, ctxcanvas->canvas);
+
+ prim->param_buffer = malloc(n * sizeof(cdPoint) + ctxcanvas->canvas->path_n * sizeof(int));
+
+ prim->param.path.n = n;
+ prim->param.path.points = (cdPoint*)prim->param_buffer;
+ memcpy(prim->param.path.points, poly, n * sizeof(cdPoint));
+ prim->param.path.path = (int*)((unsigned char*)prim->param_buffer + n * sizeof(cdPoint));
+ memcpy(prim->param.path.path, ctxcanvas->canvas->path, ctxcanvas->canvas->path_n * sizeof(int));
+ prim->param.path.path_n = ctxcanvas->canvas->path_n;
+
+ picAddPrim(ctxcanvas, prim);
+
+ for (i = 0; i < n; i++)
+ {
+ picUpdateBBox(ctxcanvas, poly[i].x, poly[i].y, 0);
+ }
+}
+
static void cdpoly(cdCtxCanvas *ctxcanvas, int mode, cdPoint* poly, int n)
{
int i;
tPrimNode *prim;
if (mode == CD_CLIP || mode == CD_REGION) return;
+ if (mode == CD_PATH)
+ {
+ cdpath(ctxcanvas, poly, n);
+ return;
+ }
prim = primCreate(CDPIC_POLY);
if (mode == CD_FILL)
primAddAttrib_Fill(prim, ctxcanvas->canvas);
else
primAddAttrib_Line(prim, ctxcanvas->canvas);
+ prim->param.poly.mode = mode;
prim->param.poly.n = n;
prim->param.poly.points = malloc(n * sizeof(cdPoint));
memcpy(prim->param.poly.points, poly, n * sizeof(cdPoint));
@@ -633,6 +711,56 @@ static void cdpoly(cdCtxCanvas *ctxcanvas, int mode, cdPoint* poly, int n)
}
}
+static void cdfpath(cdCtxCanvas *ctxcanvas, cdfPoint* poly, int n)
+{
+ int i, p, fill = -1;
+ tPrimNode *prim;
+
+ for (p=0; p<ctxcanvas->canvas->path_n; p++)
+ {
+ if (ctxcanvas->canvas->path[p] == CD_PATH_CLIP)
+ return;
+ else if (ctxcanvas->canvas->path[p] == CD_PATH_FILL ||
+ ctxcanvas->canvas->path[p] == CD_PATH_FILLSTROKE) /* no support for both in cdPicture */
+ {
+ fill = 1;
+ break;
+ }
+ else if (ctxcanvas->canvas->path[p] == CD_PATH_STROKE)
+ {
+ fill = -1;
+ break;
+ }
+ }
+
+ if (fill == -1)
+ return;
+
+ prim = primCreate(CDPIC_FPATH);
+ prim->param.pathf.fill = fill;
+
+ if (fill)
+ primAddAttrib_Fill(prim, ctxcanvas->canvas);
+ else
+ primAddAttrib_Line(prim, ctxcanvas->canvas);
+
+ prim->param_buffer = malloc(n * sizeof(cdfPoint) + ctxcanvas->canvas->path_n * sizeof(int));
+
+ prim->param.pathf.n = n;
+ prim->param.pathf.points = (cdfPoint*)prim->param_buffer;
+ memcpy(prim->param.pathf.points, poly, n * sizeof(cdfPoint));
+ prim->param.pathf.path = (int*)((unsigned char*)prim->param_buffer + n * sizeof(cdfPoint));
+ memcpy(prim->param.pathf.path, ctxcanvas->canvas->path, ctxcanvas->canvas->path_n * sizeof(int));
+ prim->param.pathf.path_n = ctxcanvas->canvas->path_n;
+
+ picAddPrim(ctxcanvas, prim);
+
+ for (i = 0; i < n; i++)
+ {
+ picUpdateBBox(ctxcanvas, _cdRound(poly[i].x), _cdRound(poly[i].y), 0);
+ }
+}
+
static void cdfpoly(cdCtxCanvas *ctxcanvas, int mode, cdfPoint* poly, int n)
{
int i;
@@ -643,9 +771,10 @@ static void cdfpoly(cdCtxCanvas *ctxcanvas, int mode, cdfPoint* poly, int n)
primAddAttrib_Fill(prim, ctxcanvas->canvas);
else
primAddAttrib_Line(prim, ctxcanvas->canvas);
+ prim->param.polyf.mode = mode;
prim->param.polyf.n = n;
- prim->param.polyf.points = malloc(n * sizeof(cdPoint));
- memcpy(prim->param.polyf.points, poly, n * sizeof(cdPoint));
+ prim->param.polyf.points = malloc(n * sizeof(cdfPoint));
+ memcpy(prim->param.polyf.points, poly, n * sizeof(cdfPoint));
prim->param_buffer = prim->param.polyf.points;
picAddPrim(ctxcanvas, prim);
@@ -843,7 +972,7 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void
tPrimNode *prim;
cdCanvas* pic_canvas = (cdCanvas*)data;
cdCtxCanvas* ctxcanvas = pic_canvas->ctxcanvas;
- int p, i, scale = 0,
+ int p, i, n, scale = 0,
pic_xmin = ctxcanvas->xmin,
pic_ymin = ctxcanvas->ymin;
double factorX = 1, factorY = 1;
@@ -949,6 +1078,72 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void
cdfCanvasVertex(canvas, sfScaleX(prim->param.polyf.points[p].x), sfScaleY(prim->param.polyf.points[p].y));
cdCanvasEnd(canvas);
break;
+ case CDPIC_PATH:
+ if (prim->param.path.fill)
+ primUpdateAttrib_Fill(prim, canvas);
+ else
+ primUpdateAttrib_Line(prim, canvas);
+ cdCanvasBegin(canvas, CD_PATH);
+ n = 0;
+ for (p=0; p<prim->param.path.path_n; p++)
+ {
+ cdCanvasPathSet(canvas, prim->param.path.path[p]);
+
+ switch(prim->param.path.path[p])
+ {
+ case CD_PATH_MOVETO:
+ case CD_PATH_LINETO:
+ if (n+1 > n) break;
+ cdCanvasVertex(canvas, sScaleX(prim->param.path.points[n].x), sScaleY(prim->param.path.points[n].y));
+ n++;
+ break;
+ case CD_PATH_CURVETO:
+ case CD_PATH_ARC:
+ {
+ if (n+3 > n) break;
+ cdCanvasVertex(canvas, sScaleX(prim->param.path.points[n].x), sScaleY(prim->param.path.points[n].y));
+ cdCanvasVertex(canvas, sScaleX(prim->param.path.points[n+1].x), sScaleY(prim->param.path.points[n+1].y));
+ cdCanvasVertex(canvas, sScaleX(prim->param.path.points[n+2].x), sScaleY(prim->param.path.points[n+2].y));
+ n += 3;
+ }
+ break;
+ }
+ }
+ cdCanvasEnd(canvas);
+ break;
+ case CDPIC_FPATH:
+ if (prim->param.path.fill)
+ primUpdateAttrib_Fill(prim, canvas);
+ else
+ primUpdateAttrib_Line(prim, canvas);
+ cdCanvasBegin(canvas, CD_PATH);
+ n = 0;
+ for (p=0; p<prim->param.pathf.path_n; p++)
+ {
+ cdCanvasPathSet(canvas, prim->param.pathf.path[p]);
+
+ switch(prim->param.pathf.path[p])
+ {
+ case CD_PATH_MOVETO:
+ case CD_PATH_LINETO:
+ if (n+1 > n) break;
+ cdfCanvasVertex(canvas, sfScaleX(prim->param.pathf.points[n].x), sfScaleY(prim->param.pathf.points[n].y));
+ n++;
+ break;
+ case CD_PATH_CURVETO:
+ case CD_PATH_ARC:
+ {
+ if (n+3 > n) break;
+ cdfCanvasVertex(canvas, sfScaleX(prim->param.pathf.points[n].x), sfScaleY(prim->param.pathf.points[n].y));
+ cdfCanvasVertex(canvas, sfScaleX(prim->param.pathf.points[n+1].x), sfScaleY(prim->param.pathf.points[n+1].y));
+ cdfCanvasVertex(canvas, sfScaleX(prim->param.pathf.points[n+2].x), sfScaleY(prim->param.pathf.points[n+2].y));
+ n += 3;
+ }
+ break;
+ }
+ }
+ cdCanvasEnd(canvas);
+ break;
case CDPIC_IMAGERGB:
cdCanvasPutImageRectRGB(canvas, prim->param.imagergba.iw, prim->param.imagergba.ih, prim->param.imagergba.r, prim->param.imagergba.g, prim->param.imagergba.b, sScaleX(prim->param.imagergba.x), sScaleY(prim->param.imagergba.y), sScaleW(prim->param.imagergba.w), sScaleH(prim->param.imagergba.h), 0, 0, 0, 0);
break;