NetSurf
|
Knockout rendering implementation. More...
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/errors.h"
#include "netsurf/bitmap.h"
#include "content/content.h"
#include "netsurf/plotters.h"
#include "desktop/gui_internal.h"
#include "desktop/knockout.h"
Go to the source code of this file.
Data Structures | |
struct | knockout_box |
struct | knockout_entry |
Macros | |
#define | KNOCKOUT_ENTRIES 3072 /* 40 bytes each */ |
#define | KNOCKOUT_BOXES 768 /* 28 bytes each */ |
#define | KNOCKOUT_POLYGONS 3072 /* 4 bytes each */ |
Functions | |
static nserror | knockout_plot_fill_recursive (const struct redraw_context *ctx, struct knockout_box *box, plot_style_t *plot_style) |
fill an area recursively More... | |
static nserror | knockout_plot_bitmap_recursive (const struct redraw_context *ctx, struct knockout_box *box, struct knockout_entry *entry) |
bitmap plot recusivley More... | |
static nserror | knockout_plot_flush (const struct redraw_context *ctx) |
Flush the current knockout session to empty the buffers. More... | |
static void | knockout_calculate (const struct redraw_context *ctx, int x0, int y0, int x1, int y1, struct knockout_box *owner) |
Knockout a section of previous rendering. More... | |
static nserror | knockout_plot_rectangle (const struct redraw_context *ctx, const plot_style_t *pstyle, const struct rect *rect) |
knockout rectangle plotting. More... | |
static nserror | knockout_plot_line (const struct redraw_context *ctx, const plot_style_t *pstyle, const struct rect *line) |
Knockout line plotting. More... | |
static nserror | knockout_plot_polygon (const struct redraw_context *ctx, const plot_style_t *pstyle, const int *p, unsigned int n) |
Knockout polygon plotting. More... | |
static nserror | knockout_plot_path (const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6]) |
knockout path plotting. More... | |
static nserror | knockout_plot_clip (const struct redraw_context *ctx, const struct rect *clip) |
static nserror | knockout_plot_text (const struct redraw_context *ctx, const plot_font_style_t *fstyle, int x, int y, const char *text, size_t length) |
Text plotting. More... | |
static nserror | knockout_plot_disc (const struct redraw_context *ctx, const plot_style_t *pstyle, int x, int y, int radius) |
knockout circle plotting More... | |
static nserror | knockout_plot_arc (const struct redraw_context *ctx, const plot_style_t *pstyle, int x, int y, int radius, int angle1, int angle2) |
Plots an arc. More... | |
static nserror | knockout_plot_bitmap (const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags) |
knockout bitmap plotting. More... | |
static nserror | knockout_plot_group_start (const struct redraw_context *ctx, const char *name) |
Start of a group of objects. More... | |
static nserror | knockout_plot_group_end (const struct redraw_context *ctx) |
End a group of objects. More... | |
bool | knockout_plot_start (const struct redraw_context *ctx, struct redraw_context *knk_ctx) |
Start a knockout plotting session. More... | |
bool | knockout_plot_end (const struct redraw_context *ctx) |
End a knockout plotting session. More... | |
Variables | |
static struct knockout_entry | knockout_entries [KNOCKOUT_ENTRIES] |
static struct knockout_box | knockout_boxes [KNOCKOUT_BOXES] |
static int | knockout_polygons [KNOCKOUT_POLYGONS] |
static int | knockout_entry_cur = 0 |
static int | knockout_box_cur = 0 |
static int | knockout_polygon_cur = 0 |
static struct knockout_box * | knockout_list = NULL |
static struct plotter_table | real_plot |
static struct rect | clip_cur |
static int | nested_depth = 0 |
const struct plotter_table | knockout_plotters |
knockout plotter operation table More... | |
Knockout rendering implementation.
Knockout rendering is an optimisation which is particularly for unaccelerated screen redraw. It tries to avoid plotting the same area more than once.
If the object is to plot two overlapping rectangles (one large, one small), such as:
+--------------—+ |#################| |####+----—+####| |####|:::::::|####| |####|:::::::|####| |####|:::::::|####| |####+----—+####| |#################| +--------------—+
Without knockout rendering we plot the bottom rectangle and then the top one:
+--------------—+ +--------------—+ |#################| |#################| |#################| |####+----—+####| |#################| |####|:::::::|####| |#################| and then, |####|:::::::|####| |#################| |####|:::::::|####| |#################| |####+----—+####| |#################| |#################| +--------------—+ +--------------—+
With knockout rendering, the bottom rectangle is split up into smaller ones and each pixel is just plotted once:
+--------------—+ |#################| +-—+----—+-—+ |####|:::::::|####| |####|:::::::|####| |####|:::::::|####| +-—+----—+-—+ |#################| +--------------—+
Definition in file knockout.c.
#define KNOCKOUT_BOXES 768 /* 28 bytes each */ |
Definition at line 84 of file knockout.c.
#define KNOCKOUT_ENTRIES 3072 /* 40 bytes each */ |
Definition at line 83 of file knockout.c.
#define KNOCKOUT_POLYGONS 3072 /* 4 bytes each */ |
Definition at line 85 of file knockout.c.
enum knockout_type |
Definition at line 90 of file knockout.c.
|
static |
Knockout a section of previous rendering.
ctx | The current redraw context. |
x0 | The left edge of the removal box |
y0 | The bottom edge of the removal box |
x1 | The right edge of the removal box |
y1 | The top edge of the removal box |
owner | The parent box set to consider, or NULL for top level |
Definition at line 394 of file knockout.c.
References knockout_box::bbox, knockout_box::child, knockout_box::deleted, knockout_box_cur, KNOCKOUT_BOXES, knockout_boxes, knockout_calculate(), knockout_list, knockout_plot_flush(), knockout_box::next, parent, rect::x0, rect::x1, rect::y0, and rect::y1.
Referenced by knockout_calculate(), knockout_plot_bitmap(), and knockout_plot_rectangle().
|
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. |
pstyle | 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 807 of file knockout.c.
References knockout_entry::angle1, knockout_entry::angle2, knockout_entry::arc, knockout_entry::data, KNOCKOUT_ENTRIES, knockout_entries, knockout_entry_cur, KNOCKOUT_PLOT_ARC, knockout_plot_flush(), NSERROR_OK, knockout_entry::plot_style, knockout_entry::radius, knockout_entry::type, knockout_entry::x, and knockout_entry::y.
|
static |
knockout bitmap plotting.
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 856 of file knockout.c.
References knockout_box::bbox, netsurf_table::bitmap, knockout_entry::bitmap, bitmap(), BITMAPF_REPEAT_X, BITMAPF_REPEAT_Y, knockout_entry::box, knockout_box::child, clip_cur, knockout_entry::data, knockout_box::deleted, gui_bitmap_table::get_opaque, guit, bitmap::height, height, knockout_box_cur, KNOCKOUT_BOXES, knockout_boxes, knockout_calculate(), KNOCKOUT_ENTRIES, knockout_entries, knockout_entry_cur, knockout_list, KNOCKOUT_PLOT_BITMAP, knockout_plot_clip(), knockout_plot_flush(), knockout_box::next, NSERROR_OK, knockout_entry::type, bitmap::width, width, rect::x0, rect::x1, rect::y0, and rect::y1.
|
static |
bitmap plot recusivley
Definition at line 221 of file knockout.c.
References knockout_entry::bitmap, plotter_table::bitmap, plotter_table::clip, knockout_entry::data, bitmap::height, knockout_plot_bitmap_recursive(), NSERROR_OK, parent, real_plot, and bitmap::width.
Referenced by knockout_plot_bitmap_recursive(), and knockout_plot_flush().
|
static |
Definition at line 699 of file knockout.c.
References knockout_entry::clip, clip(), clip_cur, knockout_entry::data, KNOCKOUT_ENTRIES, knockout_entries, knockout_entry_cur, KNOCKOUT_PLOT_CLIP, knockout_plot_flush(), NSERROR_BAD_SIZE, NSERROR_OK, NSLOG, and knockout_entry::type.
Referenced by knockout_plot_bitmap().
|
static |
knockout circle plotting
Plot a circle centered on (x,y), which is optionally filled.
ctx | The current redraw context. |
pstyle | Style controlling the circle plot. |
x | x coordinate of circle centre. |
y | y coordinate of circle centre. |
radius | circle radius. |
Definition at line 770 of file knockout.c.
References knockout_entry::data, knockout_entry::disc, KNOCKOUT_ENTRIES, knockout_entries, knockout_entry_cur, KNOCKOUT_PLOT_DISC, knockout_plot_flush(), NSERROR_OK, knockout_entry::plot_style, knockout_entry::radius, knockout_entry::type, knockout_entry::x, and knockout_entry::y.
bool knockout_plot_end | ( | const struct redraw_context * | ctx | ) |
End a knockout plotting session.
Definition at line 997 of file knockout.c.
References knockout_plot_flush(), and nested_depth.
Referenced by browser_window_redraw(), content_scaled_redraw(), knockout_plot_start(), page_info_redraw(), and treeview_redraw().
|
static |
fill an area recursively
Definition at line 190 of file knockout.c.
References knockout_plot_fill_recursive(), NSERROR_OK, parent, real_plot, and plotter_table::rectangle.
Referenced by knockout_plot_fill_recursive(), and knockout_plot_flush().
|
static |
Flush the current knockout session to empty the buffers.
Definition at line 261 of file knockout.c.
References knockout_entry::angle1, knockout_entry::angle2, knockout_entry::arc, plotter_table::arc, knockout_entry::bitmap, plotter_table::bitmap, knockout_entry::box, knockout_box::child, knockout_entry::clip, plotter_table::clip, knockout_entry::data, knockout_entry::disc, plotter_table::disc, knockout_entry::fill, plotter_table::group_end, knockout_entry::group_start, plotter_table::group_start, bitmap::height, knockout_box_cur, KNOCKOUT_BOXES, KNOCKOUT_ENTRIES, knockout_entries, knockout_entry_cur, knockout_list, KNOCKOUT_PLOT_ARC, KNOCKOUT_PLOT_BITMAP, knockout_plot_bitmap_recursive(), KNOCKOUT_PLOT_CLIP, KNOCKOUT_PLOT_DISC, KNOCKOUT_PLOT_FILL, knockout_plot_fill_recursive(), KNOCKOUT_PLOT_GROUP_END, KNOCKOUT_PLOT_GROUP_START, KNOCKOUT_PLOT_LINE, KNOCKOUT_PLOT_POLYGON, KNOCKOUT_PLOT_RECTANGLE, KNOCKOUT_PLOT_TEXT, knockout_polygon_cur, KNOCKOUT_POLYGONS, knockout_entry::l, knockout_entry::line, plotter_table::line, knockout_entry::n, knockout_entry::name, NSERROR_OK, NSLOG, knockout_entry::p, knockout_entry::plot_style, knockout_entry::polygon, plotter_table::polygon, knockout_entry::r, knockout_entry::radius, real_plot, knockout_entry::rectangle, plotter_table::rectangle, knockout_entry::text, plotter_table::text, type, bitmap::width, knockout_entry::x, and knockout_entry::y.
Referenced by knockout_calculate(), knockout_plot_arc(), knockout_plot_bitmap(), knockout_plot_clip(), knockout_plot_disc(), knockout_plot_end(), knockout_plot_group_end(), knockout_plot_group_start(), knockout_plot_line(), knockout_plot_path(), knockout_plot_polygon(), knockout_plot_rectangle(), and knockout_plot_text().
|
static |
End a group of objects.
Used when plotter implements export to a vector graphics file format.
ctx | The current redraw context. |
Definition at line 957 of file knockout.c.
References plotter_table::group_end, KNOCKOUT_ENTRIES, knockout_entries, knockout_entry_cur, knockout_plot_flush(), KNOCKOUT_PLOT_GROUP_END, NSERROR_OK, real_plot, and knockout_entry::type.
|
static |
Start of a group of objects.
Used when plotter implements export to a vector graphics file format.
ctx | The current redraw context. |
name | The name of the group being started. |
Definition at line 934 of file knockout.c.
References knockout_entry::data, knockout_entry::group_start, plotter_table::group_start, KNOCKOUT_ENTRIES, knockout_entries, knockout_entry_cur, knockout_plot_flush(), KNOCKOUT_PLOT_GROUP_START, knockout_entry::name, NSERROR_OK, real_plot, and knockout_entry::type.
|
static |
Knockout line plotting.
plot a line from (x0,y0) to (x1,y1). Coordinates are at centre of line width/thickness.
ctx | The current redraw context. |
pstyle | Style controlling the line plot. |
line | A rectangle defining the line to be drawn |
Definition at line 591 of file knockout.c.
References knockout_entry::data, KNOCKOUT_ENTRIES, knockout_entries, knockout_entry_cur, knockout_plot_flush(), KNOCKOUT_PLOT_LINE, knockout_entry::l, knockout_entry::line, line(), NSERROR_OK, knockout_entry::plot_style, and knockout_entry::type.
|
static |
knockout path plotting.
The knockout implementation simply flushes the queue and plots the path directly using real plotter.
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 678 of file knockout.c.
References knockout_plot_flush(), NSERROR_OK, plotter_table::path, and real_plot.
|
static |
Knockout polygon plotting.
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. |
pstyle | Style controlling the polygon plot. |
p | verticies of polygon |
n | number of verticies. |
Definition at line 620 of file knockout.c.
References knockout_entry::data, KNOCKOUT_ENTRIES, knockout_entries, knockout_entry_cur, knockout_plot_flush(), KNOCKOUT_PLOT_POLYGON, knockout_polygon_cur, KNOCKOUT_POLYGONS, knockout_polygons, knockout_entry::n, NSERROR_OK, knockout_entry::p, knockout_entry::plot_style, knockout_entry::polygon, plotter_table::polygon, real_plot, and knockout_entry::type.
|
static |
knockout rectangle plotting.
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. |
pstyle | Style controlling the rectangle plot. |
rect | A rectangle defining the line to be drawn |
Definition at line 526 of file knockout.c.
References knockout_box::bbox, knockout_entry::box, knockout_box::child, clip_cur, knockout_entry::data, knockout_box::deleted, knockout_entry::fill, plot_style_s::fill_type, knockout_box_cur, KNOCKOUT_BOXES, knockout_boxes, knockout_calculate(), KNOCKOUT_ENTRIES, knockout_entries, knockout_entry_cur, knockout_list, KNOCKOUT_PLOT_FILL, knockout_plot_flush(), KNOCKOUT_PLOT_RECTANGLE, knockout_box::next, NSERROR_OK, PLOT_OP_TYPE_NONE, knockout_entry::plot_style, knockout_entry::r, knockout_entry::rectangle, plot_style_s::stroke_type, knockout_entry::type, rect::x0, rect::x1, rect::y0, and rect::y1.
bool knockout_plot_start | ( | const struct redraw_context * | ctx, |
struct redraw_context * | knk_ctx | ||
) |
Start a knockout plotting session.
ctx | the redraw context with real plotter table |
knk_ctx | updated to copy of ctx, with plotter table replaced |
Definition at line 971 of file knockout.c.
References knockout_entry_cur, knockout_plot_end(), knockout_plotters, nested_depth, redraw_context::plot, real_plot, and plotter_table::rectangle.
Referenced by browser_window_redraw(), content_scaled_redraw(), page_info_redraw(), and treeview_redraw().
|
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 735 of file knockout.c.
References knockout_entry::data, KNOCKOUT_ENTRIES, knockout_entries, knockout_entry_cur, knockout_plot_flush(), KNOCKOUT_PLOT_TEXT, NSERROR_OK, knockout_entry::text, text(), and knockout_entry::type.
|
static |
Definition at line 182 of file knockout.c.
Referenced by knockout_plot_bitmap(), knockout_plot_clip(), and knockout_plot_rectangle().
|
static |
Definition at line 176 of file knockout.c.
Referenced by knockout_calculate(), knockout_plot_bitmap(), knockout_plot_flush(), and knockout_plot_rectangle().
|
static |
Definition at line 173 of file knockout.c.
Referenced by knockout_calculate(), knockout_plot_bitmap(), and knockout_plot_rectangle().
|
static |
Definition at line 172 of file knockout.c.
Referenced by knockout_plot_arc(), knockout_plot_bitmap(), knockout_plot_clip(), knockout_plot_disc(), knockout_plot_flush(), knockout_plot_group_end(), knockout_plot_group_start(), knockout_plot_line(), knockout_plot_polygon(), knockout_plot_rectangle(), and knockout_plot_text().
|
static |
Definition at line 175 of file knockout.c.
Referenced by knockout_plot_arc(), knockout_plot_bitmap(), knockout_plot_clip(), knockout_plot_disc(), knockout_plot_flush(), knockout_plot_group_end(), knockout_plot_group_start(), knockout_plot_line(), knockout_plot_polygon(), knockout_plot_rectangle(), knockout_plot_start(), and knockout_plot_text().
|
static |
Definition at line 178 of file knockout.c.
Referenced by knockout_calculate(), knockout_plot_bitmap(), knockout_plot_flush(), and knockout_plot_rectangle().
const struct plotter_table knockout_plotters |
knockout plotter operation table
Definition at line 1012 of file knockout.c.
Referenced by knockout_plot_start().
|
static |
Definition at line 177 of file knockout.c.
Referenced by knockout_plot_flush(), and knockout_plot_polygon().
|
static |
Definition at line 174 of file knockout.c.
Referenced by knockout_plot_polygon().
|
static |
Definition at line 183 of file knockout.c.
Referenced by knockout_plot_end(), and knockout_plot_start().
|
static |
Definition at line 180 of file knockout.c.
Referenced by knockout_plot_bitmap_recursive(), knockout_plot_fill_recursive(), knockout_plot_flush(), knockout_plot_group_end(), knockout_plot_group_start(), knockout_plot_path(), knockout_plot_polygon(), and knockout_plot_start().