NetSurf
|
GTK and Cairo plotter implementations. More...
#include <math.h>
#include <assert.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "utils/log.h"
#include "netsurf/plotters.h"
#include "utils/nsoption.h"
#include "gtk/layout_pango.h"
#include "gtk/plotters.h"
#include "gtk/scaffolding.h"
#include "gtk/bitmap.h"
Go to the source code of this file.
Functions | |
void | nsgtk_set_colour (colour c) |
Set cairo context colour to nsgtk colour. More... | |
static void | nsgtk_set_solid (void) |
Set cairo context to solid plot operation. More... | |
static void | nsgtk_set_dotted (void) |
Set cairo context to dotted plot operation. More... | |
static void | nsgtk_set_dashed (void) |
Set cairo context to dashed plot operation. More... | |
static void | nsgtk_set_line_width (plot_style_fixed width) |
Set cairo context line width. More... | |
static nserror | nsgtk_plot_clip (const struct redraw_context *ctx, const struct rect *clip) |
Sets a clip rectangle for subsequent plot operations. More... | |
static nserror | nsgtk_plot_arc (const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius, int angle1, int angle2) |
Plots an arc. More... | |
static nserror | nsgtk_plot_disc (const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius) |
Plots a circle. More... | |
static nserror | nsgtk_plot_line (const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line) |
Plots a line. More... | |
void | nsgtk_plot_caret (int x, int y, int h) |
Plot a caret. More... | |
static nserror | nsgtk_plot_rectangle (const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect) |
Plots a rectangle. More... | |
static nserror | nsgtk_plot_polygon (const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n) |
Plot a polygon. More... | |
static nserror | nsgtk_plot_path (const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6]) |
Plots a path. More... | |
static nserror | nsgtk_plot_bitmap (const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags) |
Plot a bitmap. More... | |
static nserror | nsgtk_plot_text (const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length) |
Text plotting. More... | |
Variables | |
cairo_t * | current_cr |
static GdkRectangle | cliprect |
const struct plotter_table | nsgtk_plotters |
GTK plotter table. More... | |
GTK and Cairo plotter implementations.
Uses Cairo drawing primitives to render browser output.
Definition in file plotters.c.
|
static |
Plots an arc.
plot an arc segment around (x,y), anticlockwise from angle1 to angle2. Angles are measured anticlockwise from horizontal, in degrees.
ctx | The current redraw context. |
style | Style controlling the arc plot. |
x | The x coordinate of the arc. |
y | The y coordinate of the arc. |
radius | The radius of the arc. |
angle1 | The start angle of the arc. |
angle2 | The finish angle of the arc. |
Definition at line 147 of file plotters.c.
References current_cr, plot_style_s::fill_colour, M_PI, NSERROR_OK, nsgtk_set_colour(), and nsgtk_set_solid().
|
static |
Plot a bitmap.
Tiled plot of a bitmap image. (x,y) gives the top left coordinate of an explicitly placed tile. From this tile the image can repeat in all four directions – up, down, left and right – to the extents given by the current clip rectangle.
The bitmap_flags say whether to tile in the x and y directions. If not tiling in x or y directions, the single image is plotted. The width and height give the dimensions the image is to be scaled to.
ctx | The current redraw context. |
bitmap | The bitmap to plot |
x | The x coordinate to plot the bitmap |
y | The y coordiante to plot the bitmap |
width | The width of area to plot the bitmap into |
height | The height of area to plot the bitmap into |
bg | the background colour to alpha blend into |
flags | the flags controlling the type of plot operation |
Definition at line 515 of file plotters.c.
References BITMAPF_REPEAT_X, BITMAPF_REPEAT_Y, cliprect, current_cr, height, NSERROR_OK, bitmap::surface, and width.
void nsgtk_plot_caret | ( | int | x, |
int | y, | ||
int | h | ||
) |
Plot a caret.
Definition at line 278 of file plotters.c.
References current_cr, nsgtk_set_colour(), and nsgtk_set_solid().
Referenced by nsgtk_window_draw_event().
|
static |
Sets a clip rectangle for subsequent plot operations.
ctx | The current redraw context. |
clip | The rectangle to limit all subsequent plot operations within. |
Definition at line 114 of file plotters.c.
References clip(), cliprect, current_cr, and NSERROR_OK.
|
static |
Plots a circle.
Plot a circle centered on (x,y), which is optionally filled.
ctx | The current redraw context. |
style | Style controlling the circle plot. |
x | x coordinate of circle centre. |
y | y coordinate of circle centre. |
radius | circle radius. |
Definition at line 177 of file plotters.c.
References current_cr, plot_style_s::fill_colour, plot_style_s::fill_type, M_PI, NSERROR_OK, nsgtk_set_colour(), nsgtk_set_dashed(), nsgtk_set_dotted(), nsgtk_set_line_width(), nsgtk_set_solid(), PLOT_OP_TYPE_DASH, PLOT_OP_TYPE_DOT, PLOT_OP_TYPE_NONE, PLOT_OP_TYPE_SOLID, plot_style_s::stroke_colour, plot_style_s::stroke_type, and plot_style_s::stroke_width.
|
static |
Plots a line.
plot a line from (x0,y0) to (x1,y1). Coordinates are at centre of line width/thickness.
ctx | The current redraw context. |
style | Style controlling the line plot. |
line | A rectangle defining the line to be drawn |
Definition at line 231 of file plotters.c.
References current_cr, line(), NSERROR_OK, nsgtk_set_colour(), nsgtk_set_dashed(), nsgtk_set_dotted(), nsgtk_set_line_width(), nsgtk_set_solid(), PLOT_OP_TYPE_DASH, PLOT_OP_TYPE_DOT, PLOT_OP_TYPE_NONE, PLOT_OP_TYPE_SOLID, plot_style_s::stroke_colour, plot_style_s::stroke_type, and plot_style_s::stroke_width.
|
static |
Plots a path.
Path plot consisting of cubic Bezier curves. Line and fill colour is controlled by the plot style.
ctx | The current redraw context. |
pstyle | Style controlling the path plot. |
p | elements of path |
n | nunber of elements on path |
transform | A transform to apply to the path. |
Definition at line 406 of file plotters.c.
References current_cr, plot_style_s::fill_colour, NS_TRANSPARENT, NSERROR_INVALID, NSERROR_OK, nsgtk_set_colour(), nsgtk_set_line_width(), nsgtk_set_solid(), NSLOG, PLOTTER_PATH_BEZIER, PLOTTER_PATH_CLOSE, PLOTTER_PATH_LINE, PLOTTER_PATH_MOVE, plot_style_s::stroke_colour, and plot_style_s::stroke_width.
|
static |
Plot a polygon.
Plots a filled polygon with straight lines between points. The lines around the edge of the ploygon are not plotted. The polygon is filled with the non-zero winding rule.
ctx | The current redraw context. |
style | Style controlling the polygon plot. |
p | verticies of polygon |
n | number of verticies. |
Definition at line 370 of file plotters.c.
References current_cr, plot_style_s::fill_colour, NSERROR_OK, nsgtk_set_colour(), and nsgtk_set_solid().
|
static |
Plots a rectangle.
The rectangle can be filled an outline or both controlled by the plot style The line can be solid, dotted or dashed. Top left corner at (x0,y0) and rectangle has given width and height.
ctx | The current redraw context. |
style | Style controlling the rectangle plot. |
rect | A rectangle defining the line to be drawn |
Definition at line 306 of file plotters.c.
References current_cr, plot_style_s::fill_colour, plot_style_s::fill_type, NSERROR_OK, nsgtk_set_colour(), nsgtk_set_dashed(), nsgtk_set_dotted(), nsgtk_set_line_width(), nsgtk_set_solid(), PLOT_OP_TYPE_DASH, PLOT_OP_TYPE_DOT, PLOT_OP_TYPE_NONE, PLOT_OP_TYPE_SOLID, plot_style_s::stroke_colour, plot_style_s::stroke_type, plot_style_s::stroke_width, rect::x0, rect::x1, rect::y0, and rect::y1.
|
static |
Text plotting.
ctx | The current redraw context. |
fstyle | plot style for this text |
x | x coordinate |
y | y coordinate |
text | UTF-8 string to plot |
length | length of string, in bytes |
Definition at line 635 of file plotters.c.
References nsfont_paint(), and text().
void nsgtk_set_colour | ( | colour | c | ) |
Set cairo context colour to nsgtk colour.
c | the netsurf colour to set in cairo |
Definition at line 51 of file plotters.c.
References current_cr.
Referenced by nsfont_paint(), nsgtk_plot_arc(), nsgtk_plot_caret(), nsgtk_plot_disc(), nsgtk_plot_line(), nsgtk_plot_path(), nsgtk_plot_polygon(), and nsgtk_plot_rectangle().
|
inlinestatic |
Set cairo context to dashed plot operation.
Definition at line 84 of file plotters.c.
References current_cr.
Referenced by nsgtk_plot_disc(), nsgtk_plot_line(), and nsgtk_plot_rectangle().
|
inlinestatic |
Set cairo context to dotted plot operation.
Definition at line 74 of file plotters.c.
References current_cr.
Referenced by nsgtk_plot_disc(), nsgtk_plot_line(), and nsgtk_plot_rectangle().
|
inlinestatic |
Set cairo context line width.
Definition at line 94 of file plotters.c.
References current_cr, plot_style_fixed_to_double, and width.
Referenced by nsgtk_plot_disc(), nsgtk_plot_line(), nsgtk_plot_path(), and nsgtk_plot_rectangle().
|
inlinestatic |
Set cairo context to solid plot operation.
Definition at line 64 of file plotters.c.
References current_cr.
Referenced by nsgtk_plot_arc(), nsgtk_plot_caret(), nsgtk_plot_disc(), nsgtk_plot_line(), nsgtk_plot_path(), nsgtk_plot_polygon(), and nsgtk_plot_rectangle().
|
static |
Definition at line 44 of file plotters.c.
Referenced by nsbeos_plot_bitmap(), nsgtk_plot_bitmap(), and nsgtk_plot_clip().
cairo_t* current_cr |
Definition at line 42 of file plotters.c.
Referenced by bitmap_render(), nsfont_paint(), nsgtk_cw_draw_event(), nsgtk_plot_arc(), nsgtk_plot_bitmap(), nsgtk_plot_caret(), nsgtk_plot_clip(), nsgtk_plot_disc(), nsgtk_plot_line(), nsgtk_plot_path(), nsgtk_plot_polygon(), nsgtk_plot_rectangle(), nsgtk_set_colour(), nsgtk_set_dashed(), nsgtk_set_dotted(), nsgtk_set_line_width(), nsgtk_set_solid(), and nsgtk_window_draw_event().
const struct plotter_table nsgtk_plotters |
GTK plotter table.
Definition at line 647 of file plotters.c.
Referenced by bitmap_render(), nsgtk_cookies_draw(), nsgtk_global_history_draw(), nsgtk_hotlist_draw(), nsgtk_local_history_draw(), nsgtk_pi_draw(), and nsgtk_window_draw_event().