summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/page/cpdf_page.cpp20
-rw-r--r--core/fpdfapi/page/cpdf_page.h11
-rw-r--r--core/fpdfapi/page/cpdf_textobject.cpp18
-rw-r--r--core/fpdfapi/page/cpdf_textobject.h2
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp13
5 files changed, 27 insertions, 37 deletions
diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
index 7714369df8..ba30ce57c3 100644
--- a/core/fpdfapi/page/cpdf_page.cpp
+++ b/core/fpdfapi/page/cpdf_page.cpp
@@ -120,15 +120,14 @@ CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteString& name) const {
return nullptr;
}
-void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix,
- int xPos,
- int yPos,
- int xSize,
- int ySize,
- int iRotate) const {
- if (m_PageWidth == 0 || m_PageHeight == 0) {
- return;
- }
+CFX_Matrix CPDF_Page::GetDisplayMatrix(int xPos,
+ int yPos,
+ int xSize,
+ int ySize,
+ int iRotate) const {
+ if (m_PageWidth == 0 || m_PageHeight == 0)
+ return CFX_Matrix();
+
float x0 = 0;
float y0 = 0;
float x1 = 0;
@@ -170,8 +169,9 @@ void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix,
y2 = yPos;
break;
}
- matrix = m_PageMatrix;
+ CFX_Matrix matrix = m_PageMatrix;
matrix.Concat(CFX_Matrix((x2 - x0) / m_PageWidth, (y2 - y0) / m_PageWidth,
(x1 - x0) / m_PageHeight, (y1 - y0) / m_PageHeight,
x0, y0));
+ return matrix;
}
diff --git a/core/fpdfapi/page/cpdf_page.h b/core/fpdfapi/page/cpdf_page.h
index 3812d28670..6d29a8f34e 100644
--- a/core/fpdfapi/page/cpdf_page.h
+++ b/core/fpdfapi/page/cpdf_page.h
@@ -31,12 +31,11 @@ class CPDF_Page : public CPDF_PageObjectHolder {
void ParseContent();
- void GetDisplayMatrix(CFX_Matrix& matrix,
- int xPos,
- int yPos,
- int xSize,
- int ySize,
- int iRotate) const;
+ CFX_Matrix GetDisplayMatrix(int xPos,
+ int yPos,
+ int xSize,
+ int ySize,
+ int iRotate) const;
FX_FLOAT GetPageWidth() const { return m_PageWidth; }
FX_FLOAT GetPageHeight() const { return m_PageHeight; }
diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp
index fb81a40d0c..503ea78f9e 100644
--- a/core/fpdfapi/page/cpdf_textobject.cpp
+++ b/core/fpdfapi/page/cpdf_textobject.cpp
@@ -134,8 +134,7 @@ CPDF_PageObject::Type CPDF_TextObject::GetType() const {
}
void CPDF_TextObject::Transform(const CFX_Matrix& matrix) {
- CFX_Matrix text_matrix;
- GetTextMatrix(&text_matrix);
+ CFX_Matrix text_matrix = GetTextMatrix();
text_matrix.Concat(matrix);
FX_FLOAT* pTextMatrix = m_TextState.GetMutableMatrix();
@@ -160,14 +159,10 @@ const CPDF_TextObject* CPDF_TextObject::AsText() const {
return this;
}
-void CPDF_TextObject::GetTextMatrix(CFX_Matrix* pMatrix) const {
+CFX_Matrix CPDF_TextObject::GetTextMatrix() const {
const FX_FLOAT* pTextMatrix = m_TextState.GetMatrix();
- pMatrix->a = pTextMatrix[0];
- pMatrix->b = pTextMatrix[2];
- pMatrix->c = pTextMatrix[1];
- pMatrix->d = pTextMatrix[3];
- pMatrix->e = m_PosX;
- pMatrix->f = m_PosY;
+ return CFX_Matrix(pTextMatrix[0], pTextMatrix[2], pTextMatrix[1],
+ pTextMatrix[3], m_PosX, m_PosY);
}
void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs,
@@ -361,13 +356,12 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX,
min_y = min_y * fontsize / 1000;
max_y = max_y * fontsize / 1000;
}
- CFX_Matrix matrix;
- GetTextMatrix(&matrix);
+
m_Left = min_x;
m_Right = max_x;
m_Bottom = min_y;
m_Top = max_y;
- matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom);
+ GetTextMatrix().TransformRect(m_Left, m_Right, m_Top, m_Bottom);
if (TextRenderingModeIsStrokeMode(m_TextState.GetTextMode())) {
FX_FLOAT half_width = m_GraphState.GetLineWidth() / 2;
m_Left -= half_width;
diff --git a/core/fpdfapi/page/cpdf_textobject.h b/core/fpdfapi/page/cpdf_textobject.h
index b520e3ee92..2e54f2035e 100644
--- a/core/fpdfapi/page/cpdf_textobject.h
+++ b/core/fpdfapi/page/cpdf_textobject.h
@@ -40,7 +40,7 @@ class CPDF_TextObject : public CPDF_PageObject {
FX_FLOAT GetCharWidth(uint32_t charcode) const;
FX_FLOAT GetPosX() const;
FX_FLOAT GetPosY() const;
- void GetTextMatrix(CFX_Matrix* pMatrix) const;
+ CFX_Matrix GetTextMatrix() const;
CPDF_Font* GetFont() const;
FX_FLOAT GetFontSize() const;
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 86b9670cd1..1bdf4a0382 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1544,11 +1544,10 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
text_device.Attach(pTextMask.get(), false, nullptr, false);
for (uint32_t i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) {
CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i);
- if (!textobj) {
+ if (!textobj)
break;
- }
- CFX_Matrix text_matrix;
- textobj->GetTextMatrix(&text_matrix);
+
+ CFX_Matrix text_matrix = textobj->GetTextMatrix();
CPDF_TextRenderer::DrawTextPath(
&text_device, textobj->m_nChars, textobj->m_pCharCodes,
textobj->m_pCharPos, textobj->m_TextState.GetFont(),
@@ -1732,8 +1731,7 @@ bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj,
fill_argb = GetFillArgb(textobj);
}
}
- CFX_Matrix text_matrix;
- textobj->GetTextMatrix(&text_matrix);
+ CFX_Matrix text_matrix = textobj->GetTextMatrix();
if (!IsAvailableMatrix(text_matrix))
return true;
@@ -1795,8 +1793,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
CFX_Matrix dCTM = m_pDevice->GetCTM();
FX_FLOAT sa = FXSYS_fabs(dCTM.a);
FX_FLOAT sd = FXSYS_fabs(dCTM.d);
- CFX_Matrix text_matrix;
- textobj->GetTextMatrix(&text_matrix);
+ CFX_Matrix text_matrix = textobj->GetTextMatrix();
CFX_Matrix char_matrix = pType3Font->GetFontMatrix();
FX_FLOAT font_size = textobj->m_TextState.GetFontSize();
char_matrix.Scale(font_size, font_size);