Skip to content

Commit

Permalink
rendlay: fix accumulated rounding error when drawing text
Browse files Browse the repository at this point in the history
  • Loading branch information
happppp committed Feb 27, 2023
1 parent 406b96d commit 63eaa6b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/emu/rendlay.cpp
Expand Up @@ -3204,10 +3204,10 @@ class layout_element::reel_component : public component
width = font->string_width(ourheight / num_shown, aspect, m_stopnames[fruit]);
if (width < bounds.width())
break;
aspect *= 0.9f;
aspect *= 0.95f;
}

s32 curx = bounds.left() + (bounds.width() - width) / 2;
float curx = bounds.left() + (bounds.width() - width) / 2.0f;

// loop over characters
std::string_view s = m_stopnames[fruit];
Expand All @@ -3234,7 +3234,7 @@ class layout_element::reel_component : public component
u32 *const d = &dest.pix(effy);
for (int x = 0; x < chbounds.width(); x++)
{
int effx = curx + x + chbounds.left();
int effx = int(curx) + x + chbounds.left();
if (effx >= bounds.left() && effx <= bounds.right())
{
u32 spix = rgb_t(src[x]).a();
Expand Down Expand Up @@ -3352,10 +3352,10 @@ class layout_element::reel_component : public component
width = font->string_width(dest.height(), aspect, m_stopnames[fruit]);
if (width < bounds.width())
break;
aspect *= 0.9f;
aspect *= 0.95f;
}

s32 curx = bounds.left();
float curx = bounds.left();

// allocate a temporary bitmap
bitmap_argb32 tempbitmap(dest.width(), dest.height());
Expand Down Expand Up @@ -3385,7 +3385,7 @@ class layout_element::reel_component : public component
u32 *const d = &dest.pix(effy);
for (int x = 0; x < chbounds.width(); x++)
{
int effx = basex + curx + x;
int effx = basex + int(curx) + x;
if (effx >= bounds.left() && effx <= bounds.right())
{
u32 spix = rgb_t(src[x]).a();
Expand Down Expand Up @@ -3707,11 +3707,11 @@ void layout_element::component::draw_text(
width = font.string_width(bounds.height(), aspect, str);
if (width < bounds.width())
break;
aspect *= 0.9f;
aspect *= 0.95f;
}

// get alignment
s32 curx;
float curx;
switch (align)
{
// left
Expand All @@ -3726,7 +3726,7 @@ void layout_element::component::draw_text(

// default to center
default:
curx = bounds.left() + (bounds.width() - width) / 2;
curx = bounds.left() + (bounds.width() - width) / 2.0f;
break;
}

Expand Down Expand Up @@ -3756,7 +3756,7 @@ void layout_element::component::draw_text(
u32 *const d = &dest.pix(effy);
for (int x = 0; x < chbounds.width(); x++)
{
int effx = curx + x + chbounds.left();
int effx = int(curx) + x + chbounds.left();
if (effx >= bounds.left() && effx <= bounds.right())
{
u32 spix = rgb_t(src[x]).a();
Expand Down

1 comment on commit 63eaa6b

@happppp
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.