From a039bc2d0142efe9148ed4580ef304b33570b431 Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 18 May 2016 12:50:41 -0700 Subject: Remove Release() from CXFA_RenderContext Review-Url: https://codereview.chromium.org/1994733002 --- xfa/fxfa/app/xfa_rendercontext.cpp | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'xfa/fxfa/app') diff --git a/xfa/fxfa/app/xfa_rendercontext.cpp b/xfa/fxfa/app/xfa_rendercontext.cpp index 7bfd9630cb..de78a202ad 100644 --- a/xfa/fxfa/app/xfa_rendercontext.cpp +++ b/xfa/fxfa/app/xfa_rendercontext.cpp @@ -10,20 +10,20 @@ #include "xfa/fxfa/include/xfa_ffwidget.h" #include "xfa/fxgraphics/include/cfx_graphics.h" -#define XFA_RENDERCONTEXT_MaxCount 30 +namespace { -CXFA_RenderContext::CXFA_RenderContext() { - m_pWidgetIterator = NULL; - m_pWidget = NULL; - m_pPageView = NULL; - m_pGS = NULL; - m_dwStatus = 0; +const int32_t kMaxCount = 30; + +} // namsepace + +CXFA_RenderContext::CXFA_RenderContext() + : m_pWidget(nullptr), m_pPageView(nullptr), m_pGS(nullptr), m_dwStatus(0) { m_matrix.SetIdentity(); m_rtClipRect.Reset(); } -CXFA_RenderContext::~CXFA_RenderContext() { - StopRender(); -} + +CXFA_RenderContext::~CXFA_RenderContext() {} + int32_t CXFA_RenderContext::StartRender(CXFA_FFPageView* pPageView, CFX_Graphics* pGS, const CFX_Matrix& matrix, @@ -42,11 +42,12 @@ int32_t CXFA_RenderContext::StartRender(CXFA_FFPageView* pPageView, uint32_t dwFilterType = XFA_WidgetStatus_Visible | (m_options.m_bPrint ? XFA_WidgetStatus_Printable : XFA_WidgetStatus_Viewable); - m_pWidgetIterator = - m_pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, dwFilterType); + m_pWidgetIterator.reset( + m_pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, dwFilterType)); m_pWidget = m_pWidgetIterator->MoveToNext(); return XFA_RENDERSTATUS_Ready; } + int32_t CXFA_RenderContext::DoRender(IFX_Pause* pPause) { int32_t iCount = 0; while (m_pWidget) { @@ -55,19 +56,16 @@ int32_t CXFA_RenderContext::DoRender(IFX_Pause* pPause) { pWidget->GetBBox(rtWidgetBox, XFA_WidgetStatus_Visible); rtWidgetBox.width += 1; rtWidgetBox.height += 1; - if (rtWidgetBox.IntersectWith(m_rtClipRect)) { + if (rtWidgetBox.IntersectWith(m_rtClipRect)) pWidget->RenderWidget(m_pGS, &m_matrix, m_dwStatus); - } m_pWidget = m_pWidgetIterator->MoveToNext(); iCount++; - if (iCount > XFA_RENDERCONTEXT_MaxCount && pPause && - pPause->NeedToPauseNow()) { + if (iCount > kMaxCount && pPause && pPause->NeedToPauseNow()) return XFA_RENDERSTATUS_ToBeContinued; - } } return XFA_RENDERSTATUS_Done; } + void CXFA_RenderContext::StopRender() { - delete m_pWidgetIterator; - m_pWidgetIterator = nullptr; + m_pWidgetIterator.reset(); } -- cgit v1.2.3