summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-21 13:10:34 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-21 20:55:15 +0000
commit0748d3cb67926bfd38d3d67901fdda87109c6895 (patch)
tree36a6934a9ee51edf8032c3579580ba2f281be71a /core/fpdfapi
parente150045e9d1944b654b600c0d77f924ee0c5032d (diff)
downloadpdfium-0748d3cb67926bfd38d3d67901fdda87109c6895.tar.xz
Return unique_ptr from CPDF_Type3Cache::RenderGlyph().
Change-Id: I0701c6e5a9c1789f5fe929778df0e2aa55d8bf00 Reviewed-on: https://pdfium-review.googlesource.com/4434 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/render/cpdf_type3cache.cpp20
-rw-r--r--core/fpdfapi/render/cpdf_type3cache.h10
-rw-r--r--core/fpdfapi/render/cpdf_type3glyphs.cpp5
-rw-r--r--core/fpdfapi/render/cpdf_type3glyphs.h3
4 files changed, 19 insertions, 19 deletions
diff --git a/core/fpdfapi/render/cpdf_type3cache.cpp b/core/fpdfapi/render/cpdf_type3cache.cpp
index b7a4cb808f..699b24f15c 100644
--- a/core/fpdfapi/render/cpdf_type3cache.cpp
+++ b/core/fpdfapi/render/cpdf_type3cache.cpp
@@ -104,19 +104,21 @@ CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode,
}
auto it2 = pSizeCache->m_GlyphMap.find(charcode);
if (it2 != pSizeCache->m_GlyphMap.end())
- return it2->second;
+ return it2->second.get();
- CFX_GlyphBitmap* pGlyphBitmap =
+ std::unique_ptr<CFX_GlyphBitmap> pNewBitmap =
RenderGlyph(pSizeCache, charcode, pMatrix, retinaScaleX, retinaScaleY);
- pSizeCache->m_GlyphMap[charcode] = pGlyphBitmap;
+ CFX_GlyphBitmap* pGlyphBitmap = pNewBitmap.get();
+ pSizeCache->m_GlyphMap[charcode] = std::move(pNewBitmap);
return pGlyphBitmap;
}
-CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
- uint32_t charcode,
- const CFX_Matrix* pMatrix,
- float retinaScaleX,
- float retinaScaleY) {
+std::unique_ptr<CFX_GlyphBitmap> CPDF_Type3Cache::RenderGlyph(
+ CPDF_Type3Glyphs* pSize,
+ uint32_t charcode,
+ const CFX_Matrix* pMatrix,
+ float retinaScaleX,
+ float retinaScaleY) {
const CPDF_Type3Char* pChar = m_pFont->LoadChar(charcode);
if (!pChar || !pChar->m_pBitmap)
return nullptr;
@@ -163,7 +165,7 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
if (!pResBitmap)
return nullptr;
- CFX_GlyphBitmap* pGlyph = new CFX_GlyphBitmap;
+ auto pGlyph = pdfium::MakeUnique<CFX_GlyphBitmap>();
pGlyph->m_Left = left;
pGlyph->m_Top = -top;
pGlyph->m_pBitmap->TakeOver(std::move(pResBitmap));
diff --git a/core/fpdfapi/render/cpdf_type3cache.h b/core/fpdfapi/render/cpdf_type3cache.h
index dc3e91b359..3c7d95b8c0 100644
--- a/core/fpdfapi/render/cpdf_type3cache.h
+++ b/core/fpdfapi/render/cpdf_type3cache.h
@@ -32,11 +32,11 @@ class CPDF_Type3Cache : public CFX_Retainable {
explicit CPDF_Type3Cache(CPDF_Type3Font* pFont);
~CPDF_Type3Cache() override;
- CFX_GlyphBitmap* RenderGlyph(CPDF_Type3Glyphs* pSize,
- uint32_t charcode,
- const CFX_Matrix* pMatrix,
- float retinaScaleX,
- float retinaScaleY);
+ std::unique_ptr<CFX_GlyphBitmap> RenderGlyph(CPDF_Type3Glyphs* pSize,
+ uint32_t charcode,
+ const CFX_Matrix* pMatrix,
+ float retinaScaleX,
+ float retinaScaleY);
CPDF_Type3Font* const m_pFont;
std::map<CFX_ByteString, std::unique_ptr<CPDF_Type3Glyphs>> m_SizeMap;
diff --git a/core/fpdfapi/render/cpdf_type3glyphs.cpp b/core/fpdfapi/render/cpdf_type3glyphs.cpp
index 5fce32ce93..01b689f80f 100644
--- a/core/fpdfapi/render/cpdf_type3glyphs.cpp
+++ b/core/fpdfapi/render/cpdf_type3glyphs.cpp
@@ -13,10 +13,7 @@
CPDF_Type3Glyphs::CPDF_Type3Glyphs()
: m_TopBlueCount(0), m_BottomBlueCount(0) {}
-CPDF_Type3Glyphs::~CPDF_Type3Glyphs() {
- for (const auto& pair : m_GlyphMap)
- delete pair.second;
-}
+CPDF_Type3Glyphs::~CPDF_Type3Glyphs() {}
static int _AdjustBlue(float pos, int& count, int blues[]) {
float min_distance = 1000000.0f;
diff --git a/core/fpdfapi/render/cpdf_type3glyphs.h b/core/fpdfapi/render/cpdf_type3glyphs.h
index 443910dac0..778b639642 100644
--- a/core/fpdfapi/render/cpdf_type3glyphs.h
+++ b/core/fpdfapi/render/cpdf_type3glyphs.h
@@ -8,6 +8,7 @@
#define CORE_FPDFAPI_RENDER_CPDF_TYPE3GLYPHS_H_
#include <map>
+#include <memory>
#include "core/fxcrt/fx_system.h"
@@ -22,7 +23,7 @@ class CPDF_Type3Glyphs {
void AdjustBlue(float top, float bottom, int& top_line, int& bottom_line);
- std::map<uint32_t, CFX_GlyphBitmap*> m_GlyphMap;
+ std::map<uint32_t, std::unique_ptr<CFX_GlyphBitmap>> m_GlyphMap;
int m_TopBlue[TYPE3_MAX_BLUES];
int m_BottomBlue[TYPE3_MAX_BLUES];
int m_TopBlueCount;