summaryrefslogtreecommitdiff
path: root/render/html_redraw.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2010-08-14 13:03:57 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2010-08-14 13:03:57 +0000
commitdbe7069171865e5bb9282883abffc2862f801e7c (patch)
treeb625604e7491df6e953ddf1825afbd23b541d52f /render/html_redraw.c
parentb65fa053751e9ab29637e4bf3d0612cf123e707f (diff)
downloadnetsurf-dbe7069171865e5bb9282883abffc2862f801e7c.tar.gz
netsurf-dbe7069171865e5bb9282883abffc2862f801e7c.tar.bz2
Render 1px wide border parts with rectangle plotter, rather than polygon.
svn path=/trunk/netsurf/; revision=10701
Diffstat (limited to 'render/html_redraw.c')
-rw-r--r--render/html_redraw.c62
1 files changed, 54 insertions, 8 deletions
diff --git a/render/html_redraw.c b/render/html_redraw.c
index e5f9e480b..9febc6435 100644
--- a/render/html_redraw.c
+++ b/render/html_redraw.c
@@ -28,6 +28,7 @@
#include <assert.h>
#include <stdbool.h>
+#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "utils/config.h"
@@ -1540,7 +1541,6 @@ bool html_redraw_border_plot(const int i, const int *p, colour c,
break;
}
-
return true;
}
@@ -1559,26 +1559,32 @@ bool html_redraw_plot_border_part(const int *p, unsigned int n,
{
bool is_v = false; /* vertical border */
bool is_h = false; /* horizontal border */
+ bool v_odd = false;
+ bool h_odd = false;
+ int i;
assert(n == 4);
if ((p[1] == p[3] && p[5] == p[7])) {
+ /* 1st and 3rd (odd) lines are vertical */
is_v = true;
- }
-
- if ((p[1] == p[7] && p[3] == p[5])) {
+ v_odd = true;
+ } else if ((p[1] == p[7] && p[3] == p[5])) {
+ /* 4th and 2nd (even) lines are vertical */
is_v = true;
+ v_odd = false;
}
if ((p[0] == p[2] && p[4] == p[6])) {
+ /* 1st and 3rd (odd) lines are horizontal */
is_h = true;
- }
-
- if ((p[0] == p[6] && p[2] == p[4])) {
+ h_odd = true;
+ } else if ((p[0] == p[6] && p[2] == p[4])) {
+ /* 4th and 2nd (even) lines are horizontal */
is_h = true;
+ h_odd = false;
}
- /* TODO: handle 1px wide border parts specially */
if (is_v && is_h) {
/* border is rectangular */
int x0, y0, x1, y1;
@@ -1598,6 +1604,46 @@ bool html_redraw_plot_border_part(const int *p, unsigned int n,
}
if (!plot.rectangle(x0, y0, x1, y1, pstyle))
return false;
+ } else if (is_v && ((v_odd == true && abs(p[1] - p[5])) ||
+ (v_odd == false && abs(p[1] - p[3]) == 1))) {
+ /* 1px wide vertical border */
+ int x0, y0, x1, y1;
+ if (p[0] < p[4]) {
+ x0 = p[0];
+ x1 = p[4];
+ } else {
+ x0 = p[4];
+ x1 = p[0];
+ }
+ y0 = p[1];
+ y1 = p[3];
+ for (i = 1; i < 8; i += 2) {
+ y0 = y0 > p[i] ? p[i] : y0;
+ y1 = y1 < p[i] ? p[i] : y1;
+ }
+ /* TODO: Use line plotter? */
+ if (!plot.rectangle(x0, y0, x1, y1, pstyle))
+ return false;
+ } else if (is_h && ((h_odd == true && abs(p[0] - p[4])) ||
+ (h_odd == false && abs(p[0] - p[2]) == 1))) {
+ /* 1px wide horizontal border */
+ int x0, y0, x1, y1;
+ if (p[1] < p[5]) {
+ y0 = p[1];
+ y1 = p[5];
+ } else {
+ y0 = p[5];
+ y1 = p[1];
+ }
+ x0 = p[0];
+ x1 = p[2];
+ for (i = 0; i < 7; i += 2) {
+ x0 = x0 > p[i] ? p[i] : x0;
+ x1 = x1 < p[i] ? p[i] : x1;
+ }
+ /* TODO: Use line plotter? */
+ if (!plot.rectangle(x0, y0, x1, y1, pstyle))
+ return false;
} else {
/* have to plot as polygon */
if (!plot.polygon(p, 4, pstyle))