NetSurf
Functions | Variables
plot.c File Reference

win32 plotter implementation. More...

#include "utils/config.h"
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <windows.h>
#include "utils/log.h"
#include "utils/utf8.h"
#include "netsurf/mouse.h"
#include "netsurf/window.h"
#include "netsurf/plotters.h"
#include "windows/bitmap.h"
#include "windows/font.h"
#include "windows/gui.h"
#include "windows/plot.h"
Include dependency graph for plot.c:

Go to the source code of this file.

Functions

static nserror plot_block (COLORREF col, int x, int y, int width, int height)
 bitmap helper to plot a solid block of colour More...
 
static nserror plot_alpha_bitmap (HDC hdc, struct bitmap *bitmap, int x, int y, int width, int height)
 plot an alpha blended bitmap More...
 
static nserror plot_bitmap (struct bitmap *bitmap, int x, int y, int width, int height)
 Internal bitmap plotting. More...
 
static nserror clip (const struct redraw_context *ctx, const struct rect *clip)
 Sets a clip rectangle for subsequent plot operations. More...
 
static nserror 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 disc (const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
 Plots a circle. More...
 
static nserror line (const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
 Plots a line. More...
 
static nserror rectangle (const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect)
 Plots a rectangle. More...
 
static nserror polygon (const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
 Plot a polygon. More...
 
static nserror 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 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 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

HDC plot_hdc
 
static RECT plot_clip
 currently set clipping rectangle More...
 
const struct plotter_table win_plotters
 win32 API plot operation table More...
 

Detailed Description

win32 plotter implementation.

Definition in file plot.c.

Function Documentation

◆ arc()

static nserror arc ( const struct redraw_context ctx,
const plot_style_t style,
int  x,
int  y,
int  radius,
int  angle1,
int  angle2 
)
static

Plots an arc.

plot an arc segment around (x,y), anticlockwise from angle1 to angle2. Angles are measured anticlockwise from horizontal, in degrees.

Parameters
ctxThe current redraw context.
styleStyle controlling the arc plot.
xThe x coordinate of the arc.
yThe y coordinate of the arc.
radiusThe radius of the arc.
angle1The start angle of the arc.
angle2The finish angle of the arc.
Returns
NSERROR_OK on success else error code.

Definition at line 387 of file plot.c.

References M_PI, NSERROR_INVALID, NSERROR_OK, NSLOG, plot_clip, plot_hdc, and plot_style_s::stroke_colour.

◆ bitmap()

static nserror bitmap ( const struct redraw_context ctx,
struct bitmap bitmap,
int  x,
int  y,
int  width,
int  height,
colour  bg,
bitmap_flags_t  flags 
)
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.

Parameters
ctxThe current redraw context.
bitmapThe bitmap to plot
xThe x coordinate to plot the bitmap
yThe y coordiante to plot the bitmap
widthThe width of area to plot the bitmap into
heightThe height of area to plot the bitmap into
bgthe background colour to alpha blend into
flagsthe flags controlling the type of plot operation
Returns
NSERROR_OK on success else error code.

TODO: Currently using top left pixel. Maybe centre pixel or average value would be better.

Definition at line 857 of file plot.c.

References BITMAPF_REPEAT_X, BITMAPF_REPEAT_Y, bitmap::height, height, NSERROR_OK, NSLOG, bitmap::opaque, bitmap::pixdata, plot_bitmap(), plot_block(), plot_clip, bitmap::width, and width.

Referenced by amiga_bitmap_create(), amiga_bitmap_destroy(), amiga_bitmap_get_buffer(), amiga_bitmap_get_opaque(), amiga_bitmap_get_rowstride(), amiga_bitmap_modified(), amiga_bitmap_set_opaque(), amiga_icon_from_bitmap(), atari_bitmap_buffer_size(), atari_bitmap_create_ex(), atari_bitmap_destroy(), atari_bitmap_get_height(), atari_bitmap_get_opaque(), atari_bitmap_get_rowstride(), atari_bitmap_get_width(), bitmap_destroy(), bitmap_get_buffer(), bitmap_get_height(), bitmap_get_opaque(), bitmap_get_rowstride(), bitmap_get_width(), bitmap_modified(), bitmap_set_opaque(), browser_window_history_get_thumbnail(), content__get_bitmap(), framebuffer_bitmap_get_opaque(), gif_content_is_opaque(), gif_get_bitmap(), gif_redraw(), image_cache_add(), jpeg_cache_convert(), jpegxl_cache_convert(), knockout_plot_bitmap(), make_toolbar_item_websearch(), plot_bitmap(), png_cache_convert(), riscos_bitmap_create(), ro_gui_save_create_thumbnail(), ro_gui_window_iconise(), rsvg_cache_convert(), NSResizeKnob::SetBitmap(), NSThrobber::SetBitmap(), webp_cache_convert(), win32_bitmap_create(), and win32_bitmap_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clip()

static nserror clip ( const struct redraw_context ctx,
const struct rect clip 
)
static

Sets a clip rectangle for subsequent plot operations.

Parameters
ctxThe current redraw context.
clipThe rectangle to limit all subsequent plot operations within.
Returns
NSERROR_OK on success else error code.

Definition at line 357 of file plot.c.

References clip(), NSERROR_OK, NSLOG, and plot_clip.

Referenced by ablend_pixel(), about_userdraw(), ami_clip(), ami_do_redraw_tiled(), atari_cookie_manager_draw(), atari_global_history_draw(), atari_hotlist_draw(), atari_treeview_redraw(), bitmap_convert_tc(), browser_window_place_caret(), browser_window_redraw(), clip(), content_redraw(), content_scaled_redraw(), cookie_manager_redraw(), fb_cw_draw_event(), fb_redraw(), fbtk_clip_rect(), form_clip_inside_select_menu(), form_redraw_select_menu(), framebuffer_plot_clip(), gif_redraw(), global_history_redraw(), gui_get_clipboard(), gui_set_clipboard(), gui_window_place_caret(), hotlist_redraw(), html_redraw(), html_redraw_background(), html_redraw_border_plot(), html_redraw_borders(), html_redraw_box(), html_redraw_box_children(), html_redraw_inline_background(), html_redraw_inline_borders(), html_redraw_text_box(), html_set_focus(), image_bitmap_plot(), image_cache_redraw(), knockout_plot_clip(), local_history_redraw(), monkey_plot_clip(), monkey_window_handle_redraw(), nsbeos_plot_clip(), nsbeos_window_expose_event(), nsgtk_cw_draw_event(), nsgtk_plot_clip(), nsgtk_print_plot_clip(), nsgtk_window_draw_event(), nsico_redraw(), nsw32_corewindow_paint(), nsws_drawable_paint(), on_aes_event(), on_redraw(), on_redraw_event(), page_info_redraw(), plot_bitmap(), plot_blit_bitmap(), plot_clip(), plot_clipped_rectangle(), plot_get_clip_grect(), plot_init(), print_declare_fonts(), print_document(), print_draw_next_page(), redraw_entry(), ro_gui_progress_bar_redraw_window(), ro_gui_url_bar_redraw(), ro_gui_window__redraw_rect(), ro_plot_clip(), scrollbar_redraw(), svg_redraw(), text_draw(), text_redraw(), textarea_redraw(), textplain_redraw(), toolbar_key_input(), toolbar_redraw(), toolbar_redraw_cb(), treeview_redraw(), window_redraw_content(), and window_redraw_favicon().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disc()

static nserror disc ( const struct redraw_context ctx,
const plot_style_t style,
int  x,
int  y,
int  radius 
)
static

Plots a circle.

Plot a circle centered on (x,y), which is optionally filled.

Parameters
ctxThe current redraw context.
styleStyle controlling the circle plot.
xx coordinate of circle centre.
yy coordinate of circle centre.
radiuscircle radius.
Returns
NSERROR_OK on success else error code.

Definition at line 500 of file plot.c.

References plot_style_s::fill_colour, plot_style_s::fill_type, NSERROR_INVALID, NSERROR_OK, NSLOG, plot_clip, plot_hdc, PLOT_OP_TYPE_NONE, and plot_style_s::stroke_colour.

◆ line()

static nserror line ( const struct redraw_context ctx,
const plot_style_t style,
const struct rect line 
)
static

Plots a line.

plot a line from (x0,y0) to (x1,y1). Coordinates are at centre of line width/thickness.

Parameters
ctxThe current redraw context.
styleStyle controlling the line plot.
lineA rectangle defining the line to be drawn
Returns
NSERROR_OK on success else error code.

Definition at line 579 of file plot.c.

References line(), NSERROR_INVALID, NSERROR_OK, NSLOG, plot_clip, plot_hdc, PLOT_OP_TYPE_DASH, PLOT_OP_TYPE_DOT, plot_style_fixed_to_int, plot_style_s::stroke_colour, plot_style_s::stroke_type, and plot_style_s::stroke_width.

Referenced by __assert2(), ami_line(), ami_memory_slab_stats_cb(), duk__emit_op_only(), duk__error_getter_helper(), duk_err_create_and_throw(), duk_error_raw(), fb_redraw(), fb_redraw_text(), fb_redraw_text_button(), framebuffer_plot_line(), get_key_value(), gtk_fetch_filetype_init(), gtk_print_font_paint(), knockout_plot_line(), layout_flex__build_line(), layout_flex__collect_items_into_lines(), layout_flex__distribute_free_main(), layout_flex__get_min_max_violations(), layout_flex__item_freeze(), layout_flex__place_line_items_cross(), layout_flex__place_line_items_main(), layout_flex__place_lines(), layout_flex__remaining_free_main(), layout_flex__resolve_line(), line(), llcache_process_metadata(), monkey_fetch_filetype_init(), monkey_plot_line(), nsbeos_plot_line(), nsfont_paint(), nsfont_split(), nsgtk_plot_line(), nsgtk_print_plot_line(), optionline(), plot_line(), ro_gui_ieurl_file_parse(), ro_gui_uri_file_parse(), ro_gui_url_complete_redraw(), ro_gui_url_file_parse(), ro_plot_line(), ro_textarea_redraw_internal(), ro_textarea_set_caret_xy(), scrollbar_rectangle(), textarea_get_b_off_xy(), textarea_keypress(), textarea_redraw(), textarea_reflow_multiline(), textplain_coords_from_range(), textplain_find_line(), textplain_get_line(), textplain_offset_from_coords(), textplain_redraw(), textplain_reformat(), textplain_textsearch_find(), xdg_get_default_app(), and xdg_get_exec_cmd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ path()

static nserror path ( const struct redraw_context ctx,
const plot_style_t pstyle,
const float *  p,
unsigned int  n,
const float  transform[6] 
)
static

Plots a path.

Path plot consisting of cubic Bezier curves. Line and fill colour is controlled by the plot style.

Parameters
ctxThe current redraw context.
pstyleStyle controlling the path plot.
pelements of path
nnunber of elements on path
transformA transform to apply to the path.
Returns
NSERROR_OK on success else error code.

Definition at line 821 of file plot.c.

References NSERROR_OK, and NSLOG.

Referenced by ami_file_set_type(), ami_gui_map_filename(), amiga_basename(), amiga_bitmap_save(), amiga_icon_superimpose_favicon(), amiga_nsurl_to_path(), amiga_path_to_nsurl(), atari_basename(), atari_nsurl_to_path(), atari_path_to_nsurl(), browser_window__navigate_internal(), check_dirname(), check_homedir(), cookie_manager_delete_entry(), download_ro_filetype(), expand_path(), fetch_filetype(), fetch_resource_finalise(), fetch_resource_initialise(), fetch_resource_setup(), file_select(), filepath_path_to_strvec(), filesize(), find_app_resources(), find_resource(), gemdos_realpath(), gen_nice_title(), get_resource_url(), global_history_export(), gui_default_mimetype(), gui_default_pdf_password(), gui_get_resource_url(), gui_init(), handle_filesystem_select_button(), hash_add_file(), hotlist_export(), hotlist_get_temp_path(), hotlist_load(), hotlist_populate(), hotlist_save(), html_css_fetcher_setup(), is_dir(), is_internal_navigate_url(), main(), menu_save_page(), messages_add_from_file(), messages_load_ctx(), mouse_action_drag_none(), netsurf_path_to_nsurl(), netsurf_recursive_rm(), nsbeos_find_app_path(), nsbeos_gui_view_source(), nsbeos_scaffolding_dispatch_event(), nsgtk_download_tree_view_row_activated(), nsgtk_get_resource_url(), nsgtk_PDF_no_pass(), nsgtk_pdf_password(), nsgtk_PDF_set_pass(), nsgtk_saveas_dialog(), nsoption_read(), nsoption_write(), nsw32_get_resource_data(), nsw32_get_resource_url(), posix_basename(), posix_nsurl_to_path(), posix_path_to_nsurl(), realpath(), riscos_basename(), riscos_bitmap_save(), ro_filetype_from_unix_path(), ro_gui_choose_language(), ro_gui_create_dirs(), ro_gui_default_language(), ro_gui_download_canonicalise(), ro_gui_download_remember_dir(), ro_gui_save_clipboard(), ro_gui_save_complete(), ro_gui_save_content(), ro_gui_save_datasave_ack(), ro_gui_save_link(), ro_gui_save_object_native(), ro_gui_save_ok(), ro_gui_save_set_file_type(), ro_nsurl_to_path(), ro_path_to_nsurl(), ro_plot_draw_path(), ro_plot_line(), ro_plot_path(), ro_plot_polygon(), ro_plot_rectangle(), save_as_text(), save_complete(), save_complete_ctx_initialise(), savepage_button_clicked_cb(), scrap_txt_read(), select_filepath(), url_to_path(), urldb_delete_cookie(), urldb_delete_cookie_hosts(), urldb_delete_cookie_paths(), urldb_get_cookie(), urldb_load_cookies(), urldb_match_path(), urldb_parse_cookie(), urldb_save_search_tree(), urldb_set_cookie(), urldb_write_paths(), utf8_save_text(), windows_basename(), windows_nsurl_to_path(), windows_path_to_nsurl(), xdg_get_default_app(), and xdg_get_exec_cmd().

Here is the caller graph for this function:

◆ plot_alpha_bitmap()

static nserror plot_alpha_bitmap ( HDC  hdc,
struct bitmap bitmap,
int  x,
int  y,
int  width,
int  height 
)
static

plot an alpha blended bitmap

blunt force truma way of achiving alpha blended plotting

Parameters
hdcdrawing cotext
bitmapbitmap to render
xx coordinate to plot at
yy coordinate to plot at
widthThe width to plot the bitmap into
heightThe height to plot the bitmap into
Returns
NSERROR_OK on success else appropriate error code.

Definition at line 120 of file plot.c.

References bitmap_scale(), bitmap::height, height, NSERROR_INVALID, NSERROR_OK, NSLOG, bitmap::pixdata, plot_clip, bitmap::width, width, and bitmap::windib.

Referenced by plot_bitmap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plot_bitmap()

static nserror plot_bitmap ( struct bitmap bitmap,
int  x,
int  y,
int  width,
int  height 
)
static

Internal bitmap plotting.

Parameters
bitmapThe bitmap to plot
xx coordinate to plot at
yy coordinate to plot at
widthThe width to plot the bitmap into
heightThe height to plot the bitmap into
Returns
NSERROR_OK on success else appropriate error code.

Definition at line 276 of file plot.c.

References bitmap::height, height, NSERROR_INVALID, NSERROR_OK, NSLOG, bitmap::opaque, bitmap::pbmi, bitmap::pixdata, plot_alpha_bitmap(), plot_clip, plot_hdc, bitmap::width, and width.

Referenced by bitmap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plot_block()

static nserror plot_block ( COLORREF  col,
int  x,
int  y,
int  width,
int  height 
)
static

bitmap helper to plot a solid block of colour

Parameters
colcolour to plot with
xthe x coordinate to plot at
ythe y coordinate to plot at
widththe width of block to plot
heightthe height to plot
Returns
NSERROR_OK on sucess else error code.

Definition at line 61 of file plot.c.

References height, NSERROR_INVALID, NSERROR_OK, NSLOG, plot_clip, plot_hdc, and width.

Referenced by bitmap().

Here is the caller graph for this function:

◆ polygon()

static nserror polygon ( const struct redraw_context ctx,
const plot_style_t style,
const int *  p,
unsigned int  n 
)
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.

Parameters
ctxThe current redraw context.
styleStyle controlling the polygon plot.
pverticies of polygon
nnumber of verticies.
Returns
NSERROR_OK on success else error code.

Definition at line 733 of file plot.c.

References plot_style_s::fill_colour, NSERROR_INVALID, NSERROR_OK, NSLOG, plot_clip, plot_hdc, point_s::x, and point_s::y.

◆ rectangle()

static nserror rectangle ( const struct redraw_context ctx,
const plot_style_t style,
const struct rect rect 
)
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.

Parameters
ctxThe current redraw context.
styleStyle controlling the rectangle plot.
rectA rectangle defining the line to be drawn
Returns
NSERROR_OK on success else error code.

Definition at line 648 of file plot.c.

References plot_style_s::fill_colour, plot_style_s::fill_type, NSERROR_INVALID, NSERROR_OK, NSLOG, plot_clip, plot_hdc, PLOT_OP_TYPE_DASH, PLOT_OP_TYPE_DOT, PLOT_OP_TYPE_NONE, plot_style_fixed_to_int, plot_style_s::stroke_colour, plot_style_s::stroke_type, plot_style_s::stroke_width, rect::x0, rect::x1, rect::y0, and rect::y1.

◆ text()

static nserror text ( const struct redraw_context ctx,
const struct plot_font_style fstyle,
int  x,
int  y,
const char *  text,
size_t  length 
)
static

Text plotting.

Parameters
ctxThe current redraw context.
fstyleplot style for this text
xx coordinate
yy coordinate
textUTF-8 string to plot
lengthlength of string, in bytes
Returns
NSERROR_OK on success else error code.

Definition at line 978 of file plot.c.

References plot_font_style::background, plot_font_style::foreground, get_font(), NSERROR_INVALID, NSERROR_OK, NSLOG, plot_clip, plot_hdc, and text().

Referenced by ami_clipboard_cat_collection(), ami_easy_clipboard(), ami_gui_opts_event(), ami_search_string(), ami_text(), atari_window_set_status(), beos_warn_user(), box_construct_text(), box_select_add_option(), box_textarea_create_textarea(), browser_window_set_status(), create_login_window(), die(), fb_url_enter(), fbtk_set_text(), find_occurrences_html_box(), form_add_option(), framebuffer_plot_text(), gui_download_window_create(), gui_get_clipboard(), gui_set_clipboard(), gui_window_set_status(), html_redraw_file(), knockout_plot_text(), monkey_plot_text(), nsbeos_about(), nsbeos_plot_text(), nsbeos_scaffolding_dispatch_event(), nsgtk_combo_box_text_append_text(), nsgtk_download_update(), nsgtk_plot_text(), nsgtk_print_plot_text(), options_general_dialog_handler(), plot_text(), print_fonts_plot_text(), riscos_window_set_status(), ro_gui_menu_define_menu_add(), ro_gui_options_connection_proxy_type(), ro_gui_options_image_read(), ro_gui_set_icon_string(), ro_gui_set_window_title(), ro_gui_status_bar_set_text(), ro_gui_wimp_event_prepare_gright_menu(), ro_plot_text(), ro_textarea_insert_text(), ro_textarea_reflow(), ro_textarea_replace_text(), ro_textarea_set_text(), save_complete_node_handler(), save_text_add_to_buffer(), sb_set_text(), selection_copy_box(), selection_string_append(), set_text(), text(), text_draw(), textarea_char_to_byte_offset(), textarea_drop_text(), textarea_get_text(), textarea_insert_text(), textarea_reflow_multiline(), textarea_set_text(), textplain_clone(), textplain_close(), textplain_convert(), textplain_coord_from_offset(), textplain_coords_from_range(), textplain_create(), textplain_destroy(), textplain_find_line(), textplain_get_line(), textplain_get_raw_data(), textplain_get_selection(), textplain_keypress(), textplain_line_count(), textplain_mouse_action(), textplain_mouse_track(), textplain_offset_from_coords(), textplain_open(), textplain_process_data(), textplain_redraw(), textplain_reformat(), textplain_textsearch_find(), textplain_textselection_copy(), textplain_textselection_get_end(), toolbar_key_input(), toolbar_set_url(), treeview__create_textarea(), treeview__search(), treeview_node_selection_walk_cb(), win32_window_set_status(), and window_set_stauts().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ plot_clip

RECT plot_clip
static

currently set clipping rectangle

Definition at line 47 of file plot.c.

Referenced by arc(), bitmap(), clip(), disc(), line(), plot_alpha_bitmap(), plot_bitmap(), plot_block(), polygon(), rectangle(), and text().

◆ plot_hdc

HDC plot_hdc

◆ win_plotters

const struct plotter_table win_plotters
Initial value:
= {
.rectangle = rectangle,
.line = line,
.polygon = polygon,
.clip = clip,
.text = text,
.disc = disc,
.arc = arc,
.bitmap = bitmap,
.path = path,
.option_knockout = true,
}
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
Definition: plot.c:821
static nserror 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.
Definition: plot.c:857
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
Definition: plot.c:579
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
Definition: plot.c:978
static nserror arc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius, int angle1, int angle2)
Plots an arc.
Definition: plot.c:387
static nserror disc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
Plots a circle.
Definition: plot.c:500
static nserror rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect)
Plots a rectangle.
Definition: plot.c:648
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357
static nserror polygon(const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
Plot a polygon.
Definition: plot.c:733

win32 API plot operation table

Definition at line 1040 of file plot.c.

Referenced by bitmap_render(), nsw32_cookie_draw(), nsw32_global_history_draw(), nsw32_hotlist_draw(), nsw32_local_history_draw(), and nsws_drawable_paint().