summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/page/cpdf_page.cpp56
-rw-r--r--core/fpdfapi/page/cpdf_page.h6
-rw-r--r--core/fpdftext/cpdf_textpage.cpp6
3 files changed, 30 insertions, 38 deletions
diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
index e5d7f381a5..eb1f0b535d 100644
--- a/core/fpdfapi/page/cpdf_page.cpp
+++ b/core/fpdfapi/page/cpdf_page.cpp
@@ -118,11 +118,7 @@ CFX_FloatRect CPDF_Page::GetBox(const ByteString& name) const {
return box;
}
-CFX_Matrix CPDF_Page::GetDisplayMatrix(int xPos,
- int yPos,
- int xSize,
- int ySize,
- int iRotate) const {
+CFX_Matrix CPDF_Page::GetDisplayMatrix(const FX_RECT& rect, int iRotate) const {
if (m_PageSize.width == 0 || m_PageSize.height == 0)
return CFX_Matrix();
@@ -136,41 +132,41 @@ CFX_Matrix CPDF_Page::GetDisplayMatrix(int xPos,
// This code implicitly inverts the y-axis to account for page coordinates
// pointing up and bitmap coordinates pointing down. (x0, y0) is the base
// point, (x1, y1) is that point translated on y and (x2, y2) is the point
- // translated on x. On iRotate = 0, y0 is (yPos + ySize) and the translation
+ // translated on x. On iRotate = 0, y0 is rect.bottom and the translation
// to get y1 is performed as negative. This results in the desired
// transformation.
switch (iRotate) {
case 0:
- x0 = xPos;
- y0 = yPos + ySize;
- x1 = xPos;
- y1 = yPos;
- x2 = xPos + xSize;
- y2 = yPos + ySize;
+ x0 = rect.left;
+ y0 = rect.bottom;
+ x1 = rect.left;
+ y1 = rect.top;
+ x2 = rect.right;
+ y2 = rect.bottom;
break;
case 1:
- x0 = xPos;
- y0 = yPos;
- x1 = xPos + xSize;
- y1 = yPos;
- x2 = xPos;
- y2 = yPos + ySize;
+ x0 = rect.left;
+ y0 = rect.top;
+ x1 = rect.right;
+ y1 = rect.top;
+ x2 = rect.left;
+ y2 = rect.bottom;
break;
case 2:
- x0 = xPos + xSize;
- y0 = yPos;
- x1 = xPos + xSize;
- y1 = yPos + ySize;
- x2 = xPos;
- y2 = yPos;
+ x0 = rect.right;
+ y0 = rect.top;
+ x1 = rect.right;
+ y1 = rect.bottom;
+ x2 = rect.left;
+ y2 = rect.top;
break;
case 3:
- x0 = xPos + xSize;
- y0 = yPos + ySize;
- x1 = xPos;
- y1 = yPos + ySize;
- x2 = xPos + xSize;
- y2 = yPos;
+ x0 = rect.right;
+ y0 = rect.bottom;
+ x1 = rect.left;
+ y1 = rect.bottom;
+ x2 = rect.right;
+ y2 = rect.top;
break;
}
CFX_Matrix matrix = m_PageMatrix;
diff --git a/core/fpdfapi/page/cpdf_page.h b/core/fpdfapi/page/cpdf_page.h
index c7aa12e474..39c1b72c27 100644
--- a/core/fpdfapi/page/cpdf_page.h
+++ b/core/fpdfapi/page/cpdf_page.h
@@ -33,11 +33,7 @@ class CPDF_Page : public CPDF_PageObjectHolder {
void ParseContent();
- CFX_Matrix GetDisplayMatrix(int xPos,
- int yPos,
- int xSize,
- int ySize,
- int iRotate) const;
+ CFX_Matrix GetDisplayMatrix(const FX_RECT& rect, int iRotate) const;
float GetPageWidth() const { return m_PageSize.width; }
float GetPageHeight() const { return m_PageSize.height; }
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 91c92492cd..46c2a4e341 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -143,9 +143,9 @@ CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, FPDFText_Direction flags)
m_bIsParsed(false),
m_TextlineDir(TextOrientation::Unknown) {
m_TextBuf.EstimateSize(0, 10240);
- m_DisplayMatrix =
- pPage->GetDisplayMatrix(0, 0, static_cast<int>(pPage->GetPageWidth()),
- static_cast<int>(pPage->GetPageHeight()), 0);
+ const FX_RECT rect(0, 0, static_cast<int>(pPage->GetPageWidth()),
+ static_cast<int>(pPage->GetPageHeight()));
+ m_DisplayMatrix = pPage->GetDisplayMatrix(rect, 0);
}
CPDF_TextPage::~CPDF_TextPage() {}