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

Unified Diff: xfa/fde/tto/fde_textout.cpp

Issue 1960673003: Replace some calls to Release() with direct delete, part 1. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Add unique ptrs Created 4 years, 7 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
Index: xfa/fde/tto/fde_textout.cpp
diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp
index fc97d9912588397aa63347c41f53ea250fd10731..e5bd596b0c0d55236228add4d632cc353cb7c700 100644
--- a/xfa/fde/tto/fde_textout.cpp
+++ b/xfa/fde/tto/fde_textout.cpp
@@ -40,8 +40,7 @@ CFDE_TextOut::CFDE_TextOut()
m_iCurPiece(0),
m_iTotalLines(0),
m_pCharPos(NULL),
- m_iCharPosSize(0),
- m_pRenderDevice(NULL) {
+ m_iCharPosSize(0) {
m_pTxtBreak = new CFX_TxtBreak(FX_TXTBREAKPOLICY_None);
m_Matrix.SetIdentity();
m_rtClip.Reset();
@@ -53,9 +52,6 @@ CFDE_TextOut::~CFDE_TextOut() {
}
FX_Free(m_pCharWidths);
FX_Free(m_pEllCharWidths);
- if (m_pRenderDevice) {
- m_pRenderDevice->Release();
- }
FX_Free(m_pCharPos);
m_ttoLines.RemoveAll();
}
@@ -134,21 +130,15 @@ void CFDE_TextOut::SetLineSpace(FX_FLOAT fLineSpace) {
void CFDE_TextOut::SetDIBitmap(CFX_DIBitmap* pDIB) {
ASSERT(pDIB);
- if (m_pRenderDevice)
- m_pRenderDevice->Release();
-
+ m_pRenderDevice.reset();
CFX_FxgeDevice* device = new CFX_FxgeDevice;
device->Attach(pDIB, 0, FALSE);
- m_pRenderDevice = new CFDE_RenderDevice(device, FALSE);
+ m_pRenderDevice.reset(new CFDE_RenderDevice(device, FALSE));
}
void CFDE_TextOut::SetRenderDevice(CFX_RenderDevice* pDevice) {
ASSERT(pDevice);
-
- if (m_pRenderDevice)
- m_pRenderDevice->Release();
-
- m_pRenderDevice = new CFDE_RenderDevice(pDevice, FALSE);
+ m_pRenderDevice.reset(new CFDE_RenderDevice(pDevice, FALSE));
}
void CFDE_TextOut::SetClipRect(const CFX_Rect& rtClip) {
@@ -780,13 +770,13 @@ void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) {
}
}
void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) {
- if (m_pRenderDevice == NULL) {
+ if (!m_pRenderDevice)
return;
- }
+
int32_t iLines = m_ttoLines.GetSize();
- if (iLines < 1) {
+ if (iLines < 1)
return;
- }
+
CFDE_Brush* pBrush = new CFDE_Brush;
pBrush->SetColor(m_TxtColor);
CFDE_Pen* pPen = NULL;
@@ -916,7 +906,7 @@ void CFDE_TextOut::DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen*& pPen) {
if (iLineCount > 0) {
m_pRenderDevice->DrawPath(pPen, 1, pPath, &m_Matrix);
}
- pPath->Release();
+ delete pPath;
Wei Li 2016/05/06 22:01:21 Nit: why not use unique_ptr for pPath as well?
Tom Sepez 2016/05/11 17:05:39 Done.
}
CFDE_TTOLine::CFDE_TTOLine()
: m_bNewReload(FALSE), m_pieces(5), m_iPieceCount(0) {}

Powered by Google App Engine
This is Rietveld 408576698