summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-24 23:53:03 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-24 23:53:03 +0000
commit98d1b48e9a3471a02968f3d12692645fa0fcb50d (patch)
tree7ae40e8cef9500e737f9576bba908ad23bf80928
parent030bfc05d3460eabaa059f9561897cc1279bd60f (diff)
downloadpdfium-98d1b48e9a3471a02968f3d12692645fa0fcb50d.tar.xz
Clean up CFX_ImageTransformer parameters.
- A valid matrix is always passed in, so make the parameter const-ref. Since it is not obvious who owns the passed in matrix, make a copy with the corresponding matrix member. - Since the matrix parameter is const-ref, CFX_DIBBase::TransformTo() can also have a const-ref matrix parameter. - |flags| should be uint32_t, since |m_Flags| is. - |pClips| is only used inside the ctor, so remove |m_pClip|. Change-Id: If3d58a3fd28fa72b4ac7caac15f49a8057c594db Reviewed-on: https://pdfium-review.googlesource.com/c/44541 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp4
-rw-r--r--core/fpdfapi/render/cpdf_type3cache.cpp2
-rw-r--r--core/fxge/dib/cfx_dibbase.cpp4
-rw-r--r--core/fxge/dib/cfx_dibbase.h2
-rw-r--r--core/fxge/dib/cfx_imagerenderer.cpp2
-rw-r--r--core/fxge/dib/cfx_imagetransformer.cpp46
-rw-r--r--core/fxge/dib/cfx_imagetransformer.h9
-rw-r--r--xfa/fxfa/cxfa_imagerenderer.cpp2
-rw-r--r--xfa/fxgraphics/cxfa_graphics.cpp2
9 files changed, 34 insertions, 39 deletions
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index da63f556a7..362cf558f7 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -416,7 +416,7 @@ bool CPDF_ImageRenderer::StartDIBBase() {
clip_box.Intersect(image_rect);
m_Status = 2;
m_pTransformer = pdfium::MakeUnique<CFX_ImageTransformer>(
- m_pDIBBase, &m_ImageMatrix, m_Flags, &clip_box);
+ m_pDIBBase, m_ImageMatrix, m_Flags, &clip_box);
return true;
}
if (m_ImageMatrix.a < 0)
@@ -485,7 +485,7 @@ bool CPDF_ImageRenderer::StartBitmapAlpha() {
int left;
int top;
RetainPtr<CFX_DIBitmap> pTransformed =
- pAlphaMask->TransformTo(&m_ImageMatrix, &left, &top);
+ pAlphaMask->TransformTo(m_ImageMatrix, &left, &top);
if (!pTransformed)
return true;
diff --git a/core/fpdfapi/render/cpdf_type3cache.cpp b/core/fpdfapi/render/cpdf_type3cache.cpp
index a2b4538ef4..ea15a94ca8 100644
--- a/core/fpdfapi/render/cpdf_type3cache.cpp
+++ b/core/fpdfapi/render/cpdf_type3cache.cpp
@@ -154,7 +154,7 @@ std::unique_ptr<CFX_GlyphBitmap> CPDF_Type3Cache::RenderGlyph(
}
}
if (!pResBitmap)
- pResBitmap = pBitmap->TransformTo(&image_matrix, &left, &top);
+ pResBitmap = pBitmap->TransformTo(image_matrix, &left, &top);
if (!pResBitmap)
return nullptr;
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp
index c70aad69b4..7fc9bef9cb 100644
--- a/core/fxge/dib/cfx_dibbase.cpp
+++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -1167,11 +1167,11 @@ RetainPtr<CFX_DIBitmap> CFX_DIBBase::SwapXY(bool bXFlip, bool bYFlip) const {
return pTransBitmap;
}
-RetainPtr<CFX_DIBitmap> CFX_DIBBase::TransformTo(const CFX_Matrix* pDestMatrix,
+RetainPtr<CFX_DIBitmap> CFX_DIBBase::TransformTo(const CFX_Matrix& mtDest,
int* result_left,
int* result_top) {
RetainPtr<CFX_DIBBase> holder(this);
- CFX_ImageTransformer transformer(holder, pDestMatrix, 0, nullptr);
+ CFX_ImageTransformer transformer(holder, mtDest, 0, nullptr);
transformer.Continue(nullptr);
*result_left = transformer.result().left;
*result_top = transformer.result().top;
diff --git a/core/fxge/dib/cfx_dibbase.h b/core/fxge/dib/cfx_dibbase.h
index ef35fc86e7..81b0691563 100644
--- a/core/fxge/dib/cfx_dibbase.h
+++ b/core/fxge/dib/cfx_dibbase.h
@@ -82,7 +82,7 @@ class CFX_DIBBase : public Retainable {
int dest_height,
uint32_t flags,
const FX_RECT* pClip);
- RetainPtr<CFX_DIBitmap> TransformTo(const CFX_Matrix* pMatrix,
+ RetainPtr<CFX_DIBitmap> TransformTo(const CFX_Matrix& mtDest,
int* left,
int* top);
RetainPtr<CFX_DIBitmap> SwapXY(bool bXFlip, bool bYFlip) const;
diff --git a/core/fxge/dib/cfx_imagerenderer.cpp b/core/fxge/dib/cfx_imagerenderer.cpp
index 64c484f24d..ffab8ee623 100644
--- a/core/fxge/dib/cfx_imagerenderer.cpp
+++ b/core/fxge/dib/cfx_imagerenderer.cpp
@@ -60,7 +60,7 @@ CFX_ImageRenderer::CFX_ImageRenderer(const RetainPtr<CFX_DIBitmap>& pDevice,
}
m_Status = 2;
m_pTransformer = pdfium::MakeUnique<CFX_ImageTransformer>(
- pSource, &m_Matrix, dib_flags, &m_ClipBox);
+ pSource, m_Matrix, dib_flags, &m_ClipBox);
return;
}
diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp
index 9edcc5d1fa..96249750ee 100644
--- a/core/fxge/dib/cfx_imagetransformer.cpp
+++ b/core/fxge/dib/cfx_imagetransformer.cpp
@@ -202,42 +202,38 @@ class CFX_BilinearMatrix final : public CPDF_FixedMatrix {
} // namespace
CFX_ImageTransformer::CFX_ImageTransformer(const RetainPtr<CFX_DIBBase>& pSrc,
- const CFX_Matrix* pMatrix,
- int flags,
+ const CFX_Matrix& matrix,
+ uint32_t flags,
const FX_RECT* pClip)
- : m_pSrc(pSrc),
- m_pMatrix(pMatrix),
- m_pClip(pClip),
- m_Flags(flags),
- m_Status(0) {
- FX_RECT result_rect = m_pMatrix->GetUnitRect().GetClosestRect();
+ : m_pSrc(pSrc), m_matrix(matrix), m_Flags(flags) {
+ FX_RECT result_rect = m_matrix.GetUnitRect().GetClosestRect();
FX_RECT result_clip = result_rect;
- if (m_pClip)
- result_clip.Intersect(*m_pClip);
+ if (pClip)
+ result_clip.Intersect(*pClip);
if (result_clip.IsEmpty())
return;
m_result = result_clip;
- if (fabs(m_pMatrix->a) < fabs(m_pMatrix->b) / 20 &&
- fabs(m_pMatrix->d) < fabs(m_pMatrix->c) / 20 &&
- fabs(m_pMatrix->a) < 0.5f && fabs(m_pMatrix->d) < 0.5f) {
+ if (fabs(m_matrix.a) < fabs(m_matrix.b) / 20 &&
+ fabs(m_matrix.d) < fabs(m_matrix.c) / 20 && fabs(m_matrix.a) < 0.5f &&
+ fabs(m_matrix.d) < 0.5f) {
int dest_width = result_rect.Width();
int dest_height = result_rect.Height();
result_clip.Offset(-result_rect.left, -result_rect.top);
result_clip = FXDIB_SwapClipBox(result_clip, dest_width, dest_height,
- m_pMatrix->c > 0, m_pMatrix->b < 0);
+ m_matrix.c > 0, m_matrix.b < 0);
m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>(
&m_Storer, m_pSrc, dest_height, dest_width, result_clip, m_Flags);
m_Stretcher->Start();
m_Status = 1;
return;
}
- if (fabs(m_pMatrix->b) < kFix16 && fabs(m_pMatrix->c) < kFix16) {
- int dest_width = static_cast<int>(m_pMatrix->a > 0 ? ceil(m_pMatrix->a)
- : floor(m_pMatrix->a));
- int dest_height = static_cast<int>(m_pMatrix->d > 0 ? -ceil(m_pMatrix->d)
- : -floor(m_pMatrix->d));
+ if (fabs(m_matrix.b) < kFix16 && fabs(m_matrix.c) < kFix16) {
+ int dest_width =
+ static_cast<int>(m_matrix.a > 0 ? ceil(m_matrix.a) : floor(m_matrix.a));
+ int dest_height = static_cast<int>(m_matrix.d > 0 ? -ceil(m_matrix.d)
+ : -floor(m_matrix.d));
result_clip.Offset(-result_rect.left, -result_rect.top);
m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>(
&m_Storer, m_pSrc, dest_width, dest_height, result_clip, m_Flags);
@@ -246,14 +242,14 @@ CFX_ImageTransformer::CFX_ImageTransformer(const RetainPtr<CFX_DIBBase>& pSrc,
return;
}
int stretch_width =
- static_cast<int>(ceil(FXSYS_sqrt2(m_pMatrix->a, m_pMatrix->b)));
+ static_cast<int>(ceil(FXSYS_sqrt2(m_matrix.a, m_matrix.b)));
int stretch_height =
- static_cast<int>(ceil(FXSYS_sqrt2(m_pMatrix->c, m_pMatrix->d)));
+ static_cast<int>(ceil(FXSYS_sqrt2(m_matrix.c, m_matrix.d)));
CFX_Matrix stretch2dest(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, stretch_height);
stretch2dest.Concat(
- CFX_Matrix(m_pMatrix->a / stretch_width, m_pMatrix->b / stretch_width,
- m_pMatrix->c / stretch_height, m_pMatrix->d / stretch_height,
- m_pMatrix->e, m_pMatrix->f));
+ CFX_Matrix(m_matrix.a / stretch_width, m_matrix.b / stretch_width,
+ m_matrix.c / stretch_height, m_matrix.d / stretch_height,
+ m_matrix.e, m_matrix.f));
m_dest2stretch = stretch2dest.GetInverse();
m_StretchClip =
@@ -274,7 +270,7 @@ bool CFX_ImageTransformer::Continue(PauseIndicatorIface* pPause) {
if (m_Storer.GetBitmap()) {
m_Storer.Replace(
- m_Storer.GetBitmap()->SwapXY(m_pMatrix->c > 0, m_pMatrix->b < 0));
+ m_Storer.GetBitmap()->SwapXY(m_matrix.c > 0, m_matrix.b < 0));
}
return false;
}
diff --git a/core/fxge/dib/cfx_imagetransformer.h b/core/fxge/dib/cfx_imagetransformer.h
index c19e744c1a..ecd91872c0 100644
--- a/core/fxge/dib/cfx_imagetransformer.h
+++ b/core/fxge/dib/cfx_imagetransformer.h
@@ -21,8 +21,8 @@ class CFX_ImageStretcher;
class CFX_ImageTransformer {
public:
CFX_ImageTransformer(const RetainPtr<CFX_DIBBase>& pSrc,
- const CFX_Matrix* pMatrix,
- int flags,
+ const CFX_Matrix& matrix,
+ uint32_t flags,
const FX_RECT* pClip);
~CFX_ImageTransformer();
@@ -99,15 +99,14 @@ class CFX_ImageTransformer {
std::function<void(const DownSampleData&, uint8_t*)> func);
RetainPtr<CFX_DIBBase> const m_pSrc;
- UnownedPtr<const CFX_Matrix> const m_pMatrix;
- const FX_RECT* const m_pClip;
+ const CFX_Matrix m_matrix;
FX_RECT m_StretchClip;
FX_RECT m_result;
CFX_Matrix m_dest2stretch;
std::unique_ptr<CFX_ImageStretcher> m_Stretcher;
CFX_BitmapStorer m_Storer;
const uint32_t m_Flags;
- int m_Status;
+ int m_Status = 0;
};
#endif // CORE_FXGE_DIB_CFX_IMAGETRANSFORMER_H_
diff --git a/xfa/fxfa/cxfa_imagerenderer.cpp b/xfa/fxfa/cxfa_imagerenderer.cpp
index 9f65eaa07c..5f90b3cff6 100644
--- a/xfa/fxfa/cxfa_imagerenderer.cpp
+++ b/xfa/fxfa/cxfa_imagerenderer.cpp
@@ -49,7 +49,7 @@ bool CXFA_ImageRenderer::Start() {
clip_box.Intersect(image_rect);
m_Status = 2;
m_pTransformer = pdfium::MakeUnique<CFX_ImageTransformer>(
- pDib, &m_ImageMatrix, FXDIB_INTERPOL, &clip_box);
+ pDib, m_ImageMatrix, FXDIB_INTERPOL, &clip_box);
return true;
}
if (m_ImageMatrix.a < 0)
diff --git a/xfa/fxgraphics/cxfa_graphics.cpp b/xfa/fxgraphics/cxfa_graphics.cpp
index 03689da618..32499271b6 100644
--- a/xfa/fxgraphics/cxfa_graphics.cpp
+++ b/xfa/fxgraphics/cxfa_graphics.cpp
@@ -423,7 +423,7 @@ void CXFA_Graphics::SetDIBitsWithMatrix(const RetainPtr<CFX_DIBBase>& source,
int32_t left;
int32_t top;
RetainPtr<CFX_DIBitmap> bmp1 = source->FlipImage(false, true);
- RetainPtr<CFX_DIBitmap> bmp2 = bmp1->TransformTo(&m, &left, &top);
+ RetainPtr<CFX_DIBitmap> bmp2 = bmp1->TransformTo(m, &left, &top);
m_renderDevice->SetDIBits(bmp2, left, top);
}
}