summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2009-07-14 10:03:58 +0000
committerVincent Sanders <vince@netsurf-browser.org>2009-07-14 10:03:58 +0000
commit86232d72a6709243136496770aade7c4d47ef28a (patch)
treee6c849cb2f755a6ef314ccdb5a05122bec7dcd52 /desktop
parented2206316ceb8fe422085a4a50c028aa7718d644 (diff)
downloadnetsurf-86232d72a6709243136496770aade7c4d47ef28a.tar.gz
netsurf-86232d72a6709243136496770aade7c4d47ef28a.tar.bz2
next round of plotter refactor
svn path=/trunk/netsurf/; revision=8512
Diffstat (limited to 'desktop')
-rw-r--r--desktop/knockout.c36
-rw-r--r--desktop/plot_style.c16
-rw-r--r--desktop/plot_style.h2
-rw-r--r--desktop/plotters.h31
-rw-r--r--desktop/save_pdf/pdf_plotters.c42
5 files changed, 81 insertions, 46 deletions
diff --git a/desktop/knockout.c b/desktop/knockout.c
index 7cecb92c8..b9a6862e5 100644
--- a/desktop/knockout.c
+++ b/desktop/knockout.c
@@ -86,15 +86,14 @@ static bool knockout_plot_bitmap_recursive(struct knockout_box *box,
struct knockout_entry *entry);
static bool knockout_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
-static bool knockout_plot_polygon(const int *p, unsigned int n, colour fill);
+static bool knockout_plot_polygon(const int *p, unsigned int n, const plot_style_t *pstyle);
static bool knockout_plot_rectangle(int x0, int y0, int x1, int y1, const 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,
const char *text, size_t length, colour bg, colour c);
-static bool knockout_plot_disc(int x, int y, int radius, colour colour, bool filled);
-static bool knockout_plot_arc(int x, int y, int radius, int angle1, int angle2,
- colour c);
+static bool knockout_plot_disc(int x, int y, int radius, const plot_style_t *pstyle);
+static bool knockout_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *pstyle);
static bool knockout_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bitmap_flags_t flags);
@@ -171,7 +170,7 @@ struct knockout_entry {
struct {
int *p;
unsigned int n;
- colour fill;
+ plot_style_t plot_style;
} polygon;
struct {
int x0;
@@ -199,8 +198,7 @@ struct knockout_entry {
int x;
int y;
int radius;
- colour colour;
- bool filled;
+ plot_style_t plot_style;
} disc;
struct {
int x;
@@ -208,7 +206,7 @@ struct knockout_entry {
int radius;
int angle1;
int angle2;
- colour c;
+ plot_style_t plot_style;
} arc;
struct {
int x;
@@ -326,7 +324,7 @@ bool knockout_plot_flush(void)
success &= plot.polygon(
knockout_entries[i].data.polygon.p,
knockout_entries[i].data.polygon.n,
- knockout_entries[i].data.polygon.fill);
+ &knockout_entries[i].data.polygon.plot_style);
break;
case KNOCKOUT_PLOT_FILL:
box = knockout_entries[i].box->child;
@@ -363,8 +361,7 @@ bool knockout_plot_flush(void)
knockout_entries[i].data.disc.x,
knockout_entries[i].data.disc.y,
knockout_entries[i].data.disc.radius,
- knockout_entries[i].data.disc.colour,
- knockout_entries[i].data.disc.filled);
+ &knockout_entries[i].data.disc.plot_style);
break;
case KNOCKOUT_PLOT_ARC:
success &= plot.arc(
@@ -373,7 +370,7 @@ bool knockout_plot_flush(void)
knockout_entries[i].data.arc.radius,
knockout_entries[i].data.arc.angle1,
knockout_entries[i].data.arc.angle2,
- knockout_entries[i].data.arc.c);
+ &knockout_entries[i].data.arc.plot_style);
break;
case KNOCKOUT_PLOT_BITMAP:
box = knockout_entries[i].box->child;
@@ -676,7 +673,7 @@ bool knockout_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *psty
}
-bool knockout_plot_polygon(const int *p, unsigned int n, colour fill)
+bool knockout_plot_polygon(const int *p, unsigned int n, const plot_style_t *pstyle)
{
bool success = true;
int *dest;
@@ -684,7 +681,7 @@ bool knockout_plot_polygon(const int *p, unsigned int n, colour fill)
/* ensure we have sufficient room even when flushed */
if (n * 2 >= KNOCKOUT_POLYGONS) {
knockout_plot_flush();
- success = real_plot.polygon(p, n, fill);
+ success = real_plot.polygon(p, n, pstyle);
return success;
}
@@ -698,7 +695,7 @@ bool knockout_plot_polygon(const int *p, unsigned int n, colour fill)
knockout_polygon_cur += n * 2;
knockout_entries[knockout_entry_cur].data.polygon.p = dest;
knockout_entries[knockout_entry_cur].data.polygon.n = n;
- knockout_entries[knockout_entry_cur].data.polygon.fill = fill;
+ knockout_entries[knockout_entry_cur].data.polygon.plot_style = *pstyle;
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_POLYGON;
if (++knockout_entry_cur >= KNOCKOUT_ENTRIES)
knockout_plot_flush();
@@ -757,27 +754,26 @@ bool knockout_plot_text(int x, int y, const struct css_style *style,
}
-bool knockout_plot_disc(int x, int y, int radius, colour colour, bool filled)
+bool knockout_plot_disc(int x, int y, int radius, const plot_style_t *pstyle)
{
knockout_entries[knockout_entry_cur].data.disc.x = x;
knockout_entries[knockout_entry_cur].data.disc.y = y;
knockout_entries[knockout_entry_cur].data.disc.radius = radius;
- knockout_entries[knockout_entry_cur].data.disc.colour = colour;
- knockout_entries[knockout_entry_cur].data.disc.filled = filled;
+ knockout_entries[knockout_entry_cur].data.disc.plot_style = *pstyle;
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_DISC;
if (++knockout_entry_cur >= KNOCKOUT_ENTRIES)
knockout_plot_flush();
return true;
}
-bool knockout_plot_arc(int x, int y, int radius, int angle1, int angle2, colour c)
+bool knockout_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *pstyle)
{
knockout_entries[knockout_entry_cur].data.arc.x = x;
knockout_entries[knockout_entry_cur].data.arc.y = y;
knockout_entries[knockout_entry_cur].data.arc.radius = radius;
knockout_entries[knockout_entry_cur].data.arc.angle1 = angle1;
knockout_entries[knockout_entry_cur].data.arc.angle2 = angle2;
- knockout_entries[knockout_entry_cur].data.arc.c = c;
+ knockout_entries[knockout_entry_cur].data.arc.plot_style = *pstyle;
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_ARC;
if (++knockout_entry_cur >= KNOCKOUT_ENTRIES)
knockout_plot_flush();
diff --git a/desktop/plot_style.c b/desktop/plot_style.c
index 8ed8fb5e6..42a4c924f 100644
--- a/desktop/plot_style.c
+++ b/desktop/plot_style.c
@@ -73,13 +73,27 @@ plot_style_t *plot_style_caret = &plot_style_caret_static;
/* html redraw widget styles */
-/** plot style for widget base. */
+/** plot style for filled widget base colour. */
static plot_style_t plot_style_fill_wbasec_static = {
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = WIDGET_BASEC,
};
plot_style_t *plot_style_fill_wbasec = &plot_style_fill_wbasec_static;
+/** plot style for dark filled widget base colour . */
+static plot_style_t plot_style_fill_darkwbasec_static = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+ .fill_colour = double_darken_colour(WIDGET_BASEC),
+};
+plot_style_t *plot_style_fill_darkwbasec = &plot_style_fill_darkwbasec_static;
+
+/** plot style for light filled widget base colour. */
+static plot_style_t plot_style_fill_lightwbasec_static = {
+ .fill_type = PLOT_OP_TYPE_SOLID,
+ .fill_colour = double_lighten_colour(WIDGET_BASEC),
+};
+plot_style_t *plot_style_fill_lightwbasec = &plot_style_fill_lightwbasec_static;
+
/** plot style for widget background. */
static plot_style_t plot_style_fill_wblobc_static = {
diff --git a/desktop/plot_style.h b/desktop/plot_style.h
index 9de9cbf97..8c10af0fa 100644
--- a/desktop/plot_style.h
+++ b/desktop/plot_style.h
@@ -91,6 +91,8 @@ extern plot_style_t *plot_style_stroke_yellow;
extern plot_style_t *plot_style_caret;
extern plot_style_t *plot_style_stroke_history;
extern plot_style_t *plot_style_fill_wbasec;
+extern plot_style_t *plot_style_fill_darkwbasec;
+extern plot_style_t *plot_style_fill_lightwbasec;
extern plot_style_t *plot_style_fill_wblobc;
extern plot_style_t *plot_style_stroke_wblobc;
extern plot_style_t *plot_style_stroke_darkwbasec;
diff --git a/desktop/plotters.h b/desktop/plotters.h
index 4a6261516..91fbd5188 100644
--- a/desktop/plotters.h
+++ b/desktop/plotters.h
@@ -95,22 +95,35 @@ typedef unsigned long bitmap_flags_t;
* 3 | | | | | |
*/
struct plotter_table {
- bool (*rectangle)(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
- bool (*line)(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
- bool (*polygon)(const int *p, unsigned int n, colour fill);
+ /* clipping operations */
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);
- bool (*disc)(int x, int y, int radius, colour c, bool filled);
- bool (*arc)(int x, int y, int radius, int angle1, int angle2, colour c);
+
+ /* shape primatives */
+ bool (*arc)(int x, int y, int radius, int angle1, int angle2, const plot_style_t *pstyle);
+ bool (*disc)(int x, int y, int radius, const plot_style_t *pstyle);
+ bool (*line)(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
+ bool (*rectangle)(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
+ bool (*polygon)(const int *p, unsigned int n, const plot_style_t *pstyle);
+
+ /* complex path (for SVG) */
+ bool (*path)(const float *p, unsigned int n, colour fill, float width,
+ colour c, const float transform[6]);
+
+ /* Image */
bool (*bitmap)(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bitmap_flags_t flags);
+
+ /* text */
+ bool (*text)(int x, int y, const struct css_style *style,
+ const char *text, size_t length, colour bg, colour c);
+
+ /* optional callbacks */
bool (*group_start)(const char *name); /**< optional, may be NULL */
bool (*group_end)(void); /**< optional, may be NULL */
bool (*flush)(void); /**< optional, may be NULL */
- bool (*path)(const float *p, unsigned int n, colour fill, float width,
- colour c, const float transform[6]);
+
+ /* flags */
bool option_knockout; /**< set if knockout rendering is required */
};
diff --git a/desktop/save_pdf/pdf_plotters.c b/desktop/save_pdf/pdf_plotters.c
index 58df607d6..70dee78bf 100644
--- a/desktop/save_pdf/pdf_plotters.c
+++ b/desktop/save_pdf/pdf_plotters.c
@@ -47,14 +47,14 @@
static bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
static bool pdf_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
-static bool pdf_plot_polygon(const int *p, unsigned int n, colour fill);
+static bool pdf_plot_polygon(const int *p, unsigned int n, const 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,
const char *text, size_t length, colour bg, colour c);
-static bool pdf_plot_disc(int x, int y, int radius, colour c, bool filled);
+static bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style);
static bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2,
- colour c);
+ const plot_style_t *style);
static bool pdf_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bitmap_flags_t flags);
@@ -231,7 +231,7 @@ bool pdf_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle)
return true;
}
-bool pdf_plot_polygon(const int *p, unsigned int n, colour fill)
+bool pdf_plot_polygon(const int *p, unsigned int n, const plot_style_t *style)
{
unsigned int i;
#ifdef PDF_DEBUG
@@ -242,7 +242,7 @@ bool pdf_plot_polygon(const int *p, unsigned int n, colour fill)
if (n == 0)
return true;
- apply_clip_and_mode(false, fill, TRANSPARENT, 0., DashPattern_eNone);
+ apply_clip_and_mode(false, style->fill_colour, TRANSPARENT, 0., DashPattern_eNone);
HPDF_Page_MoveTo(pdf_page, p[0], page_height - p[1]);
for (i = 1 ; i<n ; i++) {
@@ -318,35 +318,45 @@ bool pdf_plot_text(int x, int y, const struct css_style *style,
return true;
}
-bool pdf_plot_disc(int x, int y, int radius, colour c, bool filled)
+bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style)
{
#ifdef PDF_DEBUG
LOG(("."));
#endif
+ if (style->fill_type != PLOT_OP_TYPE_NONE) {
+ apply_clip_and_mode(false,
+ style->fill_colour,
+ TRANSPARENT,
+ 1., DashPattern_eNone);
- /* FIXME: line width 1 is ok ? */
- apply_clip_and_mode(false,
- filled ? c : TRANSPARENT, filled ? TRANSPARENT : c,
- 1., DashPattern_eNone);
-
- HPDF_Page_Circle(pdf_page, x, page_height - y, radius);
+ HPDF_Page_Circle(pdf_page, x, page_height - y, radius);
- if (filled)
HPDF_Page_Fill(pdf_page);
- else
+ }
+
+ if (style->stroke_type != PLOT_OP_TYPE_NONE) {
+ /* FIXME: line width 1 is ok ? */
+ apply_clip_and_mode(false,
+ TRANSPARENT,
+ style->stroke_colour,
+ 1., DashPattern_eNone);
+
+ HPDF_Page_Circle(pdf_page, x, page_height - y, radius);
+
HPDF_Page_Stroke(pdf_page);
+ }
return true;
}
-bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2, colour c)
+bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *style)
{
#ifdef PDF_DEBUG
LOG(("%d %d %d %d %d %X", x, y, radius, angle1, angle2, c));
#endif
/* FIXME: line width 1 is ok ? */
- apply_clip_and_mode(false, TRANSPARENT, c, 1., DashPattern_eNone);
+ apply_clip_and_mode(false, TRANSPARENT, style->fill_colour, 1., DashPattern_eNone);
/* Normalize angles */
angle1 %= 360;