summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-14 05:57:10 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-14 05:57:10 -0800
commita9caab94c1f16929e5acf2676117224617d80f53 (patch)
treed71ff9a82fae6e6080deb76375f43056127b3ee2 /core/fpdfapi
parent992ecf7c189e5cabf43e5ad862511cf63d030966 (diff)
downloadpdfium-a9caab94c1f16929e5acf2676117224617d80f53.tar.xz
Avoid the ptr.reset(new XXX()) anti-pattern
Be suspicious of |new|. This removes some of the easy cases. Review-Url: https://codereview.chromium.org/2571913002
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/cpdf_modulemgr.cpp3
-rw-r--r--core/fpdfapi/edit/fpdf_edit_create.cpp5
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.cpp5
-rw-r--r--core/fpdfapi/font/cpdf_font.cpp12
-rw-r--r--core/fpdfapi/font/fpdf_font.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_contentparser.cpp15
-rw-r--r--core/fpdfapi/page/cpdf_form.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_page.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_tilingpattern.cpp3
-rw-r--r--core/fpdfapi/page/fpdf_page_func.cpp11
-rw-r--r--core/fpdfapi/parser/cpdf_document_unittest.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp5
-rw-r--r--core/fpdfapi/parser/cpdf_stream.cpp3
-rw-r--r--core/fpdfapi/render/cpdf_devicebuffer.cpp3
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp5
-rw-r--r--core/fpdfapi/render/cpdf_progressiverenderer.cpp3
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp9
-rw-r--r--core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp3
-rw-r--r--core/fpdfapi/render/fpdf_render_loadimage.cpp11
19 files changed, 62 insertions, 45 deletions
diff --git a/core/fpdfapi/cpdf_modulemgr.cpp b/core/fpdfapi/cpdf_modulemgr.cpp
index 8ae8464ef5..ac28b36663 100644
--- a/core/fpdfapi/cpdf_modulemgr.cpp
+++ b/core/fpdfapi/cpdf_modulemgr.cpp
@@ -8,6 +8,7 @@
#include "core/fpdfapi/page/cpdf_pagemodule.h"
#include "core/fxcodec/fx_codec.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -33,7 +34,7 @@ CPDF_ModuleMgr::CPDF_ModuleMgr() : m_pCodecModule(nullptr) {}
CPDF_ModuleMgr::~CPDF_ModuleMgr() {}
void CPDF_ModuleMgr::InitPageModule() {
- m_pPageModule.reset(new CPDF_PageModule);
+ m_pPageModule = pdfium::MakeUnique<CPDF_PageModule>();
}
CCodec_FaxModule* CPDF_ModuleMgr::GetFaxModule() {
diff --git a/core/fpdfapi/edit/fpdf_edit_create.cpp b/core/fpdfapi/edit/fpdf_edit_create.cpp
index 62314f43f5..7b38883ef8 100644
--- a/core/fpdfapi/edit/fpdf_edit_create.cpp
+++ b/core/fpdfapi/edit/fpdf_edit_create.cpp
@@ -25,6 +25,7 @@
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/fx_ext.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#define PDF_OBJECTSTREAM_MAXLENGTH (256 * 1024)
@@ -1446,7 +1447,7 @@ int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) {
CPDF_Dictionary* pDict = m_pDocument->GetRoot();
m_pMetadata = pDict ? pDict->GetDirectObjectFor("Metadata") : nullptr;
if (m_dwFlags & FPDFCREATE_OBJECTSTREAM) {
- m_pXRefStream.reset(new CPDF_XRefStream);
+ m_pXRefStream = pdfium::MakeUnique<CPDF_XRefStream>();
m_pXRefStream->Start();
if ((m_dwFlags & FPDFCREATE_INCREMENTAL) != 0 && m_pParser) {
FX_FILESIZE prev = m_pParser->GetLastXRefOffset();
@@ -1929,7 +1930,7 @@ void CPDF_Creator::InitID(bool bDefault) {
CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : nullptr;
bool bNewId = !m_pIDArray;
if (bNewId) {
- m_pIDArray.reset(new CPDF_Array);
+ m_pIDArray = pdfium::MakeUnique<CPDF_Array>();
CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetObjectAt(0) : nullptr;
if (pID1) {
m_pIDArray->Add(pID1->Clone());
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index 0217391c12..91df025e0f 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -19,6 +19,7 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "third_party/base/numerics/safe_math.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -398,7 +399,7 @@ bool CPDF_CIDFont::Load() {
CPDF_Object* pmap = pCIDFontDict->GetDirectObjectFor("CIDToGIDMap");
if (pmap) {
if (CPDF_Stream* pStream = pmap->AsStream()) {
- m_pStreamAcc.reset(new CPDF_StreamAcc);
+ m_pStreamAcc = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pStreamAcc->LoadAllData(pStream, false);
} else if (pmap->GetString() == "Identity") {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
@@ -581,7 +582,7 @@ int CPDF_CIDFont::GetGlyphIndex(uint32_t unicode, bool* pVertGlyph) {
if (error || !m_Font.GetSubData())
return index;
- m_pTTGSUBTable.reset(new CFX_CTTGSUBTable);
+ m_pTTGSUBTable = pdfium::MakeUnique<CFX_CTTGSUBTable>();
m_pTTGSUBTable->LoadGSUBTable((FT_Bytes)m_Font.GetSubData());
return GetVerticalGlyph(index, pVertGlyph);
}
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index 0b76ceedff..5563202455 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -279,7 +279,7 @@ void CPDF_Font::LoadUnicodeMap() const {
if (!pStream) {
return;
}
- m_pToUnicodeMap.reset(new CPDF_ToUnicodeMap);
+ m_pToUnicodeMap = pdfium::MakeUnique<CPDF_ToUnicodeMap>();
m_pToUnicodeMap->Load(pStream);
}
@@ -324,18 +324,18 @@ std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc,
if (tag == CFX_ByteString(kChineseFontNames[i], 4)) {
CPDF_Dictionary* pFontDesc = pFontDict->GetDictFor("FontDescriptor");
if (!pFontDesc || !pFontDesc->KeyExist("FontFile2"))
- pFont.reset(new CPDF_CIDFont);
+ pFont = pdfium::MakeUnique<CPDF_CIDFont>();
break;
}
}
if (!pFont)
- pFont.reset(new CPDF_TrueTypeFont);
+ pFont = pdfium::MakeUnique<CPDF_TrueTypeFont>();
} else if (type == "Type3") {
- pFont.reset(new CPDF_Type3Font);
+ pFont = pdfium::MakeUnique<CPDF_Type3Font>();
} else if (type == "Type0") {
- pFont.reset(new CPDF_CIDFont);
+ pFont = pdfium::MakeUnique<CPDF_CIDFont>();
} else {
- pFont.reset(new CPDF_Type1Font);
+ pFont = pdfium::MakeUnique<CPDF_Type1Font>();
}
pFont->m_pFontDict = pFontDict;
pFont->m_pDocument = pDoc;
diff --git a/core/fpdfapi/font/fpdf_font.cpp b/core/fpdfapi/font/fpdf_font.cpp
index bf1fac4518..7bbd637177 100644
--- a/core/fpdfapi/font/fpdf_font.cpp
+++ b/core/fpdfapi/font/fpdf_font.cpp
@@ -24,6 +24,7 @@
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxge/fx_freetype.h"
#include "third_party/base/numerics/safe_conversions.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
int TT2PDF(int m, FXFT_Face face) {
@@ -87,7 +88,7 @@ CPDF_Font* CPDF_FontGlobals::Set(CPDF_Document* pDoc,
uint32_t index,
std::unique_ptr<CPDF_Font> pFont) {
if (!pdfium::ContainsKey(m_StockMap, pDoc))
- m_StockMap[pDoc].reset(new CFX_StockFontArray);
+ m_StockMap[pDoc] = pdfium::MakeUnique<CFX_StockFontArray>();
return m_StockMap[pDoc]->SetFont(index, std::move(pFont));
}
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index 0b8574bfd4..1e0fe62e09 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -17,6 +17,7 @@
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/ptr_util.h"
#define PARSE_STEP_LIMIT 100
@@ -54,7 +55,7 @@ void CPDF_ContentParser::Start(CPDF_Page* pPage) {
}
if (CPDF_Stream* pStream = pContent->AsStream()) {
m_nStreams = 0;
- m_pSingleStream.reset(new CPDF_StreamAcc);
+ m_pSingleStream = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pSingleStream->LoadAllData(pStream, false);
} else if (CPDF_Array* pArray = pContent->AsArray()) {
m_nStreams = pArray->GetCount();
@@ -94,9 +95,9 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm,
form_bbox.Transform(pParentMatrix);
}
CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictFor("Resources");
- m_pParser.reset(new CPDF_StreamContentParser(
+ m_pParser = pdfium::MakeUnique<CPDF_StreamContentParser>(
pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources,
- pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level));
+ pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level);
m_pParser->GetCurStates()->m_CTM = form_matrix;
m_pParser->GetCurStates()->m_ParentMatrix = form_matrix;
if (ClipPath) {
@@ -111,7 +112,7 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm,
pState->SetSoftMask(nullptr);
}
m_nStreams = 0;
- m_pSingleStream.reset(new CPDF_StreamAcc);
+ m_pSingleStream = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pSingleStream->LoadAllData(pForm->m_pFormStream, false);
m_pData = (uint8_t*)m_pSingleStream->GetData();
m_Size = m_pSingleStream->GetSize();
@@ -153,7 +154,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
} else {
CPDF_Array* pContent =
m_pObjectHolder->m_pFormDict->GetArrayFor("Contents");
- m_StreamArray[m_CurrentOffset].reset(new CPDF_StreamAcc);
+ m_StreamArray[m_CurrentOffset] = pdfium::MakeUnique<CPDF_StreamAcc>();
CPDF_Stream* pStreamObj = ToStream(
pContent ? pContent->GetDirectObjectAt(m_CurrentOffset) : nullptr);
m_StreamArray[m_CurrentOffset]->LoadAllData(pStreamObj, false);
@@ -162,10 +163,10 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
}
if (m_InternalStage == STAGE_PARSE) {
if (!m_pParser) {
- m_pParser.reset(new CPDF_StreamContentParser(
+ m_pParser = pdfium::MakeUnique<CPDF_StreamContentParser>(
m_pObjectHolder->m_pDocument, m_pObjectHolder->m_pPageResources,
nullptr, nullptr, m_pObjectHolder, m_pObjectHolder->m_pResources,
- &m_pObjectHolder->m_BBox, nullptr, 0));
+ &m_pObjectHolder->m_BBox, nullptr, 0);
m_pParser->GetCurStates()->m_ColorState.SetDefault();
}
if (m_CurrentOffset >= m_Size) {
diff --git a/core/fpdfapi/page/cpdf_form.cpp b/core/fpdfapi/page/cpdf_form.cpp
index 3a5fa0a74a..b3f2b372e3 100644
--- a/core/fpdfapi/page/cpdf_form.cpp
+++ b/core/fpdfapi/page/cpdf_form.cpp
@@ -12,6 +12,7 @@
#include "core/fpdfapi/page/pageint.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
+#include "third_party/base/ptr_util.h"
CPDF_Form::CPDF_Form(CPDF_Document* pDoc,
CPDF_Dictionary* pPageResources,
@@ -39,7 +40,7 @@ void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates,
if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING)
return;
- m_pParser.reset(new CPDF_ContentParser);
+ m_pParser = pdfium::MakeUnique<CPDF_ContentParser>();
m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, level);
m_ParseState = CONTENT_PARSING;
}
diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
index b4e2e67939..f9c02837a7 100644
--- a/core/fpdfapi/page/cpdf_page.cpp
+++ b/core/fpdfapi/page/cpdf_page.cpp
@@ -17,6 +17,7 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfapi/render/cpdf_pagerendercache.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
CPDF_Page::CPDF_Page(CPDF_Document* pDocument,
@@ -88,7 +89,7 @@ void CPDF_Page::StartParse() {
if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING)
return;
- m_pParser.reset(new CPDF_ContentParser);
+ m_pParser = pdfium::MakeUnique<CPDF_ContentParser>();
m_pParser->Start(this);
m_ParseState = CONTENT_PARSING;
}
diff --git a/core/fpdfapi/page/cpdf_tilingpattern.cpp b/core/fpdfapi/page/cpdf_tilingpattern.cpp
index 1b7bee4366..a041f38074 100644
--- a/core/fpdfapi/page/cpdf_tilingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_tilingpattern.cpp
@@ -10,6 +10,7 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
+#include "third_party/base/ptr_util.h"
CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc,
CPDF_Object* pPatternObj,
@@ -47,7 +48,7 @@ bool CPDF_TilingPattern::Load() {
if (!pStream)
return false;
- m_pForm.reset(new CPDF_Form(m_pDocument, nullptr, pStream));
+ m_pForm = pdfium::MakeUnique<CPDF_Form>(m_pDocument, nullptr, pStream);
m_pForm->ParseContent(nullptr, &m_ParentMatrix, nullptr);
m_BBox = pDict->GetRectFor("BBox");
return true;
diff --git a/core/fpdfapi/page/fpdf_page_func.cpp b/core/fpdfapi/page/fpdf_page_func.cpp
index a6c73b0e5f..672bfc02be 100644
--- a/core/fpdfapi/page/fpdf_page_func.cpp
+++ b/core/fpdfapi/page/fpdf_page_func.cpp
@@ -20,6 +20,7 @@
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -495,7 +496,7 @@ bool CPDF_SampledFunc::v_Init(CPDF_Object* pObj) {
return false;
m_SampleMax = 0xffffffff >> (32 - m_nBitsPerSample);
- m_pSampleStream.reset(new CPDF_StreamAcc);
+ m_pSampleStream = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pSampleStream->LoadAllData(pStream, false);
FX_SAFE_UINT32 nTotalSampleBits = 1;
m_EncodeInfo.resize(m_nInputs);
@@ -742,13 +743,13 @@ std::unique_ptr<CPDF_Function> CPDF_Function::Load(CPDF_Object* pFuncObj) {
Type type = IntegerToFunctionType(iType);
if (type == Type::kType0Sampled)
- pFunc.reset(new CPDF_SampledFunc());
+ pFunc = pdfium::MakeUnique<CPDF_SampledFunc>();
else if (type == Type::kType2ExpotentialInterpolation)
- pFunc.reset(new CPDF_ExpIntFunc());
+ pFunc = pdfium::MakeUnique<CPDF_ExpIntFunc>();
else if (type == Type::kType3Stitching)
- pFunc.reset(new CPDF_StitchFunc());
+ pFunc = pdfium::MakeUnique<CPDF_StitchFunc>();
else if (type == Type::kType4PostScript)
- pFunc.reset(new CPDF_PSFunc());
+ pFunc = pdfium::MakeUnique<CPDF_PSFunc>();
if (!pFunc || !pFunc->Init(pFuncObj))
return nullptr;
diff --git a/core/fpdfapi/parser/cpdf_document_unittest.cpp b/core/fpdfapi/parser/cpdf_document_unittest.cpp
index e4fe033c8a..91beba3a6b 100644
--- a/core/fpdfapi/parser/cpdf_document_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_document_unittest.cpp
@@ -108,7 +108,7 @@ class CPDF_TestDocumentWithPageWithoutPageNum : public CPDF_Document {
allPages->Add(CreateNumberedPage(2));
CPDF_Dictionary* pagesDict =
CreatePageTreeNode(std::move(allPages), this, 3);
- m_pOwnedRootDict.reset(new CPDF_Dictionary());
+ m_pOwnedRootDict = pdfium::MakeUnique<CPDF_Dictionary>();
m_pOwnedRootDict->SetNewFor<CPDF_Reference>("Pages", this,
pagesDict->GetObjNum());
m_pRootDict = m_pOwnedRootDict.get();
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index 47c5c4eab4..62364c0a75 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -24,6 +24,7 @@
#include "core/fpdfapi/parser/fpdf_parser_utility.h"
#include "core/fxcrt/fx_ext.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
namespace {
@@ -57,7 +58,7 @@ CPDF_Parser::CPDF_Parser()
m_FileVersion(0),
m_pEncryptDict(nullptr),
m_dwXrefStartObjNum(0) {
- m_pSyntax.reset(new CPDF_SyntaxParser);
+ m_pSyntax = pdfium::MakeUnique<CPDF_SyntaxParser>();
}
CPDF_Parser::~CPDF_Parser() {
@@ -242,7 +243,7 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() {
std::unique_ptr<CPDF_SecurityHandler> pSecurityHandler;
Error err = HANDLER_ERROR;
if (filter == "Standard") {
- pSecurityHandler.reset(new CPDF_SecurityHandler);
+ pSecurityHandler = pdfium::MakeUnique<CPDF_SecurityHandler>();
err = PASSWORD_ERROR;
}
if (!pSecurityHandler)
diff --git a/core/fpdfapi/parser/cpdf_stream.cpp b/core/fpdfapi/parser/cpdf_stream.cpp
index 4f76ec1c63..3159791e82 100644
--- a/core/fpdfapi/parser/cpdf_stream.cpp
+++ b/core/fpdfapi/parser/cpdf_stream.cpp
@@ -13,6 +13,7 @@
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
#include "third_party/base/numerics/safe_conversions.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
CPDF_Stream::CPDF_Stream() {}
@@ -103,7 +104,7 @@ void CPDF_Stream::SetData(const uint8_t* pData, uint32_t size) {
FXSYS_memcpy(m_pDataBuf.get(), pData, size);
m_dwSize = size;
if (!m_pDict)
- m_pDict.reset(new CPDF_Dictionary());
+ m_pDict = pdfium::MakeUnique<CPDF_Dictionary>();
m_pDict->SetNewFor<CPDF_Number>("Length", static_cast<int>(size));
m_pDict->RemoveFor("Filter");
m_pDict->RemoveFor("DecodeParms");
diff --git a/core/fpdfapi/render/cpdf_devicebuffer.cpp b/core/fpdfapi/render/cpdf_devicebuffer.cpp
index 06b4d13c7a..edc91802fb 100644
--- a/core/fpdfapi/render/cpdf_devicebuffer.cpp
+++ b/core/fpdfapi/render/cpdf_devicebuffer.cpp
@@ -12,6 +12,7 @@
#include "core/fxge/cfx_fxgedevice.h"
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/fx_dib.h"
+#include "third_party/base/ptr_util.h"
CPDF_DeviceBuffer::CPDF_DeviceBuffer()
: m_pDevice(nullptr), m_pContext(nullptr), m_pObject(nullptr) {}
@@ -49,7 +50,7 @@ bool CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext,
CFX_FloatRect rect(*pRect);
m_Matrix.TransformRect(rect);
FX_RECT bitmap_rect = rect.GetOuterRect();
- m_pBitmap.reset(new CFX_DIBitmap);
+ m_pBitmap = pdfium::MakeUnique<CFX_DIBitmap>();
m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb);
return true;
}
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index eae32443d8..5ca7ea842f 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -28,6 +28,7 @@
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxge/cfx_fxgedevice.h"
#include "core/fxge/cfx_pathdata.h"
+#include "third_party/base/ptr_util.h"
#ifdef _SKIA_SUPPORT_
#include "core/fxge/skia/fx_skia_device.h"
@@ -437,8 +438,8 @@ bool CPDF_ImageRenderer::StartDIBSource() {
FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox();
clip_box.Intersect(image_rect);
m_Status = 2;
- m_pTransformer.reset(new CFX_ImageTransformer(m_pDIBSource, &m_ImageMatrix,
- m_Flags, &clip_box));
+ m_pTransformer = pdfium::MakeUnique<CFX_ImageTransformer>(
+ m_pDIBSource, &m_ImageMatrix, m_Flags, &clip_box);
m_pTransformer->Start();
return true;
}
diff --git a/core/fpdfapi/render/cpdf_progressiverenderer.cpp b/core/fpdfapi/render/cpdf_progressiverenderer.cpp
index 46d78b6c4e..6aa3b8a309 100644
--- a/core/fpdfapi/render/cpdf_progressiverenderer.cpp
+++ b/core/fpdfapi/render/cpdf_progressiverenderer.cpp
@@ -12,6 +12,7 @@
#include "core/fpdfapi/render/cpdf_renderoptions.h"
#include "core/fpdfapi/render/cpdf_renderstatus.h"
#include "core/fxge/cfx_renderdevice.h"
+#include "third_party/base/ptr_util.h"
CPDF_ProgressiveRenderer::CPDF_ProgressiveRenderer(
CPDF_RenderContext* pContext,
@@ -48,7 +49,7 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex);
m_LastObjectRendered =
m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end();
- m_pRenderStatus.reset(new CPDF_RenderStatus());
+ m_pRenderStatus = pdfium::MakeUnique<CPDF_RenderStatus>();
m_pRenderStatus->Initialize(
m_pContext, m_pDevice, nullptr, nullptr, nullptr, nullptr, m_pOptions,
m_pCurrentLayer->m_pObjectHolder->m_Transparency, false, nullptr);
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index b23b98cdb1..3897963de8 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -54,6 +54,7 @@
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/ifx_renderdevicedriver.h"
#include "third_party/base/numerics/safe_math.h"
+#include "third_party/base/ptr_util.h"
#ifdef _SKIA_SUPPORT_
#include "core/fxge/skia/fx_skia_device.h"
@@ -1079,7 +1080,7 @@ bool CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject* pObj,
return false;
if (pObj->IsImage()) {
- m_pImageRenderer.reset(new CPDF_ImageRenderer);
+ m_pImageRenderer = pdfium::MakeUnique<CPDF_ImageRenderer>();
if (!m_pImageRenderer->Start(this, pObj, pObj2Device, false,
FXDIB_BLEND_NORMAL)) {
if (!m_pImageRenderer->GetResult())
@@ -1382,7 +1383,7 @@ void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath,
CPDF_TextObject* pText = ClipPath.GetText(i);
if (pText) {
if (!pTextClippingPath)
- pTextClippingPath.reset(new CFX_PathData);
+ pTextClippingPath = pdfium::MakeUnique<CFX_PathData>();
ProcessText(pText, pObj2Device, pTextClippingPath.get());
continue;
}
@@ -1513,7 +1514,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
CFX_FxgeDevice bitmap_device;
std::unique_ptr<CFX_DIBitmap> oriDevice;
if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) {
- oriDevice.reset(new CFX_DIBitmap);
+ oriDevice = pdfium::MakeUnique<CFX_DIBitmap>();
if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height))
return true;
m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top);
@@ -1527,7 +1528,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
new_matrix.Scale(scaleX, scaleY);
std::unique_ptr<CFX_DIBitmap> pTextMask;
if (bTextClip) {
- pTextMask.reset(new CFX_DIBitmap);
+ pTextMask = pdfium::MakeUnique<CFX_DIBitmap>();
if (!pTextMask->Create(width, height, FXDIB_8bppMask))
return true;
diff --git a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
index a14bb9ea43..bcc03ba2dd 100644
--- a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
+++ b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
@@ -10,6 +10,7 @@
#include "core/fpdfapi/render/cpdf_renderoptions.h"
#include "core/fxge/cfx_fxgedevice.h"
#include "core/fxge/cfx_renderdevice.h"
+#include "third_party/base/ptr_util.h"
#define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024)
@@ -43,7 +44,7 @@ bool CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext,
if (dpiv > max_dpi)
m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv);
}
- m_pBitmapDevice.reset(new CFX_FxgeDevice);
+ m_pBitmapDevice = pdfium::MakeUnique<CFX_FxgeDevice>();
FXDIB_Format dibFormat = FXDIB_Rgb;
int32_t bpp = 24;
if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_ALPHA_OUTPUT) {
diff --git a/core/fpdfapi/render/fpdf_render_loadimage.cpp b/core/fpdfapi/render/fpdf_render_loadimage.cpp
index 085077f2e9..4a018a849d 100644
--- a/core/fpdfapi/render/fpdf_render_loadimage.cpp
+++ b/core/fpdfapi/render/fpdf_render_loadimage.cpp
@@ -22,6 +22,7 @@
#include "core/fpdfapi/render/cpdf_renderstatus.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -171,7 +172,7 @@ bool CPDF_DIBSource::Load(CPDF_Document* pDoc,
if (!src_size.IsValid()) {
return false;
}
- m_pStreamAcc.reset(new CPDF_StreamAcc);
+ m_pStreamAcc = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pStreamAcc->LoadAllData(pStream, false, src_size.ValueOrDie(), true);
if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData()) {
return false;
@@ -293,7 +294,7 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc,
if (!src_size.IsValid()) {
return 0;
}
- m_pStreamAcc.reset(new CPDF_StreamAcc);
+ m_pStreamAcc = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pStreamAcc->LoadAllData(pStream, false, src_size.ValueOrDie(), true);
if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData()) {
return 0;
@@ -335,12 +336,12 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) {
}
CCodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module();
if (!m_pJbig2Context) {
- m_pJbig2Context.reset(new CCodec_Jbig2Context());
+ m_pJbig2Context = pdfium::MakeUnique<CCodec_Jbig2Context>();
if (m_pStreamAcc->GetImageParam()) {
CPDF_Stream* pGlobals =
m_pStreamAcc->GetImageParam()->GetStreamFor("JBIG2Globals");
if (pGlobals) {
- m_pGlobalStream.reset(new CPDF_StreamAcc);
+ m_pGlobalStream = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pGlobalStream->LoadAllData(pGlobals, false);
}
}
@@ -676,7 +677,7 @@ void CPDF_DIBSource::LoadJpxBitmap() {
format = FXDIB_Rgb;
}
- m_pCachedBitmap.reset(new CFX_DIBitmap);
+ m_pCachedBitmap = pdfium::MakeUnique<CFX_DIBitmap>();
if (!m_pCachedBitmap->Create(width, height, format)) {
m_pCachedBitmap.reset();
return;