Refactor fill plotter to take a style

svn path=/trunk/netsurf/; revision=8332
This commit is contained in:
Vincent Sanders 2009-07-05 20:10:17 +00:00
parent ab2391ade1
commit 0ade453958
18 changed files with 188 additions and 82 deletions

View File

@ -235,13 +235,13 @@ bool ami_polygon(const int *p, unsigned int n, colour fill)
return true;
}
bool ami_fill(int x0, int y0, int x1, int y1, colour c)
bool ami_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
{
#ifndef NS_AMIGA_CAIRO_ALL
p96RectFill(currp,x0,y0,x1-1,y1-1,
p96EncodeColor(RGBFB_A8B8G8R8,c));
p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour));
#else
ami_cairo_set_colour(glob.cr,c);
ami_cairo_set_colour(glob.cr, style->fill_colour);
ami_cairo_set_solid(glob.cr);
cairo_set_line_width(glob.cr, 0);

View File

@ -28,7 +28,7 @@ bool ami_rectangle(int x0, int y0, int width, int height,
bool ami_line(int x0, int y0, int x1, int y1, int width,
colour c, bool dotted, bool dashed);
bool ami_polygon(const int *p, unsigned int n, colour fill);
bool ami_fill(int x0, int y0, int x1, int y1, colour c);
bool ami_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
bool ami_clip(int x0, int y0, int x1, int y1);
bool ami_text(int x, int y, const struct css_style *style,
const char *text, size_t length, colour bg, colour c);

View File

@ -68,7 +68,7 @@ static bool nsbeos_plot_line(int x0, int y0, int x1, int y1, int width,
static bool nsbeos_plot_polygon(const int *p, unsigned int n, colour fill);
static bool nsbeos_plot_path(const float *p, unsigned int n, colour fill, float width,
colour c, const float transform[6]);
static bool nsbeos_plot_fill(int x0, int y0, int x1, int y1, colour c);
static bool nsbeos_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
static bool nsbeos_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
static bool nsbeos_plot_text(int x, int y, const struct css_style *style,
@ -301,7 +301,7 @@ bool nsbeos_plot_polygon(const int *p, unsigned int n, colour fill)
}
bool nsbeos_plot_fill(int x0, int y0, int x1, int y1, colour c)
bool nsbeos_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
{
BView *view;
@ -311,7 +311,7 @@ bool nsbeos_plot_fill(int x0, int y0, int x1, int y1, colour c)
return false;
}
nsbeos_set_colour(c);
nsbeos_set_colour(style->fill_colour);
BRect rect(x0, y0, x1 - 1, y1 - 1);
view->FillRect(rect);
@ -319,7 +319,7 @@ bool nsbeos_plot_fill(int x0, int y0, int x1, int y1, colour c)
//nsbeos_current_gc_unlock();
#if 0 /* GTK */
nsbeos_set_colour(c);
nsbeos_set_colour(style->fill_colour);
nsbeos_set_solid();
#ifdef CAIRO_VERSION
if (option_render_cairo) {

View File

@ -75,6 +75,25 @@
#define KNOCKOUT_BOXES 768 /* 28 bytes each */
#define KNOCKOUT_POLYGONS 3072 /* 4 bytes each */
/** Global fill styles - used everywhere, should they be here? */
static plot_style_t plot_style_fill_white_static = {
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = 0xffffff,
};
static plot_style_t plot_style_fill_red_static = {
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = 0x000000ff,
};
static plot_style_t plot_style_fill_black_static = {
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = 0x0,
};
plot_style_t *plot_style_fill_white = &plot_style_fill_white_static;
plot_style_t *plot_style_fill_red = &plot_style_fill_red_static;
plot_style_t *plot_style_fill_black = &plot_style_fill_black_static;
struct knockout_box;
struct knockout_entry;
@ -82,7 +101,7 @@ struct knockout_entry;
static void knockout_set_plotters(void);
static void knockout_calculate(int x0, int y0, int x1, int y1, struct knockout_box *box);
static bool knockout_plot_fill_recursive(struct knockout_box *box, colour c);
static bool knockout_plot_fill_recursive(struct knockout_box *box, plot_style_t *plot_style);
static bool knockout_plot_bitmap_recursive(struct knockout_box *box,
struct knockout_entry *entry);
@ -91,7 +110,7 @@ static bool knockout_plot_rectangle(int x0, int y0, int width, int height,
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(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_fill(int x0, int y0, int x1, int y1, plot_style_t *plot_style);
static bool knockout_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
static bool knockout_plot_text(int x, int y, const struct css_style *style,
@ -189,7 +208,7 @@ struct knockout_entry {
int y0;
int x1;
int y1;
colour c;
plot_style_t plot_style;
} fill;
struct {
int x0;
@ -349,14 +368,14 @@ bool knockout_plot_flush(void)
box = knockout_entries[i].box->child;
if (box)
success &= knockout_plot_fill_recursive(box,
knockout_entries[i].data.fill.c);
&knockout_entries[i].data.fill.plot_style);
else if (!knockout_entries[i].box->deleted)
success &= plot.fill(
knockout_entries[i].data.fill.x0,
knockout_entries[i].data.fill.y0,
knockout_entries[i].data.fill.x1,
knockout_entries[i].data.fill.y1,
knockout_entries[i].data.fill.c);
&knockout_entries[i].data.fill.plot_style);
break;
case KNOCKOUT_PLOT_CLIP:
success &= plot.clip(
@ -575,7 +594,7 @@ void knockout_calculate(int x0, int y0, int x1, int y1, struct knockout_box *own
}
bool knockout_plot_fill_recursive(struct knockout_box *box, colour c)
bool knockout_plot_fill_recursive(struct knockout_box *box, plot_style_t *plot_style)
{
bool success = true;
struct knockout_box *parent;
@ -584,13 +603,13 @@ bool knockout_plot_fill_recursive(struct knockout_box *box, colour c)
if (parent->deleted)
continue;
if (parent->child)
knockout_plot_fill_recursive(parent->child, c);
knockout_plot_fill_recursive(parent->child, plot_style);
else
success &= plot.fill(parent->bbox.x0,
parent->bbox.y0,
parent->bbox.x1,
parent->bbox.y1,
c);
plot_style);
}
return success;
}
@ -700,7 +719,7 @@ bool knockout_plot_path(const float *p, unsigned int n, colour fill,
}
bool knockout_plot_fill(int x0, int y0, int x1, int y1, colour c)
bool knockout_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *plot_style)
{
int kx0, ky0, kx1, ky1;
@ -728,7 +747,7 @@ bool knockout_plot_fill(int x0, int y0, int x1, int y1, colour c)
knockout_entries[knockout_entry_cur].data.fill.y0 = y0;
knockout_entries[knockout_entry_cur].data.fill.x1 = x1;
knockout_entries[knockout_entry_cur].data.fill.y1 = y1;
knockout_entries[knockout_entry_cur].data.fill.c = c;
knockout_entries[knockout_entry_cur].data.fill.plot_style = *plot_style;
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_FILL;
if ((++knockout_entry_cur >= KNOCKOUT_ENTRIES) ||
(++knockout_box_cur >= KNOCKOUT_BOXES))

View File

@ -35,6 +35,27 @@ typedef unsigned long bitmap_flags_t;
#define BITMAPF_REPEAT_X 1
#define BITMAPF_REPEAT_Y 2
typedef enum {
PLOT_OP_TYPE_NONE = 0, /**< No operation */
PLOT_OP_TYPE_SOLID, /**< Solid colour */
PLOT_OP_TYPE_DOT, /**< Doted plot */
PLOT_OP_TYPE_DASH, /**< dashed plot */
} plot_operation_type_t;
typedef struct {
plot_operation_type_t stroke_type;
int stroke_width;
colour stroke_colour;
plot_operation_type_t fill_type;
colour fill_colour;
} plot_style_t;
/* global styles */
extern plot_style_t *plot_style_fill_white;
extern plot_style_t *plot_style_fill_red;
extern plot_style_t *plot_style_fill_black;
/** Set of target specific plotting functions.
*
* The functions are:
@ -99,7 +120,7 @@ struct plotter_table {
bool (*line)(int x0, int y0, int x1, int y1, int width,
colour c, bool dotted, bool dashed);
bool (*polygon)(const int *p, unsigned int n, colour fill);
bool (*fill)(int x0, int y0, int x1, int y1, colour c);
bool (*fill)(int x0, int y0, int x1, int y1, plot_style_t *style);
bool (*clip)(int x0, int y0, int x1, int y1);
bool (*text)(int x, int y, const struct css_style *style,
const char *text, size_t length, colour bg, colour c);

View File

@ -50,7 +50,7 @@ static bool pdf_plot_rectangle(int x0, int y0, int width, int height,
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(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_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
static bool pdf_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
static bool pdf_plot_text(int x, int y, const struct css_style *style,
@ -214,13 +214,13 @@ bool pdf_plot_polygon(const int *p, unsigned int n, colour fill)
return true;
}
bool pdf_plot_fill(int x0, int y0, int x1, int y1, colour c)
bool pdf_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
{
#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, style->fill_colour));
#endif
apply_clip_and_mode(false, c, TRANSPARENT, 0., DashPattern_eNone);
apply_clip_and_mode(false, style->fill_colour, TRANSPARENT, 0., DashPattern_eNone);
/*Normalize boundaries of the area - to prevent overflows.
It is needed only in a few functions, where integers are subtracted.

View File

@ -41,6 +41,10 @@
#define BORDER_COLOR 0x000000
#define SELECTION_COL 0xFFDDDD
static plot_style_t plot_style_fill_selection = {
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = SELECTION_COL,
};
struct line_info {
unsigned int b_start; /**< Byte offset of line start */
@ -713,6 +717,10 @@ void textarea_redraw(struct text_area *ta, int x0, int y0, int x1, int y1)
int chars, offset;
unsigned int c_pos, c_len, b_start, b_end, line_len;
char *line_text;
plot_style_t plot_style_fill_bg = {
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = BACKGROUND_COL,
};
if (x1 < ta->x || x0 > ta->x + ta->vis_width || y1 < ta->y ||
@ -723,6 +731,9 @@ void textarea_redraw(struct text_area *ta, int x0, int y0, int x1, int y1)
if (ta->lines == NULL)
/* Nothing to redraw */
return;
if (ta->flags & TEXTAREA_READONLY)
plot_style_fill_bg.fill_colour = READONLY_BG;
line0 = (y0 - ta->y + ta->scroll_y) / ta->line_height - 1;
line1 = (y1 - ta->y + ta->scroll_y) / ta->line_height + 1;
@ -748,8 +759,7 @@ void textarea_redraw(struct text_area *ta, int x0, int y0, int x1, int y1)
y1 = ta->y + ta->vis_height;
plot.clip(x0, y0, x1, y1);
plot.fill(x0, y0, x1, y1, (ta->flags & TEXTAREA_READONLY) ?
READONLY_BG : BACKGROUND_COL);
plot.fill(x0, y0, x1, y1, &plot_style_fill_bg);
plot.rectangle(ta->x, ta->y, ta->vis_width - 1, ta->vis_height - 1, 1,
BORDER_COLOR, false, false);
@ -837,7 +847,7 @@ void textarea_redraw(struct text_area *ta, int x0, int y0, int x1, int y1)
x1 - ta->scroll_x,
ta->y + (line + 1) * ta->line_height -
1 - ta->scroll_y,
SELECTION_COL);
&plot_style_fill_selection);
}

View File

@ -197,6 +197,18 @@ framebuffer_plot_bitmap(int x, int y,
return true;
}
static bool
framebuffer_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
{
nsfb_bbox_t rect;
rect.x0 = x0;
rect.y0 = y0;
rect.x1 = x1;
rect.y1 = y1;
return nsfb_plot_rectangle_fill(nsfb, &rect, style->fill_colour);
}
static bool framebuffer_plot_flush(void)
{
@ -220,7 +232,7 @@ struct plotter_table plot = {
.rectangle = nsfb_lplot_rectangle,
.line = nsfb_lplot_line,
.polygon = nsfb_lplot_polygon,
.fill = nsfb_lplot_fill,
.fill = framebuffer_plot_fill,
.clip = nsfb_lplot_clip,
.text = framebuffer_plot_text,
.disc = nsfb_lplot_disc,

View File

@ -56,7 +56,7 @@ static bool nsgtk_plot_line(int x0, int y0, int x1, int y1, int width,
static bool nsgtk_plot_polygon(const int *p, unsigned int n, colour fill);
static bool nsgtk_plot_path(const float *p, unsigned int n, colour fill, float width,
colour c, const float transform[6]);
static bool nsgtk_plot_fill(int x0, int y0, int x1, int y1, colour c);
static bool nsgtk_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
static bool nsgtk_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
static bool nsgtk_plot_text(int x, int y, const struct css_style *style,
@ -87,7 +87,7 @@ const struct plotter_table nsgtk_plotters = {
.arc = nsgtk_plot_arc,
.bitmap = nsgtk_plot_bitmap,
.path = nsgtk_plot_path,
.option_knockout = true
.option_knockout = true
};
@ -155,9 +155,9 @@ bool nsgtk_plot_polygon(const int *p, unsigned int n, colour fill)
}
bool nsgtk_plot_fill(int x0, int y0, int x1, int y1, colour c)
bool nsgtk_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
{
nsgtk_set_colour(c);
nsgtk_set_colour(style->fill_colour);
nsgtk_set_solid();
cairo_set_line_width(current_cr, 0);

View File

@ -52,7 +52,7 @@ static bool nsgtk_print_plot_line(int x0, int y0, int x1, int y1, int width,
static bool nsgtk_print_plot_polygon(const int *p, unsigned int n, colour fill);
static bool nsgtk_print_plot_path(const float *p, unsigned int n, colour fill,
float width, colour c, const float transform[6]);
static bool nsgtk_print_plot_fill(int x0, int y0, int x1, int y1, colour c);
static bool nsgtk_print_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
static bool nsgtk_print_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
static bool nsgtk_print_plot_text(int x, int y, const struct css_style *style,
@ -183,12 +183,12 @@ bool nsgtk_print_plot_polygon(const int *p, unsigned int n, colour fill)
}
bool nsgtk_print_plot_fill(int x0, int y0, int x1, int y1, colour c)
bool nsgtk_print_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
{
LOG(("Plotting fill. x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i",
x0,y0,x1,y1));
nsgtk_print_set_colour(c);
nsgtk_print_set_colour(style->fill_colour);
nsgtk_print_set_solid();
/* Normalize boundaries of the area - to prevent overflows.

View File

@ -95,7 +95,7 @@ bool thumbnail_create(struct content *content, struct bitmap *bitmap,
#ifdef CAIRO_VERSION
current_cr = gdk_cairo_create(current_drawable);
#endif
plot.fill(0, 0, cwidth, cwidth, 0xffffffff);
plot.fill(0, 0, cwidth, cwidth, plot_style_fill_white);
/* render the content */
content_redraw(content, 0, 0, content->width, content->width,

View File

@ -135,6 +135,10 @@ bool html_redraw(struct content *c, int x, int y,
{
struct box *box;
bool result, want_knockout;
plot_style_t pstyle_fill_bg = {
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = background_colour,
};
box = c->data.html.layout;
assert(box);
@ -145,13 +149,15 @@ bool html_redraw(struct content *c, int x, int y,
/* clear to background colour */
result = plot.clip(clip_x0, clip_y0, clip_x1, clip_y1);
if (c->data.html.background_colour != TRANSPARENT)
background_colour = c->data.html.background_colour;
result &= plot.fill(clip_x0, clip_y0, clip_x1, clip_y1, background_colour);
pstyle_fill_bg.fill_colour = c->data.html.background_colour;
result &= plot.fill(clip_x0, clip_y0, clip_x1, clip_y1, &pstyle_fill_bg);
result &= html_redraw_box(box, x, y,
clip_x0, clip_y0, clip_x1, clip_y1,
scale, background_colour);
scale, pstyle_fill_bg.fill_colour);
if (want_knockout)
knockout_plot_end();
@ -801,10 +807,10 @@ bool text_redraw(const char *utf8_text, size_t utf8_len,
/* \todo make search terms visible within selected text */
if (highlighted) {
unsigned endtxt_idx = end_idx;
colour hfore_col, hback_col;
bool clip_changed = false;
bool text_visible = true;
int startx, endx;
plot_style_t *pstyle_fill_hback = plot_style_fill_white;
if (end_idx > utf8_len) {
/* adjust for trailing space, not present in
@ -849,14 +855,12 @@ bool text_redraw(const char *utf8_text, size_t utf8_len,
/* decide whether highlighted portion is to be
* white-on-black or black-on-white */
if ((current_background_color & 0x808080) == 0x808080)
hback_col = 0;
else
hback_col = 0xffffff;
hfore_col = hback_col ^ 0xffffff;
pstyle_fill_hback = plot_style_fill_black;
/* highlighted portion */
if (!plot.fill(x + startx, y, x + endx,
y + height * scale, hback_col))
y + height * scale,
pstyle_fill_hback))
return false;
if (start_idx > 0) {
@ -875,8 +879,9 @@ bool text_redraw(const char *utf8_text, size_t utf8_len,
if (text_visible &&
!plot.text(x, y + (int) (height * 0.75 * scale),
style, utf8_text, endtxt_idx,
hback_col, hfore_col))
style, utf8_text, endtxt_idx,
pstyle_fill_hback->fill_colour,
pstyle_fill_hback->fill_colour ^ 0xffffff))
return false;
/* draw any text succeeding highlighted portion */
@ -1277,6 +1282,22 @@ colour html_redraw_aa(colour c0, colour c1)
}
#define WIDGET_BASEC 0xd9d9d9
#define WIDGET_BLOBC 0x000000
/** plot style for checkbox base. */
static plot_style_t pstyle_fill_wbasec = {
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = WIDGET_BASEC,
};
/** plot style for checkbox background. */
static plot_style_t pstyle_fill_wblobc = {
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = WIDGET_BLOBC,
};
/**
* Plot a checkbox.
*
@ -1288,8 +1309,6 @@ colour html_redraw_aa(colour c0, colour c1)
* \return true if successful, false otherwise
*/
#define WIDGET_BASEC 0xd9d9d9
#define WIDGET_BLOBC 0x000000
bool html_redraw_checkbox(int x, int y, int width, int height,
bool selected)
{
@ -1300,7 +1319,7 @@ bool html_redraw_checkbox(int x, int y, int width, int height,
if (z == 0)
z = 1;
if (!(plot.fill(x, y, x + width, y + height, WIDGET_BASEC) &&
if (!(plot.fill(x, y, x + width, y + height, &pstyle_fill_wbasec) &&
plot.line(x, y, x + width, y, 1, dark, false, false) &&
plot.line(x, y, x, y + height, 1, dark, false, false) &&
plot.line(x + width, y, x + width, y + height, 1, lite,
@ -1314,7 +1333,7 @@ bool html_redraw_checkbox(int x, int y, int width, int height,
/* render a solid box instead of a tick */
if (!plot.fill(x + z + z, y + z + z,
x + width - z, y + height - z,
WIDGET_BLOBC))
&pstyle_fill_wblobc))
return false;
} else {
/* render a tick, as it'll fit comfortably */
@ -1448,6 +1467,10 @@ bool html_redraw_background(int x, int y, struct box *box, float scale,
int ox = x, oy = y;
int width, height;
struct box *parent;
plot_style_t pstyle_fill_bg = {
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = *background_colour,
};
if (html_redraw_printing && option_remove_backgrounds)
return true;
@ -1579,10 +1602,12 @@ bool html_redraw_background(int x, int y, struct box *box, float scale,
if (background->style->background_color != TRANSPARENT) {
*background_colour =
background->style->background_color;
pstyle_fill_bg.fill_colour =
background->style->background_color;
if (plot_colour)
if (!plot.fill(clip_x0, clip_y0,
clip_x1, clip_y1,
*background_colour))
&pstyle_fill_bg))
return false;
}
/* and plot the image */
@ -1662,6 +1687,10 @@ bool html_redraw_inline_background(int x, int y, struct box *box, float scale,
bool repeat_y = false;
bool plot_colour = true;
bool plot_content;
plot_style_t pstyle_fill_bg = {
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = *background_colour,
};
plot_content = (box->background != NULL);
@ -1741,10 +1770,13 @@ bool html_redraw_inline_background(int x, int y, struct box *box, float scale,
if (box->style->background_color != TRANSPARENT) {
*background_colour =
box->style->background_color;
pstyle_fill_bg.fill_colour =
box->style->background_color;
if (plot_colour)
if (!plot.fill(clip_x0, clip_y0,
clip_x1, clip_y1,
*background_colour))
&pstyle_fill_bg))
return false;
}
/* and plot the image */
@ -1933,6 +1965,14 @@ bool html_redraw_scrollbars(struct box *box, float scale,
int well_width, bar_left, bar_width;
colour c0, c1; /* highlight and shadow colours */
int v[6]; /* array of triangle vertices */
plot_style_t pstyle_css_scrollbar_bg_colour = {
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = css_scrollbar_bg_colour,
};
plot_style_t pstyle_css_scrollbar_fg_colour = {
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = css_scrollbar_fg_colour,
};
box_scrollbar_dimensions(box, padding_width, padding_height, w,
&vscroll, &hscroll,
@ -1976,7 +2016,7 @@ bool html_redraw_scrollbars(struct box *box, float scale,
y + padding_height - w + 2,
x + w - 2,
y + padding_height - 2,
css_scrollbar_fg_colour))
&pstyle_css_scrollbar_fg_colour))
return false;
/* left arrow */
v[0] = x + w / 4;
@ -1992,7 +2032,7 @@ bool html_redraw_scrollbars(struct box *box, float scale,
y + padding_height - w + 1,
x + w + well_width + (vscroll ? 2 : 1),
y + padding_height - 1,
css_scrollbar_bg_colour))
&pstyle_css_scrollbar_bg_colour))
return false;
/* scroll position indicator bar */
RECTANGLE(x + w + bar_left,
@ -2004,7 +2044,7 @@ bool html_redraw_scrollbars(struct box *box, float scale,
y + padding_height - w + 2,
x + w + bar_left + bar_width + (vscroll? 1 : 0),
y + padding_height - 2,
css_scrollbar_fg_colour))
&pstyle_css_scrollbar_fg_colour))
return false;
/* right arrow icon border */
RECTANGLE(x + w + well_width + 2,
@ -2017,7 +2057,7 @@ bool html_redraw_scrollbars(struct box *box, float scale,
y + padding_height - w + 2,
x + w + well_width + w - (vscroll ? 1 : 2),
y + padding_height - 2,
css_scrollbar_fg_colour))
&pstyle_css_scrollbar_fg_colour))
return false;
/* right arrow */
v[0] = x + w + well_width + w * 3 / 4 + (vscroll ? 1 : 0);
@ -2048,7 +2088,7 @@ bool html_redraw_scrollbars(struct box *box, float scale,
y + 2,
x + padding_width - 2,
y + w - 2,
css_scrollbar_fg_colour))
&pstyle_css_scrollbar_fg_colour))
return false;
/* up arrow */
v[0] = x + padding_width - w / 2;
@ -2064,7 +2104,7 @@ bool html_redraw_scrollbars(struct box *box, float scale,
y + w - 1,
x + padding_width - 1,
y + padding_height - w + 1,
css_scrollbar_bg_colour))
&pstyle_css_scrollbar_bg_colour))
return false;
/* scroll position indicator bar */
RECTANGLE(x + padding_width - w + 1,
@ -2076,7 +2116,7 @@ bool html_redraw_scrollbars(struct box *box, float scale,
y + w + bar_top + 1,
x + padding_width - 2,
y + w + bar_top + bar_height,
css_scrollbar_fg_colour))
&pstyle_css_scrollbar_fg_colour))
return false;
/* bottom arrow background */
RECTANGLE(x + padding_width - w + 1,
@ -2088,7 +2128,7 @@ bool html_redraw_scrollbars(struct box *box, float scale,
y + padding_height - w + 2,
x + padding_width - 2,
y + padding_height - 2,
css_scrollbar_fg_colour))
&pstyle_css_scrollbar_fg_colour))
return false;
/* down arrow */
v[0] = x + padding_width - w / 2;

