summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2012-01-16 11:06:28 +0000
committer Aaron Giles <aaron@aarongiles.com>2012-01-16 11:06:28 +0000
commit59d84eb1b05c653c1e5c727e648e807bc8340baf (patch)
tree837413310dbe2d9b678860c072206bb244e8e693 /src/lib/util
parent051af55fa90955e11ba7fb08b586ba3227c4f7d1 (diff)
Fix several rendering issues with artwork, introduced in the
recent changes. Also, did a pass through the code to take advantage of new methods available on rectangles.
Diffstat (limited to 'src/lib/util')
-rw-r--r--src/lib/util/bitmap.c14
-rw-r--r--src/lib/util/bitmap.h27
2 files changed, 23 insertions, 18 deletions
diff --git a/src/lib/util/bitmap.c b/src/lib/util/bitmap.c
index 279f931426b..a178e43beea 100644
--- a/src/lib/util/bitmap.c
+++ b/src/lib/util/bitmap.c
@@ -331,7 +331,7 @@ void bitmap_t::fill(UINT32 color, const rectangle &cliprect)
case 8:
// 8bpp always uses memset
for (INT32 y = fill.min_y; y <= fill.max_y; y++)
- memset(raw_pixptr(y, fill.min_x), (UINT8)color, fill.max_x + 1 - fill.min_x);
+ memset(raw_pixptr(y, fill.min_x), (UINT8)color, fill.width());
break;
case 16:
@@ -339,7 +339,7 @@ void bitmap_t::fill(UINT32 color, const rectangle &cliprect)
if ((UINT8)(color >> 8) == (UINT8)color)
{
for (INT32 y = fill.min_y; y <= fill.max_y; y++)
- memset(raw_pixptr(y, fill.min_x), (UINT8)color, (fill.max_x + 1 - fill.min_x) * 2);
+ memset(raw_pixptr(y, fill.min_x), (UINT8)color, fill.width() * 2);
}
else
{
@@ -353,7 +353,7 @@ void bitmap_t::fill(UINT32 color, const rectangle &cliprect)
for (INT32 y = fill.min_y + 1; y <= fill.max_y; y++)
{
destrow = &pixt<UINT16>(y, fill.min_x);
- memcpy(destrow, destrow0, (fill.max_x + 1 - fill.min_x) * 2);
+ memcpy(destrow, destrow0, fill.width() * 2);
}
}
break;
@@ -363,7 +363,7 @@ void bitmap_t::fill(UINT32 color, const rectangle &cliprect)
if ((UINT8)(color >> 8) == (UINT8)color && (UINT16)(color >> 16) == (UINT16)color)
{
for (INT32 y = fill.min_y; y <= fill.max_y; y++)
- memset(&pixt<UINT32>(y, fill.min_x), (UINT8)color, (fill.max_x + 1 - fill.min_x) * 4);
+ memset(&pixt<UINT32>(y, fill.min_x), (UINT8)color, fill.width() * 4);
}
else
{
@@ -377,7 +377,7 @@ void bitmap_t::fill(UINT32 color, const rectangle &cliprect)
for (INT32 y = fill.min_y + 1; y <= fill.max_y; y++)
{
destrow = &pixt<UINT32>(y, fill.min_x);
- memcpy(destrow, destrow0, (fill.max_x + 1 - fill.min_x) * 4);
+ memcpy(destrow, destrow0, fill.width() * 4);
}
}
break;
@@ -387,7 +387,7 @@ void bitmap_t::fill(UINT32 color, const rectangle &cliprect)
if ((UINT8)(color >> 8) == (UINT8)color && (UINT16)(color >> 16) == (UINT16)color)
{
for (INT32 y = fill.min_y; y <= fill.max_y; y++)
- memset(&pixt<UINT64>(y, fill.min_x), (UINT8)color, (fill.max_x + 1 - fill.min_x) * 8);
+ memset(&pixt<UINT64>(y, fill.min_x), (UINT8)color, fill.width() * 8);
}
else
{
@@ -401,7 +401,7 @@ void bitmap_t::fill(UINT32 color, const rectangle &cliprect)
for (INT32 y = fill.min_y + 1; y <= fill.max_y; y++)
{
destrow = &pixt<UINT64>(y, fill.min_x);
- memcpy(destrow, destrow0, (fill.max_x + 1 - fill.min_x) * 4);
+ memcpy(destrow, destrow0, fill.width() * 8);
}
}
break;
diff --git a/src/lib/util/bitmap.h b/src/lib/util/bitmap.h
index 546f6a73586..b6ae74b5a80 100644
--- a/src/lib/util/bitmap.h
+++ b/src/lib/util/bitmap.h
@@ -103,12 +103,17 @@ public:
bool contains(const rectangle &rect) const { return (min_x <= rect.min_x && max_x >= rect.max_x && min_y <= rect.min_y && max_y >= rect.max_y); }
INT32 width() const { return max_x + 1 - min_x; }
INT32 height() const { return max_y + 1 - min_y; }
+ INT32 xcenter() const { return (min_x + max_x + 1) / 2; }
+ INT32 ycenter() const { return (min_y + max_y + 1) / 2; }
// setters
void set(INT32 minx, INT32 maxx, INT32 miny, INT32 maxy) { min_x = minx; max_x = maxx; min_y = miny; max_y = maxy; }
+ void setx(INT32 minx, INT32 maxx) { min_x = minx; max_x = maxx; }
+ void sety(INT32 miny, INT32 maxy) { min_y = miny; max_y = maxy; }
void set_width(INT32 width) { max_x = min_x + width - 1; }
void set_height(INT32 height) { max_y = min_y + height - 1; }
void set_origin(INT32 x, INT32 y) { max_x += x - min_x; max_y += y - min_y; min_x = x; min_y = y; }
+ void set_size(INT32 width, INT32 height) { set_width(width); set_height(height); }
// internal state
INT32 min_x; // minimum X, or left coordinate
@@ -205,7 +210,7 @@ private:
protected:
// construction/destruction -- subclasses only
bitmap8_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 8, width, height, xslop, yslop) { }
- bitmap8_t(bitmap_format format, void *base, int width, int height, int rowpixels) : bitmap_t(format, 8, base, width, height, rowpixels) { assert(valid_format(format)); }
+ bitmap8_t(bitmap_format format, UINT8 *base, int width, int height, int rowpixels) : bitmap_t(format, 8, base, width, height, rowpixels) { assert(valid_format(format)); }
bitmap8_t(bitmap_format format, bitmap8_t &source, const rectangle &subrect) : bitmap_t(format, 8, source, subrect) { }
public:
@@ -228,7 +233,7 @@ private:
protected:
// construction/destruction -- subclasses only
bitmap16_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 16, width, height, xslop, yslop) { assert(valid_format(format)); }
- bitmap16_t(bitmap_format format, void *base, int width, int height, int rowpixels) : bitmap_t(format, 16, base, width, height, rowpixels) { assert(valid_format(format)); }
+ bitmap16_t(bitmap_format format, UINT16 *base, int width, int height, int rowpixels) : bitmap_t(format, 16, base, width, height, rowpixels) { assert(valid_format(format)); }
bitmap16_t(bitmap_format format, bitmap16_t &source, const rectangle &subrect) : bitmap_t(format, 16, source, subrect) { }
public:
@@ -251,7 +256,7 @@ private:
protected:
// construction/destruction -- subclasses only
bitmap32_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 32, width, height, xslop, yslop) { assert(valid_format(format)); }
- bitmap32_t(bitmap_format format, void *base, int width, int height, int rowpixels) : bitmap_t(format, 32, base, width, height, rowpixels) { assert(valid_format(format)); }
+ bitmap32_t(bitmap_format format, UINT32 *base, int width, int height, int rowpixels) : bitmap_t(format, 32, base, width, height, rowpixels) { assert(valid_format(format)); }
bitmap32_t(bitmap_format format, bitmap32_t &source, const rectangle &subrect) : bitmap_t(format, 32, source, subrect) { }
public:
@@ -274,7 +279,7 @@ private:
protected:
// construction/destruction -- subclasses only
bitmap64_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 64, width, height, xslop, yslop) { assert(valid_format(format)); }
- bitmap64_t(bitmap_format format, void *base, int width, int height, int rowpixels) : bitmap_t(format, 64, base, width, height, rowpixels) { assert(valid_format(format)); }
+ bitmap64_t(bitmap_format format, UINT64 *base, int width, int height, int rowpixels) : bitmap_t(format, 64, base, width, height, rowpixels) { assert(valid_format(format)); }
bitmap64_t(bitmap_format format, bitmap64_t &source, const rectangle &subrect) : bitmap_t(format, 64, source, subrect) { }
public:
@@ -298,7 +303,7 @@ class bitmap_ind8 : public bitmap8_t
public:
// construction/destruction
bitmap_ind8(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap8_t(k_bitmap_format, width, height, xslop, yslop) { }
- bitmap_ind8(void *base, int width, int height, int rowpixels) : bitmap8_t(k_bitmap_format, base, width, height, rowpixels) { }
+ bitmap_ind8(UINT8 *base, int width, int height, int rowpixels) : bitmap8_t(k_bitmap_format, base, width, height, rowpixels) { }
bitmap_ind8(bitmap_ind8 &source, const rectangle &subrect) : bitmap8_t(k_bitmap_format, source, subrect) { }
void wrap(UINT8 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
void wrap(bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); }
@@ -315,7 +320,7 @@ class bitmap_ind16 : public bitmap16_t
public:
// construction/destruction
bitmap_ind16(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap16_t(k_bitmap_format, width, height, xslop, yslop) { }
- bitmap_ind16(void *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { }
+ bitmap_ind16(UINT16 *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { }
bitmap_ind16(bitmap_ind16 &source, const rectangle &subrect) : bitmap16_t(k_bitmap_format, source, subrect) { }
void wrap(UINT16 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
void wrap(bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); }
@@ -332,7 +337,7 @@ class bitmap_ind32 : public bitmap32_t
public:
// construction/destruction
bitmap_ind32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { }
- bitmap_ind32(void *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
+ bitmap_ind32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
bitmap_ind32(bitmap_ind32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { }
void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
void wrap(bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); }
@@ -349,7 +354,7 @@ class bitmap_ind64 : public bitmap64_t
public:
// construction/destruction
bitmap_ind64(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap64_t(k_bitmap_format, width, height, xslop, yslop) { }
- bitmap_ind64(void *base, int width, int height, int rowpixels) : bitmap64_t(k_bitmap_format, base, width, height, rowpixels) { }
+ bitmap_ind64(UINT64 *base, int width, int height, int rowpixels) : bitmap64_t(k_bitmap_format, base, width, height, rowpixels) { }
bitmap_ind64(bitmap_ind64 &source, const rectangle &subrect) : bitmap64_t(k_bitmap_format, source, subrect) { }
void wrap(UINT64 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
void wrap(bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); }
@@ -369,7 +374,7 @@ class bitmap_yuy16 : public bitmap16_t
public:
// construction/destruction
bitmap_yuy16(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap16_t(k_bitmap_format, width, height, xslop, yslop) { }
- bitmap_yuy16(void *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { }
+ bitmap_yuy16(UINT16 *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { }
bitmap_yuy16(bitmap_yuy16 &source, const rectangle &subrect) : bitmap16_t(k_bitmap_format, source, subrect) { }
void wrap(UINT16 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
void wrap(bitmap_yuy16 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); }
@@ -386,7 +391,7 @@ class bitmap_rgb32 : public bitmap32_t
public:
// construction/destruction
bitmap_rgb32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { }
- bitmap_rgb32(void *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
+ bitmap_rgb32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
bitmap_rgb32(bitmap_rgb32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { }
void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
void wrap(bitmap_rgb32 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); }
@@ -403,7 +408,7 @@ class bitmap_argb32 : public bitmap32_t
public:
// construction/destruction
bitmap_argb32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { }
- bitmap_argb32(void *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
+ bitmap_argb32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
bitmap_argb32(bitmap_argb32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { }
void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
void wrap(bitmap_argb32 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<bitmap_t &>(source), subrect); }