From fbf6d4cd4116dac4287403c52233f62bac88f3c0 Mon Sep 17 00:00:00 2001 From: John Tytgat Date: Tue, 3 Feb 2009 01:27:54 +0000 Subject: - Constify parameters of struct plotter_table::polygon and struct plotter_table::path - riscos/save_draw.c(ro_save_draw_plotters): Make it static. - desktop/save_pdf/pdf_plotters.c(pdf_plot_path): fix broken implementation (coordinates path were wrong, no clip/text mode update, transformation matrix was overwritten); only update fill and/or stroke color when fill and/or stroke is done. (pdf_begin): disable compression when PDF_DEBUG is set svn path=/trunk/netsurf/; revision=6361 --- amiga/plotters.c | 6 +-- amiga/plotters.h | 6 +-- beos/beos_plotters.cpp | 12 +++--- desktop/knockout.c | 12 +++--- desktop/plotters.h | 6 +-- desktop/save_pdf/pdf_plotters.c | 90 ++++++++++++++++++++--------------------- framebuffer/fb_16bpp_plotters.c | 6 +-- framebuffer/fb_1bpp_plotters.c | 6 +-- framebuffer/fb_32bpp_plotters.c | 6 +-- framebuffer/fb_8bpp_plotters.c | 6 +-- framebuffer/fb_plotters.c | 4 +- framebuffer/fb_plotters.h | 2 +- gtk/gtk_plotters.c | 12 +++--- gtk/gtk_print.c | 12 +++--- riscos/plotters.c | 12 +++--- riscos/print.c | 12 +++--- riscos/save_draw.c | 25 +++++------- 17 files changed, 115 insertions(+), 120 deletions(-) diff --git a/amiga/plotters.c b/amiga/plotters.c index 3460e5936..b19ee394c 100755 --- a/amiga/plotters.c +++ b/amiga/plotters.c @@ -189,7 +189,7 @@ bool ami_line(int x0, int y0, int x1, int y1, int width, return true; } -bool ami_polygon(int *p, unsigned int n, colour fill) +bool ami_polygon(const int *p, unsigned int n, colour fill) { int k; #ifndef NS_AMIGA_CAIRO @@ -626,8 +626,8 @@ bool ami_flush(void) return true; } -bool ami_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform) +bool ami_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]) { /* For SVG only, because it needs Bezier curves we are going to cheat and insist on Cairo */ diff --git a/amiga/plotters.h b/amiga/plotters.h index 0ed18c5ee..676493719 100755 --- a/amiga/plotters.h +++ b/amiga/plotters.h @@ -27,7 +27,7 @@ bool ami_rectangle(int x0, int y0, int width, int height, int line_width, colour c, bool dotted, bool dashed); bool ami_line(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed); -bool ami_polygon(int *p, unsigned int n, colour fill); +bool ami_polygon(const int *p, unsigned int n, colour fill); bool ami_fill(int x0, int y0, int x1, int y1, colour c); bool ami_clip(int x0, int y0, int x1, int y1); bool ami_text(int x, int y, const struct css_style *style, @@ -43,6 +43,6 @@ bool ami_bitmap_tile(int x, int y, int width, int height, bool ami_group_start(const char *name); bool ami_group_end(void); bool ami_flush(void); -bool ami_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform); +bool ami_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]); #endif diff --git a/beos/beos_plotters.cpp b/beos/beos_plotters.cpp index 07f3ff5c6..b571c2447 100644 --- a/beos/beos_plotters.cpp +++ b/beos/beos_plotters.cpp @@ -66,9 +66,9 @@ static bool nsbeos_plot_rectangle(int x0, int y0, int width, int height, int line_width, colour c, bool dotted, bool dashed); static bool nsbeos_plot_line(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed); -static bool nsbeos_plot_polygon(int *p, unsigned int n, colour fill); -static bool nsbeos_plot_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform); +static bool nsbeos_plot_polygon(const int *p, unsigned int n, colour fill); +static bool nsbeos_plot_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]); static bool nsbeos_plot_fill(int x0, int y0, int x1, int y1, colour c); static bool nsbeos_plot_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1); @@ -261,7 +261,7 @@ bool nsbeos_plot_line(int x0, int y0, int x1, int y1, int width, } -bool nsbeos_plot_polygon(int *p, unsigned int n, colour fill) +bool nsbeos_plot_polygon(const int *p, unsigned int n, colour fill) { unsigned int i; BView *view; @@ -709,8 +709,8 @@ printf("plot_tile: -> %dx%d\n", width, height); return true; } -bool nsbeos_plot_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform) +bool nsbeos_plot_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]) { unsigned int i; diff --git a/desktop/knockout.c b/desktop/knockout.c index 678b83297..d99c96909 100644 --- a/desktop/knockout.c +++ b/desktop/knockout.c @@ -90,7 +90,7 @@ static bool knockout_plot_rectangle(int x0, int y0, int width, int height, int line_width, colour c, bool dotted, bool dashed); static bool knockout_plot_line(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed); -static bool knockout_plot_polygon(int *p, unsigned int n, colour fill); +static bool knockout_plot_polygon(const int *p, unsigned int n, colour fill); static bool knockout_plot_fill(int x0, int y0, int x1, int y1, colour c); static bool knockout_plot_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1); @@ -107,8 +107,8 @@ static bool knockout_plot_bitmap_tile(int x, int y, int width, int height, static bool knockout_plot_flush(void); static bool knockout_plot_group_start(const char *name); static bool knockout_plot_group_end(void); -static bool knockout_plot_path(float *p, unsigned int n, colour fill, - float width, colour c, float *transform); +static bool knockout_plot_path(const float *p, unsigned int n, colour fill, + float width, colour c, const float transform[6]); const struct plotter_table knockout_plotters = { @@ -704,7 +704,7 @@ bool knockout_plot_line(int x0, int y0, int x1, int y1, int width, } -bool knockout_plot_polygon(int *p, unsigned int n, colour fill) +bool knockout_plot_polygon(const int *p, unsigned int n, colour fill) { bool success = true; int *dest; @@ -734,8 +734,8 @@ bool knockout_plot_polygon(int *p, unsigned int n, colour fill) } -bool knockout_plot_path(float *p, unsigned int n, colour fill, - float width, colour c, float *transform) +bool knockout_plot_path(const float *p, unsigned int n, colour fill, + float width, colour c, const float transform[6]) { knockout_plot_flush(); return real_plot.path(p, n, fill, width, c, transform); diff --git a/desktop/plotters.h b/desktop/plotters.h index 23f3d8e8d..2a6cf77bc 100644 --- a/desktop/plotters.h +++ b/desktop/plotters.h @@ -82,7 +82,7 @@ struct plotter_table { int line_width, colour c, bool dotted, bool dashed); bool (*line)(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed); - bool (*polygon)(int *p, unsigned int n, colour fill); + bool (*polygon)(const int *p, unsigned int n, colour fill); bool (*fill)(int x0, int y0, int x1, int y1, colour c); bool (*clip)(int x0, int y0, int x1, int y1); bool (*text)(int x, int y, const struct css_style *style, @@ -98,8 +98,8 @@ struct plotter_table { bool (*group_start)(const char *name); /**< optional, may be NULL */ bool (*group_end)(void); /**< optional, may be NULL */ bool (*flush)(void); /**< optional, may be NULL */ - bool (*path)(float *p, unsigned int n, colour fill, float width, - colour c, float *transform); + bool (*path)(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]); bool option_knockout; /**< set if knockout rendering is required */ }; diff --git a/desktop/save_pdf/pdf_plotters.c b/desktop/save_pdf/pdf_plotters.c index 02d19d70f..599799555 100644 --- a/desktop/save_pdf/pdf_plotters.c +++ b/desktop/save_pdf/pdf_plotters.c @@ -51,7 +51,7 @@ static bool pdf_plot_rectangle(int x0, int y0, int width, int height, int line_width, colour c, bool dotted, bool dashed); static bool pdf_plot_line(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed); -static bool pdf_plot_polygon(int *p, unsigned int n, colour fill); +static bool pdf_plot_polygon(const int *p, unsigned int n, colour fill); static bool pdf_plot_fill(int x0, int y0, int x1, int y1, colour c); static bool pdf_plot_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1); @@ -65,8 +65,8 @@ static bool pdf_plot_bitmap(int x, int y, int width, int height, static bool pdf_plot_bitmap_tile(int x, int y, int width, int height, struct bitmap *bitmap, colour bg, bool repeat_x, bool repeat_y, struct content *content); -static bool pdf_plot_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform); +static bool pdf_plot_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]); static void pdf_set_solid(void); static void pdf_set_dashed(void); @@ -150,10 +150,10 @@ bool pdf_plot_rectangle(int x0, int y0, int width, int height, pdf_set_dashed(); HPDF_Page_SetRGBStroke(pdf_page, R(c), G(c), B(c)); - HPDF_Page_Rectangle(pdf_page, x0, page_height - y0 + height, width, height); + HPDF_Page_Rectangle(pdf_page, x0, page_height - y0, width, -height); HPDF_Page_Stroke(pdf_page); - if (dotted||dashed) + if (dotted || dashed) pdf_set_solid(); return true; @@ -181,13 +181,13 @@ bool pdf_plot_line(int x0, int y0, int x1, int y1, int width, HPDF_Page_LineTo(pdf_page, x1, page_height - y1); HPDF_Page_Stroke(pdf_page); - if (dotted||dashed) + if (dotted || dashed) pdf_set_solid(); return true; } -bool pdf_plot_polygon(int *p, unsigned int n, colour fill) +bool pdf_plot_polygon(const int *p, unsigned int n, colour fill) { unsigned int i; #ifdef PDF_DEBUG @@ -214,7 +214,7 @@ bool pdf_plot_polygon(int *p, unsigned int n, colour fill) } #ifdef PDF_DEBUG - LOG(("%d %d %d %d %f", pminx, pminy, pmaxx, pmaxy, page_height-pminy)); + LOG(("%d %d %d %d %f", pminx, pminy, pmaxx, pmaxy, page_height - pminy)); #endif HPDF_Page_LineTo(pdf_page, p[0], page_height - p[1]); @@ -226,7 +226,7 @@ bool pdf_plot_polygon(int *p, unsigned int n, colour fill) bool pdf_plot_fill(int x0, int y0, int x1, int y1, colour c) { #ifdef PDF_DEBUG - LOG(("%d %d %d %d %f %X", x0, y0, x1, y1, page_height-y0, c)); + LOG(("%d %d %d %d %f %X", x0, y0, x1, y1, page_height - y0, c)); #endif /*Normalize boundaries of the area - to prevent overflows. @@ -242,7 +242,7 @@ bool pdf_plot_fill(int x0, int y0, int x1, int y1, colour c) apply_clip_and_mode(false); HPDF_Page_SetRGBFill(pdf_page, R(c), G(c), B(c)); - HPDF_Page_Rectangle(pdf_page, x0, page_height - y1, x1-x0, y1-y0); + HPDF_Page_Rectangle(pdf_page, x0, page_height - y1, x1 - x0, y1 - y0); HPDF_Page_Fill(pdf_page); return true; @@ -330,7 +330,7 @@ bool pdf_plot_disc(int x, int y, int radius, colour c, bool filled) else HPDF_Page_SetRGBStroke(pdf_page, R(c), G(c), B(c)); - HPDF_Page_Circle(pdf_page, x, page_height-y, radius); + HPDF_Page_Circle(pdf_page, x, page_height - y, radius); if (filled) HPDF_Page_Fill(pdf_page); @@ -356,7 +356,7 @@ bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2, colour c) HPDF_Page_SetRGBStroke(pdf_page, R(c), G(c), B(c)); - HPDF_Page_Arc(pdf_page, x, page_height-y, radius, angle1, angle2); + HPDF_Page_Arc(pdf_page, x, page_height - y, radius, angle1, angle2); HPDF_Page_Stroke(pdf_page); return true; @@ -382,7 +382,7 @@ bool pdf_plot_bitmap(int x, int y, int width, int height, return false; HPDF_Page_DrawImage(pdf_page, image, - x, page_height-y-height, + x, page_height - y - height, width, height); return true; @@ -394,6 +394,8 @@ bool pdf_plot_bitmap_tile(int x, int y, int width, int height, bool repeat_x, bool repeat_y, struct content *content) { HPDF_Image image; + HPDF_REAL current_x, current_y ; + HPDF_REAL max_width, max_height; #ifdef PDF_DEBUG LOG(("%d %d %d %d %p 0x%x %p", x, y, width, height, @@ -407,22 +409,17 @@ bool pdf_plot_bitmap_tile(int x, int y, int width, int height, image = pdf_extract_image(bitmap, content); if (!image) return false; - else { - /*The position of the next tile*/ - HPDF_REAL current_x, current_y ; - HPDF_REAL max_width, max_height; - max_width = (repeat_x ? page_width : width); - max_height = (repeat_y ? page_height: height); + /*The position of the next tile*/ + max_width = (repeat_x) ? page_width : width; + max_height = (repeat_y) ? page_height : height; - - for (current_y=0; current_y < max_height; current_y += height) - for (current_x=0; current_x < max_width; current_x += width) - HPDF_Page_DrawImage(pdf_page, image, - current_x + x, - page_height-current_y - y - height, - width, height); - } + for (current_y = 0; current_y < max_height; current_y += height) + for (current_x = 0; current_x < max_width; current_x += width) + HPDF_Page_DrawImage(pdf_page, image, + current_x + x, + page_height - current_y - y - height, + width, height); return true; } @@ -542,46 +539,45 @@ static void apply_clip_and_mode(bool selectTextMode) } } -static inline float transform_x(float *transform, float x, float y) +static inline float transform_x(const float transform[6], float x, float y) { - return ((transform[0] * x) + (transform[2] * (-y) ) + transform[4]) * 2; + return transform[0] * x + transform[2] * y + transform[4]; } -static inline float transform_y(float *transform, float x, float y) +static inline float transform_y(const float transform[6], float x, float y) { - return page_height - (((transform[1] * x) + - (transform[3] * (-y)) - transform[5]) * 2); + return page_height + - (transform[1] * x + transform[3] * y + transform[5]); } -bool pdf_plot_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform) +bool pdf_plot_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]) { #ifdef PDF_DEBUG LOG((".")); #endif unsigned int i; - bool empty_path = true; + bool empty_path; if (n == 0) return true; - if ((c == TRANSPARENT) && (fill == TRANSPARENT)) + if (c == TRANSPARENT && fill == TRANSPARENT) return true; - if (p[0] != PLOTTER_PATH_MOVE) { + if (p[0] != PLOTTER_PATH_MOVE) return false; - } - HPDF_Page_SetRGBFill(pdf_page, R(fill), G(fill), B(fill)); - HPDF_Page_SetRGBStroke(pdf_page, R(c), G(c), B(c)); + apply_clip_and_mode(false); - transform[0] = 0.1; - transform[1] = 0; - transform[2] = 0; - transform[3] = -0.1; - transform[4] = 0; - transform[5] = 0; + if (fill != TRANSPARENT) + HPDF_Page_SetRGBFill(pdf_page, R(fill), G(fill), B(fill)); + if (c != TRANSPARENT) { + HPDF_Page_SetLineWidth(pdf_page, width); + HPDF_Page_SetRGBStroke(pdf_page, R(c), G(c), B(c)); + } + empty_path = true; for (i = 0 ; i < n ; ) { if (p[i] == PLOTTER_PATH_MOVE) { HPDF_Page_MoveTo(pdf_page, @@ -672,8 +668,10 @@ bool pdf_begin(struct print_settings *print_settings) page_height = settings->page_height - settings->margins[MARGINTOP]; +#ifndef PDF_DEBUG if (option_enable_PDF_compression) HPDF_SetCompressionMode(pdf_doc, HPDF_COMP_ALL); /*Compression on*/ +#endif HPDF_SetInfoAttr(pdf_doc, HPDF_INFO_CREATOR, user_agent_string()); pdf_font = NULL; diff --git a/framebuffer/fb_16bpp_plotters.c b/framebuffer/fb_16bpp_plotters.c index 78d7cc2aa..a7afefd53 100644 --- a/framebuffer/fb_16bpp_plotters.c +++ b/framebuffer/fb_16bpp_plotters.c @@ -147,7 +147,7 @@ static bool fb_16bpp_rectangle(int x0, int y0, int width, int height, return true; } -static bool fb_16bpp_polygon(int *p, unsigned int n, colour fill) +static bool fb_16bpp_polygon(const int *p, unsigned int n, colour fill) { return fb_plotters_polygon(p, n, fill, fb_16bpp_line); } @@ -386,8 +386,8 @@ static bool fb_16bpp_flush(void) return true; } -static bool fb_16bpp_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform) +static bool fb_16bpp_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]) { LOG(("%f, %d, 0x%lx, %f, 0x%lx, %f", *p, n, fill, width, c, *transform)); diff --git a/framebuffer/fb_1bpp_plotters.c b/framebuffer/fb_1bpp_plotters.c index f0abfef85..bd511e7ff 100644 --- a/framebuffer/fb_1bpp_plotters.c +++ b/framebuffer/fb_1bpp_plotters.c @@ -50,7 +50,7 @@ static bool fb_1bpp_line(int x0, int y0, int x1, int y1, int width, return true; } -static bool fb_1bpp_polygon(int *p, unsigned int n, colour fill) +static bool fb_1bpp_polygon(const int *p, unsigned int n, colour fill) { LOG(("%s(%p, %d, 0x%lx)\n", __func__, p,n,fill)); return true; @@ -235,8 +235,8 @@ static bool fb_1bpp_flush(void) return true; } -static bool fb_1bpp_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform) +static bool fb_1bpp_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]) { LOG(("%s(%f, %d, 0x%lx, %f, 0x%lx, %f)\n", __func__, *p, n, fill, width, c, *transform)); diff --git a/framebuffer/fb_32bpp_plotters.c b/framebuffer/fb_32bpp_plotters.c index 3805ff753..c4dc42807 100644 --- a/framebuffer/fb_32bpp_plotters.c +++ b/framebuffer/fb_32bpp_plotters.c @@ -135,7 +135,7 @@ static bool fb_32bpp_rectangle(int x0, int y0, int width, int height, } -static bool fb_32bpp_polygon(int *p, unsigned int n, colour fill) +static bool fb_32bpp_polygon(const int *p, unsigned int n, colour fill) { return fb_plotters_polygon(p, n, fill, fb_32bpp_line); } @@ -367,8 +367,8 @@ static bool fb_32bpp_flush(void) return true; } -static bool fb_32bpp_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform) +static bool fb_32bpp_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]) { printf("path\n"); return true; diff --git a/framebuffer/fb_8bpp_plotters.c b/framebuffer/fb_8bpp_plotters.c index 9f0498db2..15804a9ed 100644 --- a/framebuffer/fb_8bpp_plotters.c +++ b/framebuffer/fb_8bpp_plotters.c @@ -55,7 +55,7 @@ static bool fb_8bpp_line(int x0, int y0, int x1, int y1, int width, return true; } -static bool fb_8bpp_polygon(int *p, unsigned int n, colour fill) +static bool fb_8bpp_polygon(const int *p, unsigned int n, colour fill) { /*LOG(("%p, %d, 0x%lx", p,n,fill));*/ return fb_plotters_polygon(p, n, fill, fb_8bpp_line); @@ -266,8 +266,8 @@ static bool fb_8bpp_flush(void) return true; } -static bool fb_8bpp_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform) +static bool fb_8bpp_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]) { LOG(("%s(%f, %d, 0x%lx, %f, 0x%lx, %f)\n", __func__, *p, n, fill, width, c, *transform)); diff --git a/framebuffer/fb_plotters.c b/framebuffer/fb_plotters.c index 87a179425..28f64177f 100644 --- a/framebuffer/fb_plotters.c +++ b/framebuffer/fb_plotters.c @@ -221,10 +221,10 @@ colour fb_plotters_ablend(colour pixel, colour scrpixel) } bool -fb_plotters_polygon(int *p, unsigned int n, colour fill,bool (linefn)(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed)) +fb_plotters_polygon(const int *p, unsigned int n, colour fill,bool (linefn)(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed)) { unsigned int pnt; - int *cur = p; + const int *cur = p; for (pnt = 1; pnt < n; pnt++) { cur = p + (pnt << 1); diff --git a/framebuffer/fb_plotters.h b/framebuffer/fb_plotters.h index f9f528336..c06ad2961 100644 --- a/framebuffer/fb_plotters.h +++ b/framebuffer/fb_plotters.h @@ -34,7 +34,7 @@ bool fb_plotters_clip_rect(const bbox_t *clip, int *x0, int *y0, int *x1, int *y bool fb_plotters_clip_line_ctx(int *x0, int *y0, int *x1, int *y1); bool fb_plotters_clip_line(const bbox_t *clip, int *x0, int *y0, int *x1, int *y1); -bool fb_plotters_polygon(int *p, unsigned int n, colour fill, bool (linefn)(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed)); +bool fb_plotters_polygon(const int *p, unsigned int n, colour fill, bool (linefn)(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed)); bool fb_plotters_bitmap_tile(int x, int y, int width, int height, diff --git a/gtk/gtk_plotters.c b/gtk/gtk_plotters.c index 2f03cc1bb..e73d4519c 100644 --- a/gtk/gtk_plotters.c +++ b/gtk/gtk_plotters.c @@ -54,9 +54,9 @@ static bool nsgtk_plot_rectangle(int x0, int y0, int width, int height, int line_width, colour c, bool dotted, bool dashed); static bool nsgtk_plot_line(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed); -static bool nsgtk_plot_polygon(int *p, unsigned int n, colour fill); -static bool nsgtk_plot_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform); +static bool nsgtk_plot_polygon(const int *p, unsigned int n, colour fill); +static bool nsgtk_plot_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]); static bool nsgtk_plot_fill(int x0, int y0, int x1, int y1, colour c); static bool nsgtk_plot_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1); @@ -149,7 +149,7 @@ bool nsgtk_plot_line(int x0, int y0, int x1, int y1, int width, } -bool nsgtk_plot_polygon(int *p, unsigned int n, colour fill) +bool nsgtk_plot_polygon(const int *p, unsigned int n, colour fill) { unsigned int i; @@ -341,8 +341,8 @@ bool nsgtk_plot_bitmap_tile(int x, int y, int width, int height, return true; } -bool nsgtk_plot_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform) +bool nsgtk_plot_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]) { unsigned int i; cairo_matrix_t old_ctm, n_ctm; diff --git a/gtk/gtk_print.c b/gtk/gtk_print.c index 1b03f5532..4ac8956f5 100644 --- a/gtk/gtk_print.c +++ b/gtk/gtk_print.c @@ -55,9 +55,9 @@ static bool nsgtk_print_plot_rectangle(int x0, int y0, int width, int height, int line_width, colour c, bool dotted, bool dashed); static bool nsgtk_print_plot_line(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed); -static bool nsgtk_print_plot_polygon(int *p, unsigned int n, colour fill); -static bool nsgtk_print_plot_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform); +static bool nsgtk_print_plot_polygon(const int *p, unsigned int n, colour fill); +static bool nsgtk_print_plot_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]); static bool nsgtk_print_plot_fill(int x0, int y0, int x1, int y1, colour c); static bool nsgtk_print_plot_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1); @@ -170,7 +170,7 @@ bool nsgtk_print_plot_line(int x0, int y0, int x1, int y1, int width, } -bool nsgtk_print_plot_polygon(int *p, unsigned int n, colour fill) +bool nsgtk_print_plot_polygon(const int *p, unsigned int n, colour fill) { LOG(("Plotting polygon.")); @@ -385,8 +385,8 @@ bool nsgtk_print_plot_bitmap_tile(int x, int y, int width, int height, return true; } -bool nsgtk_print_plot_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform) +bool nsgtk_print_plot_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]) { /* Only the internal SVG renderer uses this plot call currently, * and the GTK version uses librsvg. Thus, we ignore this complexity, diff --git a/riscos/plotters.c b/riscos/plotters.c index bfba10c39..6b0ebee79 100644 --- a/riscos/plotters.c +++ b/riscos/plotters.c @@ -41,9 +41,9 @@ static bool ro_plot_line(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed); static bool ro_plot_draw_path(const draw_path * const path, int width, colour c, bool dotted, bool dashed); -static bool ro_plot_polygon(int *p, unsigned int n, colour fill); -static bool ro_plot_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform); +static bool ro_plot_polygon(const int *p, unsigned int n, colour fill); +static bool ro_plot_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]); static bool ro_plot_fill(int x0, int y0, int x1, int y1, colour c); static bool ro_plot_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1); @@ -190,7 +190,7 @@ bool ro_plot_draw_path(const draw_path * const path, int width, } -bool ro_plot_polygon(int *p, unsigned int n, colour fill) +bool ro_plot_polygon(const int *p, unsigned int n, colour fill) { int path[n * 3 + 2]; unsigned int i; @@ -222,8 +222,8 @@ bool ro_plot_polygon(int *p, unsigned int n, colour fill) } -bool ro_plot_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform) +bool ro_plot_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]) { static const draw_line_style line_style = { draw_JOIN_MITRED, draw_CAP_BUTT, draw_CAP_BUTT, 0, 0x7fffffff, diff --git a/riscos/print.c b/riscos/print.c index 8edc24afd..008d63cbc 100644 --- a/riscos/print.c +++ b/riscos/print.c @@ -103,7 +103,7 @@ static bool print_fonts_plot_rectangle(int x0, int y0, int width, int height, int line_width, colour c, bool dotted, bool dashed); static bool print_fonts_plot_line(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed); -static bool print_fonts_plot_polygon(int *p, unsigned int n, colour fill); +static bool print_fonts_plot_polygon(const int *p, unsigned int n, colour fill); static bool print_fonts_plot_fill(int x0, int y0, int x1, int y1, colour c); static bool print_fonts_plot_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1); @@ -119,8 +119,8 @@ static bool print_fonts_plot_bitmap(int x, int y, int width, int height, static bool print_fonts_plot_bitmap_tile(int x, int y, int width, int height, struct bitmap *bitmap, colour bg, bool repeat_x, bool repeat_y, struct content *content); -static bool print_fonts_plot_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform); +static bool print_fonts_plot_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]); static void print_fonts_callback(void *context, const char *font_name, unsigned int font_size, const char *s8, unsigned short *s16, unsigned int n, @@ -831,7 +831,7 @@ bool print_fonts_plot_line(int x0, int y0, int x1, int y1, int width, { return true; } -bool print_fonts_plot_polygon(int *p, unsigned int n, colour fill) +bool print_fonts_plot_polygon(const int *p, unsigned int n, colour fill) { return true; } @@ -865,8 +865,8 @@ bool print_fonts_plot_bitmap_tile(int x, int y, int width, int height, { return true; } -bool print_fonts_plot_path(float *p, unsigned int n, colour fill, float width, - colour c, float *transform) +bool print_fonts_plot_path(const float *p, unsigned int n, colour fill, float width, + colour c, const float transform[6]) { return true; } diff --git a/riscos/save_draw.c b/riscos/save_draw.c index fe3dae533..57add139b 100644 --- a/riscos/save_draw.c +++ b/riscos/save_draw.c @@ -41,9 +41,9 @@ static bool ro_save_draw_rectangle(int x0, int y0, int width, int height, int line_width, colour c, bool dotted, bool dashed); static bool ro_save_draw_line(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed); -static bool ro_save_draw_polygon(int *p, unsigned int n, colour fill); -static bool ro_save_draw_path(float *p, unsigned int n, colour fill, - float width, colour c, float *transform); +static bool ro_save_draw_polygon(const int *p, unsigned int n, colour fill); +static bool ro_save_draw_path(const float *p, unsigned int n, colour fill, + float width, colour c, const float transform[6]); static bool ro_save_draw_fill(int x0, int y0, int x1, int y1, colour c); static bool ro_save_draw_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1); @@ -63,7 +63,7 @@ static bool ro_save_draw_group_end(void); static bool ro_save_draw_error(pencil_code code); -const struct plotter_table ro_save_draw_plotters = { +static const struct plotter_table ro_save_draw_plotters = { ro_save_draw_clg, ro_save_draw_rectangle, ro_save_draw_line, @@ -199,7 +199,7 @@ bool ro_save_draw_line(int x0, int y0, int x1, int y1, int width, } -bool ro_save_draw_polygon(int *p, unsigned int n, colour fill) +bool ro_save_draw_polygon(const int *p, unsigned int n, colour fill) { pencil_code code; int path[n * 3 + 1]; @@ -224,14 +224,9 @@ bool ro_save_draw_polygon(int *p, unsigned int n, colour fill) } -bool ro_save_draw_path(float *p, unsigned int n, colour fill, - float width, colour c, float *transform) +bool ro_save_draw_path(const float *p, unsigned int n, colour fill, + float width, colour c, const float transform[6]) { - pencil_code code; - int *path; - unsigned int i; - bool empty_path = true; - if (n == 0) return true; @@ -240,12 +235,14 @@ bool ro_save_draw_path(float *p, unsigned int n, colour fill, return false; } - path = malloc(sizeof *path * (n + 10)); + int *path = malloc(sizeof *path * (n + 10)); if (!path) { LOG(("out of memory")); return false; } + unsigned int i; + bool empty_path = true; for (i = 0; i < n; ) { if (p[i] == PLOTTER_PATH_MOVE) { path[i] = draw_MOVE_TO; @@ -304,7 +301,7 @@ bool ro_save_draw_path(float *p, unsigned int n, colour fill, return true; } - code = pencil_path(ro_save_draw_diagram, path, i + 1, + pencil_code code = pencil_path(ro_save_draw_diagram, path, i + 1, fill == TRANSPARENT ? pencil_TRANSPARENT : fill << 8, c == TRANSPARENT ? pencil_TRANSPARENT : c << 8, width, pencil_JOIN_MITRED, -- cgit v1.2.3