Rename job-surface to job->context.
Add job->imagedata.
setColorScheme (agget (g, "colorscheme"));
setup_page(job, g);
gvrender_begin_page(job);
+ gvdevice_prepare(job);
gvrender_set_pencolor(job, DEFAULT_COLOR);
gvrender_set_fillcolor(job, DEFAULT_FILL);
gvrender_set_font(job, gvc->defaultfontname, gvc->defaultfontsize);
gvrender_end_anchor(job);
// if (boxf_overlap(job->clip, job->pageBox))
emit_view(job,g,flags);
+ gvdevice_format(job);
gvrender_end_page(job);
}
emit_graph(job, g); /* FIXME? - this should be a special case of finalize() */
/* Flush is necessary because we may be writing to a pipe. */
- if (job->output_file && ! job->external_surface && job->output_lang != TK)
+ if (job->output_file && ! job->external_context && job->output_lang != TK)
fflush(job->output_file);
}
void *display;
int screen;
- void *surface; /* gd or cairo surface */
- boolean external_surface; /* surface belongs to caller */
+ void *context; /* gd or cairo surface */
+ boolean external_context; /* context belongs to caller */
+ unsigned char *imagedata; /* location of imagedata */
int flags; /* emit_graph flags */
/* device */
extern void gvdevice_initialize(GVJ_t * job);
+ extern void gvdevice_prepare(GVJ_t * job);
+ extern void gvdevice_format(GVJ_t * job);
extern void gvdevice_finalize(GVJ_t * job);
/* render */
{
gvdevice_engine_t *gvde = firstjob->device.engine;
- if (gvde) {
- if (gvde->initialize) {
- gvde->initialize(firstjob);
- }
- }
+ if (gvde && gvde->initialize)
+ gvde->initialize(firstjob);
+}
+
+void gvdevice_prepare(GVJ_t * job)
+{
+ gvdevice_engine_t *gvde = job->device.engine;
+
+ if (gvde && gvde->prepare)
+ gvde->prepare(job);
+}
+
+void gvdevice_format(GVJ_t * job)
+{
+ gvdevice_engine_t *gvde = job->device.engine;
+
+ if (gvde && gvde->format)
+ gvde->format(job);
}
void gvdevice_finalize(GVJ_t * firstjob)
for (job = firstjob; job; job = job->next_active) {
if (job->output_filename
&& job->output_file != stdout
- && ! job->external_surface) {
+ && ! job->external_context) {
if (job->output_file) {
fclose(job->output_file);
job->output_file = NULL;
struct gvdevice_engine_s {
void (*initialize) (GVJ_t * firstjob);
- void (*format) (GVJ_t * firstjob, unsigned int width, unsigned int height, unsigned char *data);
+ void (*prepare) (GVJ_t * firstjob);
+ void (*format) (GVJ_t * firstjob);
void (*finalize) (GVJ_t * firstjob);
};
}
}
-static void devil_format(GVJ_t * job, unsigned int width, unsigned int height, unsigned char *data)
+static void devil_format(GVJ_t * job)
{
ILuint ImgId;
ILenum Error;
// Bind this image name.
ilBindImage(ImgId);
- Y_inv ( width, height, data );
+ Y_inv ( job->width, job->height, job->imagedata );
- rc = ilTexImage( width, height,
+ rc = ilTexImage( job->width, job->height,
1, // Depth
4, // Bpp
IL_BGRA, // Format
IL_UNSIGNED_BYTE,// Type
- data);
+ job->imagedata);
#if 1
ilSaveF(job->device.id, job->output_file);
}
static gvdevice_engine_t devil_engine = {
+ NULL,
NULL,
devil_format,
NULL,
FORMAT_XBM,
} format_type;
-static void gd_format(GVJ_t * job, unsigned int width, unsigned int height, unsigned char *data)
+static void gd_format(GVJ_t * job)
{
gdImagePtr im;
- unsigned int x, y, *intdata, color, alpha;
+ unsigned int x, y, color, alpha;
+ unsigned int *data = (unsigned int*)(job->imagedata);
+ unsigned int width = job->width;
+ unsigned int height = job->height;
#ifdef HAVE_SETMODE
#ifdef O_BINARY
#endif
#endif
- intdata = (unsigned int*)data;
im = gdImageCreateTrueColor(width, height);
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
- color = *intdata++;
+ color = *data++;
/* gd's max alpha is 127 */
if ((alpha = (color >> 25) & 0x7f))
/* gd's alpha is transparency instead of opacity */
}
static gvdevice_engine_t gd_engine = {
+ NULL,
NULL,
gd_format,
NULL,
static void gd_loadimage_gd(GVJ_t * job, usershape_t *us, boxf b, boolean filled)
{
- gdImagePtr im3, im2 = NULL, im = (gdImagePtr) job->surface;
+ gdImagePtr im3, im2 = NULL, im = (gdImagePtr) job->context;
if ((im2 = gd_loadimage(job, us))) {
if (job->rotation) {
static void gdgen_resolve_color(GVJ_t * job, gvcolor_t * color)
{
- gdImagePtr im = (gdImagePtr) job->surface;
+ gdImagePtr im = (gdImagePtr) job->context;
int alpha;
if (!im)
if (GD_has_images(job->gvc->g))
truecolor_p = TRUE; /* force truecolor */
- if (job->external_surface) {
+ if (job->external_context) {
if (job->common->verbose)
fprintf(stderr, "%s: using existing GD image\n", job->common->cmdname);
- im = (gdImagePtr) (job->surface);
+ im = (gdImagePtr) (job->context);
} else {
if (truecolor_p) {
if (job->common->verbose)
job->common->cmdname, ROUND(job->width * job->height / 1024.));
im = gdImageCreate(job->width, job->height);
}
- job->surface = (void *) im;
+ job->context = (void *) im;
}
if (!im) {
static void gdgen_end_page(GVJ_t * job)
{
- gdImagePtr im = (gdImagePtr) job->surface;
+ gdImagePtr im = (gdImagePtr) job->context;
if (!im)
return;
- if (job->external_surface) {
+ if (job->external_context) {
/* leave image in memory to be handled by Gdtclft output routines */
#ifdef MYTRACE
fprintf(stderr, "gdgen_end_graph (to memory)\n");
#ifdef MYTRACE
fprintf(stderr, "gdgen_end_graph (to file)\n");
#endif
- job->surface = NULL;
+ job->context = NULL;
}
}
static void gdgen_textpara(GVJ_t * job, pointf p, textpara_t * para)
{
- gdImagePtr im = (gdImagePtr) job->surface;
+ gdImagePtr im = (gdImagePtr) job->context;
pointf spf, epf;
double parawidth = para->width * job->scale.x;
int arrow_at_end, int filled)
{
obj_state_t *obj = job->obj;
- gdImagePtr im = (gdImagePtr) job->surface;
+ gdImagePtr im = (gdImagePtr) job->context;
pointf p0, p1, V[4];
int i, j, step, pen;
boolean pen_ok, fill_ok;
static void gdgen_polygon(GVJ_t * job, pointf * A, int n, int filled)
{
obj_state_t *obj = job->obj;
- gdImagePtr im = (gdImagePtr) job->surface;
+ gdImagePtr im = (gdImagePtr) job->context;
gdImagePtr brush = NULL;
int i;
int pen;
static void gdgen_ellipse(GVJ_t * job, pointf * A, int filled)
{
obj_state_t *obj = job->obj;
- gdImagePtr im = (gdImagePtr) job->surface;
+ gdImagePtr im = (gdImagePtr) job->context;
double dx, dy;
int pen;
boolean pen_ok, fill_ok;
static void gdgen_polyline(GVJ_t * job, pointf * A, int n)
{
- gdImagePtr im = (gdImagePtr) job->surface;
+ gdImagePtr im = (gdImagePtr) job->context;
pointf p, p1;
int i;
int pen;
return FALSE;
}
-static void gdk_pixbuf_format(GVJ_t * job, unsigned int width, unsigned int height, unsigned char *data)
+static void gdk_pixbuf_format(GVJ_t * job)
{
char *format_str = "";
GdkPixbuf *pixbuf;
break;
}
- argb2rgba(width, height, data);
+ argb2rgba(job->width, job->height, job->imagedata);
pixbuf = gdk_pixbuf_new_from_data(
- data, // data
+ job->imagedata, // data
GDK_COLORSPACE_RGB, // colorspace
TRUE, // has_alpha
8, // bits_per_sample
- width, // width
- height, // height
- 4 * width, // rowstride
+ job->width, // width
+ job->height, // height
+ 4 * job->width, // rowstride
NULL, // destroy_fn
NULL // destroy_fn_data
);
}
static gvdevice_engine_t gdk_pixbuf_engine = {
+ NULL,
NULL,
gdk_pixbuf_format,
NULL,
(job->callbacks->motion)(job, job->pointer);
- job->surface = (void *)cr;
- job->external_surface = TRUE;
+ job->context = (void *)cr;
+ job->external_context = TRUE;
job->width = widget->allocation.width;
job->height = widget->allocation.height;
if (job->has_been_rendered) {
(job->callbacks->motion)(job, job->pointer);
- job->surface = (void *)cr;
- job->external_surface = TRUE;
+ job->context = (void *)cr;
+ job->external_context = TRUE;
job->width = widget->allocation.width;
job->height = widget->allocation.height;
static gvdevice_engine_t device_engine_gtk = {
initialize_gtk,
NULL,
+ NULL,
finalize_gtk,
};
#endif
SWFMovie_setRate(movie, SWFFRAMERATE);
SWFMovie_setDimension(movie, job->width, job->height);
- job->surface = (void*) movie;
+ job->context = (void*) movie;
}
static void ming_end_job(GVJ_t * job)
{
- SWFMovie movie = (SWFMovie)(job->surface);
+ SWFMovie movie = (SWFMovie)(job->context);
SWFMovie_output_to_stream(movie, job->output_file);
destroySWFMovie(movie);
- job->surface = NULL;
+ job->context = NULL;
}
static void ming_begin_page(GVJ_t * job)
{
-// SWFMovie movie = (SWFMovie)(job->surface);
+// SWFMovie movie = (SWFMovie)(job->context);
// SWFMovie_setNumberOfFrames(movie, job->common->viewNum + 1);
static void ming_end_page(GVJ_t * job)
{
- SWFMovie movie = (SWFMovie)(job->surface);
+ SWFMovie movie = (SWFMovie)(job->context);
SWFMovie_nextFrame(movie);
}
static void ming_textpara(GVJ_t * job, pointf p, textpara_t * para)
{
- SWFMovie movie = (SWFMovie)(job->surface);
+ SWFMovie movie = (SWFMovie)(job->context);
SWFTextField textfield;
SWFDisplayItem item;
obj_state_t *obj = job->obj;
static void ming_ellipse(GVJ_t * job, pointf * A, int filled)
{
- SWFMovie movie = (SWFMovie)(job->surface);
+ SWFMovie movie = (SWFMovie)(job->context);
SWFShape shape;
SWFFill fill;
SWFDisplayItem item;
static void
ming_polygon(GVJ_t * job, pointf * A, int n, int filled)
{
- SWFMovie movie = (SWFMovie)(job->surface);
+ SWFMovie movie = (SWFMovie)(job->context);
SWFShape shape;
SWFFill fill;
obj_state_t *obj = job->obj;
ming_bezier(GVJ_t * job, pointf * A, int n, int arrow_at_start,
int arrow_at_end, int filled)
{
- SWFMovie movie = (SWFMovie)(job->surface);
+ SWFMovie movie = (SWFMovie)(job->context);
SWFShape shape;
obj_state_t *obj = job->obj;
gvcolor_t pencolor = obj->pencolor;
static void
ming_polyline(GVJ_t * job, pointf * A, int n)
{
- SWFMovie movie = (SWFMovie)(job->surface);
+ SWFMovie movie = (SWFMovie)(job->context);
SWFShape shape;
obj_state_t *obj = job->obj;
gvcolor_t pencolor = obj->pencolor;
static void pango_loadimage_cairo(GVJ_t * job, usershape_t *us, boxf b, boolean filled)
{
- cairo_t *cr = (cairo_t *) job->surface; /* target context */
- cairo_surface_t *surface = NULL; /* source surface */
+ cairo_t *cr = (cairo_t *) job->context; /* target context */
+ cairo_surface_t *surface; /* source surface */
surface = cairo_loadimage(job, us);
if (surface) {
static void pango_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, boolean filled)
{
- cairo_surface_t *surface = NULL; /* source surface */
+ cairo_surface_t *surface; /* source surface */
FILE *out = job->output_file;
int X, Y, x, y, stride;
unsigned char *data, *ix, alpha, red, green, blue;
fedisableexcept(FE_ALL_EXCEPT);
#endif
- if (job->surface)
- cr = (cairo_t *) job->surface;
+ if (job->context)
+ cr = (cairo_t *) job->context;
switch (job->render.id) {
case FORMAT_CAIRO:
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
job->width, job->height);
cr = cairo_create(surface);
+ job->imagedata = cairo_image_surface_get_data(surface);
cairo_surface_destroy (surface);
}
break;
default:
break;
}
- job->surface = (void *) cr;
+ job->context = (void *) cr;
cairo_save(cr);
cairo_scale(cr, job->scale.x, job->scale.y);
static void cairogen_end_page(GVJ_t * job)
{
- cairo_t *cr = (cairo_t *) job->surface;
+ cairo_t *cr = (cairo_t *) job->context;
cairo_surface_t *surface;
#ifdef CAIRO_HAS_PNG_FUNCTIONS
case FORMAT_PNG:
- surface = cairo_get_target(cr);
#ifdef HAVE_SETMODE
#ifdef O_BINARY
/*
setmode(fileno(job->output_file), O_BINARY);
#endif
#endif
+ surface = cairo_get_target(cr);
cairo_surface_write_to_png_stream(surface, writer, job->output_file);
break;
#endif
cairo_show_page(cr);
break;
- case FORMAT_CAIRO:
- {
- gvdevice_engine_t *gvde = job->device.engine;
- unsigned int width, height;
- unsigned char *data;
-
- if (gvde && gvde->format) {
- surface = cairo_get_target(cr);
- width = cairo_image_surface_get_width(surface);
- height = cairo_image_surface_get_height(surface);
- data = cairo_image_surface_get_data(surface);
- gvde->format(job, width, height, data);
- }
- }
-
+ case FORMAT_CAIRO: /* formatting already done by gvdevice_format() */
default:
break;
}
- if (job->external_surface)
+ if (job->external_context)
cairo_restore(cr);
else {
cairo_destroy(cr);
- job->surface = NULL;
+ job->context = NULL;
}
#if defined HAVE_FENV_H && defined HAVE_FESETENV && defined HAVE_FEGETENV && defined(HAVE_FEENABLEEXCEPT)
static void cairogen_textpara(GVJ_t * job, pointf p, textpara_t * para)
{
obj_state_t *obj = job->obj;
- cairo_t *cr = (cairo_t *) job->surface;
+ cairo_t *cr = (cairo_t *) job->context;
pointf offset;
PangoLayout *layout = (PangoLayout*)(para->layout);
static void cairogen_ellipse(GVJ_t * job, pointf * A, int filled)
{
obj_state_t *obj = job->obj;
- cairo_t *cr = (cairo_t *) job->surface;
+ cairo_t *cr = (cairo_t *) job->context;
cairo_matrix_t matrix;
double rx, ry;
cairogen_polygon(GVJ_t * job, pointf * A, int n, int filled)
{
obj_state_t *obj = job->obj;
- cairo_t *cr = (cairo_t *) job->surface;
+ cairo_t *cr = (cairo_t *) job->context;
int i;
cairogen_set_penstyle(job, cr);
int arrow_at_end, int filled)
{
obj_state_t *obj = job->obj;
- cairo_t *cr = (cairo_t *) job->surface;
+ cairo_t *cr = (cairo_t *) job->context;
int i;
cairogen_set_penstyle(job, cr);
cairogen_polyline(GVJ_t * job, pointf * A, int n)
{
obj_state_t *obj = job->obj;
- cairo_t *cr = (cairo_t *) job->surface;
+ cairo_t *cr = (cairo_t *) job->context;
int i;
cairogen_set_penstyle(job, cr);
surface = cairo_xlib_surface_create(dpy,
window->pix, window->visual,
job->width, job->height);
- job->surface = (void *)cairo_create(surface);
+ job->context = (void *)cairo_create(surface);
cairo_surface_destroy(surface);
(job->callbacks->refresh)(job);
XCopyArea(dpy, window->pix, window->win, window->gc,
static gvdevice_engine_t device_engine_xlib = {
initialize_xlib,
NULL,
+ NULL,
finalize_xlib,
};
#endif