summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-02-07 16:36:39 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-08 01:36:02 +0000
commitbba2a7cf30da9e84bcc14ef32dbb0bb944229219 (patch)
tree94a74de8d07b3e395bf6e08a62811a3a0d652d19 /core/fpdfapi
parent55e026b7b6eec17b012c819c4a7d39e63094b5c4 (diff)
downloadpdfium-bba2a7cf30da9e84bcc14ef32dbb0bb944229219.tar.xz
Update to use CFX_Rect{F} and CFX_Matrix constructors.
This Cl updates the code to use the constructors instead of creating an empty object and calling Set(). It also removes the various memsets of the CFX_Rect{F} classes. Change-Id: I6e20cec00866a38372858dcba5a30d31103172e4 Reviewed-on: https://pdfium-review.googlesource.com/2550 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/page/cpdf_page.cpp17
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp7
-rw-r--r--core/fpdfapi/page/cpdf_textobject.cpp8
-rw-r--r--core/fpdfapi/parser/cpdf_array.cpp7
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp18
-rw-r--r--core/fpdfapi/render/cpdf_type3cache.cpp6
6 files changed, 36 insertions, 27 deletions
diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
index f9c02837a7..7714369df8 100644
--- a/core/fpdfapi/page/cpdf_page.cpp
+++ b/core/fpdfapi/page/cpdf_page.cpp
@@ -66,16 +66,17 @@ CPDF_Page::CPDF_Page(CPDF_Document* pDocument,
switch (rotate) {
case 0:
- m_PageMatrix.Set(1.0f, 0, 0, 1.0f, -m_BBox.left, -m_BBox.bottom);
+ m_PageMatrix = CFX_Matrix(1.0f, 0, 0, 1.0f, -m_BBox.left, -m_BBox.bottom);
break;
case 1:
- m_PageMatrix.Set(0, -1.0f, 1.0f, 0, -m_BBox.bottom, m_BBox.right);
+ m_PageMatrix =
+ CFX_Matrix(0, -1.0f, 1.0f, 0, -m_BBox.bottom, m_BBox.right);
break;
case 2:
- m_PageMatrix.Set(-1.0f, 0, 0, -1.0f, m_BBox.right, m_BBox.top);
+ m_PageMatrix = CFX_Matrix(-1.0f, 0, 0, -1.0f, m_BBox.right, m_BBox.top);
break;
case 3:
- m_PageMatrix.Set(0, 1.0f, -1.0f, 0, m_BBox.top, -m_BBox.left);
+ m_PageMatrix = CFX_Matrix(0, 1.0f, -1.0f, 0, m_BBox.top, -m_BBox.left);
break;
}
@@ -128,7 +129,6 @@ void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix,
if (m_PageWidth == 0 || m_PageHeight == 0) {
return;
}
- CFX_Matrix display_matrix;
float x0 = 0;
float y0 = 0;
float x1 = 0;
@@ -170,9 +170,8 @@ void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix,
y2 = yPos;
break;
}
- display_matrix.Set((x2 - x0) / m_PageWidth, (y2 - y0) / m_PageWidth,
- (x1 - x0) / m_PageHeight, (y1 - y0) / m_PageHeight, x0,
- y0);
matrix = m_PageMatrix;
- matrix.Concat(display_matrix);
+ matrix.Concat(CFX_Matrix((x2 - x0) / m_PageWidth, (y2 - y0) / m_PageWidth,
+ (x1 - x0) / m_PageHeight, (y1 - y0) / m_PageHeight,
+ x0, y0));
}
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 3dec01a52e..28f3594f47 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -673,7 +673,7 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent() {
}
void CPDF_StreamContentParser::Handle_BeginText() {
- m_pCurStates->m_TextMatrix.Set(1.0f, 0, 0, 1.0f, 0, 0);
+ m_pCurStates->m_TextMatrix = CFX_Matrix();
OnChangeTextMatrix();
m_pCurStates->m_TextX = 0;
m_pCurStates->m_TextY = 0;
@@ -1365,8 +1365,9 @@ void CPDF_StreamContentParser::Handle_SetTextLeading() {
}
void CPDF_StreamContentParser::Handle_SetTextMatrix() {
- m_pCurStates->m_TextMatrix.Set(GetNumber(5), GetNumber(4), GetNumber(3),
- GetNumber(2), GetNumber(1), GetNumber(0));
+ m_pCurStates->m_TextMatrix =
+ CFX_Matrix(GetNumber(5), GetNumber(4), GetNumber(3), GetNumber(2),
+ GetNumber(1), GetNumber(0));
OnChangeTextMatrix();
m_pCurStates->m_TextX = 0;
m_pCurStates->m_TextY = 0;
diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp
index 0979fcfb33..fb81a40d0c 100644
--- a/core/fpdfapi/page/cpdf_textobject.cpp
+++ b/core/fpdfapi/page/cpdf_textobject.cpp
@@ -162,8 +162,12 @@ const CPDF_TextObject* CPDF_TextObject::AsText() const {
void CPDF_TextObject::GetTextMatrix(CFX_Matrix* pMatrix) const {
const FX_FLOAT* pTextMatrix = m_TextState.GetMatrix();
- pMatrix->Set(pTextMatrix[0], pTextMatrix[2], pTextMatrix[1], pTextMatrix[3],
- m_PosX, m_PosY);
+ pMatrix->a = pTextMatrix[0];
+ pMatrix->b = pTextMatrix[2];
+ pMatrix->c = pTextMatrix[1];
+ pMatrix->d = pTextMatrix[3];
+ pMatrix->e = m_PosX;
+ pMatrix->f = m_PosY;
}
void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs,
diff --git a/core/fpdfapi/parser/cpdf_array.cpp b/core/fpdfapi/parser/cpdf_array.cpp
index 64010e19e8..05a93702f1 100644
--- a/core/fpdfapi/parser/cpdf_array.cpp
+++ b/core/fpdfapi/parser/cpdf_array.cpp
@@ -78,11 +78,10 @@ CFX_FloatRect CPDF_Array::GetRect() {
CFX_Matrix CPDF_Array::GetMatrix() {
CFX_Matrix matrix;
if (!IsArray() || m_Objects.size() != 6)
- return matrix;
+ return CFX_Matrix();
- matrix.Set(GetNumberAt(0), GetNumberAt(1), GetNumberAt(2), GetNumberAt(3),
- GetNumberAt(4), GetNumberAt(5));
- return matrix;
+ return CFX_Matrix(GetNumberAt(0), GetNumberAt(1), GetNumberAt(2),
+ GetNumberAt(3), GetNumberAt(4), GetNumberAt(5));
}
CPDF_Object* CPDF_Array::GetObjectAt(size_t i) const {
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 8fe7a31ce4..861aec4eea 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -327,8 +327,10 @@ void DrawFuncShading(CFX_DIBitmap* pBitmap,
ymax = pDomain->GetNumberAt(3);
}
CFX_Matrix mtDomain2Target = pDict->GetMatrixFor("Matrix");
- CFX_Matrix matrix, reverse_matrix;
+ CFX_Matrix matrix;
matrix.SetReverse(*pObject2Bitmap);
+
+ CFX_Matrix reverse_matrix;
reverse_matrix.SetReverse(mtDomain2Target);
matrix.Concat(reverse_matrix);
int width = pBitmap->GetWidth();
@@ -891,6 +893,7 @@ std::unique_ptr<CFX_DIBitmap> DrawPatternBitmap(
CFX_FloatRect bitmap_rect(0.0f, 0.0f, (FX_FLOAT)width, (FX_FLOAT)height);
CFX_Matrix mtAdjust;
mtAdjust.MatchRect(bitmap_rect, cell_bbox);
+
CFX_Matrix mtPattern2Bitmap = *pObject2Device;
mtPattern2Bitmap.Concat(mtAdjust);
CPDF_RenderOptions options;
@@ -1987,16 +1990,19 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj,
: pFont->m_FontFallbacks[charpos.m_FallbackFontPosition].get();
const CFX_PathData* pPath =
font->LoadGlyphPath(charpos.m_GlyphIndex, charpos.m_FontCharWidth);
- if (!pPath) {
+ if (!pPath)
continue;
- }
+
CPDF_PathObject path;
path.m_GraphState = textobj->m_GraphState;
path.m_ColorState = textobj->m_ColorState;
+
CFX_Matrix matrix;
- if (charpos.m_bGlyphAdjust)
- matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1],
- charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0);
+ if (charpos.m_bGlyphAdjust) {
+ matrix = CFX_Matrix(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1],
+ charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3],
+ 0, 0);
+ }
matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX,
charpos.m_OriginY);
path.m_Path.Append(pPath, &matrix);
diff --git a/core/fpdfapi/render/cpdf_type3cache.cpp b/core/fpdfapi/render/cpdf_type3cache.cpp
index b27fdf507e..63cc780d1d 100644
--- a/core/fpdfapi/render/cpdf_type3cache.cpp
+++ b/core/fpdfapi/render/cpdf_type3cache.cpp
@@ -122,10 +122,10 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
return nullptr;
CFX_DIBitmap* pBitmap = pChar->m_pBitmap.get();
- CFX_Matrix image_matrix, text_matrix;
- image_matrix = pChar->m_ImageMatrix;
- text_matrix.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, 0, 0);
+ CFX_Matrix image_matrix = pChar->m_ImageMatrix;
+ CFX_Matrix text_matrix(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, 0, 0);
image_matrix.Concat(text_matrix);
+
std::unique_ptr<CFX_DIBitmap> pResBitmap;
int left = 0;
int top = 0;