Add a helper function to generate fill rendering options.
Create a helper GetFillOptionsForDrawTextPath() to generate the fill
options for CPDF_TextRenderer::DrawTextPath(). Meanwhile, rename
GetFillRenderOptionsHelper() to GetFillOptionsForDrawPathWithBlend() to
distinguish these two helper functions.
Change-Id: I4937479ff6f3cded594b472cca13cef935d08c07
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/70934
Commit-Queue: Hui Yingst <nigi@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 136e93e..676fa03 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -73,11 +73,12 @@
constexpr int kRenderMaxRecursionDepth = 64;
int g_CurrentRecursionDepth = 0;
-int GetFillRenderOptionsHelper(const CPDF_RenderOptions::Options& options,
- const CPDF_PathObject* path_obj,
- int fill_type,
- bool is_stroke,
- bool is_type3_char) {
+int GetFillOptionsForDrawPathWithBlend(
+ const CPDF_RenderOptions::Options& options,
+ const CPDF_PathObject* path_obj,
+ int fill_type,
+ bool is_stroke,
+ bool is_type3_char) {
int fill_options = fill_type;
if (fill_type && options.bRectAA)
fill_options |= FXFILL_RECT_AA;
@@ -93,6 +94,23 @@
return fill_options;
}
+int GetFillOptionsForDrawTextPath(const CPDF_RenderOptions::Options& options,
+ const CPDF_TextObject* text_obj,
+ bool is_stroke,
+ bool is_fill) {
+ int fill_options = 0;
+ if (is_stroke && is_fill) {
+ fill_options |= FX_FILL_STROKE;
+ fill_options |= FX_STROKE_TEXT_MODE;
+ }
+ if (text_obj->m_GeneralState.GetStrokeAdjust())
+ fill_options |= FX_STROKE_ADJUST;
+ if (options.bNoTextSmooth)
+ fill_options |= FXFILL_NOPATHSMOOTH;
+
+ return fill_options;
+}
+
bool IsAvailableMatrix(const CFX_Matrix& matrix) {
if (matrix.a == 0 || matrix.d == 0)
return matrix.b != 0 && matrix.c != 0;
@@ -400,11 +418,11 @@
if (!IsAvailableMatrix(path_matrix))
return true;
- int fill_options = GetFillRenderOptionsHelper(options, pPathObj, FillType,
- bStroke, m_pType3Char);
return m_pDevice->DrawPathWithBlend(
pPathObj->path().GetObject(), &path_matrix,
- pPathObj->m_GraphState.GetObject(), fill_argb, stroke_argb, fill_options,
+ pPathObj->m_GraphState.GetObject(), fill_argb, stroke_argb,
+ GetFillOptionsForDrawPathWithBlend(options, pPathObj, FillType, bStroke,
+ m_pType3Char),
m_curBlend);
}
@@ -859,20 +877,13 @@
pDeviceMatrix = &device_matrix;
}
}
- int flag = 0;
- if (bStroke && bFill) {
- flag |= FX_FILL_STROKE;
- flag |= FX_STROKE_TEXT_MODE;
- }
- if (textobj->m_GeneralState.GetStrokeAdjust())
- flag |= FX_STROKE_ADJUST;
- if (m_Options.GetOptions().bNoTextSmooth)
- flag |= FXFILL_NOPATHSMOOTH;
return CPDF_TextRenderer::DrawTextPath(
m_pDevice, textobj->GetCharCodes(), textobj->GetCharPositions(),
pFont.Get(), font_size, text_matrix, pDeviceMatrix,
textobj->m_GraphState.GetObject(), fill_argb, stroke_argb,
- pClippingPath, flag);
+ pClippingPath,
+ GetFillOptionsForDrawTextPath(m_Options.GetOptions(), textobj, bStroke,
+ bFill));
}
text_matrix.Concat(mtObj2Device);
return CPDF_TextRenderer::DrawNormalText(