Pass CFX_Matrix by const-ref in various OnDraw() methods.
Change-Id: I6e953206520c024b2fc23b9b60c5c43112d04896
Reviewed-on: https://pdfium-review.googlesource.com/c/43603
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.cpp b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
index 2fd7f92..3dc3f09 100644
--- a/fpdfsdk/cpdfsdk_annothandlermgr.cpp
+++ b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
@@ -118,10 +118,10 @@
void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
+ const CFX_Matrix& mtUser2Device,
bool bDrawAnnots) {
ASSERT(pAnnot);
- GetAnnotHandler(pAnnot)->OnDraw(pPageView, pAnnot, pDevice, pUser2Device,
+ GetAnnotHandler(pAnnot)->OnDraw(pPageView, pAnnot, pDevice, mtUser2Device,
bDrawAnnots);
}
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.h b/fpdfsdk/cpdfsdk_annothandlermgr.h
index 799a1be..55b13f3 100644
--- a/fpdfsdk/cpdfsdk_annothandlermgr.h
+++ b/fpdfsdk/cpdfsdk_annothandlermgr.h
@@ -53,7 +53,7 @@
void Annot_OnDraw(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
+ const CFX_Matrix& mtUser2Device,
bool bDrawAnnots);
void Annot_OnMouseEnter(CPDFSDK_PageView* pPageView,
diff --git a/fpdfsdk/cpdfsdk_baannothandler.cpp b/fpdfsdk/cpdfsdk_baannothandler.cpp
index a5969c9..93d3e46 100644
--- a/fpdfsdk/cpdfsdk_baannothandler.cpp
+++ b/fpdfsdk/cpdfsdk_baannothandler.cpp
@@ -65,14 +65,14 @@
void CPDFSDK_BAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
+ const CFX_Matrix& mtUser2Device,
bool bDrawAnnots) {
#ifdef PDF_ENABLE_XFA
if (pAnnot->IsXFAField())
return;
#endif // PDF_ENABLE_XFA
if (bDrawAnnots && pAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP) {
- pAnnot->AsBAAnnot()->DrawAppearance(pDevice, *pUser2Device,
+ pAnnot->AsBAAnnot()->DrawAppearance(pDevice, mtUser2Device,
CPDF_Annot::Normal, nullptr);
}
}
diff --git a/fpdfsdk/cpdfsdk_baannothandler.h b/fpdfsdk/cpdfsdk_baannothandler.h
index 53c06f1..5adabc2 100644
--- a/fpdfsdk/cpdfsdk_baannothandler.h
+++ b/fpdfsdk/cpdfsdk_baannothandler.h
@@ -49,7 +49,7 @@
void OnDraw(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
+ const CFX_Matrix& mtUser2Device,
bool bDrawAnnots) override;
void OnLoad(CPDFSDK_Annot* pAnnot) override;
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp
index 0713d29..ff87ea8 100644
--- a/fpdfsdk/cpdfsdk_pageview.cpp
+++ b/fpdfsdk/cpdfsdk_pageview.cpp
@@ -63,10 +63,10 @@
}
void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
+ const CFX_Matrix& mtUser2Device,
CPDF_RenderOptions* pOptions,
const FX_RECT& pClip) {
- m_curMatrix = *pUser2Device;
+ m_curMatrix = mtUser2Device;
#ifdef PDF_ENABLE_XFA
CPDFXFA_Page* pPage = GetPDFXFAPage();
@@ -83,7 +83,7 @@
gs.SetClipRect(rectClip);
CXFA_FFPageView* xfaView = pPage->GetXFAPageView();
- CXFA_RenderContext renderContext(xfaView, rectClip, *pUser2Device);
+ CXFA_RenderContext renderContext(xfaView, rectClip, mtUser2Device);
renderContext.DoRender(&gs);
CXFA_FFDocView* docView = xfaView->GetDocView();
@@ -94,7 +94,7 @@
return;
// Render the focus widget
docView->GetWidgetHandler()->RenderWidget(annot->GetXFAWidget(), &gs,
- *pUser2Device, false);
+ mtUser2Device, false);
return;
}
#endif // PDF_ENABLE_XFA
@@ -103,7 +103,7 @@
CPDFSDK_AnnotIteration annotIteration(this, true);
for (const auto& pSDKAnnot : annotIteration) {
m_pFormFillEnv->GetAnnotHandlerMgr()->Annot_OnDraw(
- this, pSDKAnnot.Get(), pDevice, pUser2Device,
+ this, pSDKAnnot.Get(), pDevice, mtUser2Device,
pOptions->GetDrawAnnots());
}
}
diff --git a/fpdfsdk/cpdfsdk_pageview.h b/fpdfsdk/cpdfsdk_pageview.h
index 46c35e1..4674c1b 100644
--- a/fpdfsdk/cpdfsdk_pageview.h
+++ b/fpdfsdk/cpdfsdk_pageview.h
@@ -26,7 +26,7 @@
~CPDFSDK_PageView();
void PageView_OnDraw(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
+ const CFX_Matrix& mtUser2Device,
CPDF_RenderOptions* pOptions,
const FX_RECT& pClip);
@@ -88,8 +88,8 @@
int GetPageIndex() const;
void SetValid(bool bValid) { m_bValid = bValid; }
- bool IsValid() { return m_bValid; }
- bool IsLocked() { return m_bLocked; }
+ bool IsValid() const { return m_bValid; }
+ bool IsLocked() const { return m_bLocked; }
void SetBeingDestroyed() { m_bBeingDestroyed = true; }
bool IsBeingDestroyed() const { return m_bBeingDestroyed; }
void TakePageOwnership() { m_pOwnsPage.Reset(ToPDFPage(m_page)); }
diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp
index 7cfe74f..70d0397 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_widgethandler.cpp
@@ -89,14 +89,14 @@
void CPDFSDK_WidgetHandler::OnDraw(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
+ const CFX_Matrix& mtUser2Device,
bool bDrawAnnots) {
if (pAnnot->IsSignatureWidget()) {
- pAnnot->AsBAAnnot()->DrawAppearance(pDevice, *pUser2Device,
+ pAnnot->AsBAAnnot()->DrawAppearance(pDevice, mtUser2Device,
CPDF_Annot::Normal, nullptr);
} else {
if (m_pFormFiller)
- m_pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device);
+ m_pFormFiller->OnDraw(pPageView, pAnnot, pDevice, mtUser2Device);
}
}
diff --git a/fpdfsdk/cpdfsdk_widgethandler.h b/fpdfsdk/cpdfsdk_widgethandler.h
index 82ea549..c74869c 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.h
+++ b/fpdfsdk/cpdfsdk_widgethandler.h
@@ -50,7 +50,7 @@
void OnDraw(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
+ const CFX_Matrix& mtUser2Device,
bool bDrawAnnots) override;
void OnLoad(CPDFSDK_Annot* pAnnot) override;
diff --git a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp
index 82eda21..eeccf21 100644
--- a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp
@@ -49,20 +49,19 @@
void CPDFSDK_XFAWidgetHandler::OnDraw(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
+ const CFX_Matrix& mtUser2Device,
bool bDrawAnnots) {
ASSERT(pPageView);
ASSERT(pAnnot);
CXFA_Graphics gs(pDevice);
- CFX_Matrix mt = *pUser2Device;
bool bIsHighlight = false;
if (pPageView->GetFormFillEnv()->GetFocusAnnot() != pAnnot)
bIsHighlight = true;
- GetXFAWidgetHandler(pAnnot)->RenderWidget(pAnnot->GetXFAWidget(), &gs, mt,
- bIsHighlight);
+ GetXFAWidgetHandler(pAnnot)->RenderWidget(pAnnot->GetXFAWidget(), &gs,
+ mtUser2Device, bIsHighlight);
// to do highlight and shadow
}
diff --git a/fpdfsdk/cpdfsdk_xfawidgethandler.h b/fpdfsdk/cpdfsdk_xfawidgethandler.h
index 442d10b..5b68556 100644
--- a/fpdfsdk/cpdfsdk_xfawidgethandler.h
+++ b/fpdfsdk/cpdfsdk_xfawidgethandler.h
@@ -45,7 +45,7 @@
void OnDraw(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
+ const CFX_Matrix& mtUser2Device,
bool bDrawAnnots) override;
void OnLoad(CPDFSDK_Annot* pAnnot) override;
void OnMouseEnter(CPDFSDK_PageView* pPageView,
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
index d76ce99..cef2a45 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
@@ -56,7 +56,7 @@
void CFFL_InteractiveFormFiller::OnDraw(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
+ const CFX_Matrix& mtUser2Device) {
ASSERT(pPageView);
CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
if (!IsVisible(pWidget))
@@ -64,7 +64,7 @@
CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, false);
if (pFormFiller && pFormFiller->IsValid()) {
- pFormFiller->OnDraw(pPageView, pAnnot, pDevice, *pUser2Device);
+ pFormFiller->OnDraw(pPageView, pAnnot, pDevice, mtUser2Device);
pAnnot->GetPDFPage();
if (m_pFormFillEnv->GetFocusAnnot() != pAnnot)
return;
@@ -89,16 +89,16 @@
gsd.m_DashArray = {1.0f};
gsd.m_DashPhase = 0;
gsd.m_LineWidth = 1.0f;
- pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0),
+ pDevice->DrawPath(&path, &mtUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0),
FXFILL_ALTERNATE);
return;
}
pFormFiller = GetFormFiller(pAnnot, false);
if (pFormFiller) {
- pFormFiller->OnDrawDeactive(pPageView, pAnnot, pDevice, *pUser2Device);
+ pFormFiller->OnDrawDeactive(pPageView, pAnnot, pDevice, mtUser2Device);
} else {
- pWidget->DrawAppearance(pDevice, *pUser2Device, CPDF_Annot::Normal,
+ pWidget->DrawAppearance(pDevice, mtUser2Device, CPDF_Annot::Normal,
nullptr);
}
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.h b/fpdfsdk/formfiller/cffl_interactiveformfiller.h
index 46248d6..bf9fa3c 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.h
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.h
@@ -34,7 +34,7 @@
void OnDraw(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device);
+ const CFX_Matrix& mtUser2Device);
void OnDelete(CPDFSDK_Annot* pAnnot);
diff --git a/fpdfsdk/fpdf_formfill.cpp b/fpdfsdk/fpdf_formfill.cpp
index 644f332..056559a 100644
--- a/fpdfsdk/fpdf_formfill.cpp
+++ b/fpdfsdk/fpdf_formfill.cpp
@@ -211,7 +211,7 @@
pdfium::MakeRetain<CPDF_OCContext>(pPDFDoc, CPDF_OCContext::View));
if (pPageView)
- pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, rect);
+ pPageView->PageView_OnDraw(pDevice.get(), matrix, &options, rect);
}
#ifdef _SKIA_SUPPORT_PATHS_
diff --git a/fpdfsdk/ipdfsdk_annothandler.h b/fpdfsdk/ipdfsdk_annothandler.h
index 11c43ec..61c0ad0 100644
--- a/fpdfsdk/ipdfsdk_annothandler.h
+++ b/fpdfsdk/ipdfsdk_annothandler.h
@@ -49,7 +49,7 @@
virtual void OnDraw(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
+ const CFX_Matrix& mtUser2Device,
bool bDrawAnnots) = 0;
virtual void OnLoad(CPDFSDK_Annot* pAnnot) = 0;