All your codebase are belong to us.

This commit is contained in:
Drake Arconis
2014-08-22 00:15:09 -04:00
parent 2a64c07215
commit 948ebe5213
110 changed files with 661 additions and 611 deletions

View File

@@ -230,10 +230,10 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
case LEFT:
break;
case RIGHT:
cur_x -= llmin(scaled_max_pixels, llround(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX));
cur_x -= llmin(scaled_max_pixels, llmath::llround(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX));
break;
case HCENTER:
cur_x -= llmin(scaled_max_pixels, llround(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX)) / 2;
cur_x -= llmin(scaled_max_pixels, llmath::llround(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX)) / 2;
break;
default:
break;
@@ -242,7 +242,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
cur_render_y = cur_y;
cur_render_x = cur_x;
F32 start_x = (F32)llround(cur_x);
F32 start_x = (F32)llmath::llround(cur_x);
const LLFontBitmapCache* font_bitmap_cache = mFontFreetype->getFontBitmapCache();
@@ -256,12 +256,12 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
if (use_ellipses && halign == LEFT)
{
// check for too long of a string
S32 string_width = llround(getWidthF32(wstr.c_str(), begin_offset, max_chars) * sScaleX);
S32 string_width = llmath::llround(getWidthF32(wstr.c_str(), begin_offset, max_chars) * sScaleX);
if (string_width > scaled_max_pixels)
{
// use four dots for ellipsis width to generate padding
const LLWString dots(utf8str_to_wstring(std::string("....")));
scaled_max_pixels = llmax(0, scaled_max_pixels - llround(getWidthF32(dots.c_str())));
scaled_max_pixels = llmax(0, scaled_max_pixels - llmath::llround(getWidthF32(dots.c_str())));
draw_ellipses = TRUE;
}
}
@@ -308,8 +308,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
gGL.getTexUnit(0)->bind(ext_image);
// snap origin to whole screen pixel
const F32 ext_x = (F32)llround(cur_render_x + (EXT_X_BEARING * sScaleX));
const F32 ext_y = (F32)llround(cur_render_y + (EXT_Y_BEARING * sScaleY + mFontFreetype->getAscenderHeight() - mFontFreetype->getLineHeight()));
const F32 ext_x = (F32)llmath::llround(cur_render_x + (EXT_X_BEARING * sScaleX));
const F32 ext_y = (F32)llmath::llround(cur_render_y + (EXT_Y_BEARING * sScaleY + mFontFreetype->getAscenderHeight() - mFontFreetype->getLineHeight()));
LLRectf uv_rect(0.f, 1.f, 1.f, 0.f);
LLRectf screen_rect(ext_x, ext_y + ext_height, ext_x + ext_width, ext_y);
@@ -398,10 +398,10 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
(fgi->mXBitmapOffset + fgi->mWidth) * inv_width,
(fgi->mYBitmapOffset - PAD_UVY) * inv_height);
// snap glyph origin to whole screen pixel
LLRectf screen_rect((F32)llround(cur_render_x + (F32)fgi->mXBearing),
(F32)llround(cur_render_y + (F32)fgi->mYBearing),
(F32)llround(cur_render_x + (F32)fgi->mXBearing) + (F32)fgi->mWidth,
(F32)llround(cur_render_y + (F32)fgi->mYBearing) - (F32)fgi->mHeight);
LLRectf screen_rect((F32)llmath::llround(cur_render_x + (F32)fgi->mXBearing),
(F32)llmath::llround(cur_render_y + (F32)fgi->mYBearing),
(F32)llmath::llround(cur_render_x + (F32)fgi->mXBearing) + (F32)fgi->mWidth,
(F32)llmath::llround(cur_render_y + (F32)fgi->mYBearing) - (F32)fgi->mHeight);
if (glyph_count >= GLYPH_BATCH_SIZE)
{
@@ -432,8 +432,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
// Must do this to cur_x, not just to cur_render_x, otherwise you
// will squish sub-pixel kerned characters too close together.
// For example, "CCCCC" looks bad.
cur_x = (F32)llround(cur_x);
//cur_y = (F32)llround(cur_y);
cur_x = (F32)llmath::llround(cur_x);
//cur_y = (F32)llmath::llround(cur_y);
cur_render_x = cur_x;
cur_render_y = cur_y;
@@ -523,7 +523,7 @@ F32 LLFontGL::getDescenderHeight() const
F32 LLFontGL::getLineHeight() const
{
return (F32)llround(mFontFreetype->getLineHeight() / sScaleY);
return (F32)llmath::llround(mFontFreetype->getLineHeight() / sScaleY);
}
S32 LLFontGL::getWidth(const std::string& utf8text) const
@@ -546,7 +546,7 @@ S32 LLFontGL::getWidth(const std::string& utf8text, const S32 begin_offset, cons
S32 LLFontGL::getWidth(const llwchar* wchars, const S32 begin_offset, const S32 max_chars, BOOL use_embedded) const
{
F32 width = getWidthF32(wchars, begin_offset, max_chars, use_embedded);
return llround(width);
return llmath::llround(width);
}
F32 LLFontGL::getWidthF32(const std::string& utf8text) const
@@ -620,7 +620,7 @@ F32 LLFontGL::getWidthF32(const llwchar* wchars, const S32 begin_offset, const S
cur_x += mFontFreetype->getXKerning(fgi, next_glyph);
}
// Round after kerning.
cur_x = (F32)llround(cur_x);
cur_x = (F32)llmath::llround(cur_x);
}
}
@@ -749,7 +749,7 @@ S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_ch
}
}
// Round after kerning.
cur_x = (F32)llround(cur_x);
cur_x = (F32)llmath::llround(cur_x);
drawn_x = cur_x;
}
@@ -837,7 +837,7 @@ S32 LLFontGL::firstDrawableChar(const llwchar* wchars, F32 max_pixels, S32 text_
}
// Round after kerning.
total_width = (F32)llround(total_width);
total_width = (F32)llmath::llround(total_width);
}
if (drawable_chars == 0)
@@ -929,7 +929,7 @@ S32 LLFontGL::charFromPixelOffset(const llwchar* wchars, const S32 begin_offset,
// Round after kerning.
cur_x = (F32)llround(cur_x);
cur_x = (F32)llmath::llround(cur_x);
}