summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-18 12:50:41 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-18 12:50:41 -0700
commita039bc2d0142efe9148ed4580ef304b33570b431 (patch)
treebe4bed659f3c1cf50de9552ad58364fe8331c0e9
parente7b2853a4143137803609fe96330d7924c1731ed (diff)
downloadpdfium-a039bc2d0142efe9148ed4580ef304b33570b431.tar.xz
Remove Release() from CXFA_RenderContext
Review-Url: https://codereview.chromium.org/1994733002
-rw-r--r--fpdfsdk/fsdk_mgr.cpp3
-rw-r--r--xfa/fxfa/app/xfa_rendercontext.cpp36
-rw-r--r--xfa/fxfa/include/xfa_rendercontext.h5
3 files changed, 21 insertions, 23 deletions
diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/fsdk_mgr.cpp
index 40a891ca1e..3f957c7f3f 100644
--- a/fpdfsdk/fsdk_mgr.cpp
+++ b/fpdfsdk/fsdk_mgr.cpp
@@ -521,14 +521,13 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
static_cast<FX_FLOAT>(pClip.Width()),
static_cast<FX_FLOAT>(pClip.Height()));
gs.SetClipRect(rectClip);
- CXFA_RenderContext* pRenderContext = new CXFA_RenderContext;
+ std::unique_ptr<CXFA_RenderContext> pRenderContext(new CXFA_RenderContext);
CXFA_RenderOptions renderOptions;
renderOptions.m_bHighlight = TRUE;
CXFA_FFPageView* xfaView = pPage->GetXFAPageView();
pRenderContext->StartRender(xfaView, &gs, *pUser2Device, renderOptions);
pRenderContext->DoRender();
pRenderContext->StopRender();
- pRenderContext->Release();
CXFA_FFDocView* docView = xfaView->GetDocView();
if (!docView)
return;
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();
}
diff --git a/xfa/fxfa/include/xfa_rendercontext.h b/xfa/fxfa/include/xfa_rendercontext.h
index cd7949d78b..1154b8c5f4 100644
--- a/xfa/fxfa/include/xfa_rendercontext.h
+++ b/xfa/fxfa/include/xfa_rendercontext.h
@@ -7,6 +7,8 @@
#ifndef XFA_FXFA_INCLUDE_XFA_RENDERCONTEXT_H_
#define XFA_FXFA_INCLUDE_XFA_RENDERCONTEXT_H_
+#include <memory>
+
#include "xfa/fxfa/include/fxfa.h"
class CXFA_RenderContext {
@@ -14,7 +16,6 @@ class CXFA_RenderContext {
CXFA_RenderContext();
~CXFA_RenderContext();
- void Release() { delete this; }
int32_t StartRender(CXFA_FFPageView* pPageView,
CFX_Graphics* pGS,
const CFX_Matrix& matrix,
@@ -23,7 +24,7 @@ class CXFA_RenderContext {
void StopRender();
protected:
- IXFA_WidgetIterator* m_pWidgetIterator;
+ std::unique_ptr<IXFA_WidgetIterator> m_pWidgetIterator;
CXFA_FFWidget* m_pWidget;
CXFA_FFPageView* m_pPageView;
CFX_Graphics* m_pGS;