summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/screen.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2020-09-27 14:00:42 +1000
committer Vas Crabb <vas@vastheman.com>2020-09-27 14:00:42 +1000
commita1d35e5abf431e03e06d55b96379a3b14753ed4d (patch)
tree506ffe906e707f50eca2306da80b1657644e0507 /src/emu/screen.cpp
parentd294948a3bb8c6e8fdbc96841ceae30ec6687870 (diff)
Cleaned up bitmap API.
Made const-qualified pixel accessors (pix, pixt, raw_pixptr) return const-qualified references/pointers to pixesl, and added non-const versions. This makes bitmap more like standard library containers where const protects the content as well as the dimensions. Made the templated pixt accessor protected - having it public makes it too easy to inadvertently get a pointer to the wrong location. Removed the pix(8|16|32|64) accessors from the specific bitmaps. You could only use the "correct" one anyway, and having the "incorrect" ones available prevented explicit instantiations of the class template because the static assertions would fail. You can still see the pixel type in the bitmap class names, and you can't assign the result of &pix(y, x) to the wrong kind of pointer without a cast. Added fill member functions to the specific bitmap template, and added a explicit instantiations. This allows the bitmap size check to be skipped on most bitmap fills, although the clipping check is still there. Also fixed a couple of places that were trying to fill an indexed 16-bit bitmap with rgb_t::black() exposed by this (replaced with zero to get the same net effect). The explicit template instantiations in the .cpp file mean the compiler can inline the function if necessary, but don't need to generate a local out-of-line body if it chooses not to. Extended the size of the fill value parameter in the base bitmap class to 64 bits so it works correctly for 64-bit bitmaps. Fixed places where IE15 and VGM visualiser weren't accounting for row bytes potentially being larger than width. Fixed an off-by-one in an HP-DIO card where it was treating the Topcat cursor right edge as exclusive. Updated everything to work with the API changes, reduced the scope of many variables, added more const, and replaced a few fill/copy loops with stuff from <algorithm>.
Diffstat (limited to 'src/emu/screen.cpp')
-rw-r--r--src/emu/screen.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/emu/screen.cpp b/src/emu/screen.cpp
index 8c6e69c0059..cacd16d5982 100644
--- a/src/emu/screen.cpp
+++ b/src/emu/screen.cpp
@@ -1730,9 +1730,9 @@ void screen_device::create_composited_bitmap()
{
for (int y = 0; y < dstheight; y++)
{
- bitmap_ind16 &srcbitmap = *(bitmap_ind16 *)m_scan_bitmaps[m_curbitmap][y];
- u16 *dst = &curbitmap.as_ind16().pix16(y);
- const u16 *src = &srcbitmap.pix16(0);
+ const bitmap_ind16 &srcbitmap = *(bitmap_ind16 *)m_scan_bitmaps[m_curbitmap][y];
+ u16 *dst = &curbitmap.as_ind16().pix(y);
+ const u16 *src = &srcbitmap.pix(0);
const int dx = (m_scan_widths[y] << 15) / dstwidth;
for (int x = 0; x < m_scan_widths[y]; x += dx)
{
@@ -1746,9 +1746,9 @@ void screen_device::create_composited_bitmap()
{
for (int y = 0; y < dstheight; y++)
{
- bitmap_rgb32 &srcbitmap = *(bitmap_rgb32 *)m_scan_bitmaps[m_curbitmap][y];
- u32 *dst = &curbitmap.as_rgb32().pix32(y);
- const u32 *src = &srcbitmap.pix32(0);
+ const bitmap_rgb32 &srcbitmap = *(bitmap_rgb32 *)m_scan_bitmaps[m_curbitmap][y];
+ u32 *dst = &curbitmap.as_rgb32().pix(y);
+ const u32 *src = &srcbitmap.pix(0);
const int dx = (m_scan_widths[y] << 15) / dstwidth;
for (int x = 0; x < dstwidth << 15; x += dx)
{
@@ -1837,10 +1837,10 @@ void screen_device::update_burnin()
// iterate over rows in the destination
for (int y = 0, srcy = ystart; y < dstheight; y++, srcy += ystep)
{
- bitmap_ind16 &srcbitmap = per_scanline ? *(bitmap_ind16 *)m_scan_bitmaps[m_curbitmap][y] : curbitmap.as_ind16();
- u64 *dst = &m_burnin.pix64(y);
- const u16 *src = &srcbitmap.pix16(per_scanline ? 0 : (srcy >> 16));
- const rgb_t *palette = m_palette->palette()->entry_list_adjusted();
+ const bitmap_ind16 &srcbitmap = per_scanline ? *(bitmap_ind16 *)m_scan_bitmaps[m_curbitmap][y] : curbitmap.as_ind16();
+ u64 *const dst = &m_burnin.pix(y);
+ u16 const *const src = &srcbitmap.pix(per_scanline ? 0 : (srcy >> 16));
+ rgb_t const *const palette = m_palette->palette()->entry_list_adjusted();
for (int x = 0, srcx = xstart; x < dstwidth; x++, srcx += xstep)
{
rgb_t pixel = palette[src[srcx >> 16]];
@@ -1855,9 +1855,9 @@ void screen_device::update_burnin()
// iterate over rows in the destination
for (int y = 0, srcy = ystart; y < dstheight; y++, srcy += ystep)
{
- bitmap_rgb32 &srcbitmap = per_scanline ? *(bitmap_rgb32 *)m_scan_bitmaps[m_curbitmap][y] : curbitmap.as_rgb32();
- u64 *dst = &m_burnin.pix64(y);
- const u32 *src = &srcbitmap.pix32(per_scanline ? 0 : (srcy >> 16));
+ const bitmap_rgb32 &srcbitmap = per_scanline ? *(bitmap_rgb32 *)m_scan_bitmaps[m_curbitmap][y] : curbitmap.as_rgb32();
+ u64 *const dst = &m_burnin.pix(y);
+ u32 const *const src = &srcbitmap.pix(per_scanline ? 0 : (srcy >> 16));
for (int x = 0, srcx = xstart; x < dstwidth; x++, srcx += xstep)
{
rgb_t pixel = src[srcx >> 16];
@@ -1900,7 +1900,7 @@ void screen_device::finalize_burnin()
u64 maxval = 0;
for (int y = 0; y < srcheight; y++)
{
- u64 *src = &m_burnin.pix64(y);
+ u64 const *const src = &m_burnin.pix(y);
for (int x = 0; x < srcwidth; x++)
{
minval = std::min(minval, src[x]);
@@ -1914,8 +1914,8 @@ void screen_device::finalize_burnin()
// now normalize and convert to RGB
for (int y = 0, srcy = 0; y < dstheight; y++, srcy += ystep)
{
- u64 *src = &m_burnin.pix64(srcy >> 16);
- u32 *dst = &finalmap.pix32(y);
+ u64 const *const src = &m_burnin.pix(srcy >> 16);
+ u32 *const dst = &finalmap.pix(y);
for (int x = 0, srcx = 0; x < dstwidth; x++, srcx += xstep)
{
int brightness = u64(maxval - src[srcx >> 16]) * 255 / (maxval - minval);