View File

@ -338,9 +338,9 @@ bool textplain_redraw(struct content *c, int x, int y,
long line0 = clip_y0 / scaled_line_height - 1;
long line1 = clip_y1 / scaled_line_height + 1;
struct textplain_line *line = c->data.textplain.physical_line;
colour hback_col;
struct rect clip;
size_t length;
plot_style_t *plot_style_highlight;
clip.x0 = clip_x0;
clip.y0 = clip_y0;
@ -358,7 +358,7 @@ bool textplain_redraw(struct content *c, int x, int y,
if (line1 < line0)
line1 = line0;
if (!plot.fill(clip_x0, clip_y0, clip_x1, clip_y1, 0xffffff))
if (!plot.fill(clip_x0, clip_y0, clip_x1, clip_y1, plot_style_fill_white))
return false;
if (!line)
@ -366,9 +366,9 @@ bool textplain_redraw(struct content *c, int x, int y,
/* choose a suitable background colour for any highlighted text */
if ((background_colour & 0x808080) == 0x808080)
hback_col = 0;
else
hback_col = 0xffffff;
plot_style_highlight = plot_style_fill_black;
else
plot_style_highlight = plot_style_fill_white;
x += MARGIN * scale;
y += MARGIN * scale;
@ -437,8 +437,9 @@ bool textplain_redraw(struct content *c, int x, int y,
if (highlighted) {
int sy = y + (lineno * scaled_line_height);
if (!plot.fill(tx, sy, ntx, sy + scaled_line_height,
hback_col))
if (!plot.fill(tx, sy,
ntx, sy + scaled_line_height,
plot_style_highlight))
return false;
}
}

View File

@ -509,8 +509,9 @@ void ro_gui_progress_bar_redraw_window(wimp_draw *redraw,
progress_ymid - progress_height,
tinct_FILL_HORIZONTALLY);
} else {
plot.fill(clip_x0, clip_y0, clip_x1, clip_y1,
0x000000ff);
plot.fill(clip_x0, clip_y0,
clip_x1, clip_y1,
plot_style_fill_red);
}
}
}

