Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1096)

Unified Diff: xfa/fde/fde_render.cpp

Issue 2208423002: Use smart pointers for class owned pointers under xfa/fde (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: one more change Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « xfa/fde/fde_render.h ('k') | xfa/fde/tto/fde_textout.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fde/fde_render.cpp
diff --git a/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp
index e2c395eeb53e8e5da385fa293f086e5e9c105936..f3189b0877c86d5facf0d7353523a9eb22880701 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);
}
« no previous file with comments | « xfa/fde/fde_render.h ('k') | xfa/fde/tto/fde_textout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698