summaryrefslogtreecommitdiff
path: root/xfa/fde/fde_render.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-11 10:26:05 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-11 10:26:05 -0700
commitf74ad998d2e8d2636fb25e94823946a3b151e34e (patch)
tree0b18e0a29fdc4bf1cce66ea437d8a4841b3daf4a /xfa/fde/fde_render.cpp
parent2c3a16a7698ba15476173e849f82c97ea3da9939 (diff)
downloadpdfium-f74ad998d2e8d2636fb25e94823946a3b151e34e.tar.xz
Replace some calls to Release() with direct delete, part 1.
Searching for the anti-pattern: void Release() { delete this; } We must be explicit on the ownership model. Add unique_ptrs as a result. Review-Url: https://codereview.chromium.org/1960673003
Diffstat (limited to 'xfa/fde/fde_render.cpp')
-rw-r--r--xfa/fde/fde_render.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp
index 7c989a0c6b..074a851e9f 100644
--- a/xfa/fde/fde_render.cpp
+++ b/xfa/fde/fde_render.cpp
@@ -16,11 +16,9 @@
CFDE_RenderContext::CFDE_RenderContext()
: m_eStatus(FDE_RENDERSTATUS_Reset),
m_pRenderDevice(nullptr),
- m_pBrush(nullptr),
m_Transform(),
m_pCharPos(nullptr),
- m_iCharPosCount(0),
- m_pIterator(nullptr) {
+ m_iCharPosCount(0) {
m_Transform.SetIdentity();
}
@@ -42,7 +40,7 @@ FX_BOOL CFDE_RenderContext::StartRender(CFDE_RenderDevice* pRenderDevice,
m_pRenderDevice = pRenderDevice;
m_Transform = tmDoc2Device;
if (!m_pIterator)
- m_pIterator = new CFDE_VisualSetIterator;
+ m_pIterator.reset(new CFDE_VisualSetIterator);
return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects();
}
@@ -101,12 +99,8 @@ void CFDE_RenderContext::StopRender() {
m_eStatus = FDE_RENDERSTATUS_Reset;
m_pRenderDevice = nullptr;
m_Transform.SetIdentity();
- if (m_pIterator) {
- m_pIterator->Release();
- m_pIterator = nullptr;
- }
- delete m_pBrush;
- m_pBrush = nullptr;
+ m_pIterator.reset();
+ m_pBrush.reset();
FX_Free(m_pCharPos);
m_pCharPos = nullptr;
m_iCharPosCount = 0;
@@ -126,7 +120,7 @@ void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet,
return;
if (!m_pBrush)
- m_pBrush = new CFDE_Brush;
+ m_pBrush.reset(new CFDE_Brush);
if (!m_pCharPos)
m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iCount);
@@ -142,8 +136,8 @@ void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet,
m_pBrush->SetColor(dwColor);
FDE_HDEVICESTATE hState;
FX_BOOL bClip = ApplyClip(pTextSet, hText, hState);
- m_pRenderDevice->DrawString(m_pBrush, pFont, m_pCharPos, iCount, fFontSize,
- &m_Transform);
+ m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_pCharPos, iCount,
+ fFontSize, &m_Transform);
if (bClip)
RestoreClip(hState);
}