Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Unified Diff: core/fxge/ge/cfx_facecache.cpp

Issue 2296193002: Use CheckedNumeric for strength calculation. (Closed)
Patch Set: Fix operation order Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxge/ge/cfx_facecache.cpp
diff --git a/core/fxge/ge/cfx_facecache.cpp b/core/fxge/ge/cfx_facecache.cpp
index c35830fbdefc821ba79d185a11256984829a0b26..d59ae3269e03e755ea8cd02aed2306551980534b 100644
--- a/core/fxge/ge/cfx_facecache.cpp
+++ b/core/fxge/ge/cfx_facecache.cpp
@@ -14,6 +14,7 @@
#include "core/fxge/include/cfx_pathdata.h"
#include "core/fxge/include/cfx_substfont.h"
#include "core/fxge/include/fx_freetype.h"
+#include "third_party/base/numerics/safe_math.h"
#ifdef _SKIA_SUPPORT_
#include "third_party/skia/include/core/SkStream.h"
@@ -154,19 +155,17 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont,
uint32_t index = (weight - 400) / 10;
if (index >= CFX_Font::kWeightPowArraySize)
return nullptr;
- int level = 0;
- if (pSubstFont->m_Charset == FXFONT_SHIFTJIS_CHARSET) {
- level =
- CFX_Font::s_WeightPow_SHIFTJIS[index] * 2 *
- (FXSYS_abs((int)(ft_matrix.xx)) + FXSYS_abs((int)(ft_matrix.xy))) /
- 36655;
- } else {
- level =
- CFX_Font::s_WeightPow_11[index] *
- (FXSYS_abs((int)(ft_matrix.xx)) + FXSYS_abs((int)(ft_matrix.xy))) /
- 36655;
- }
- FXFT_Outline_Embolden(FXFT_Get_Glyph_Outline(m_Face), level);
+ pdfium::base::CheckedNumeric<signed long> level = 0;
+ if (pSubstFont->m_Charset == FXFONT_SHIFTJIS_CHARSET)
+ level = CFX_Font::s_WeightPow_SHIFTJIS[index] * 2;
+ else
+ level = CFX_Font::s_WeightPow_11[index];
+
+ level = level * (FXSYS_abs(static_cast<int>(ft_matrix.xx)) +
+ FXSYS_abs(static_cast<int>(ft_matrix.xy))) /
+ 36655;
+ FXFT_Outline_Embolden(FXFT_Get_Glyph_Outline(m_Face),
+ level.ValueOrDefault(0));
}
FXFT_Library_SetLcdFilter(CFX_GEModule::Get()->GetFontMgr()->GetFTLibrary(),
FT_LCD_FILTER_DEFAULT);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698