Change CPDF_TextRenderer methods to pass options by reference.
Both DrawTextString() and DrawNormalText() can take CPDF_RenderOptions
by reference instead of by pointer since the arguments are never null.
Change-Id: I01d101c05aa87c937298ab17b99f046c0888a564
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/55720
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index f5fa718..e374285 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1776,7 +1776,7 @@
text_matrix.Concat(mtObj2Device);
return CPDF_TextRenderer::DrawNormalText(
m_pDevice, textobj->GetCharCodes(), textobj->GetCharPositions(), pFont,
- font_size, text_matrix, fill_argb, &m_Options);
+ font_size, text_matrix, fill_argb, m_Options);
}
RetainPtr<CPDF_Type3Cache> CPDF_RenderStatus::GetCachedType3(
diff --git a/core/fpdfapi/render/cpdf_textrenderer.cpp b/core/fpdfapi/render/cpdf_textrenderer.cpp
index 0e994bb..c681858 100644
--- a/core/fpdfapi/render/cpdf_textrenderer.cpp
+++ b/core/fpdfapi/render/cpdf_textrenderer.cpp
@@ -78,8 +78,7 @@
const CFX_Matrix& matrix,
const ByteString& str,
FX_ARGB fill_argb,
- const CFX_GraphStateData* pGraphState,
- const CPDF_RenderOptions* pOptions) {
+ const CPDF_RenderOptions& options) {
if (pFont->IsType3Font())
return;
@@ -103,7 +102,7 @@
new_matrix.e = origin_x;
new_matrix.f = origin_y;
DrawNormalText(pDevice, codes, positions, pFont, font_size, new_matrix,
- fill_argb, pOptions);
+ fill_argb, options);
}
// static
@@ -114,30 +113,27 @@
float font_size,
const CFX_Matrix& mtText2Device,
FX_ARGB fill_argb,
- const CPDF_RenderOptions* pOptions) {
+ const CPDF_RenderOptions& options) {
CPDF_CharPosList CharPosList(charCodes, charPos, pFont, font_size);
if (CharPosList.empty())
return true;
- int FXGE_flags = 0;
- if (pOptions) {
- if (pOptions->GetOptions().bClearType) {
- FXGE_flags |= FXTEXT_CLEARTYPE;
- if (pOptions->GetOptions().bBGRStripe)
- FXGE_flags |= FXTEXT_BGR_STRIPE;
- }
- if (pOptions->GetOptions().bNoTextSmooth)
- FXGE_flags |= FXTEXT_NOSMOOTH;
- if (pOptions->GetOptions().bPrintGraphicText)
- FXGE_flags |= FXTEXT_PRINTGRAPHICTEXT;
- if (pOptions->GetOptions().bNoNativeText)
- FXGE_flags |= FXTEXT_NO_NATIVETEXT;
- if (pOptions->GetOptions().bPrintImageText)
- FXGE_flags |= FXTEXT_PRINTIMAGETEXT;
- } else {
- FXGE_flags = FXTEXT_CLEARTYPE;
+ int fxge_flags = 0;
+ if (options.GetOptions().bClearType) {
+ fxge_flags |= FXTEXT_CLEARTYPE;
+ if (options.GetOptions().bBGRStripe)
+ fxge_flags |= FXTEXT_BGR_STRIPE;
}
+ if (options.GetOptions().bNoTextSmooth)
+ fxge_flags |= FXTEXT_NOSMOOTH;
+ if (options.GetOptions().bPrintGraphicText)
+ fxge_flags |= FXTEXT_PRINTGRAPHICTEXT;
+ if (options.GetOptions().bNoNativeText)
+ fxge_flags |= FXTEXT_NO_NATIVETEXT;
+ if (options.GetOptions().bPrintImageText)
+ fxge_flags |= FXTEXT_PRINTIMAGETEXT;
+
if (pFont->IsCIDFont())
- FXGE_flags |= FXFONT_CIDFONT;
+ fxge_flags |= FXFONT_CIDFONT;
bool bDraw = true;
int32_t fontPosition = CharPosList.GetAt(0).m_FallbackFontPosition;
uint32_t startIndex = 0;
@@ -149,7 +145,7 @@
CFX_Font* font = GetFont(pFont, fontPosition);
if (!pDevice->DrawNormalText(i - startIndex, &CharPosList.GetAt(startIndex),
font, font_size, mtText2Device, fill_argb,
- FXGE_flags)) {
+ fxge_flags)) {
bDraw = false;
}
fontPosition = curFontPosition;
@@ -158,7 +154,7 @@
CFX_Font* font = GetFont(pFont, fontPosition);
if (!pDevice->DrawNormalText(CharPosList.GetCount() - startIndex,
&CharPosList.GetAt(startIndex), font, font_size,
- mtText2Device, fill_argb, FXGE_flags)) {
+ mtText2Device, fill_argb, fxge_flags)) {
bDraw = false;
}
return bDraw;
diff --git a/core/fpdfapi/render/cpdf_textrenderer.h b/core/fpdfapi/render/cpdf_textrenderer.h
index f4870a9..93b7c6a 100644
--- a/core/fpdfapi/render/cpdf_textrenderer.h
+++ b/core/fpdfapi/render/cpdf_textrenderer.h
@@ -30,8 +30,7 @@
const CFX_Matrix& matrix,
const ByteString& str,
FX_ARGB fill_argb,
- const CFX_GraphStateData* pGraphState,
- const CPDF_RenderOptions* pOptions);
+ const CPDF_RenderOptions& options);
static bool DrawTextPath(CFX_RenderDevice* pDevice,
const std::vector<uint32_t>& charCodes,
@@ -53,7 +52,7 @@
float font_size,
const CFX_Matrix& mtText2Device,
FX_ARGB fill_argb,
- const CPDF_RenderOptions* pOptions);
+ const CPDF_RenderOptions& options);
CPDF_TextRenderer() = delete;
CPDF_TextRenderer(const CPDF_TextRenderer&) = delete;
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.cpp b/fpdfsdk/pwl/cpwl_edit_impl.cpp
index c4e3ff4..23eee8b 100644
--- a/fpdfsdk/pwl/cpwl_edit_impl.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_impl.cpp
@@ -51,8 +51,7 @@
ASSERT(ro.GetOptions().bClearType);
ro.SetColorMode(CPDF_RenderOptions::kNormal);
CPDF_TextRenderer::DrawTextString(pDevice, pos.x, pos.y, pFont, fFontSize,
- mtUser2Device, str, crTextFill, nullptr,
- &ro);
+ mtUser2Device, str, crTextFill, ro);
}
} // namespace