From 129297f6ae97169093d4affe3c8421b757bd95ec Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 17 Aug 2017 12:01:03 -0700 Subject: Remove default parameters in CXFA_Graphics methods. Constify parameters as well. Change-Id: I7e87b11cc73b133b04d49ceed1c46f5afcb89d1a Reviewed-on: https://pdfium-review.googlesource.com/11111 Commit-Queue: Lei Zhang Reviewed-by: dsinclair --- xfa/fwl/cfwl_edit.cpp | 2 +- xfa/fwl/theme/cfwl_listboxtp.cpp | 2 +- xfa/fwl/theme/cfwl_scrollbartp.cpp | 2 +- xfa/fxfa/cxfa_ffpushbutton.cpp | 2 +- xfa/fxfa/cxfa_fwltheme.cpp | 8 +++--- xfa/fxgraphics/cxfa_graphics.cpp | 50 ++++++++++++++++++-------------------- xfa/fxgraphics/cxfa_graphics.h | 28 ++++++++++----------- 7 files changed, 46 insertions(+), 48 deletions(-) diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index 6d14ad2e3c..184329fcac 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -188,7 +188,7 @@ void CFWL_Edit::DrawSpellCheck(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix) { pGraphics->SaveGraphState(); if (pMatrix) - pGraphics->ConcatMatrix(const_cast(pMatrix)); + pGraphics->ConcatMatrix(pMatrix); CFWL_EventCheckWord checkWordEvent(this); CFX_ByteString sLatinWord; diff --git a/xfa/fwl/theme/cfwl_listboxtp.cpp b/xfa/fwl/theme/cfwl_listboxtp.cpp index 8ea90198a3..deb7d6ff50 100644 --- a/xfa/fwl/theme/cfwl_listboxtp.cpp +++ b/xfa/fwl/theme/cfwl_listboxtp.cpp @@ -41,7 +41,7 @@ void CFWL_ListBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { } case CFWL_Part::Icon: { pParams->m_pGraphics->StretchImage(pParams->m_pImage, pParams->m_rtPart, - &pParams->m_matrix); + pParams->m_matrix); break; } case CFWL_Part::Check: { diff --git a/xfa/fwl/theme/cfwl_scrollbartp.cpp b/xfa/fwl/theme/cfwl_scrollbartp.cpp index 5deec8d6d6..6b998a9641 100644 --- a/xfa/fwl/theme/cfwl_scrollbartp.cpp +++ b/xfa/fwl/theme/cfwl_scrollbartp.cpp @@ -141,7 +141,7 @@ void CFWL_ScrollBarTP::DrawPaw(CXFA_Graphics* pGraphics, pGraphics->SetLineWidth(1); pGraphics->SetStrokeColor( CXFA_Color(m_pThemeData->clrPawColorLight[eState - 1])); - pGraphics->StrokePath(&path); + pGraphics->StrokePath(&path, nullptr); fX++; path.Clear(); diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp index 91b6f3ff27..b6ba0f56b1 100644 --- a/xfa/fxfa/cxfa_ffpushbutton.cpp +++ b/xfa/fxfa/cxfa_ffpushbutton.cpp @@ -215,7 +215,7 @@ void CXFA_FFPushButton::OnDrawWidget(CXFA_Graphics* pGraphics, CXFA_Path path; path.AddRectangle(rtFill.left, rtFill.top, rtFill.width, rtFill.height); pGraphics->SetFillColor(CXFA_Color(FXARGB_MAKE(128, 128, 255, 255))); - pGraphics->FillPath(&path, FXFILL_WINDING, (CFX_Matrix*)pMatrix); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } return; } diff --git a/xfa/fxfa/cxfa_fwltheme.cpp b/xfa/fxfa/cxfa_fwltheme.cpp index 85e48a5123..67258c1868 100644 --- a/xfa/fxfa/cxfa_fwltheme.cpp +++ b/xfa/fxfa/cxfa_fwltheme.cpp @@ -111,10 +111,10 @@ void CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) { return; CFX_Matrix mtPart = pParams->m_matrix; - CFX_Matrix* pMatrix = pGraphics->GetMatrix(); - if (pMatrix) { + const CFX_Matrix* pMatrix = pGraphics->GetMatrix(); + if (pMatrix) mtPart.Concat(*pMatrix); - } + m_pTextOut->SetMatrix(mtPart); m_pTextOut->DrawLogicText(pRenderDevice, pParams->m_wsText.c_str(), pParams->m_wsText.GetLength(), pParams->m_rtPart); @@ -136,7 +136,7 @@ void CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) { m_pTextOut->SetFontSize(pAcc->GetFontSize()); m_pTextOut->SetTextColor(pAcc->GetTextColor()); CFX_Matrix mtPart = pParams->m_matrix; - CFX_Matrix* pMatrix = pGraphics->GetMatrix(); + const CFX_Matrix* pMatrix = pGraphics->GetMatrix(); if (pMatrix) mtPart.Concat(*pMatrix); diff --git a/xfa/fxgraphics/cxfa_graphics.cpp b/xfa/fxgraphics/cxfa_graphics.cpp index 4975a83251..7cad380802 100644 --- a/xfa/fxgraphics/cxfa_graphics.cpp +++ b/xfa/fxgraphics/cxfa_graphics.cpp @@ -178,7 +178,7 @@ void CXFA_Graphics::SetFillColor(const CXFA_Color& color) { m_info.fillColor = color; } -void CXFA_Graphics::StrokePath(CXFA_Path* path, CFX_Matrix* matrix) { +void CXFA_Graphics::StrokePath(CXFA_Path* path, const CFX_Matrix* matrix) { if (!path) return; if (m_type == FX_CONTEXT_Device && m_renderDevice) @@ -187,7 +187,7 @@ void CXFA_Graphics::StrokePath(CXFA_Path* path, CFX_Matrix* matrix) { void CXFA_Graphics::FillPath(CXFA_Path* path, FX_FillMode fillMode, - CFX_Matrix* matrix) { + const CFX_Matrix* matrix) { if (!path) return; if (m_type == FX_CONTEXT_Device && m_renderDevice) @@ -196,7 +196,7 @@ void CXFA_Graphics::FillPath(CXFA_Path* path, void CXFA_Graphics::StretchImage(const CFX_RetainPtr& source, const CFX_RectF& rect, - CFX_Matrix* matrix) { + const CFX_Matrix& matrix) { if (!source) return; if (m_type == FX_CONTEXT_Device && m_renderDevice) @@ -211,7 +211,7 @@ void CXFA_Graphics::ConcatMatrix(const CFX_Matrix* matrix) { } } -CFX_Matrix* CXFA_Graphics::GetMatrix() { +const CFX_Matrix* CXFA_Graphics::GetMatrix() const { if (m_type == FX_CONTEXT_Device && m_renderDevice) return &m_info.CTM; return nullptr; @@ -268,8 +268,8 @@ void CXFA_Graphics::RenderDeviceSetLineDash(FX_DashStyle dashStyle) { } } -void CXFA_Graphics::RenderDeviceStrokePath(CXFA_Path* path, - CFX_Matrix* matrix) { +void CXFA_Graphics::RenderDeviceStrokePath(const CXFA_Path* path, + const CFX_Matrix* matrix) { if (m_info.strokeColor.GetType() != CXFA_Color::Solid) return; @@ -281,9 +281,9 @@ void CXFA_Graphics::RenderDeviceStrokePath(CXFA_Path* path, m_info.strokeColor.GetArgb(), 0); } -void CXFA_Graphics::RenderDeviceFillPath(CXFA_Path* path, +void CXFA_Graphics::RenderDeviceFillPath(const CXFA_Path* path, FX_FillMode fillMode, - CFX_Matrix* matrix) { + const CFX_Matrix* matrix) { CFX_Matrix m = m_info.CTM; if (matrix) m.Concat(*matrix); @@ -294,10 +294,10 @@ void CXFA_Graphics::RenderDeviceFillPath(CXFA_Path* path, m_info.fillColor.GetArgb(), 0x0, fillMode); return; case CXFA_Color::Pattern: - FillPathWithPattern(path, fillMode, &m); + FillPathWithPattern(path, fillMode, m); return; case CXFA_Color::Shading: - FillPathWithShading(path, fillMode, &m); + FillPathWithShading(path, fillMode, m); return; default: return; @@ -307,12 +307,11 @@ void CXFA_Graphics::RenderDeviceFillPath(CXFA_Path* path, void CXFA_Graphics::RenderDeviceStretchImage( const CFX_RetainPtr& source, const CFX_RectF& rect, - CFX_Matrix* matrix) { + const CFX_Matrix& matrix) { CFX_Matrix m1(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, m_info.CTM.f); - if (matrix) { - m1.Concat(*matrix); - } + m1.Concat(matrix); + CFX_RetainPtr bmp1 = source->StretchTo(static_cast(rect.Width()), static_cast(rect.Height()), 0, nullptr); @@ -330,9 +329,9 @@ void CXFA_Graphics::RenderDeviceStretchImage( FXSYS_round(r.left - left), FXSYS_round(r.top - top)); } -void CXFA_Graphics::FillPathWithPattern(CXFA_Path* path, +void CXFA_Graphics::FillPathWithPattern(const CXFA_Path* path, FX_FillMode fillMode, - CFX_Matrix* matrix) { + const CFX_Matrix& matrix) { CXFA_Pattern* pattern = m_info.fillColor.GetPattern(); CFX_RetainPtr bitmap = m_renderDevice->GetBitmap(); int32_t width = bitmap->GetWidth(); @@ -348,8 +347,7 @@ void CXFA_Graphics::FillPathWithPattern(CXFA_Path* path, mask->Create(data.width, data.height, FXDIB_1bppMask); memcpy(mask->GetBuffer(), data.maskBits, mask->GetPitch() * data.height); CFX_FloatRect rectf = path->GetPathData()->GetBoundingBox(); - if (matrix) - matrix->TransformRect(rectf); + matrix.TransformRect(rectf); FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); @@ -361,13 +359,13 @@ void CXFA_Graphics::FillPathWithPattern(CXFA_Path* path, device.SetBitMask(mask, i, j, m_info.fillColor.GetPattern()->m_foreArgb); } CFX_RenderDevice::StateRestorer restorer(m_renderDevice); - m_renderDevice->SetClip_PathFill(path->GetPathData(), matrix, fillMode); - SetDIBitsWithMatrix(bmp, &pattern->m_matrix); + m_renderDevice->SetClip_PathFill(path->GetPathData(), &matrix, fillMode); + SetDIBitsWithMatrix(bmp, pattern->m_matrix); } -void CXFA_Graphics::FillPathWithShading(CXFA_Path* path, +void CXFA_Graphics::FillPathWithShading(const CXFA_Path* path, FX_FillMode fillMode, - CFX_Matrix* matrix) { + const CFX_Matrix& matrix) { CFX_RetainPtr bitmap = m_renderDevice->GetBitmap(); int32_t width = bitmap->GetWidth(); int32_t height = bitmap->GetHeight(); @@ -478,20 +476,20 @@ void CXFA_Graphics::FillPathWithShading(CXFA_Path* path, } if (result) { CFX_RenderDevice::StateRestorer restorer(m_renderDevice); - m_renderDevice->SetClip_PathFill(path->GetPathData(), matrix, fillMode); + m_renderDevice->SetClip_PathFill(path->GetPathData(), &matrix, fillMode); SetDIBitsWithMatrix(bmp, matrix); } } void CXFA_Graphics::SetDIBitsWithMatrix( const CFX_RetainPtr& source, - CFX_Matrix* matrix) { - if (matrix->IsIdentity()) { + const CFX_Matrix& matrix) { + if (matrix.IsIdentity()) { m_renderDevice->SetDIBits(source, 0, 0); } else { CFX_Matrix m((float)source->GetWidth(), 0, 0, (float)source->GetHeight(), 0, 0); - m.Concat(*matrix); + m.Concat(matrix); int32_t left; int32_t top; CFX_RetainPtr bmp1 = source->FlipImage(false, true); diff --git a/xfa/fxgraphics/cxfa_graphics.h b/xfa/fxgraphics/cxfa_graphics.h index 05f9640ca8..99f86870c3 100644 --- a/xfa/fxgraphics/cxfa_graphics.h +++ b/xfa/fxgraphics/cxfa_graphics.h @@ -50,7 +50,7 @@ class CXFA_Graphics { void RestoreGraphState(); CFX_RectF GetClipRect() const; - CFX_Matrix* GetMatrix(); + const CFX_Matrix* GetMatrix() const; CFX_RenderDevice* GetRenderDevice(); void SetLineCap(CFX_GraphStateData::LineCap lineCap); @@ -61,13 +61,13 @@ class CXFA_Graphics { void SetStrokeColor(const CXFA_Color& color); void SetFillColor(const CXFA_Color& color); void SetClipRect(const CFX_RectF& rect); - void StrokePath(CXFA_Path* path, CFX_Matrix* matrix = nullptr); + void StrokePath(CXFA_Path* path, const CFX_Matrix* matrix); void FillPath(CXFA_Path* path, - FX_FillMode fillMode = FXFILL_WINDING, - CFX_Matrix* matrix = nullptr); + FX_FillMode fillMode, + const CFX_Matrix* matrix); void StretchImage(const CFX_RetainPtr& source, const CFX_RectF& rect, - CFX_Matrix* matrix = nullptr); + const CFX_Matrix& matrix); void ConcatMatrix(const CFX_Matrix* matrix); protected: @@ -87,23 +87,23 @@ class CXFA_Graphics { } m_info; void RenderDeviceSetLineDash(FX_DashStyle dashStyle); - void RenderDeviceStrokePath(CXFA_Path* path, CFX_Matrix* matrix); - void RenderDeviceFillPath(CXFA_Path* path, + void RenderDeviceStrokePath(const CXFA_Path* path, const CFX_Matrix* matrix); + void RenderDeviceFillPath(const CXFA_Path* path, FX_FillMode fillMode, - CFX_Matrix* matrix); + const CFX_Matrix* matrix); void RenderDeviceStretchImage(const CFX_RetainPtr& source, const CFX_RectF& rect, - CFX_Matrix* matrix); + const CFX_Matrix& matrix); - void FillPathWithPattern(CXFA_Path* path, + void FillPathWithPattern(const CXFA_Path* path, FX_FillMode fillMode, - CFX_Matrix* matrix); - void FillPathWithShading(CXFA_Path* path, + const CFX_Matrix& matrix); + void FillPathWithShading(const CXFA_Path* path, FX_FillMode fillMode, - CFX_Matrix* matrix); + const CFX_Matrix& matrix); void SetDIBitsWithMatrix(const CFX_RetainPtr& source, - CFX_Matrix* matrix); + const CFX_Matrix& matrix); CFX_RenderDevice* const m_renderDevice; // Not owned. std::vector> m_infoStack; -- cgit v1.2.3