summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'desktop')
-rw-r--r--desktop/browser.c2
-rw-r--r--desktop/history_core.c7
-rw-r--r--desktop/knockout.c77
-rw-r--r--desktop/plotters.h3
-rw-r--r--desktop/save_pdf/pdf_plotters.c15
-rw-r--r--desktop/textarea.c4
-rw-r--r--desktop/tree.c29
7 files changed, 58 insertions, 79 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index 36661f1de..351b327c6 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -100,7 +100,7 @@ bool browser_window_redraw(struct browser_window *bw, int x, int y,
return false;
}
- plot.clip(clip->x0, clip->y0, clip->x1, clip->y1);
+ plot.clip(clip);
if (bw->current_content == NULL) {
return plot.rectangle(clip->x0, clip->y0, clip->x1, clip->y1,
diff --git a/desktop/history_core.c b/desktop/history_core.c
index ee964ad6d..96a760a9d 100644
--- a/desktop/history_core.c
+++ b/desktop/history_core.c
@@ -628,7 +628,12 @@ bool history_redraw_entry(struct history *history,
plot_font_style_t fstyle = *plot_style_font;
if (clip) {
- if(!plot.clip(x0 + xoffset, y0 + yoffset, x1 + xoffset, y1 + yoffset))
+ struct rect rect;
+ rect.x0 = x0 + xoffset;
+ rect.y0 = y0 + yoffset;
+ rect.x1 = x1 + xoffset;
+ rect.y1 = y1 + yoffset;
+ if(!plot.clip(&rect))
return false;
}
diff --git a/desktop/knockout.c b/desktop/knockout.c
index 680257b0f..3525df972 100644
--- a/desktop/knockout.c
+++ b/desktop/knockout.c
@@ -88,8 +88,7 @@ static bool knockout_plot_bitmap_recursive(struct knockout_box *box,
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, 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_clip(const struct rect *clip);
static bool knockout_plot_text(int x, int y, const char *text, size_t length,
const plot_font_style_t *fstyle);
static bool knockout_plot_disc(int x, int y, int radius, const plot_style_t *pstyle);
@@ -137,12 +136,7 @@ typedef enum {
struct knockout_box {
- struct {
- int x0;
- int y0;
- int x1;
- int y1;
- } bbox;
+ struct rect bbox;
bool deleted; /* box has been deleted, ignore */
struct knockout_box *child;
struct knockout_box *next;
@@ -179,12 +173,7 @@ struct knockout_entry {
int y1;
plot_style_t plot_style;
} fill;
- struct {
- int x0;
- int y0;
- int x1;
- int y1;
- } clip;
+ struct rect clip;
struct {
int x;
int y;
@@ -232,10 +221,7 @@ static struct knockout_box *knockout_list = NULL;
static struct plotter_table real_plot;
-static int clip_x0_cur;
-static int clip_y0_cur;
-static int clip_x1_cur;
-static int clip_y1_cur;
+static struct rect clip_cur;
static int nested_depth = 0;
/**
@@ -339,10 +325,7 @@ bool knockout_plot_flush(void)
break;
case KNOCKOUT_PLOT_CLIP:
success &= plot.clip(
- knockout_entries[i].data.clip.x0,
- knockout_entries[i].data.clip.y0,
- knockout_entries[i].data.clip.x1,
- knockout_entries[i].data.clip.y1);
+ &knockout_entries[i].data.clip);
break;
case KNOCKOUT_PLOT_TEXT:
success &= plot.text(
@@ -584,10 +567,7 @@ bool knockout_plot_bitmap_recursive(struct knockout_box *box,
if (parent->child)
knockout_plot_bitmap_recursive(parent->child, entry);
else {
- success &= plot.clip(parent->bbox.x0,
- parent->bbox.y0,
- parent->bbox.x1,
- parent->bbox.y1);
+ success &= plot.clip(&parent->bbox);
success &= plot.bitmap(entry->data.bitmap.x,
entry->data.bitmap.y,
entry->data.bitmap.width,
@@ -608,12 +588,12 @@ bool knockout_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t
/* filled draw */
/* get our bounds */
- kx0 = (x0 > clip_x0_cur) ? x0 : clip_x0_cur;
- ky0 = (y0 > clip_y0_cur) ? y0 : clip_y0_cur;
- kx1 = (x1 < clip_x1_cur) ? x1 : clip_x1_cur;
- ky1 = (y1 < clip_y1_cur) ? y1 : clip_y1_cur;
- if ((kx0 > clip_x1_cur) || (kx1 < clip_x0_cur) ||
- (ky0 > clip_y1_cur) || (ky1 < clip_y0_cur))
+ kx0 = (x0 > clip_cur.x0) ? x0 : clip_cur.x0;
+ ky0 = (y0 > clip_cur.y0) ? y0 : clip_cur.y0;
+ kx1 = (x1 < clip_cur.x1) ? x1 : clip_cur.x1;
+ ky1 = (y1 < clip_cur.y1) ? y1 : clip_cur.y1;
+ if ((kx0 > clip_cur.x1) || (kx1 < clip_cur.x0) ||
+ (ky0 > clip_cur.y1) || (ky1 < clip_cur.y0))
return true;
/* fills both knock out and get knocked out */
@@ -707,25 +687,18 @@ bool knockout_plot_path(const float *p, unsigned int n, colour fill,
}
-bool knockout_plot_clip(int clip_x0, int clip_y0,
- int clip_x1, int clip_y1)
+bool knockout_plot_clip(const struct rect *clip)
{
- if (clip_x1 < clip_x0 || clip_y0 > clip_y1) {
+ if (clip->x1 < clip->x0 || clip->y0 > clip->y1) {
LOG(("bad clip rectangle %i %i %i %i",
- clip_x0, clip_y0, clip_x1, clip_y1));
+ clip->x0, clip->y0, clip->x1, clip->y1));
return false;
}
/* memorise clip for bitmap tiling */
- clip_x0_cur = clip_x0;
- clip_y0_cur = clip_y0;
- clip_x1_cur = clip_x1;
- clip_y1_cur = clip_y1;
-
- knockout_entries[knockout_entry_cur].data.clip.x0 = clip_x0;
- knockout_entries[knockout_entry_cur].data.clip.y0 = clip_y0;
- knockout_entries[knockout_entry_cur].data.clip.x1 = clip_x1;
- knockout_entries[knockout_entry_cur].data.clip.y1 = clip_y1;
+ clip_cur = *clip;
+
+ knockout_entries[knockout_entry_cur].data.clip = *clip;
knockout_entries[knockout_entry_cur].type = KNOCKOUT_PLOT_CLIP;
if (++knockout_entry_cur >= KNOCKOUT_ENTRIES)
knockout_plot_flush();
@@ -783,16 +756,16 @@ bool knockout_plot_bitmap(int x, int y, int width, int height,
int kx0, ky0, kx1, ky1;
/* get our bounds */
- kx0 = clip_x0_cur;
- ky0 = clip_y0_cur;
- kx1 = clip_x1_cur;
- ky1 = clip_y1_cur;
+ kx0 = clip_cur.x0;
+ ky0 = clip_cur.y0;
+ kx1 = clip_cur.x1;
+ ky1 = clip_cur.y1;
if (!(flags & BITMAPF_REPEAT_X)) {
if (x > kx0)
kx0 = x;
if (x + width < kx1)
kx1 = x + width;
- if ((kx0 > clip_x1_cur) || (kx1 < clip_x0_cur))
+ if ((kx0 > clip_cur.x1) || (kx1 < clip_cur.x0))
return true;
}
if (!(flags & BITMAPF_REPEAT_Y)) {
@@ -800,7 +773,7 @@ bool knockout_plot_bitmap(int x, int y, int width, int height,
ky0 = y;
if (y + height < ky1)
ky1 = y + height;
- if ((ky0 > clip_y1_cur) || (ky1 < clip_y0_cur))
+ if ((ky0 > clip_cur.y1) || (ky1 < clip_cur.y0))
return true;
}
@@ -827,7 +800,7 @@ bool knockout_plot_bitmap(int x, int y, int width, int height,
if ((++knockout_entry_cur >= KNOCKOUT_ENTRIES) ||
(++knockout_box_cur >= KNOCKOUT_BOXES))
knockout_plot_flush();
- return knockout_plot_clip(clip_x0_cur, clip_y0_cur, clip_x1_cur, clip_y1_cur);
+ return knockout_plot_clip(&clip_cur);
}
bool knockout_plot_group_start(const char *name)
diff --git a/desktop/plotters.h b/desktop/plotters.h
index 076baf242..02735a15f 100644
--- a/desktop/plotters.h
+++ b/desktop/plotters.h
@@ -27,6 +27,7 @@
#include "css/css.h"
#include "content/content.h"
#include "desktop/plot_style.h"
+#include "desktop/shape.h"
struct bitmap;
@@ -96,7 +97,7 @@ typedef unsigned long bitmap_flags_t;
*/
struct plotter_table {
/* clipping operations */
- bool (*clip)(int x0, int y0, int x1, int y1);
+ bool (*clip)(const struct rect *clip);
/* shape primatives */
bool (*arc)(int x, int y, int radius, int angle1, int angle2, const plot_style_t *pstyle);
diff --git a/desktop/save_pdf/pdf_plotters.c b/desktop/save_pdf/pdf_plotters.c
index f33070edb..847d6dafc 100644
--- a/desktop/save_pdf/pdf_plotters.c
+++ b/desktop/save_pdf/pdf_plotters.c
@@ -49,8 +49,7 @@
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, 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_clip(const struct rect *clip);
static bool pdf_plot_text(int x, int y, const char *text, size_t length,
const plot_font_style_t *fstyle);
static bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style);
@@ -267,19 +266,19 @@ bool pdf_plot_polygon(const int *p, unsigned int n, const plot_style_t *style)
/**here the clip is only queried */
-bool pdf_plot_clip(int clip_x0, int clip_y0, int clip_x1, int clip_y1)
+bool pdf_plot_clip(const struct rect *clip)
{
#ifdef PDF_DEBUG
- LOG(("%d %d %d %d", clip_x0, clip_y0, clip_x1, clip_y1));
+ LOG(("%d %d %d %d", clip->x0, clip->y0, clip->x1, clip->y1));
#endif
/*Normalize cllipping area - to prevent overflows.
See comment in pdf_plot_fill.
*/
- last_clip_x0 = min(max(clip_x0, 0), page_width);
- last_clip_y0 = min(max(clip_y0, 0), page_height);
- last_clip_x1 = min(max(clip_x1, 0), page_width);
- last_clip_y1 = min(max(clip_y1, 0), page_height);
+ last_clip_x0 = min(max(clip->x0, 0), page_width);
+ last_clip_y0 = min(max(clip->y0, 0), page_height);
+ last_clip_x1 = min(max(clip->x1, 0), page_width);
+ last_clip_y1 = min(max(clip->y1, 0), page_height);
clip_update_needed = true;
diff --git a/desktop/textarea.c b/desktop/textarea.c
index a0dc860ba..5450dde64 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -777,7 +777,7 @@ void textarea_redraw(struct text_area *ta, int x, int y,
if (r.y1 > y + ta->vis_height)
r.y1 = y + ta->vis_height;
- plot.clip(r.x0, r.y0, r.x1, r.y1);
+ plot.clip(&r);
plot.rectangle(r.x0, r.y0, r.x1, r.y1, &plot_style_fill_bg);
plot.rectangle(x, y,
x + ta->vis_width - 1, y + ta->vis_height - 1,
@@ -787,7 +787,7 @@ void textarea_redraw(struct text_area *ta, int x, int y,
r.x0 = x + MARGIN_LEFT;
if (r.x1 > x + ta->vis_width - MARGIN_RIGHT)
r.x1 = x + ta->vis_width - MARGIN_RIGHT;
- plot.clip(r.x0, r.y0, r.x1, r.y1);
+ plot.clip(&r);
if (line0 > 0)
c_pos = utf8_bounded_length(ta->text,
diff --git a/desktop/tree.c b/desktop/tree.c
index 7e303827d..9dc38c247 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -1577,7 +1577,7 @@ static void tree_draw_node_expansion_toggle(struct tree *tree,
*/
static void tree_draw_node_element(struct tree *tree,
struct node_element *element, int tree_x, int tree_y,
- struct rect clip)
+ const struct rect *clip)
{
struct bitmap *bitmap = NULL;
@@ -1605,28 +1605,28 @@ static void tree_draw_node_element(struct tree *tree,
CONTENT_STATUS_READY ||
content_get_status(icon) ==
CONTENT_STATUS_DONE) &&
- x + TREE_ICON_SIZE > clip.x0 &&
- x < clip.x1) {
+ x + TREE_ICON_SIZE > clip->x0 &&
+ x < clip->x1) {
struct rect c;
/* Clip to image area */
c.x0 = x;
c.y0 = y + icon_inset;
c.x1 = x + TREE_ICON_SIZE;
c.y1 = y + icon_inset + TREE_ICON_SIZE;
- if (c.x0 < clip.x0) c.x0 = clip.x0;
- if (c.y0 < clip.y0) c.y0 = clip.y0;
- if (c.x1 > clip.x1) c.x1 = clip.x1;
- if (c.y1 > clip.y1) c.y1 = clip.y1;
+ if (c.x0 < clip->x0) c.x0 = clip->x0;
+ if (c.y0 < clip->y0) c.y0 = clip->y0;
+ if (c.x1 > clip->x1) c.x1 = clip->x1;
+ if (c.y1 > clip->y1) c.y1 = clip->y1;
if (c.x1 > c.x0 && c.y1 > c.y0) {
/* Valid clip rectangles only */
- plot.clip(c.x0, c.y0, c.x1, c.y1);
+ plot.clip(&c);
content_redraw(icon , x, y + icon_inset,
TREE_ICON_SIZE, TREE_ICON_SIZE,
&c, 1, 0);
/* Restore previous clipping area */
- plot.clip(clip.x0, clip.y0, clip.x1, clip.y1);
+ plot.clip(clip);
}
}
@@ -1635,7 +1635,7 @@ static void tree_draw_node_element(struct tree *tree,
/* fall through */
case NODE_ELEMENT_TEXT:
- if (element->text == NULL || clip.x1 < x)
+ if (element->text == NULL || clip->x1 < x)
break;
if (element == tree->editing)
@@ -1720,7 +1720,7 @@ static void tree_draw_node(struct tree *tree, struct node *node,
}
/* Set up the clipping area */
- plot.clip(clip.x0, clip.y0, clip.x1, clip.y1);
+ plot.clip(&clip);
/* Draw node's furniture */
if (!(tree->flags & TREE_NO_FURNITURE)) {
@@ -1772,11 +1772,12 @@ static void tree_draw_node(struct tree *tree, struct node *node,
element = element->next) {
/* Draw each element of expanded node */
tree_draw_node_element(tree, element, tree_x, tree_y,
- clip);
+ &clip);
}
} else {
/* Draw main title element of node */
- tree_draw_node_element(tree, &node->data, tree_x, tree_y, clip);
+ tree_draw_node_element(tree, &node->data, tree_x, tree_y,
+ &clip);
}
}
@@ -1849,7 +1850,7 @@ void tree_draw(struct tree *tree, int x, int y,
clip.y0 = y + clip_y;
clip.x1 = clip.x0 + clip_width;
clip.y1 = clip.y0 + clip_height;
- plot.clip(clip.x0, clip.y0, clip.x1, clip.y1);
+ plot.clip(&clip);
/* Flat fill extents of clipping area */
plot.rectangle(clip.x0, clip.y0, clip.x1, clip.y1,