diff options
author | weili <weili@chromium.org> | 2016-08-04 15:43:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-04 15:43:59 -0700 |
commit | cddf8253692d3beaa97a502c8b60c1d18f81664a (patch) | |
tree | baa5b2456a1bdfec97fa97be2ef07eb3295a82d7 /xfa/fde/fde_render.cpp | |
parent | 32e693fe13105fab5baf81b334e932fce62d89b5 (diff) | |
download | pdfium-cddf8253692d3beaa97a502c8b60c1d18f81664a.tar.xz |
Use smart pointers for class owned pointers under xfa/fde
Use smart pointer to replace raw pointer type for class
owned member variables so that memory management will
be easier.
BUG=pdfium:518
Review-Url: https://codereview.chromium.org/2208423002
Diffstat (limited to 'xfa/fde/fde_render.cpp')
-rw-r--r-- | xfa/fde/fde_render.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp index e2c395eeb5..f3189b0877 100644 --- a/xfa/fde/fde_render.cpp +++ b/xfa/fde/fde_render.cpp @@ -16,9 +16,7 @@ CFDE_RenderContext::CFDE_RenderContext() : m_eStatus(FDE_RENDERSTATUS_Reset), m_pRenderDevice(nullptr), - m_Transform(), - m_pCharPos(nullptr), - m_iCharPosCount(0) { + m_Transform() { m_Transform.SetIdentity(); } @@ -101,9 +99,7 @@ void CFDE_RenderContext::StopRender() { m_Transform.SetIdentity(); m_pIterator.reset(); m_pBrush.reset(); - FX_Free(m_pCharPos); - m_pCharPos = nullptr; - m_iCharPosCount = 0; + m_CharPos.clear(); } void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet, @@ -122,19 +118,14 @@ void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet, if (!m_pBrush) m_pBrush.reset(new CFDE_Brush); - if (!m_pCharPos) - m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iCount); - else if (m_iCharPosCount < iCount) - m_pCharPos = FX_Realloc(FXTEXT_CHARPOS, m_pCharPos, iCount); + if (m_CharPos.size() < static_cast<size_t>(iCount)) + m_CharPos.resize(iCount, FXTEXT_CHARPOS()); - if (m_iCharPosCount < iCount) - m_iCharPosCount = iCount; - - iCount = pTextSet->GetDisplayPos(pText, m_pCharPos, FALSE); + iCount = pTextSet->GetDisplayPos(pText, m_CharPos.data(), FALSE); FX_FLOAT fFontSize = pTextSet->GetFontSize(); FX_ARGB dwColor = pTextSet->GetFontColor(); m_pBrush->SetColor(dwColor); - m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_pCharPos, iCount, + m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_CharPos.data(), iCount, fFontSize, &m_Transform); } |