diff options
author | John Tytgat <joty@netsurf-browser.org> | 2009-02-03 01:27:54 +0000 |
---|---|---|
committer | John Tytgat <joty@netsurf-browser.org> | 2009-02-03 01:27:54 +0000 |
commit | fbf6d4cd4116dac4287403c52233f62bac88f3c0 (patch) | |
tree | 7f05710df78ef24f788fdeaa0cb186df5a3e77b6 /desktop | |
parent | 9a1751020684c410d7ad8824dd3cab7c5dd90733 (diff) | |
download | netsurf-fbf6d4cd4116dac4287403c52233f62bac88f3c0.tar.gz netsurf-fbf6d4cd4116dac4287403c52233f62bac88f3c0.tar.bz2 |
- 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
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/knockout.c | 12 | ||||
-rw-r--r-- | desktop/plotters.h | 6 | ||||
-rw-r--r-- | desktop/save_pdf/pdf_plotters.c | 90 |
3 files changed, 53 insertions, 55 deletions
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; |