summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/sprite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/video/sprite.cpp')
-rw-r--r--src/devices/video/sprite.cpp70
1 files changed, 35 insertions, 35 deletions
diff --git a/src/devices/video/sprite.cpp b/src/devices/video/sprite.cpp
index 32911a7bc18..717ea041a31 100644
--- a/src/devices/video/sprite.cpp
+++ b/src/devices/video/sprite.cpp
@@ -14,19 +14,16 @@
// sparse_dirty_bitmap -- constructor
//-------------------------------------------------
-sparse_dirty_bitmap::sparse_dirty_bitmap(int granularity)
- : m_width(0),
- m_height(0),
- m_granularity(granularity),
- m_rect_list_bounds(0, -1, 0, -1)
+sparse_dirty_bitmap::sparse_dirty_bitmap(int granularity) :
+ m_width(0),
+ m_height(0),
+ m_granularity(granularity),
+ m_rect_list_bounds(0, -1, 0, -1)
{
}
-sparse_dirty_bitmap::sparse_dirty_bitmap(int width, int height, int granularity)
- : m_width(0),
- m_height(0),
- m_granularity(granularity),
- m_rect_list_bounds(0, -1, 0, -1)
+sparse_dirty_bitmap::sparse_dirty_bitmap(int width, int height, int granularity) :
+ sparse_dirty_bitmap(granularity)
{
// resize to the specified width/height
resize(width, height);
@@ -40,8 +37,13 @@ sparse_dirty_bitmap::sparse_dirty_bitmap(int width, int height, int granularity)
void sparse_dirty_bitmap::dirty(int32_t left, int32_t right, int32_t top, int32_t bottom)
{
// compute a rectangle in dirty space, and fill it with 1
- rectangle rect(left >> m_granularity, right >> m_granularity, top >> m_granularity, bottom >> m_granularity);
- m_bitmap.fill(1, rect);
+ m_bitmap.fill(
+ 1,
+ rectangle(
+ left >> m_granularity,
+ right >> m_granularity,
+ top >> m_granularity,
+ bottom >> m_granularity));
// invalidate existing rect list
invalidate_rect_list();
@@ -94,27 +96,27 @@ void sparse_dirty_bitmap::resize(int width, int height)
// rectangle in the list
//-------------------------------------------------
-sparse_dirty_rect *sparse_dirty_bitmap::first_dirty_rect(const rectangle &cliprect)
+void sparse_dirty_bitmap::calculate_rect_list(const rectangle &cliprect)
{
// if what we have is valid, just return it again
if (m_rect_list_bounds == cliprect)
- return m_rect_list.first();
+ return;
// reclaim the dirty list and start over
- m_rect_allocator.reclaim_all(m_rect_list);
+ m_rect_list.clear();
// compute dirty space rectangle coordinates
- int sx = cliprect.min_x >> m_granularity;
- int ex = cliprect.max_x >> m_granularity;
- int sy = cliprect.min_y >> m_granularity;
- int ey = cliprect.max_y >> m_granularity;
- int tilesize = 1 << m_granularity;
+ int const sx = cliprect.min_x >> m_granularity;
+ int const ex = cliprect.max_x >> m_granularity;
+ int const sy = cliprect.min_y >> m_granularity;
+ int const ey = cliprect.max_y >> m_granularity;
+ int const tilesize = 1 << m_granularity;
// loop over all grid rows that intersect our cliprect
for (int y = sy; y <= ey; y++)
{
- uint8_t *dirtybase = &m_bitmap.pix(y);
- sparse_dirty_rect *currect = nullptr;
+ uint8_t const *const dirtybase = &m_bitmap.pix(y);
+ rectangle *currect = nullptr;
// loop over all grid columns that intersect our cliprect
for (int x = sx; x <= ex; x++)
@@ -122,36 +124,34 @@ sparse_dirty_rect *sparse_dirty_bitmap::first_dirty_rect(const rectangle &clipre
// if this tile is not dirty, end our current run and continue
if (!dirtybase[x])
{
- if (currect != nullptr)
+ if (currect)
*currect &= cliprect;
currect = nullptr;
continue;
}
// if we can't add to an existing rect, create a new one
- if (currect == nullptr)
+ if (!currect)
{
- // allocate a new rect and add it to the list
- currect = &m_rect_list.append(*m_rect_allocator.alloc());
-
// make a rect describing this grid square
- currect->min_x = x << m_granularity;
- currect->max_x = currect->min_x + tilesize - 1;
- currect->min_y = y << m_granularity;
- currect->max_y = currect->min_y + tilesize - 1;
+ int32_t const min_x = x << m_granularity;
+ int32_t const min_y = y << m_granularity;
+ currect = &m_rect_list.emplace_back(
+ min_x, min_x + tilesize - 1,
+ min_y, min_y + tilesize - 1);
}
-
- // if we can add to the previous rect, just expand its width
else
+ {
+ // if we can add to the previous rect, just expand its width
currect->max_x += tilesize;
+ }
}
// clip the last rect to the cliprect
- if (currect != nullptr)
+ if (currect)
*currect &= cliprect;
}
// mark the list as valid
m_rect_list_bounds = cliprect;
- return m_rect_list.first();
}