From 0a186150f085c34462b8c6cd5257849c73f80b65 Mon Sep 17 00:00:00 2001 From: scuri Date: Wed, 2 Dec 2009 20:30:55 +0000 Subject: New: driver SVG. --- src/cd.def | 1 + src/config.mak | 5 ++++- src/lua3/cdluactx.c | 24 ++++++++++++++++++++++++ src/lua5/cdlua5ctx.c | 22 +++++++++++++++++++++- 4 files changed, 50 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/cd.def b/src/cd.def index 61ac5cf..004538b 100644 --- a/src/cd.def +++ b/src/cd.def @@ -15,6 +15,7 @@ EXPORTS cdContextDBufferRGB cdContextPicture cdContextDebug + cdContextSVG cdRedImage cdGreenImage diff --git a/src/config.mak b/src/config.mak index 5465a06..05b5182 100644 --- a/src/config.mak +++ b/src/config.mak @@ -4,6 +4,9 @@ OPT = YES DEFINES = CD_NO_OLD_INTERFACE +SRCSVG = base64.c lodpng.c cdsvg.c +SRCSVG := $(addprefix svg/, $(SRCSVG)) + SRCINTCGM = circle.c ellipse.c intcgm1.c \ intcgm2.c intcgm4.c intcgm6.c list.c \ sism.c tparse.c bparse.c @@ -27,7 +30,7 @@ SRCNULL := $(addprefix drv/, $(SRCNULL)) SRCCOMM = cd.c wd.c wdhdcpy.c rgb2map.c cd_vectortext.c cd_active.c \ cd_attributes.c cd_bitmap.c cd_image.c cd_primitives.c cd_text.c cd_util.c -SRC = $(SRCCOMM) $(SRCINTCGM) $(SRCDRV) $(SRCSIM) +SRC = $(SRCCOMM) $(SRCSVG) $(SRCINTCGM) $(SRCDRV) $(SRCSIM) ifneq ($(findstring Win, $(TEC_SYSNAME)), ) SRC += $(SRCWIN32) diff --git a/src/lua3/cdluactx.c b/src/lua3/cdluactx.c index fc09313..1ddd8e6 100644 --- a/src/lua3/cdluactx.c +++ b/src/lua3/cdluactx.c @@ -24,6 +24,7 @@ #include "cdclipbd.h" #include "cdmf.h" #include "cdps.h" +#include "cdsvg.h" #include "cddbuf.h" #include "cdgdiplus.h" @@ -778,6 +779,28 @@ static cdContextLUA cdluapsctx = 0 }; +/***************************************************************************\ +* CD_SVG. * +\***************************************************************************/ +static void *cdsvg_checkdata(int param) +{ + lua_Object data = lua_getparam(param); + if (!lua_isstring(data)) + lua_error("cdCreateCanvas CD_SVG: data should be of type string!"); + + return lua_getstring(data); +} + +static cdContextLUA cdluasvgctx = +{ + 0, + "CD_SVG", + cdContextSVG, + cdsvg_checkdata, + NULL, + 0 +}; + /***************************************************************************\ * CD_PRINTER. * \***************************************************************************/ @@ -940,6 +963,7 @@ void cdlua_initdrivers(void) cdlua_addcontext(&cdluacgmctx); cdlua_addcontext(&cdluamfctx); cdlua_addcontext(&cdluapsctx); + cdlua_addcontext(&cdluasvgctx); cdlua_addcontext(&cdluaclipboardctx); cdlua_addcontext(&cdluanativewindowctx); cdlua_addcontext(&cdluaprinterctx); diff --git a/src/lua5/cdlua5ctx.c b/src/lua5/cdlua5ctx.c index e3bd19e..4d97f3b 100644 --- a/src/lua5/cdlua5ctx.c +++ b/src/lua5/cdlua5ctx.c @@ -1,5 +1,5 @@ /***************************************************************************\ -* $Id: cdlua5ctx.c,v 1.1 2008/10/17 06:10:42 scuri Exp $ +* $Id: cdlua5ctx.c,v 1.2 2009/12/02 20:31:02 scuri Exp $ * * \***************************************************************************/ @@ -23,6 +23,7 @@ #include "cdclipbd.h" #include "cdmf.h" #include "cdps.h" +#include "cdsvg.h" #include "cddbuf.h" #include "cdgdiplus.h" @@ -687,6 +688,24 @@ static cdluaContext cdluapsctx = 0 }; +/***************************************************************************\ +* CD_SVG. * +\***************************************************************************/ +static void *cdsvg_checkdata( lua_State *L, int param) +{ + return (void *)luaL_checkstring(L, param); +} + +static cdluaContext cdluasvgctx = +{ + 0, + "SVG", + cdContextSVG, + cdsvg_checkdata, + NULL, + 0 +}; + /***************************************************************************\ * CD_PRINTER. * \***************************************************************************/ @@ -793,6 +812,7 @@ void cdlua_initdrivers(lua_State * L, cdluaLuaState* cdL) cdlua_addcontext(L, cdL, &cdluacgmctx); cdlua_addcontext(L, cdL, &cdluamfctx); cdlua_addcontext(L, cdL, &cdluapsctx); + cdlua_addcontext(L, cdL, &cdluasvgctx); cdlua_addcontext(L, cdL, &cdluaclipboardctx); cdlua_addcontext(L, cdL, &cdluanativewindowctx); cdlua_addcontext(L, cdL, &cdluaprinterctx); -- cgit v1.2.3