Pass a CFX_Matrix by reference in font code.
The callers always pass in a valid CFX_Matrix, so eliminate the
possibility of a nullptr.
Change-Id: Id7d8b731ed60d5f66517b50c56efeca343e897c4
Reviewed-on: https://pdfium-review.googlesource.com/33152
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp
index 1801814..bc7d999 100644
--- a/core/fxge/apple/fx_apple_platform.cpp
+++ b/core/fxge/apple/fx_apple_platform.cpp
@@ -168,7 +168,7 @@
std::unique_ptr<CFX_GlyphBitmap> CFX_FaceCache::RenderGlyph_Nativetext(
const CFX_Font* pFont,
uint32_t glyph_index,
- const CFX_Matrix* pMatrix,
+ const CFX_Matrix& matrix,
uint32_t dest_width,
int anti_alias) {
return nullptr;
diff --git a/core/fxge/cfx_facecache.cpp b/core/fxge/cfx_facecache.cpp
index ba316c1..c2051c3 100644
--- a/core/fxge/cfx_facecache.cpp
+++ b/core/fxge/cfx_facecache.cpp
@@ -72,17 +72,17 @@
const CFX_Font* pFont,
uint32_t glyph_index,
bool bFontStyle,
- const CFX_Matrix* pMatrix,
+ const CFX_Matrix& matrix,
uint32_t dest_width,
int anti_alias) {
if (!m_Face)
return nullptr;
FXFT_Matrix ft_matrix;
- ft_matrix.xx = (signed long)(pMatrix->a / 64 * 65536);
- ft_matrix.xy = (signed long)(pMatrix->c / 64 * 65536);
- ft_matrix.yx = (signed long)(pMatrix->b / 64 * 65536);
- ft_matrix.yy = (signed long)(pMatrix->d / 64 * 65536);
+ ft_matrix.xx = matrix.a / 64 * 65536;
+ ft_matrix.xy = matrix.c / 64 * 65536;
+ ft_matrix.yx = matrix.b / 64 * 65536;
+ ft_matrix.yy = matrix.d / 64 * 65536;
bool bUseCJKSubFont = false;
const CFX_SubstFont* pSubstFont = pFont->GetSubstFont();
if (pSubstFont) {
@@ -215,7 +215,7 @@
const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(const CFX_Font* pFont,
uint32_t glyph_index,
bool bFontStyle,
- const CFX_Matrix* pMatrix,
+ const CFX_Matrix& matrix,
uint32_t dest_width,
int anti_alias,
int& text_flags) {
@@ -223,10 +223,10 @@
return nullptr;
UniqueKeyGen keygen;
- int nMatrixA = static_cast<int>(pMatrix->a * 10000);
- int nMatrixB = static_cast<int>(pMatrix->b * 10000);
- int nMatrixC = static_cast<int>(pMatrix->c * 10000);
- int nMatrixD = static_cast<int>(pMatrix->d * 10000);
+ int nMatrixA = static_cast<int>(matrix.a * 10000);
+ int nMatrixB = static_cast<int>(matrix.b * 10000);
+ int nMatrixC = static_cast<int>(matrix.c * 10000);
+ int nMatrixD = static_cast<int>(matrix.d * 10000);
#if _FX_PLATFORM_ != _FX_PLATFORM_APPLE_
if (pFont->GetSubstFont()) {
keygen.Generate(9, nMatrixA, nMatrixB, nMatrixC, nMatrixD, dest_width,
@@ -262,11 +262,11 @@
ByteString FaceGlyphsKey(keygen.key_, keygen.key_len_);
#if _FX_PLATFORM_ != _FX_PLATFORM_APPLE_ || defined _SKIA_SUPPORT_ || \
defined _SKIA_SUPPORT_PATHS_
- return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index,
+ return LookUpGlyphBitmap(pFont, matrix, FaceGlyphsKey, glyph_index,
bFontStyle, dest_width, anti_alias);
#else
if (text_flags & FXTEXT_NO_NATIVETEXT) {
- return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index,
+ return LookUpGlyphBitmap(pFont, matrix, FaceGlyphsKey, glyph_index,
bFontStyle, dest_width, anti_alias);
}
std::unique_ptr<CFX_GlyphBitmap> pGlyphBitmap;
@@ -277,7 +277,7 @@
if (it2 != pSizeCache->end())
return it2->second.get();
- pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix,
+ pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, matrix,
dest_width, anti_alias);
if (pGlyphBitmap) {
CFX_GlyphBitmap* pResult = pGlyphBitmap.get();
@@ -285,7 +285,7 @@
return pResult;
}
} else {
- pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix,
+ pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, matrix,
dest_width, anti_alias);
if (pGlyphBitmap) {
CFX_GlyphBitmap* pResult = pGlyphBitmap.get();
@@ -307,7 +307,7 @@
}
ByteString FaceGlyphsKey2(keygen.key_, keygen.key_len_);
text_flags |= FXTEXT_NO_NATIVETEXT;
- return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey2, glyph_index,
+ return LookUpGlyphBitmap(pFont, matrix, FaceGlyphsKey2, glyph_index,
bFontStyle, dest_width, anti_alias);
#endif
}
@@ -335,7 +335,7 @@
CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(
const CFX_Font* pFont,
- const CFX_Matrix* pMatrix,
+ const CFX_Matrix& matrix,
const ByteString& FaceGlyphsKey,
uint32_t glyph_index,
bool bFontStyle,
@@ -355,7 +355,7 @@
return it2->second.get();
std::unique_ptr<CFX_GlyphBitmap> pGlyphBitmap = RenderGlyph(
- pFont, glyph_index, bFontStyle, pMatrix, dest_width, anti_alias);
+ pFont, glyph_index, bFontStyle, matrix, dest_width, anti_alias);
CFX_GlyphBitmap* pResult = pGlyphBitmap.get();
(*pSizeCache)[glyph_index] = std::move(pGlyphBitmap);
return pResult;
diff --git a/core/fxge/cfx_facecache.h b/core/fxge/cfx_facecache.h
index 4ff4c41..c7b0593 100644
--- a/core/fxge/cfx_facecache.h
+++ b/core/fxge/cfx_facecache.h
@@ -29,7 +29,7 @@
const CFX_GlyphBitmap* LoadGlyphBitmap(const CFX_Font* pFont,
uint32_t glyph_index,
bool bFontStyle,
- const CFX_Matrix* pMatrix,
+ const CFX_Matrix& matrix,
uint32_t dest_width,
int anti_alias,
int& text_flags);
@@ -49,17 +49,17 @@
std::unique_ptr<CFX_GlyphBitmap> RenderGlyph(const CFX_Font* pFont,
uint32_t glyph_index,
bool bFontStyle,
- const CFX_Matrix* pMatrix,
+ const CFX_Matrix& matrix,
uint32_t dest_width,
int anti_alias);
std::unique_ptr<CFX_GlyphBitmap> RenderGlyph_Nativetext(
const CFX_Font* pFont,
uint32_t glyph_index,
- const CFX_Matrix* pMatrix,
+ const CFX_Matrix& matrix,
uint32_t dest_width,
int anti_alias);
CFX_GlyphBitmap* LookUpGlyphBitmap(const CFX_Font* pFont,
- const CFX_Matrix* pMatrix,
+ const CFX_Matrix& matrix,
const ByteString& FaceGlyphsKey,
uint32_t glyph_index,
bool bFontStyle,
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
index 98322fd..4634b87 100644
--- a/core/fxge/cfx_font.cpp
+++ b/core/fxge/cfx_font.cpp
@@ -612,11 +612,11 @@
const CFX_GlyphBitmap* CFX_Font::LoadGlyphBitmap(uint32_t glyph_index,
bool bFontStyle,
- const CFX_Matrix* pMatrix,
+ const CFX_Matrix& matrix,
uint32_t dest_width,
int anti_alias,
int& text_flags) const {
- return GetFaceCache()->LoadGlyphBitmap(this, glyph_index, bFontStyle, pMatrix,
+ return GetFaceCache()->LoadGlyphBitmap(this, glyph_index, bFontStyle, matrix,
dest_width, anti_alias, text_flags);
}
diff --git a/core/fxge/cfx_font.h b/core/fxge/cfx_font.h
index 1d17714..7ef8ed7 100644
--- a/core/fxge/cfx_font.h
+++ b/core/fxge/cfx_font.h
@@ -51,7 +51,7 @@
const CFX_GlyphBitmap* LoadGlyphBitmap(uint32_t glyph_index,
bool bFontStyle,
- const CFX_Matrix* pMatrix,
+ const CFX_Matrix& matrix,
uint32_t dest_width,
int anti_alias,
int& text_flags) const;
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index aed1bff..c63f2f5 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -936,11 +936,11 @@
charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0);
new_matrix.Concat(deviceCtm);
glyph.m_pGlyph = pFont->LoadGlyphBitmap(
- charpos.m_GlyphIndex, charpos.m_bFontStyle, &new_matrix,
+ charpos.m_GlyphIndex, charpos.m_bFontStyle, new_matrix,
charpos.m_FontCharWidth, anti_alias, nativetext_flags);
} else {
glyph.m_pGlyph = pFont->LoadGlyphBitmap(
- charpos.m_GlyphIndex, charpos.m_bFontStyle, &deviceCtm,
+ charpos.m_GlyphIndex, charpos.m_bFontStyle, deviceCtm,
charpos.m_FontCharWidth, anti_alias, nativetext_flags);
}
}