summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render/cpdf_renderstatus.cpp
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-02-13 16:08:51 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-13 22:07:02 +0000
commit58e4c5ac24a88f83d1ba8277dee87baf4cba36a0 (patch)
tree5c6c05ffb40c1bb2653b415842537f7043bd6407 /core/fpdfapi/render/cpdf_renderstatus.cpp
parent9787a7441a905e582b10d9ffc425098b3233d36c (diff)
downloadpdfium-58e4c5ac24a88f83d1ba8277dee87baf4cba36a0.tar.xz
Clean up CPDF_TextObject a bit
Modernizing CPDF_TextObject a little bit, in preparation for the addition of APIs for adding text to PDFs. m_pCharCodes, m_pCharPos are now vectors, this caused some propagation to other classes. Also m_Pos is now a point. Note that GetItemInfo is being changed in another CL, so did minimal changes there. Change-Id: I6e5f19b5d45872e3e714a7cb587c81c92e640ea3 Reviewed-on: https://pdfium-review.googlesource.com/2614 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/render/cpdf_renderstatus.cpp')
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp41
1 files changed, 18 insertions, 23 deletions
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 2d3c23994e..05323ed49f 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1549,10 +1549,10 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
CFX_Matrix text_matrix = textobj->GetTextMatrix();
CPDF_TextRenderer::DrawTextPath(
- &text_device, textobj->m_nChars, textobj->m_pCharCodes,
- textobj->m_pCharPos, textobj->m_TextState.GetFont(),
- textobj->m_TextState.GetFontSize(), &text_matrix, &new_matrix,
- textobj->m_GraphState.GetObject(), (FX_ARGB)-1, 0, nullptr, 0);
+ &text_device, textobj->m_CharCodes, textobj->m_CharPos,
+ textobj->m_TextState.GetFont(), textobj->m_TextState.GetFontSize(),
+ &text_matrix, &new_matrix, textobj->m_GraphState.GetObject(),
+ (FX_ARGB)-1, 0, nullptr, 0);
}
}
CPDF_RenderStatus bitmap_render;
@@ -1671,7 +1671,7 @@ void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const {
bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj,
const CFX_Matrix* pObj2Device,
CFX_PathData* pClippingPath) {
- if (textobj->m_nChars == 0)
+ if (textobj->m_CharCodes.empty())
return true;
const TextRenderingMode text_render_mode = textobj->m_TextState.GetTextMode();
@@ -1764,15 +1764,14 @@ bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj,
if (m_Options.m_Flags & RENDER_NOTEXTSMOOTH)
flag |= FXFILL_NOPATHSMOOTH;
return CPDF_TextRenderer::DrawTextPath(
- m_pDevice, textobj->m_nChars, textobj->m_pCharCodes,
- textobj->m_pCharPos, pFont, font_size, &text_matrix, pDeviceMatrix,
- textobj->m_GraphState.GetObject(), fill_argb, stroke_argb,
- pClippingPath, flag);
+ m_pDevice, textobj->m_CharCodes, textobj->m_CharPos, pFont, font_size,
+ &text_matrix, pDeviceMatrix, textobj->m_GraphState.GetObject(),
+ fill_argb, stroke_argb, pClippingPath, flag);
}
text_matrix.Concat(*pObj2Device);
- return CPDF_TextRenderer::DrawNormalText(
- m_pDevice, textobj->m_nChars, textobj->m_pCharCodes, textobj->m_pCharPos,
- pFont, font_size, &text_matrix, fill_argb, &m_Options);
+ return CPDF_TextRenderer::DrawNormalText(m_pDevice, textobj->m_CharCodes,
+ textobj->m_CharPos, pFont, font_size,
+ &text_matrix, fill_argb, &m_Options);
}
CPDF_Type3Cache* CPDF_RenderStatus::GetCachedType3(CPDF_Type3Font* pFont) {
@@ -1802,18 +1801,15 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
int device_class = m_pDevice->GetDeviceClass();
std::vector<FXTEXT_GLYPHPOS> glyphs;
if (device_class == FXDC_DISPLAY)
- glyphs.resize(textobj->m_nChars);
+ glyphs.resize(textobj->m_CharCodes.size());
else if (fill_alpha < 255)
return false;
CPDF_RefType3Cache refTypeCache(pType3Font);
- uint32_t* pChars = textobj->m_pCharCodes;
- if (textobj->m_nChars == 1)
- pChars = (uint32_t*)(&textobj->m_pCharCodes);
-
- for (int iChar = 0; iChar < textobj->m_nChars; iChar++) {
- uint32_t charcode = pChars[iChar];
- if (charcode == (uint32_t)-1)
+ for (int iChar = 0; iChar < pdfium::CollectionSize<int>(textobj->m_CharCodes);
+ iChar++) {
+ uint32_t charcode = textobj->m_CharCodes[iChar];
+ if (charcode == static_cast<uint32_t>(-1))
continue;
CPDF_Type3Char* pType3Char = pType3Font->LoadChar(charcode);
@@ -1821,7 +1817,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
continue;
CFX_Matrix matrix = char_matrix;
- matrix.e += iChar ? textobj->m_pCharPos[iChar - 1] : 0;
+ matrix.e += iChar ? textobj->m_CharPos[iChar - 1] : 0;
matrix.Concat(text_matrix);
matrix.Concat(*pObj2Device);
if (!pType3Char->LoadBitmap(m_pContext)) {
@@ -1977,8 +1973,7 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj,
return;
}
CPDF_CharPosList CharPosList;
- CharPosList.Load(textobj->m_nChars, textobj->m_pCharCodes,
- textobj->m_pCharPos, pFont, font_size);
+ CharPosList.Load(textobj->m_CharCodes, textobj->m_CharPos, pFont, font_size);
for (uint32_t i = 0; i < CharPosList.m_nChars; i++) {
FXTEXT_CHARPOS& charpos = CharPosList.m_pCharPos[i];
auto font =