diff options
author | tsepez <tsepez@chromium.org> | 2016-12-14 05:57:10 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-12-14 05:57:10 -0800 |
commit | a9caab94c1f16929e5acf2676117224617d80f53 (patch) | |
tree | d71ff9a82fae6e6080deb76375f43056127b3ee2 /core/fpdfapi/render | |
parent | 992ecf7c189e5cabf43e5ad862511cf63d030966 (diff) | |
download | pdfium-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/render')
-rw-r--r-- | core/fpdfapi/render/cpdf_devicebuffer.cpp | 3 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_imagerenderer.cpp | 5 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_progressiverenderer.cpp | 3 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 9 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp | 3 | ||||
-rw-r--r-- | core/fpdfapi/render/fpdf_render_loadimage.cpp | 11 |
6 files changed, 20 insertions, 14 deletions
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; |