summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2010-07-08 20:16:47 (GMT)
committer Michael Drake <tlsa@netsurf-browser.org>2010-07-08 20:16:47 (GMT)
commit658d9ff87eb93b7b8fa84d7453d591814b4c9fa4 (patch)
treeffc5b38c875bd687d35e0d2957cb2b3c8c1675a2
parent2774b6d0021db426c334c643de07d28faf0517af (diff)
downloadlibnsfb-658d9ff87eb93b7b8fa84d7453d591814b4c9fa4.tar.gz
libnsfb-658d9ff87eb93b7b8fa84d7453d591814b4c9fa4.tar.bz2
Pre-seed remainder counters with correct starting value to avoid clipping edge case artifact.
svn path=/trunk/libnsfb/; revision=10615
-rw-r--r--src/plot/16bpp.c26
-rw-r--r--src/plot/32bpp.c26
-rw-r--r--src/plot/8bpp.c26
3 files changed, 57 insertions, 21 deletions
diff --git a/src/plot/16bpp.c b/src/plot/16bpp.c
index 028e453..ee95770 100644
--- a/src/plot/16bpp.c
+++ b/src/plot/16bpp.c
@@ -339,7 +339,7 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc,
int rheight, rwidth; /* post-clipping render area dimensions */
int dx, dy; /* scale factor (integer part) */
int dxr, dyr; /* scale factor (remainder) */
- int rx, ry; /* remainder trackers */
+ int rx, ry, rxs; /* remainder trackers */
nsfb_bbox_t clipped; /* clipped display */
/* The part of the scaled image actually displayed is cropped to the
@@ -365,17 +365,29 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc,
else
rwidth = width;
- /* start offsets to part of image being scaled, after clipping */
- xoffs = ((clipped.x0 - x) * bmp_width) / width;
- yoff = (((clipped.y0 - y) * bmp_height) / height) * bmp_stride;
-
/* get veritcal (y) and horizontal (x) scale factors; both integer
* part and remainder */
dx = bmp_width / width;
dy = (bmp_height / height) * bmp_stride;
dxr = bmp_width % width;
dyr = bmp_height % height;
- rx = ry = 0; /* initialise remainder counters */
+
+ /* get start offsets to part of image being scaled, after clipping and
+ * set remainder trackers to correct starting */
+ if (clipped.x0 - x != 0) {
+ xoffs = ((clipped.x0 - x) * bmp_width) / width;
+ rxs = ((clipped.x0 - x) * bmp_width) % width;
+ } else {
+ xoffs = 0;
+ rxs = 0;
+ }
+ if (clipped.y0 - y != 0) {
+ yoff = (((clipped.y0 - y) * bmp_height) / height) * bmp_stride;
+ ry = ((clipped.y0 - y) * bmp_height) % height;
+ } else {
+ yoff = 0;
+ ry = 0;
+ }
/* plot the image */
pvideo = get_xy_loc(nsfb, clipped.x0, clipped.y0);
@@ -384,7 +396,7 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc,
for (; pvideo < pvideo_limit; pvideo += (nsfb->linelen >> 1)) {
/* looping through render area vertically */
xoff = xoffs;
- rx = 0;
+ rx = rxs;
for (xloop = 0; xloop < rwidth; xloop++) {
/* looping through render area horizontally */
/* get value of source pixel in question */
diff --git a/src/plot/32bpp.c b/src/plot/32bpp.c
index 434baa6..96fadbd 100644
--- a/src/plot/32bpp.c
+++ b/src/plot/32bpp.c
@@ -337,7 +337,7 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc,
int rheight, rwidth; /* post-clipping render area dimensions */
int dx, dy; /* scale factor (integer part) */
int dxr, dyr; /* scale factor (remainder) */
- int rx, ry; /* remainder trackers */
+ int rx, ry, rxs; /* remainder trackers */
nsfb_bbox_t clipped; /* clipped display */
/* The part of the scaled image actually displayed is cropped to the
@@ -363,17 +363,29 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc,
else
rwidth = width;
- /* start offsets to part of image being scaled, after clipping */
- xoffs = ((clipped.x0 - x) * bmp_width) / width;
- yoff = (((clipped.y0 - y) * bmp_height) / height) * bmp_stride;
-
/* get veritcal (y) and horizontal (x) scale factors; both integer
* part and remainder */
dx = bmp_width / width;
dy = (bmp_height / height) * bmp_stride;
dxr = bmp_width % width;
dyr = bmp_height % height;
- rx = ry = 0; /* initialise remainder counters */
+
+ /* get start offsets to part of image being scaled, after clipping and
+ * set remainder trackers to correct starting */
+ if (clipped.x0 - x != 0) {
+ xoffs = ((clipped.x0 - x) * bmp_width) / width;
+ rxs = ((clipped.x0 - x) * bmp_width) % width;
+ } else {
+ xoffs = 0;
+ rxs = 0;
+ }
+ if (clipped.y0 - y != 0) {
+ yoff = (((clipped.y0 - y) * bmp_height) / height) * bmp_stride;
+ ry = ((clipped.y0 - y) * bmp_height) % height;
+ } else {
+ yoff = 0;
+ ry = 0;
+ }
/* plot the image */
pvideo = get_xy_loc(nsfb, clipped.x0, clipped.y0);
@@ -382,7 +394,7 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc,
for (; pvideo < pvideo_limit; pvideo += (nsfb->linelen >> 2)) {
/* looping through render area vertically */
xoff = xoffs;
- rx = 0;
+ rx = rxs;
for (xloop = 0; xloop < rwidth; xloop++) {
/* looping through render area horizontally */
/* get value of source pixel in question */
diff --git a/src/plot/8bpp.c b/src/plot/8bpp.c
index 472c213..d1d43ee 100644
--- a/src/plot/8bpp.c
+++ b/src/plot/8bpp.c
@@ -316,7 +316,7 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc,
int rheight, rwidth; /* post-clipping render area dimensions */
int dx, dy; /* scale factor (integer part) */
int dxr, dyr; /* scale factor (remainder) */
- int rx, ry; /* remainder trackers */
+ int rx, ry, rxs; /* remainder trackers */
nsfb_bbox_t clipped; /* clipped display */
/* The part of the scaled image actually displayed is cropped to the
@@ -342,17 +342,29 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc,
else
rwidth = width;
- /* start offsets to part of image being scaled, after clipping */
- xoffs = ((clipped.x0 - x) * bmp_width) / width;
- yoff = (((clipped.y0 - y) * bmp_height) / height) * bmp_stride;
-
/* get veritcal (y) and horizontal (x) scale factors; both integer
* part and remainder */
dx = bmp_width / width;
dy = (bmp_height / height) * bmp_stride;
dxr = bmp_width % width;
dyr = bmp_height % height;
- rx = ry = 0; /* initialise remainder counters */
+
+ /* get start offsets to part of image being scaled, after clipping and
+ * set remainder trackers to correct starting */
+ if (clipped.x0 - x != 0) {
+ xoffs = ((clipped.x0 - x) * bmp_width) / width;
+ rxs = ((clipped.x0 - x) * bmp_width) % width;
+ } else {
+ xoffs = 0;
+ rxs = 0;
+ }
+ if (clipped.y0 - y != 0) {
+ yoff = (((clipped.y0 - y) * bmp_height) / height) * bmp_stride;
+ ry = ((clipped.y0 - y) * bmp_height) % height;
+ } else {
+ yoff = 0;
+ ry = 0;
+ }
/* plot the image */
pvideo = get_xy_loc(nsfb, clipped.x0, clipped.y0);
@@ -361,7 +373,7 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc,
for (; pvideo < pvideo_limit; pvideo += (nsfb->linelen)) {
/* looping through render area vertically */
xoff = xoffs;
- rx = 0;
+ rx = rxs;
for (xloop = 0; xloop < rwidth; xloop++) {
/* looping through render area horizontally */
/* get value of source pixel in question */