summaryrefslogtreecommitdiff
path: root/core/fxge/dib/cfx_imagetransformer.cpp
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 /core/fxge/dib/cfx_imagetransformer.cpp
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>
Diffstat (limited to 'core/fxge/dib/cfx_imagetransformer.cpp')
-rw-r--r--core/fxge/dib/cfx_imagetransformer.cpp46
1 files changed, 21 insertions, 25 deletions
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;
}