View File

@ -43,7 +43,7 @@ static bool ro_plot_draw_path(const draw_path * const path, int width,
static bool ro_plot_polygon(const int *p, unsigned int n, colour fill);
static bool ro_plot_path(const float *p, unsigned int n, colour fill, float width,
colour c, const float transform[6]);
static bool ro_plot_fill(int x0, int y0, int x1, int y1, colour c);
static bool ro_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
static bool ro_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
static bool ro_plot_text(int x, int y, const struct css_style *style,
@ -303,12 +303,13 @@ error:
}
bool ro_plot_fill(int x0, int y0, int x1, int y1, colour c)
bool ro_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
{
os_error *error;
error = xcolourtrans_set_gcol(c << 8, colourtrans_USE_ECFS_GCOL,
os_ACTION_OVERWRITE, 0, 0);
error = xcolourtrans_set_gcol(style->fill_colour << 8,
colourtrans_USE_ECFS_GCOL,
os_ACTION_OVERWRITE, 0, 0);
if (error) {
LOG(("xcolourtrans_set_gcol: 0x%x: %s",
error->errnum, error->errmess));

View File

@ -102,7 +102,7 @@ static bool print_fonts_plot_rectangle(int x0, int y0, int width, int height,
static bool print_fonts_plot_line(int x0, int y0, int x1, int y1, int width,
colour c, bool dotted, bool dashed);
static bool print_fonts_plot_polygon(const int *p, unsigned int n, colour fill);
static bool print_fonts_plot_fill(int x0, int y0, int x1, int y1, colour c);
static bool print_fonts_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
static bool print_fonts_plot_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
static bool print_fonts_plot_text(int x, int y, const struct css_style *style,
@ -824,7 +824,7 @@ bool print_fonts_plot_polygon(const int *p, unsigned int n, colour fill)
return true;
}
bool print_fonts_plot_fill(int x0, int y0, int x1, int y1, colour c)
bool print_fonts_plot_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
{
return true;
}

View File

@ -44,7 +44,7 @@ static bool ro_save_draw_line(int x0, int y0, int x1, int y1, int width,
static bool ro_save_draw_polygon(const int *p, unsigned int n, colour fill);
static bool ro_save_draw_path(const float *p, unsigned int n, colour fill,
float width, colour c, const float transform[6]);
static bool ro_save_draw_fill(int x0, int y0, int x1, int y1, colour c);
static bool ro_save_draw_fill(int x0, int y0, int x1, int y1, plot_style_t *style);
static bool ro_save_draw_clip(int clip_x0, int clip_y0,
int clip_x1, int clip_y1);
static bool ro_save_draw_text(int x, int y, const struct css_style *style,
@ -302,7 +302,7 @@ bool ro_save_draw_path(const float *p, unsigned int n, colour fill,
}
bool ro_save_draw_fill(int x0, int y0, int x1, int y1, colour c)
bool ro_save_draw_fill(int x0, int y0, int x1, int y1, plot_style_t *style)
{
pencil_code code;
const int path[] = { draw_MOVE_TO, x0 * 2, -y0 * 2 - 1,
@ -313,10 +313,11 @@ bool ro_save_draw_fill(int x0, int y0, int x1, int y1, colour c)
draw_END_PATH };
code = pencil_path(ro_save_draw_diagram, path,
sizeof path / sizeof path[0],
c << 8, pencil_TRANSPARENT, 0, pencil_JOIN_MITRED,
pencil_CAP_BUTT, pencil_CAP_BUTT, 0, 0, false,
pencil_SOLID);
sizeof path / sizeof path[0],
style->fill_colour << 8,
pencil_TRANSPARENT, 0, pencil_JOIN_MITRED,
pencil_CAP_BUTT, pencil_CAP_BUTT, 0, 0, false,
pencil_SOLID);
if (code != pencil_OK)
return ro_save_draw_error(code);

View File

@ -1483,7 +1483,7 @@ void ro_gui_window_redraw(wimp_draw *redraw)
plot.clip(clip_x0, clip_y0, clip_x1, clip_y1);
if (c->type != CONTENT_HTML)
plot.fill(clip_x0, clip_y0, clip_x1, clip_y1, 0x00ffffff);
plot.fill(clip_x0, clip_y0, clip_x1, clip_y1, plot_style_fill_white);
/* Redraw the clip rectangle area of the content */
content_redraw(c, 0, 0,