Fix tautological compares in font_atlas.cc.
This fixes the following warnings from a recent version of Clang: cc/font_atlas.cc:62:43: error: comparison of constant 128 with expression of type 'char' is always true [-Werror,-Wtautological-constant-out-of-range-compare] cc/font_atlas.cc:45:39: error: comparison of constant 128 with expression of type 'const char' is always true [-Werror,-Wtautological-constant-out-of-range-compare] The problem is that the char type is signed on this platform, and therefore always < 128. The code really wants to work with the unsigned values here. BUG=163104 Review URL: https://chromiumcodereview.appspot.com/11416239 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170041 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -42,7 +42,9 @@ void FontAtlas::drawOneLineOfTextInternal(SkCanvas* canvas, const SkPaint& paint
|
||||
gfx::Point position = destPosition;
|
||||
for (unsigned i = 0; i < textLine.length(); ++i) {
|
||||
// If the ASCII code is out of bounds, then index 0 is used, which is just a plain rectangle glyph.
|
||||
int asciiIndex = (textLine[i] < 128) ? textLine[i] : 0;
|
||||
unsigned asciiIndex = textLine[i];
|
||||
if (asciiIndex >= 128)
|
||||
asciiIndex = 0;
|
||||
gfx::Rect glyphBounds = m_asciiToRectTable[asciiIndex];
|
||||
SkIRect source = SkIRect::MakeXYWH(glyphBounds.x(), glyphBounds.y(), glyphBounds.width(), glyphBounds.height());
|
||||
canvas->drawBitmapRect(m_atlas, &source, SkRect::MakeXYWH(position.x(), position.y(), glyphBounds.width(), glyphBounds.height()), &paint);
|
||||
@ -59,7 +61,9 @@ gfx::Size FontAtlas::textSize(const std::string& text)
|
||||
for (size_t i = 0; i < lines.size(); ++i) {
|
||||
int lineWidth = 0;
|
||||
for (size_t j = 0; j < lines[i].size(); ++j) {
|
||||
int asciiIndex = (lines[i][j] < 128) ? lines[i][j] : 0;
|
||||
unsigned asciiIndex = lines[i][j];
|
||||
if (asciiIndex >= 128)
|
||||
asciiIndex = 0;
|
||||
lineWidth += m_asciiToRectTable[asciiIndex].width();
|
||||
}
|
||||
if (lineWidth > maxWidth)
|
||||
|
Reference in New Issue
Block a user