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 <thestig@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index 6d14ad2..184329f 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -188,7 +188,7 @@
const CFX_Matrix* pMatrix) {
pGraphics->SaveGraphState();
if (pMatrix)
- pGraphics->ConcatMatrix(const_cast<CFX_Matrix*>(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 8ea9019..deb7d6f 100644
--- a/xfa/fwl/theme/cfwl_listboxtp.cpp
+++ b/xfa/fwl/theme/cfwl_listboxtp.cpp
@@ -41,7 +41,7 @@
}
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 5deec8d..6b998a9 100644
--- a/xfa/fwl/theme/cfwl_scrollbartp.cpp
+++ b/xfa/fwl/theme/cfwl_scrollbartp.cpp
@@ -141,7 +141,7 @@
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 91b6f3f..b6ba0f5 100644
--- a/xfa/fxfa/cxfa_ffpushbutton.cpp
+++ b/xfa/fxfa/cxfa_ffpushbutton.cpp
@@ -215,7 +215,7 @@
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 85e48a5..67258c1 100644
--- a/xfa/fxfa/cxfa_fwltheme.cpp
+++ b/xfa/fxfa/cxfa_fwltheme.cpp
@@ -111,10 +111,10 @@
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 @@
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 4975a83..7cad380 100644
--- a/xfa/fxgraphics/cxfa_graphics.cpp
+++ b/xfa/fxgraphics/cxfa_graphics.cpp
@@ -178,7 +178,7 @@
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::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::StretchImage(const CFX_RetainPtr<CFX_DIBSource>& 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 @@
}
}
-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::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 @@
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 @@
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::RenderDeviceStretchImage(
const CFX_RetainPtr<CFX_DIBSource>& 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<CFX_DIBitmap> bmp1 =
source->StretchTo(static_cast<int32_t>(rect.Width()),
static_cast<int32_t>(rect.Height()), 0, nullptr);
@@ -330,9 +329,9 @@
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<CFX_DIBitmap> bitmap = m_renderDevice->GetBitmap();
int32_t width = bitmap->GetWidth();
@@ -348,8 +347,7 @@
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 @@
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<CFX_DIBitmap> bitmap = m_renderDevice->GetBitmap();
int32_t width = bitmap->GetWidth();
int32_t height = bitmap->GetHeight();
@@ -478,20 +476,20 @@
}
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<CFX_DIBSource>& 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<CFX_DIBitmap> bmp1 = source->FlipImage(false, true);
diff --git a/xfa/fxgraphics/cxfa_graphics.h b/xfa/fxgraphics/cxfa_graphics.h
index 05f9640..99f8687 100644
--- a/xfa/fxgraphics/cxfa_graphics.h
+++ b/xfa/fxgraphics/cxfa_graphics.h
@@ -50,7 +50,7 @@
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 @@
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<CFX_DIBSource>& source,
const CFX_RectF& rect,
- CFX_Matrix* matrix = nullptr);
+ const CFX_Matrix& matrix);
void ConcatMatrix(const CFX_Matrix* matrix);
protected:
@@ -87,23 +87,23 @@
} 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<CFX_DIBSource>& 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<CFX_DIBSource>& source,
- CFX_Matrix* matrix);
+ const CFX_Matrix& matrix);
CFX_RenderDevice* const m_renderDevice; // Not owned.
std::vector<std::unique_ptr<TInfo>> m_infoStack;