r10701 tlsa - /trunk/netsurf/render/html_redraw.c
by netsurf@semichrome.net
Author: tlsa
Date: Sat Aug 14 08:03:57 2010
New Revision: 10701
URL: http://source.netsurf-browser.org?rev=10701&view=rev
Log:
Render 1px wide border parts with rectangle plotter, rather than polygon.
Modified:
trunk/netsurf/render/html_redraw.c
Modified: trunk/netsurf/render/html_redraw.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html_redraw.c?rev=...
==============================================================================
--- trunk/netsurf/render/html_redraw.c (original)
+++ trunk/netsurf/render/html_redraw.c Sat Aug 14 08:03:57 2010
@@ -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 @@
break;
}
-
return true;
}
@@ -1559,26 +1559,32 @@
{
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;
- }
-
- /* TODO: handle 1px wide border parts specially */
+ h_odd = false;
+ }
+
if (is_v && is_h) {
/* border is rectangular */
int x0, y0, x1, y1;
@@ -1596,6 +1602,46 @@
y0 = p[5];
y1 = p[1];
}
+ 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 {
13 years, 3 months
r10700 tlsa - /trunk/netsurf/render/html_redraw.c
by netsurf@semichrome.net
Author: tlsa
Date: Sat Aug 14 05:52:25 2010
New Revision: 10700
URL: http://source.netsurf-browser.org?rev=10700&view=rev
Log:
+ Optimise border handling at 1:1 scale.
+ Reduce computation for elements with no borders.
+ Simplfy border vertex calculation.
+ Add comments.
Modified:
trunk/netsurf/render/html_redraw.c
Modified: trunk/netsurf/render/html_redraw.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html_redraw.c?rev=...
==============================================================================
--- trunk/netsurf/render/html_redraw.c (original)
+++ trunk/netsurf/render/html_redraw.c Sat Aug 14 05:52:25 2010
@@ -1059,30 +1059,37 @@
int left = box->border[LEFT].width;
int x, y;
unsigned int i, side;
- int p[16];
- int z[8];
+ int p[8]; /* Box border vertices */
+ int z[8]; /* Border vertices */
+
+ x = x_parent + box->x;
+ y = y_parent + box->y;
if (scale != 1.0) {
top *= scale;
right *= scale;
bottom *= scale;
left *= scale;
+ x *= scale;
+ y *= scale;
}
assert(box->style);
- x = (x_parent + box->x) * scale;
- y = (y_parent + box->y) * scale;
-
- /* calculate border vertices */
- p[0] = x; p[1] = y;
- p[2] = x - left; p[3] = y - top;
- p[4] = x + p_width + right; p[5] = y - top;
- p[6] = x + p_width; p[7] = y;
- p[8] = x + p_width; p[9] = y + p_height;
- p[10] = x + p_width + right; p[11] = y + p_height + bottom;
- p[12] = x - left; p[13] = y + p_height + bottom;
- p[14] = x; p[15] = y + p_height;
+ /* Calculate border vertices
+ *
+ * A----------------------+
+ * | \ / |
+ * | B--------------+ |
+ * | | | |
+ * | +--------------C |
+ * | / \ |
+ * +----------------------D
+ */
+ p[0] = x - left; p[1] = y - top; /* A */
+ p[2] = x; p[3] = y; /* B */
+ p[4] = x + p_width; p[5] = y + p_height; /* C */
+ p[6] = x + p_width + right; p[7] = y + p_height + bottom; /* D */
for (i = 0; i != 4; i++) {
colour col = 0;
@@ -1094,14 +1101,11 @@
switch (side) {
case TOP:
- z[0] = p[0];
- z[1] = p[1];
- z[2] = p[2];
- z[3] = p[3];
- z[4] = p[4];
- z[5] = p[5];
- z[6] = p[6];
- z[7] = p[7];
+ z[0] = p[2]; z[1] = p[3];
+ z[2] = p[0]; z[3] = p[1];
+ z[4] = p[6]; z[5] = p[1];
+ z[6] = p[4]; z[7] = p[3];
+
if (box->border[LEFT].color !=
CSS_BORDER_COLOR_TRANSPARENT) {
/* make border overhang left corner fully,
@@ -1116,14 +1120,11 @@
}
break;
case BOTTOM:
- z[0] = p[8];
- z[1] = p[9];
- z[2] = p[10];
- z[3] = p[11];
- z[4] = p[12];
- z[5] = p[13];
- z[6] = p[14];
- z[7] = p[15];
+ z[0] = p[4]; z[1] = p[5];
+ z[2] = p[6]; z[3] = p[7];
+ z[4] = p[0]; z[5] = p[7];
+ z[6] = p[2]; z[7] = p[5];
+
if (box->border[LEFT].color !=
CSS_BORDER_COLOR_TRANSPARENT) {
/* make border overhang left corner fully,
@@ -1138,14 +1139,11 @@
}
break;
case LEFT:
- z[0] = p[12];
- z[1] = p[13];
- z[2] = p[14];
- z[3] = p[15];
- z[4] = p[0];
- z[5] = p[1];
- z[6] = p[2];
- z[7] = p[3];
+ z[0] = p[0]; z[1] = p[7];
+ z[2] = p[2]; z[3] = p[5];
+ z[4] = p[2]; z[5] = p[3];
+ z[6] = p[0]; z[7] = p[1];
+
if (box->border[side].style == CSS_BORDER_STYLE_SOLID &&
box->border[LEFT].color ==
box->border[TOP].color) {
@@ -1162,14 +1160,11 @@
}
break;
case RIGHT:
- z[0] = p[4];
- z[1] = p[5];
- z[2] = p[6];
- z[3] = p[7];
- z[4] = p[8];
- z[5] = p[9];
- z[6] = p[10];
- z[7] = p[11];
+ z[0] = p[6]; z[1] = p[1];
+ z[2] = p[4]; z[3] = p[3];
+ z[4] = p[4]; z[5] = p[5];
+ z[6] = p[6]; z[7] = p[7];
+
if (box->border[side].style == CSS_BORDER_STYLE_SOLID &&
box->border[RIGHT].color ==
box->border[TOP].color) {
@@ -1225,8 +1220,8 @@
int bottom = box->border[BOTTOM].width;
int left = box->border[LEFT].width;
colour col;
- int p[16];
- int z[8];
+ int p[8]; /* Box border vertices */
+ int z[8]; /* Border vertices */
if (scale != 1.0) {
top *= scale;
@@ -1235,30 +1230,33 @@
left *= scale;
}
- /* calculate border vertices */
- p[0] = (first) ? x0 + left : x0; p[1] = y0 + top;
- p[2] = x0; p[3] = y0;
- p[4] = x1; p[5] = y0;
- p[6] = (last) ? x1 - right : x1; p[7] = y0 + top;
- p[8] = (last) ? x1 - right : x1; p[9] = y1 - bottom;
- p[10] = x1; p[11] = y1;
- p[12] = x0; p[13] = y1;
- p[14] = (first) ? x0 + left : x0; p[15] = y1 - bottom;
+ /* Calculate border vertices
+ *
+ * A----------------------+
+ * | \ / |
+ * | B--------------+ |
+ * | | | |
+ * | +--------------C |
+ * | / \ |
+ * +----------------------D
+ */
+ p[0] = x0; p[1] = y0; /* A */
+ p[2] = first ? x0 + left : x0; p[3] = y0 + top; /* B */
+ p[4] = last ? x1 - right : x1; p[5] = y1 - bottom; /* C */
+ p[6] = x1; p[7] = y1; /* D */
assert(box->style);
+ /* Top */
if (top != 0 && box->border[TOP].color !=
CSS_BORDER_COLOR_TRANSPARENT) {
col = nscss_color_to_ns(box->border[TOP].c);
- z[0] = p[0];
- z[1] = p[1];
- z[2] = p[2];
- z[3] = p[3];
- z[4] = p[4];
- z[5] = p[5];
- z[6] = p[6];
- z[7] = p[7];
+ z[0] = p[2]; z[1] = p[3];
+ z[2] = p[0]; z[3] = p[1];
+ z[4] = p[6]; z[5] = p[1];
+ z[6] = p[4]; z[7] = p[3];
+
if (first && box->border[LEFT].color !=
CSS_BORDER_COLOR_TRANSPARENT) {
/* make border overhang left corner fully,
@@ -1278,18 +1276,16 @@
return false;
}
+ /* Bottom */
if (bottom != 0 && box->border[BOTTOM].color !=
CSS_BORDER_COLOR_TRANSPARENT) {
col = nscss_color_to_ns(box->border[BOTTOM].c);
- z[0] = p[8];
- z[1] = p[9];
- z[2] = p[10];
- z[3] = p[11];
- z[4] = p[12];
- z[5] = p[13];
- z[6] = p[14];
- z[7] = p[15];
+ z[0] = p[4]; z[1] = p[5];
+ z[2] = p[6]; z[3] = p[7];
+ z[4] = p[0]; z[5] = p[7];
+ z[6] = p[2]; z[7] = p[5];
+
if (first && box->border[LEFT].color !=
CSS_BORDER_COLOR_TRANSPARENT) {
/* make border overhang left corner fully,
@@ -1309,18 +1305,16 @@
return false;
}
+ /* Left */
if (left != 0 && first && box->border[LEFT].color !=
CSS_BORDER_COLOR_TRANSPARENT) {
col = nscss_color_to_ns(box->border[LEFT].c);
- z[0] = p[12];
- z[1] = p[13];
- z[2] = p[14];
- z[3] = p[15];
- z[4] = p[0];
- z[5] = p[1];
- z[6] = p[2];
- z[7] = p[3];
+ z[0] = p[0]; z[1] = p[7];
+ z[2] = p[2]; z[3] = p[5];
+ z[4] = p[2]; z[5] = p[3];
+ z[6] = p[0]; z[7] = p[1];
+
if (box->border[LEFT].style == CSS_BORDER_STYLE_SOLID &&
box->border[LEFT].color ==
box->border[TOP].color) {
@@ -1342,18 +1336,16 @@
return false;
}
+ /* Right */
if (right != 0 && last && box->border[RIGHT].color !=
CSS_BORDER_COLOR_TRANSPARENT) {
col = nscss_color_to_ns(box->border[RIGHT].c);
- z[0] = p[4];
- z[1] = p[5];
- z[2] = p[6];
- z[3] = p[7];
- z[4] = p[8];
- z[5] = p[9];
- z[6] = p[10];
- z[7] = p[11];
+ z[0] = p[6]; z[1] = p[1];
+ z[2] = p[4]; z[3] = p[3];
+ z[4] = p[4]; z[5] = p[5];
+ z[6] = p[6]; z[7] = p[7];
+
if (box->border[RIGHT].style == CSS_BORDER_STYLE_SOLID &&
box->border[RIGHT].color ==
box->border[TOP].color) {
@@ -1411,7 +1403,7 @@
bool html_redraw_border_plot(const int i, const int *p, colour c,
enum css_border_style_e style, int thickness)
{
- int z[8];
+ int z[8]; /* Vertices of border part */
unsigned int light = i;
plot_style_t *plot_style_bdr_in;
plot_style_t *plot_style_bdr_out;
13 years, 3 months
r10699 tlsa - /trunk/netsurf/beos/beos_plotters.cpp
by netsurf@semichrome.net
Author: tlsa
Date: Sat Aug 14 04:33:36 2010
New Revision: 10699
URL: http://source.netsurf-browser.org?rev=10699&view=rev
Log:
Remove printfs from bitmap plotter.
Modified:
trunk/netsurf/beos/beos_plotters.cpp
Modified: trunk/netsurf/beos/beos_plotters.cpp
URL: http://source.netsurf-browser.org/trunk/netsurf/beos/beos_plotters.cpp?re...
==============================================================================
--- trunk/netsurf/beos/beos_plotters.cpp (original)
+++ trunk/netsurf/beos/beos_plotters.cpp Sat Aug 14 04:33:36 2010
@@ -561,13 +561,12 @@
if (!repeat_x && repeat_y)
pretiled = nsbeos_bitmap_get_pretile_y(bitmap);
primary = nsbeos_bitmap_get_primary(bitmap);
+
/* use the primary and pretiled widths to scale the w/h provided */
-printf("plot_tile: -> %dx%d\n", width, height);
width *= pretiled->Bounds().Width() + 1;
width /= primary->Bounds().Width() + 1;
height *= pretiled->Bounds().Height() + 1;
height /= primary->Bounds().Height() + 1;
-printf("plot_tile: -> %dx%d\n", width, height);
BView *view;
13 years, 3 months
r10697 tlsa - /trunk/netsurf/render/html_redraw.c
by netsurf@semichrome.net
Author: tlsa
Date: Fri Aug 13 17:29:49 2010
New Revision: 10697
URL: http://source.netsurf-browser.org?rev=10697&view=rev
Log:
Plot rectangular border parts with the rectangle plotter, rather than the polygon plotter.
Modified:
trunk/netsurf/render/html_redraw.c
Modified: trunk/netsurf/render/html_redraw.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html_redraw.c?rev=...
==============================================================================
--- trunk/netsurf/render/html_redraw.c (original)
+++ trunk/netsurf/render/html_redraw.c Fri Aug 13 17:29:49 2010
@@ -68,10 +68,12 @@
colour current_background_color, float scale);
static bool html_redraw_borders(struct box *box, int x_parent, int y_parent,
int p_width, int p_height, float scale);
-bool html_redraw_inline_borders(struct box *box, int x0, int y0, int x1, int y1,
- float scale, bool first, bool last);
+static bool html_redraw_inline_borders(struct box *box, int x0, int y0,
+ int x1, int y1, float scale, bool first, bool last);
static bool html_redraw_border_plot(const int i, const int *p, colour c,
enum css_border_style_e style, int thickness);
+static bool html_redraw_plot_border_part(const int *p, unsigned int n,
+ const plot_style_t *pstyle);
static bool html_redraw_checkbox(int x, int y, int width, int height,
bool selected);
static bool html_redraw_radio(int x, int y, int width, int height,
@@ -1442,7 +1444,7 @@
case CSS_BORDER_STYLE_SOLID:
/* fall through to default */
default:
- if (!plot.polygon(p, 4, &plot_style_fillbdr))
+ if (!html_redraw_plot_border_part(p, 4, &plot_style_fillbdr))
return false;
break;
@@ -1455,7 +1457,7 @@
z[5] = (p[7] * 2 + p[5]) / 3;
z[6] = p[6];
z[7] = p[7];
- if (!plot.polygon(z, 4, &plot_style_fillbdr))
+ if (!html_redraw_plot_border_part(z, 4, &plot_style_fillbdr))
return false;
z[0] = p[2];
z[1] = p[3];
@@ -1465,7 +1467,7 @@
z[5] = (p[5] * 2 + p[7]) / 3;
z[6] = p[4];
z[7] = p[5];
- if (!plot.polygon(z, 4, &plot_style_fillbdr))
+ if (!html_redraw_plot_border_part(z, 4, &plot_style_fillbdr))
return false;
break;
@@ -1489,13 +1491,13 @@
z[5] = (p[7] + p[5]) / 2;
z[6] = p[6];
z[7] = p[7];
- if (!plot.polygon(z, 4, plot_style_bdr_in))
+ if (!html_redraw_plot_border_part(z, 4, plot_style_bdr_in))
return false;
z[0] = p[2];
z[1] = p[3];
z[6] = p[4];
z[7] = p[5];
- if (!plot.polygon(z, 4, plot_style_bdr_out))
+ if (!html_redraw_plot_border_part(z, 4, plot_style_bdr_out))
return false;
break;
@@ -1535,17 +1537,80 @@
z[5] = (p[7] + p[5]) / 2;
z[6] = p[6];
z[7] = p[7];
- if (!plot.polygon(z, 4, plot_style_bdr_in))
+ if (!html_redraw_plot_border_part(z, 4, plot_style_bdr_in))
return false;
z[0] = p[2];
z[1] = p[3];
z[6] = p[4];
z[7] = p[5];
- if (!plot.polygon(z, 4, plot_style_bdr_out))
+ if (!html_redraw_plot_border_part(z, 4, plot_style_bdr_out))
return false;
break;
}
+
+ return true;
+}
+
+
+/**
+ * Plot a border part, using the most optimal plotter.
+ *
+ * \param p array of precomputed border vertices
+ * \param n number of vertices
+ * \param pstyle plot_style to plot with
+ * \return true if successful, false otherwise
+ */
+
+bool html_redraw_plot_border_part(const int *p, unsigned int n,
+ const plot_style_t *pstyle)
+{
+ bool is_v = false; /* vertical border */
+ bool is_h = false; /* horizontal border */
+
+ assert(n == 4);
+
+ if ((p[1] == p[3] && p[5] == p[7])) {
+ is_v = true;
+ }
+
+ if ((p[1] == p[7] && p[3] == p[5])) {
+ is_v = true;
+ }
+
+ if ((p[0] == p[2] && p[4] == p[6])) {
+ is_h = true;
+ }
+
+ if ((p[0] == p[6] && p[2] == p[4])) {
+ is_h = true;
+ }
+
+ /* TODO: handle 1px wide border parts specially */
+ if (is_v && is_h) {
+ /* border is rectangular */
+ int x0, y0, x1, y1;
+ if (p[0] < p[4]) {
+ x0 = p[0];
+ x1 = p[4];
+ } else {
+ x0 = p[4];
+ x1 = p[0];
+ }
+ if (p[1] < p[5]) {
+ y0 = p[1];
+ y1 = p[5];
+ } else {
+ y0 = p[5];
+ y1 = p[1];
+ }
+ if (!plot.rectangle(x0, y0, x1, y1, pstyle))
+ return false;
+ } else {
+ /* have to plot as polygon */
+ if (!plot.polygon(p, 4, pstyle))
+ return false;
+ }
return true;
}
13 years, 3 months
r10696 tlsa - /trunk/netsurf/render/html_redraw.c
by netsurf@semichrome.net
Author: tlsa
Date: Fri Aug 13 16:07:46 2010
New Revision: 10696
URL: http://source.netsurf-browser.org?rev=10696&view=rev
Log:
Make top and bottom borders flush with left and right of border box, when possible. Make left and right borders only render above/below padding box when they need to.
Modified:
trunk/netsurf/render/html_redraw.c
Modified: trunk/netsurf/render/html_redraw.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html_redraw.c?rev=...
==============================================================================
--- trunk/netsurf/render/html_redraw.c (original)
+++ trunk/netsurf/render/html_redraw.c Fri Aug 13 16:07:46 2010
@@ -1057,7 +1057,8 @@
int left = box->border[LEFT].width;
int x, y;
unsigned int i, side;
- int p[20];
+ int p[16];
+ int z[8];
if (scale != 1.0) {
top *= scale;
@@ -1080,8 +1081,6 @@
p[10] = x + p_width + right; p[11] = y + p_height + bottom;
p[12] = x - left; p[13] = y + p_height + bottom;
p[14] = x; p[15] = y + p_height;
- p[16] = p[0]; p[17] = p[1];
- p[18] = p[2]; p[19] = p[3];
for (i = 0; i != 4; i++) {
side = sides[i]; /* plot order */
@@ -1091,9 +1090,108 @@
CSS_BORDER_COLOR_TRANSPARENT)
continue;
+ switch (side) {
+ case TOP:
+ z[0] = p[0];
+ z[1] = p[1];
+ z[2] = p[2];
+ z[3] = p[3];
+ z[4] = p[4];
+ z[5] = p[5];
+ z[6] = p[6];
+ z[7] = p[7];
+ if (box->border[LEFT].color !=
+ CSS_BORDER_COLOR_TRANSPARENT) {
+ /* make border overhang left corner fully,
+ * if left border is transparent */
+ z[0] -= left;
+ }
+ if (box->border[RIGHT].color !=
+ CSS_BORDER_COLOR_TRANSPARENT) {
+ /* make border overhang right corner fully,
+ * if right border is transparent */
+ z[6] += right;
+ }
+ break;
+ case BOTTOM:
+ z[0] = p[8];
+ z[1] = p[9];
+ z[2] = p[10];
+ z[3] = p[11];
+ z[4] = p[12];
+ z[5] = p[13];
+ z[6] = p[14];
+ z[7] = p[15];
+ if (box->border[LEFT].color !=
+ CSS_BORDER_COLOR_TRANSPARENT) {
+ /* make border overhang left corner fully,
+ * if left border is transparent */
+ z[6] -= left;
+ }
+ if (box->border[RIGHT].color !=
+ CSS_BORDER_COLOR_TRANSPARENT) {
+ /* make border overhang right corner fully,
+ * if right border is transparent */
+ z[0] += right;
+ }
+ break;
+ case LEFT:
+ z[0] = p[12];
+ z[1] = p[13];
+ z[2] = p[14];
+ z[3] = p[15];
+ z[4] = p[0];
+ z[5] = p[1];
+ z[6] = p[2];
+ z[7] = p[3];
+ if (box->border[side].style == CSS_BORDER_STYLE_SOLID &&
+ box->border[LEFT].color ==
+ box->border[TOP].color) {
+ /* don't bother overlapping top corner if
+ * it's the same colour anyway */
+ z[7] += top;
+ }
+ if (box->border[side].style == CSS_BORDER_STYLE_SOLID &&
+ box->border[LEFT].color ==
+ box->border[BOTTOM].color) {
+ /* don't bother overlapping bottom corner if
+ * it's the same colour anyway */
+ z[1] -= bottom;
+ }
+ break;
+ case RIGHT:
+ z[0] = p[4];
+ z[1] = p[5];
+ z[2] = p[6];
+ z[3] = p[7];
+ z[4] = p[8];
+ z[5] = p[9];
+ z[6] = p[10];
+ z[7] = p[11];
+ if (box->border[side].style == CSS_BORDER_STYLE_SOLID &&
+ box->border[RIGHT].color ==
+ box->border[TOP].color) {
+ /* don't bother overlapping top corner if
+ * it's the same colour anyway */
+ z[1] += top;
+ }
+ if (box->border[side].style == CSS_BORDER_STYLE_SOLID &&
+ box->border[RIGHT].color ==
+ box->border[BOTTOM].color) {
+ /* don't bother overlapping bottom corner if
+ * it's the same colour anyway */
+ z[7] -= bottom;
+ }
+ break;
+ default:
+ assert(side == TOP || side == BOTTOM ||
+ side == LEFT || side == RIGHT);
+ break;
+ }
+
col = nscss_color_to_ns(box->border[side].c);
- if (!html_redraw_border_plot(side, p, col,
+ if (!html_redraw_border_plot(side, z, col,
box->border[side].style,
box->border[side].width * scale))
return false;
@@ -1125,7 +1223,8 @@
int bottom = box->border[BOTTOM].width;
int left = box->border[LEFT].width;
colour col;
- int p[20];
+ int p[16];
+ int z[8];
if (scale != 1.0) {
top *= scale;
@@ -1143,54 +1242,132 @@
p[10] = x1; p[11] = y1;
p[12] = x0; p[13] = y1;
p[14] = (first) ? x0 + left : x0; p[15] = y1 - bottom;
- p[16] = (first) ? x0 + left : x0; p[17] = y0 + top;
- p[18] = x0; p[19] = y0;
assert(box->style);
- if (box->border[LEFT].width && first) {
- if (box->border[LEFT].color == CSS_BORDER_COLOR_TRANSPARENT)
- col = NS_TRANSPARENT;
- else
- col = nscss_color_to_ns(box->border[LEFT].c);
-
- if (!html_redraw_border_plot(LEFT, p, col,
+ if (top != 0 && box->border[TOP].color !=
+ CSS_BORDER_COLOR_TRANSPARENT) {
+ col = nscss_color_to_ns(box->border[TOP].c);
+
+ z[0] = p[0];
+ z[1] = p[1];
+ z[2] = p[2];
+ z[3] = p[3];
+ z[4] = p[4];
+ z[5] = p[5];
+ z[6] = p[6];
+ z[7] = p[7];
+ if (first && box->border[LEFT].color !=
+ CSS_BORDER_COLOR_TRANSPARENT) {
+ /* make border overhang left corner fully,
+ * if left border is transparent */
+ z[0] -= left;
+ }
+ if (last && box->border[RIGHT].color !=
+ CSS_BORDER_COLOR_TRANSPARENT) {
+ /* make border overhang right corner fully,
+ * if right border is transparent */
+ z[6] += right;
+ }
+
+ if (!html_redraw_border_plot(TOP, z, col,
+ box->border[TOP].style,
+ top))
+ return false;
+ }
+
+ if (bottom != 0 && box->border[BOTTOM].color !=
+ CSS_BORDER_COLOR_TRANSPARENT) {
+ col = nscss_color_to_ns(box->border[BOTTOM].c);
+
+ z[0] = p[8];
+ z[1] = p[9];
+ z[2] = p[10];
+ z[3] = p[11];
+ z[4] = p[12];
+ z[5] = p[13];
+ z[6] = p[14];
+ z[7] = p[15];
+ if (first && box->border[LEFT].color !=
+ CSS_BORDER_COLOR_TRANSPARENT) {
+ /* make border overhang left corner fully,
+ * if left border is transparent */
+ z[6] -= left;
+ }
+ if (last && box->border[RIGHT].color !=
+ CSS_BORDER_COLOR_TRANSPARENT) {
+ /* make border overhang right corner fully,
+ * if right border is transparent */
+ z[0] += right;
+ }
+
+ if (!html_redraw_border_plot(BOTTOM, z, col,
+ box->border[BOTTOM].style,
+ bottom))
+ return false;
+ }
+
+ if (left != 0 && first && box->border[LEFT].color !=
+ CSS_BORDER_COLOR_TRANSPARENT) {
+ col = nscss_color_to_ns(box->border[LEFT].c);
+
+ z[0] = p[12];
+ z[1] = p[13];
+ z[2] = p[14];
+ z[3] = p[15];
+ z[4] = p[0];
+ z[5] = p[1];
+ z[6] = p[2];
+ z[7] = p[3];
+ if (box->border[LEFT].style == CSS_BORDER_STYLE_SOLID &&
+ box->border[LEFT].color ==
+ box->border[TOP].color) {
+ /* don't bother overlapping top corner if
+ * it's the same colour anyway */
+ z[7] += top;
+ }
+ if (box->border[LEFT].style == CSS_BORDER_STYLE_SOLID &&
+ box->border[LEFT].color ==
+ box->border[BOTTOM].color) {
+ /* don't bother overlapping bottom corner if
+ * it's the same colour anyway */
+ z[1] -= bottom;
+ }
+
+ if (!html_redraw_border_plot(LEFT, z, col,
box->border[LEFT].style,
left))
return false;
}
- if (box->border[TOP].width) {
- if (box->border[TOP].color == CSS_BORDER_COLOR_TRANSPARENT)
- col = NS_TRANSPARENT;
- else
- col = nscss_color_to_ns(box->border[TOP].c);
-
- if (!html_redraw_border_plot(TOP, p, col,
- box->border[TOP].style,
- top))
- return false;
- }
-
- if (box->border[BOTTOM].width) {
- if (box->border[BOTTOM].color == CSS_BORDER_COLOR_TRANSPARENT)
- col = NS_TRANSPARENT;
- else
- col = nscss_color_to_ns(box->border[BOTTOM].c);
-
- if (!html_redraw_border_plot(BOTTOM, p, col,
- box->border[BOTTOM].style,
- bottom))
- return false;
- }
-
- if (box->border[RIGHT].width && last) {
- if (box->border[RIGHT].color == CSS_BORDER_COLOR_TRANSPARENT)
- col = NS_TRANSPARENT;
- else
- col = nscss_color_to_ns(box->border[RIGHT].c);
-
- if (!html_redraw_border_plot(RIGHT, p, col,
+ if (right != 0 && last && box->border[RIGHT].color !=
+ CSS_BORDER_COLOR_TRANSPARENT) {
+ col = nscss_color_to_ns(box->border[RIGHT].c);
+
+ z[0] = p[4];
+ z[1] = p[5];
+ z[2] = p[6];
+ z[3] = p[7];
+ z[4] = p[8];
+ z[5] = p[9];
+ z[6] = p[10];
+ z[7] = p[11];
+ if (box->border[RIGHT].style == CSS_BORDER_STYLE_SOLID &&
+ box->border[RIGHT].color ==
+ box->border[TOP].color) {
+ /* don't bother overlapping top corner if
+ * it's the same colour anyway */
+ z[1] += top;
+ }
+ if (box->border[RIGHT].style == CSS_BORDER_STYLE_SOLID &&
+ box->border[RIGHT].color ==
+ box->border[BOTTOM].color) {
+ /* don't bother overlapping bottom corner if
+ * it's the same colour anyway */
+ z[7] -= bottom;
+ }
+
+ if (!html_redraw_border_plot(RIGHT, z, col,
box->border[RIGHT].style,
right))
return false;
@@ -1234,7 +1411,6 @@
{
int z[8];
unsigned int light = i;
- const int SIDE = i * 4; /* offset to the side's data */
plot_style_t *plot_style_bdr_in;
plot_style_t *plot_style_bdr_out;
@@ -1255,10 +1431,10 @@
plot_style_bdr.stroke_type = PLOT_OP_TYPE_DOT;
/* fall through */
case CSS_BORDER_STYLE_DASHED:
- if (!plot.line((p[SIDE + 0] + p[SIDE + 2]) / 2,
- (p[SIDE + 1] + p[SIDE + 3]) / 2,
- (p[SIDE + 4] + p[SIDE + 6]) / 2,
- (p[SIDE + 5] + p[SIDE + 7]) / 2,
+ if (!plot.line((p[0] + p[2]) / 2,
+ (p[1] + p[3]) / 2,
+ (p[4] + p[6]) / 2,
+ (p[5] + p[7]) / 2,
&plot_style_bdr))
return false;
break;
@@ -1266,29 +1442,29 @@
case CSS_BORDER_STYLE_SOLID:
/* fall through to default */
default:
- if (!plot.polygon(p + SIDE, 4, &plot_style_fillbdr))
+ if (!plot.polygon(p, 4, &plot_style_fillbdr))
return false;
break;
case CSS_BORDER_STYLE_DOUBLE:
- z[0] = p[SIDE + 0];
- z[1] = p[SIDE + 1];
- z[2] = (p[SIDE + 0] * 2 + p[SIDE + 2]) / 3;
- z[3] = (p[SIDE + 1] * 2 + p[SIDE + 3]) / 3;
- z[4] = (p[SIDE + 6] * 2 + p[SIDE + 4]) / 3;
- z[5] = (p[SIDE + 7] * 2 + p[SIDE + 5]) / 3;
- z[6] = p[SIDE + 6];
- z[7] = p[SIDE + 7];
+ z[0] = p[0];
+ z[1] = p[1];
+ z[2] = (p[0] * 2 + p[2]) / 3;
+ z[3] = (p[1] * 2 + p[3]) / 3;
+ z[4] = (p[6] * 2 + p[4]) / 3;
+ z[5] = (p[7] * 2 + p[5]) / 3;
+ z[6] = p[6];
+ z[7] = p[7];
if (!plot.polygon(z, 4, &plot_style_fillbdr))
return false;
- z[0] = p[SIDE + 2];
- z[1] = p[SIDE + 3];
- z[2] = (p[SIDE + 2] * 2 + p[SIDE + 0]) / 3;
- z[3] = (p[SIDE + 3] * 2 + p[SIDE + 1]) / 3;
- z[4] = (p[SIDE + 4] * 2 + p[SIDE + 6]) / 3;
- z[5] = (p[SIDE + 5] * 2 + p[SIDE + 7]) / 3;
- z[6] = p[SIDE + 4];
- z[7] = p[SIDE + 5];
+ z[0] = p[2];
+ z[1] = p[3];
+ z[2] = (p[2] * 2 + p[0]) / 3;
+ z[3] = (p[3] * 2 + p[1]) / 3;
+ z[4] = (p[4] * 2 + p[6]) / 3;
+ z[5] = (p[5] * 2 + p[7]) / 3;
+ z[6] = p[4];
+ z[7] = p[5];
if (!plot.polygon(z, 4, &plot_style_fillbdr))
return false;
break;
@@ -1305,20 +1481,20 @@
plot_style_bdr_in = &plot_style_fillbdr_light;
plot_style_bdr_out = &plot_style_fillbdr_dark;
}
- z[0] = p[SIDE + 0];
- z[1] = p[SIDE + 1];
- z[2] = (p[SIDE + 0] + p[SIDE + 2]) / 2;
- z[3] = (p[SIDE + 1] + p[SIDE + 3]) / 2;
- z[4] = (p[SIDE + 6] + p[SIDE + 4]) / 2;
- z[5] = (p[SIDE + 7] + p[SIDE + 5]) / 2;
- z[6] = p[SIDE + 6];
- z[7] = p[SIDE + 7];
+ z[0] = p[0];
+ z[1] = p[1];
+ z[2] = (p[0] + p[2]) / 2;
+ z[3] = (p[1] + p[3]) / 2;
+ z[4] = (p[6] + p[4]) / 2;
+ z[5] = (p[7] + p[5]) / 2;
+ z[6] = p[6];
+ z[7] = p[7];
if (!plot.polygon(z, 4, plot_style_bdr_in))
return false;
- z[0] = p[SIDE + 2];
- z[1] = p[SIDE + 3];
- z[6] = p[SIDE + 4];
- z[7] = p[SIDE + 5];
+ z[0] = p[2];
+ z[1] = p[3];
+ z[6] = p[4];
+ z[7] = p[5];
if (!plot.polygon(z, 4, plot_style_bdr_out))
return false;
break;
@@ -1351,20 +1527,20 @@
break;
}
- z[0] = p[SIDE + 0];
- z[1] = p[SIDE + 1];
- z[2] = (p[SIDE + 0] + p[SIDE + 2]) / 2;
- z[3] = (p[SIDE + 1] + p[SIDE + 3]) / 2;
- z[4] = (p[SIDE + 6] + p[SIDE + 4]) / 2;
- z[5] = (p[SIDE + 7] + p[SIDE + 5]) / 2;
- z[6] = p[SIDE + 6];
- z[7] = p[SIDE + 7];
+ z[0] = p[0];
+ z[1] = p[1];
+ z[2] = (p[0] + p[2]) / 2;
+ z[3] = (p[1] + p[3]) / 2;
+ z[4] = (p[6] + p[4]) / 2;
+ z[5] = (p[7] + p[5]) / 2;
+ z[6] = p[6];
+ z[7] = p[7];
if (!plot.polygon(z, 4, plot_style_bdr_in))
return false;
- z[0] = p[SIDE + 2];
- z[1] = p[SIDE + 3];
- z[6] = p[SIDE + 4];
- z[7] = p[SIDE + 5];
+ z[0] = p[2];
+ z[1] = p[3];
+ z[6] = p[4];
+ z[7] = p[5];
if (!plot.polygon(z, 4, plot_style_bdr_out))
return false;
break;
13 years, 3 months
r10695 tlsa - /trunk/netsurf/render/html_redraw.c
by netsurf@semichrome.net
Author: tlsa
Date: Fri Aug 13 14:02:39 2010
New Revision: 10695
URL: http://source.netsurf-browser.org?rev=10695&view=rev
Log:
Skip transparent borders early and change border side plot order.
Modified:
trunk/netsurf/render/html_redraw.c
Modified: trunk/netsurf/render/html_redraw.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html_redraw.c?rev=...
==============================================================================
--- trunk/netsurf/render/html_redraw.c (original)
+++ trunk/netsurf/render/html_redraw.c Fri Aug 13 14:02:39 2010
@@ -1050,12 +1050,13 @@
bool html_redraw_borders(struct box *box, int x_parent, int y_parent,
int p_width, int p_height, float scale)
{
+ unsigned int sides[] = { TOP, BOTTOM, LEFT, RIGHT };
int top = box->border[TOP].width;
int right = box->border[RIGHT].width;
int bottom = box->border[BOTTOM].width;
int left = box->border[LEFT].width;
int x, y;
- unsigned int i;
+ unsigned int i, side;
int p[20];
if (scale != 1.0) {
@@ -1079,23 +1080,22 @@
p[10] = x + p_width + right; p[11] = y + p_height + bottom;
p[12] = x - left; p[13] = y + p_height + bottom;
p[14] = x; p[15] = y + p_height;
- p[16] = x; p[17] = y;
- p[18] = x - left; p[19] = y - top;
+ p[16] = p[0]; p[17] = p[1];
+ p[18] = p[2]; p[19] = p[3];
for (i = 0; i != 4; i++) {
+ side = sides[i]; /* plot order */
colour col = 0;
- if (box->border[i].width == 0)
+ if (box->border[side].width == 0 || box->border[side].color ==
+ CSS_BORDER_COLOR_TRANSPARENT)
continue;
- if (box->border[i].color == CSS_BORDER_COLOR_TRANSPARENT) {
- col = NS_TRANSPARENT;
- } else {
- col = nscss_color_to_ns(box->border[i].c);
- }
-
- if (!html_redraw_border_plot(i, p, col, box->border[i].style,
- box->border[i].width * scale))
+ col = nscss_color_to_ns(box->border[side].c);
+
+ if (!html_redraw_border_plot(side, p, col,
+ box->border[side].style,
+ box->border[side].width * scale))
return false;
}
13 years, 3 months
r10694 tlsa - /trunk/netsurf/render/html_redraw.c
by netsurf@semichrome.net
Author: tlsa
Date: Fri Aug 13 11:53:30 2010
New Revision: 10694
URL: http://source.netsurf-browser.org?rev=10694&view=rev
Log:
Fix inline border ends where inline text wraps.
Modified:
trunk/netsurf/render/html_redraw.c
Modified: trunk/netsurf/render/html_redraw.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html_redraw.c?rev=...
==============================================================================
--- trunk/netsurf/render/html_redraw.c (original)
+++ trunk/netsurf/render/html_redraw.c Fri Aug 13 11:53:30 2010
@@ -1135,16 +1135,16 @@
}
/* calculate border vertices */
- p[0] = x0 + left; p[1] = y0 + top;
- p[2] = x0; p[3] = y0;
- p[4] = x1; p[5] = y0;
- p[6] = x1 - right; p[7] = y0 + top;
- p[8] = x1 - right; p[9] = y1 - bottom;
- p[10] = x1; p[11] = y1;
- p[12] = x0; p[13] = y1;
- p[14] = x0 + left; p[15] = y1 - bottom;
- p[16] = x0 + left; p[17] = y0 + top;
- p[18] = x0; p[19] = y0;
+ p[0] = (first) ? x0 + left : x0; p[1] = y0 + top;
+ p[2] = x0; p[3] = y0;
+ p[4] = x1; p[5] = y0;
+ p[6] = (last) ? x1 - right : x1; p[7] = y0 + top;
+ p[8] = (last) ? x1 - right : x1; p[9] = y1 - bottom;
+ p[10] = x1; p[11] = y1;
+ p[12] = x0; p[13] = y1;
+ p[14] = (first) ? x0 + left : x0; p[15] = y1 - bottom;
+ p[16] = (first) ? x0 + left : x0; p[17] = y0 + top;
+ p[18] = x0; p[19] = y0;
assert(box->style);
13 years, 3 months
r10693 tlsa - /trunk/netsurf/render/html_redraw.c
by netsurf@semichrome.net
Author: tlsa
Date: Fri Aug 13 09:05:07 2010
New Revision: 10693
URL: http://source.netsurf-browser.org?rev=10693&view=rev
Log:
Simplify border vertex arrangement code slightly.
Modified:
trunk/netsurf/render/html_redraw.c
Modified: trunk/netsurf/render/html_redraw.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html_redraw.c?rev=...
==============================================================================
--- trunk/netsurf/render/html_redraw.c (original)
+++ trunk/netsurf/render/html_redraw.c Fri Aug 13 09:05:07 2010
@@ -70,7 +70,7 @@
int p_width, int p_height, float scale);
bool html_redraw_inline_borders(struct box *box, int x0, int y0, int x1, int y1,
float scale, bool first, bool last);
-static bool html_redraw_border_plot(int i, int *p, colour c,
+static bool html_redraw_border_plot(const int i, const int *p, colour c,
enum css_border_style_e style, int thickness);
static bool html_redraw_checkbox(int x, int y, int width, int height,
bool selected);
@@ -1221,7 +1221,7 @@
/**
* Draw one border.
*
- * \param i index of border (TOP, RIGHT, BOTTOM, LEFT)
+ * \param i index of border side (TOP, RIGHT, BOTTOM, LEFT)
* \param p array of precomputed border vertices
* \param c colour for border
* \param style border line style
@@ -1229,11 +1229,12 @@
* \return true if successful, false otherwise
*/
-bool html_redraw_border_plot(int i, int *p, colour c,
+bool html_redraw_border_plot(const int i, const int *p, colour c,
enum css_border_style_e style, int thickness)
{
int z[8];
unsigned int light = i;
+ const int SIDE = i * 4; /* offset to the side's data */
plot_style_t *plot_style_bdr_in;
plot_style_t *plot_style_bdr_out;
@@ -1254,10 +1255,10 @@
plot_style_bdr.stroke_type = PLOT_OP_TYPE_DOT;
/* fall through */
case CSS_BORDER_STYLE_DASHED:
- if (!plot.line((p[i * 4 + 0] + p[i * 4 + 2]) / 2,
- (p[i * 4 + 1] + p[i * 4 + 3]) / 2,
- (p[i * 4 + 4] + p[i * 4 + 6]) / 2,
- (p[i * 4 + 5] + p[i * 4 + 7]) / 2,
+ if (!plot.line((p[SIDE + 0] + p[SIDE + 2]) / 2,
+ (p[SIDE + 1] + p[SIDE + 3]) / 2,
+ (p[SIDE + 4] + p[SIDE + 6]) / 2,
+ (p[SIDE + 5] + p[SIDE + 7]) / 2,
&plot_style_bdr))
return false;
break;
@@ -1265,29 +1266,29 @@
case CSS_BORDER_STYLE_SOLID:
/* fall through to default */
default:
- if (!plot.polygon(p + i * 4, 4, &plot_style_fillbdr))
+ if (!plot.polygon(p + SIDE, 4, &plot_style_fillbdr))
return false;
break;
case CSS_BORDER_STYLE_DOUBLE:
- z[0] = p[i * 4 + 0];
- z[1] = p[i * 4 + 1];
- z[2] = (p[i * 4 + 0] * 2 + p[i * 4 + 2]) / 3;
- z[3] = (p[i * 4 + 1] * 2 + p[i * 4 + 3]) / 3;
- z[4] = (p[i * 4 + 6] * 2 + p[i * 4 + 4]) / 3;
- z[5] = (p[i * 4 + 7] * 2 + p[i * 4 + 5]) / 3;
- z[6] = p[i * 4 + 6];
- z[7] = p[i * 4 + 7];
+ z[0] = p[SIDE + 0];
+ z[1] = p[SIDE + 1];
+ z[2] = (p[SIDE + 0] * 2 + p[SIDE + 2]) / 3;
+ z[3] = (p[SIDE + 1] * 2 + p[SIDE + 3]) / 3;
+ z[4] = (p[SIDE + 6] * 2 + p[SIDE + 4]) / 3;
+ z[5] = (p[SIDE + 7] * 2 + p[SIDE + 5]) / 3;
+ z[6] = p[SIDE + 6];
+ z[7] = p[SIDE + 7];
if (!plot.polygon(z, 4, &plot_style_fillbdr))
return false;
- z[0] = p[i * 4 + 2];
- z[1] = p[i * 4 + 3];
- z[2] = (p[i * 4 + 2] * 2 + p[i * 4 + 0]) / 3;
- z[3] = (p[i * 4 + 3] * 2 + p[i * 4 + 1]) / 3;
- z[4] = (p[i * 4 + 4] * 2 + p[i * 4 + 6]) / 3;
- z[5] = (p[i * 4 + 5] * 2 + p[i * 4 + 7]) / 3;
- z[6] = p[i * 4 + 4];
- z[7] = p[i * 4 + 5];
+ z[0] = p[SIDE + 2];
+ z[1] = p[SIDE + 3];
+ z[2] = (p[SIDE + 2] * 2 + p[SIDE + 0]) / 3;
+ z[3] = (p[SIDE + 3] * 2 + p[SIDE + 1]) / 3;
+ z[4] = (p[SIDE + 4] * 2 + p[SIDE + 6]) / 3;
+ z[5] = (p[SIDE + 5] * 2 + p[SIDE + 7]) / 3;
+ z[6] = p[SIDE + 4];
+ z[7] = p[SIDE + 5];
if (!plot.polygon(z, 4, &plot_style_fillbdr))
return false;
break;
@@ -1304,20 +1305,20 @@
plot_style_bdr_in = &plot_style_fillbdr_light;
plot_style_bdr_out = &plot_style_fillbdr_dark;
}
- z[0] = p[i * 4 + 0];
- z[1] = p[i * 4 + 1];
- z[2] = (p[i * 4 + 0] + p[i * 4 + 2]) / 2;
- z[3] = (p[i * 4 + 1] + p[i * 4 + 3]) / 2;
- z[4] = (p[i * 4 + 6] + p[i * 4 + 4]) / 2;
- z[5] = (p[i * 4 + 7] + p[i * 4 + 5]) / 2;
- z[6] = p[i * 4 + 6];
- z[7] = p[i * 4 + 7];
+ z[0] = p[SIDE + 0];
+ z[1] = p[SIDE + 1];
+ z[2] = (p[SIDE + 0] + p[SIDE + 2]) / 2;
+ z[3] = (p[SIDE + 1] + p[SIDE + 3]) / 2;
+ z[4] = (p[SIDE + 6] + p[SIDE + 4]) / 2;
+ z[5] = (p[SIDE + 7] + p[SIDE + 5]) / 2;
+ z[6] = p[SIDE + 6];
+ z[7] = p[SIDE + 7];
if (!plot.polygon(z, 4, plot_style_bdr_in))
return false;
- z[0] = p[i * 4 + 2];
- z[1] = p[i * 4 + 3];
- z[6] = p[i * 4 + 4];
- z[7] = p[i * 4 + 5];
+ z[0] = p[SIDE + 2];
+ z[1] = p[SIDE + 3];
+ z[6] = p[SIDE + 4];
+ z[7] = p[SIDE + 5];
if (!plot.polygon(z, 4, plot_style_bdr_out))
return false;
break;
@@ -1350,20 +1351,20 @@
break;
}
- z[0] = p[i * 4 + 0];
- z[1] = p[i * 4 + 1];
- z[2] = (p[i * 4 + 0] + p[i * 4 + 2]) / 2;
- z[3] = (p[i * 4 + 1] + p[i * 4 + 3]) / 2;
- z[4] = (p[i * 4 + 6] + p[i * 4 + 4]) / 2;
- z[5] = (p[i * 4 + 7] + p[i * 4 + 5]) / 2;
- z[6] = p[i * 4 + 6];
- z[7] = p[i * 4 + 7];
+ z[0] = p[SIDE + 0];
+ z[1] = p[SIDE + 1];
+ z[2] = (p[SIDE + 0] + p[SIDE + 2]) / 2;
+ z[3] = (p[SIDE + 1] + p[SIDE + 3]) / 2;
+ z[4] = (p[SIDE + 6] + p[SIDE + 4]) / 2;
+ z[5] = (p[SIDE + 7] + p[SIDE + 5]) / 2;
+ z[6] = p[SIDE + 6];
+ z[7] = p[SIDE + 7];
if (!plot.polygon(z, 4, plot_style_bdr_in))
return false;
- z[0] = p[i * 4 + 2];
- z[1] = p[i * 4 + 3];
- z[6] = p[i * 4 + 4];
- z[7] = p[i * 4 + 5];
+ z[0] = p[SIDE + 2];
+ z[1] = p[SIDE + 3];
+ z[6] = p[SIDE + 4];
+ z[7] = p[SIDE + 5];
if (!plot.polygon(z, 4, plot_style_bdr_out))
return false;
break;
13 years, 3 months
r10692 tlsa - /trunk/netsurf/beos/beos_plotters.cpp
by netsurf@semichrome.net
Author: tlsa
Date: Fri Aug 13 05:59:40 2010
New Revision: 10692
URL: http://source.netsurf-browser.org?rev=10692&view=rev
Log:
Delete dead code and tweak polygon plotter. Still wrong, but better.
Modified:
trunk/netsurf/beos/beos_plotters.cpp
Modified: trunk/netsurf/beos/beos_plotters.cpp
URL: http://source.netsurf-browser.org/trunk/netsurf/beos/beos_plotters.cpp?re...
==============================================================================
--- trunk/netsurf/beos/beos_plotters.cpp (original)
+++ trunk/netsurf/beos/beos_plotters.cpp Fri Aug 13 05:59:40 2010
@@ -302,7 +302,7 @@
BPoint points[n];
for (i = 0; i < n; i++) {
- points[i] = BPoint(p[2 * i], p[2 * i + 1]);
+ points[i] = BPoint(p[2 * i] - 0.5, p[2 * i + 1] - 0.5);
}
if (style->fill_colour == NS_TRANSPARENT)
@@ -310,44 +310,6 @@
else
view->FillPolygon(points, (int32)n);
-#if 0
- view->BeginLineArray(n);
-
- for (i = 0; i < n; i++) {
- BPoint start(p[2 * i], p[2 * i + 1]);
- BPoint end(p[(2 * i + 2) % n], p[(2 * i + 3) % n]);
- view->AddLine(start, end, color);
- }
-
- view->EndLineArray();
-#endif
-
- //nsbeos_current_gc_unlock();
-
-#if 0 /* GTK */
- nsbeos_set_colour(fill);
- nsbeos_set_solid();
-#ifdef CAIRO_VERSION
- if (option_render_cairo) {
- cairo_set_line_width(current_cr, 0);
- cairo_move_to(current_cr, p[0], p[1]);
- for (i = 1; i != n; i++) {
- cairo_line_to(current_cr, p[i * 2], p[i * 2 + 1]);
- }
- cairo_fill(current_cr);
- cairo_stroke(current_cr);
- } else
-#endif
- {
- GdkPoint q[n];
- for (i = 0; i != n; i++) {
- q[i].x = p[i * 2];
- q[i].y = p[i * 2 + 1];
- }
- gdk_draw_polygon(current_drawable, current_gc,
- TRUE, q, n);
- }
-#endif
return true;
}
13 years, 3 months