diff options
Diffstat (limited to 'gtk/gtk_plotters.c')
-rw-r--r-- | gtk/gtk_plotters.c | 179 |
1 files changed, 100 insertions, 79 deletions
diff --git a/gtk/gtk_plotters.c b/gtk/gtk_plotters.c index 27f173eef..8eda4a83d 100644 --- a/gtk/gtk_plotters.c +++ b/gtk/gtk_plotters.c @@ -24,6 +24,8 @@ #include "netsurf/gtk/gtk_window.h" #include "netsurf/render/font.h" #include "netsurf/utils/log.h" +#include "netsurf/desktop/options.h" +#include "netsurf/gtk/options.h" static bool nsgtk_plot_clg(colour c); static bool nsgtk_plot_rectangle(int x0, int y0, int width, int height, @@ -87,16 +89,17 @@ bool nsgtk_plot_rectangle(int x0, int y0, int width, int height, nsgtk_set_solid(); #ifdef CAIRO_VERSION - if (line_width == 0) - line_width = 1; - - cairo_set_line_width(current_cr, line_width); - cairo_rectangle(current_cr, x0, y0, width, height); - cairo_stroke(current_cr); -#else + if (option_render_cairo) { + if (line_width == 0) + line_width = 1; + + cairo_set_line_width(current_cr, line_width); + cairo_rectangle(current_cr, x0, y0, width, height); + cairo_stroke(current_cr); + } else +#endif gdk_draw_rectangle(current_drawable, current_gc, FALSE, x0, y0, width, height); -#endif return true; } @@ -113,17 +116,18 @@ bool nsgtk_plot_line(int x0, int y0, int x1, int y1, int width, nsgtk_set_solid(); #ifdef CAIRO_VERSION - if (width == 0) - width = 1; - - cairo_set_line_width(current_cr, width); - cairo_move_to(current_cr, x0, y0 - 0.5); - cairo_line_to(current_cr, x1, y1 - 0.5); - cairo_stroke(current_cr); -#else + if (option_render_cairo) { + if (width == 0) + width = 1; + + cairo_set_line_width(current_cr, width); + cairo_move_to(current_cr, x0, y0 - 0.5); + cairo_line_to(current_cr, x1, y1 - 0.5); + cairo_stroke(current_cr); + } else +#endif gdk_draw_line(current_drawable, current_gc, x0, y0, x1, y1); -#endif return true; } @@ -135,22 +139,25 @@ bool nsgtk_plot_polygon(int *p, unsigned int n, colour fill) nsgtk_set_colour(fill); nsgtk_set_solid(); #ifdef CAIRO_VERSION - cairo_set_line_width(current_cr, 0); - cairo_move_to(current_cr, p[0], p[1]); - for (i = 1; i != n; i++) { - cairo_line_to(current_cr, p[i * 2], p[i * 2 + 1]); - } - cairo_fill(current_cr); - cairo_stroke(current_cr); -#else - GdkPoint q[n]; - for (i = 0; i != n; i++) { - q[i].x = p[i * 2]; - q[i].y = p[i * 2 + 1]; - } - gdk_draw_polygon(current_drawable, current_gc, - TRUE, q, n); + if (option_render_cairo) { + cairo_set_line_width(current_cr, 0); + cairo_move_to(current_cr, p[0], p[1]); + for (i = 1; i != n; i++) { + cairo_line_to(current_cr, p[i * 2], p[i * 2 + 1]); + } + cairo_fill(current_cr); + cairo_stroke(current_cr); + } else #endif + { + GdkPoint q[n]; + for (i = 0; i != n; i++) { + q[i].x = p[i * 2]; + q[i].y = p[i * 2 + 1]; + } + gdk_draw_polygon(current_drawable, current_gc, + TRUE, q, n); + } return true; } @@ -160,14 +167,15 @@ bool nsgtk_plot_fill(int x0, int y0, int x1, int y1, colour c) nsgtk_set_colour(c); nsgtk_set_solid(); #ifdef CAIRO_VERSION - cairo_set_line_width(current_cr, 0); - cairo_rectangle(current_cr, x0, y0, x1 - x0, y1 - y0); - cairo_fill(current_cr); - cairo_stroke(current_cr); -#else + if (option_render_cairo) { + cairo_set_line_width(current_cr, 0); + cairo_rectangle(current_cr, x0, y0, x1 - x0, y1 - y0); + cairo_fill(current_cr); + cairo_stroke(current_cr); + } else +#endif gdk_draw_rectangle(current_drawable, current_gc, TRUE, x0, y0, x1 - x0, y1 - y0); -#endif return true; } @@ -176,10 +184,12 @@ bool nsgtk_plot_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1) { #ifdef CAIRO_VERSION - cairo_reset_clip(current_cr); - cairo_rectangle(current_cr, clip_x0 - 1, clip_y0 - 1, - clip_x1 - clip_x0 + 1, clip_y1 - clip_y0 + 1); - cairo_clip(current_cr); + if (option_render_cairo) { + cairo_reset_clip(current_cr); + cairo_rectangle(current_cr, clip_x0 - 1, clip_y0 - 1, + clip_x1 - clip_x0 + 1, clip_y1 - clip_y0 + 1); + cairo_clip(current_cr); + } #endif cliprect.x = clip_x0; cliprect.y = clip_y0; @@ -202,24 +212,26 @@ bool nsgtk_plot_disc(int x, int y, int radius, colour c, bool filled) nsgtk_set_colour(c); nsgtk_set_solid(); #ifdef CAIRO_VERSION - if (filled) - cairo_set_line_width(current_cr, 0); - else - cairo_set_line_width(current_cr, 1); + if (option_render_cairo) { + if (filled) + cairo_set_line_width(current_cr, 0); + else + cairo_set_line_width(current_cr, 1); - cairo_arc(current_cr, x, y, radius, 0, M_PI * 2); + cairo_arc(current_cr, x, y, radius, 0, M_PI * 2); - if (filled) - cairo_fill(current_cr); + if (filled) + cairo_fill(current_cr); - cairo_stroke(current_cr); -#else + cairo_stroke(current_cr); + } else +#endif gdk_draw_arc(current_drawable, current_gc, filled ? TRUE : FALSE, x - (radius), y - radius, radius * 2, radius * 2, 0, 360 * 64); -#endif + return true; } @@ -228,17 +240,19 @@ bool nsgtk_plot_arc(int x, int y, int radius, int angle1, int angle2, colour c) nsgtk_set_colour(c); nsgtk_set_solid(); #ifdef CAIRO_VERSION - cairo_set_line_width(current_cr, 1); - cairo_arc(current_cr, x, y, radius, - (angle1 + 90) * (M_PI / 180), - (angle2 + 90) * (M_PI / 180)); - cairo_stroke(current_cr); -#else + if (option_render_cairo) { + cairo_set_line_width(current_cr, 1); + cairo_arc(current_cr, x, y, radius, + (angle1 + 90) * (M_PI / 180), + (angle2 + 90) * (M_PI / 180)); + cairo_stroke(current_cr); + } else +#endif gdk_draw_arc(current_drawable, current_gc, FALSE, x - (radius), y - radius, radius * 2, radius * 2, angle1 * 64, angle2 * 64); -#endif + return true; } @@ -337,7 +351,9 @@ void nsgtk_set_colour(colour c) &colour); gdk_gc_set_foreground(current_gc, &colour); #ifdef CAIRO_VERSION - cairo_set_source_rgba(current_cr, r / 255.0, g / 255.0, b / 255.0, 1.0); + if (option_render_cairo) + cairo_set_source_rgba(current_cr, r / 255.0, + g / 255.0, b / 255.0, 1.0); #endif } @@ -345,39 +361,44 @@ void nsgtk_set_solid() { #ifdef CAIRO_VERSION double dashes = 0; - cairo_set_dash(current_cr, &dashes, 0, 0); -#else + if (option_render_cairo) + cairo_set_dash(current_cr, &dashes, 0, 0); + else +#endif gdk_gc_set_line_attributes(current_gc, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER); -#endif } void nsgtk_set_dotted() { -#ifdef CAIRO_VERSION - double dashes = 1; - cairo_set_dash(current_cr, &dashes, 1, 0); -#else + double cdashes = 1; gint8 dashes[] = { 1, 1 }; - - gdk_gc_set_dashes(current_gc, 0, dashes, 2); - gdk_gc_set_line_attributes(current_gc, 1, GDK_LINE_ON_OFF_DASH, - GDK_CAP_BUTT, GDK_JOIN_MITER); +#ifdef CAIRO_VERSION + if (option_render_cairo) + cairo_set_dash(current_cr, &cdashes, 1, 0); + else #endif + { + gdk_gc_set_dashes(current_gc, 0, dashes, 2); + gdk_gc_set_line_attributes(current_gc, 1, GDK_LINE_ON_OFF_DASH, + GDK_CAP_BUTT, GDK_JOIN_MITER); + } } void nsgtk_set_dashed() { -#ifdef CAIRO_VERSION - double dashes = 3; - cairo_set_dash(current_cr, &dashes, 1, 0); -#else + double cdashes = 3; gint8 dashes[] = { 3, 3 }; - - gdk_gc_set_dashes(current_gc, 0, dashes, 2); - gdk_gc_set_line_attributes(current_gc, 1, GDK_LINE_ON_OFF_DASH, - GDK_CAP_BUTT, GDK_JOIN_MITER); +#ifdef CAIRO_VERSION + if (option_render_cairo) + cairo_set_dash(current_cr, &cdashes, 1, 0); + else #endif + { + gdk_gc_set_dashes(current_gc, 0, dashes, 2); + gdk_gc_set_line_attributes(current_gc, 1, GDK_LINE_ON_OFF_DASH, + GDK_CAP_BUTT, GDK_JOIN_MITER); + } } void nsgtk_plot_set_scale(float s) |