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

Side by Side Diff: core/src/fxge/ge/fx_ge_text.cpp

Issue 1297723002: CFX_MapByteStringToPtr considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Const auto& Created 5 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 unified diff | Download patch
« no previous file with comments | « core/src/fxge/ge/fx_ge_linux.cpp ('k') | fpdfsdk/include/fsdk_annothandler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../../include/fxge/fx_ge.h" 7 #include "../../../include/fxge/fx_ge.h"
8 #include "../../../include/fxge/fx_freetype.h" 8 #include "../../../include/fxge/fx_freetype.h"
9 #include "../../../include/fxcodec/fx_codec.h" 9 #include "../../../include/fxcodec/fx_codec.h"
10 #include "text_int.h" 10 #include "text_int.h"
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 delete cache; 1225 delete cache;
1226 m_ExtFaceMap.erase(curr_it); 1226 m_ExtFaceMap.erase(curr_it);
1227 } 1227 }
1228 } 1228 }
1229 } 1229 }
1230 1230
1231 CFX_FaceCache::CFX_FaceCache(FXFT_Face face) { 1231 CFX_FaceCache::CFX_FaceCache(FXFT_Face face) {
1232 m_Face = face; 1232 m_Face = face;
1233 } 1233 }
1234 CFX_FaceCache::~CFX_FaceCache() { 1234 CFX_FaceCache::~CFX_FaceCache() {
1235 FX_POSITION pos = m_SizeMap.GetStartPosition(); 1235 for (const auto& pair : m_SizeMap) {
1236 CFX_ByteString Key; 1236 delete pair.second;
1237 CFX_SizeGlyphCache* pSizeCache = NULL;
1238 while (pos) {
1239 m_SizeMap.GetNextAssoc(pos, Key, (void*&)pSizeCache);
1240 delete pSizeCache;
1241 } 1237 }
1242 m_SizeMap.RemoveAll(); 1238 m_SizeMap.clear();
1243 pos = m_PathMap.GetStartPosition(); 1239 FX_POSITION pos = m_PathMap.GetStartPosition();
1244 void* key1; 1240 void* key1;
1245 CFX_PathData* pPath; 1241 CFX_PathData* pPath;
1246 while (pos) { 1242 while (pos) {
1247 m_PathMap.GetNextAssoc(pos, key1, (void*&)pPath); 1243 m_PathMap.GetNextAssoc(pos, key1, (void*&)pPath);
1248 delete pPath; 1244 delete pPath;
1249 } 1245 }
1250 m_PathMap.RemoveAll(); 1246 m_PathMap.RemoveAll();
1251 } 1247 }
1252 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ 1248 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
1253 void CFX_FaceCache::InitPlatform() {} 1249 void CFX_FaceCache::InitPlatform() {}
1254 #endif 1250 #endif
1255 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap( 1251 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(
1256 CFX_Font* pFont, 1252 CFX_Font* pFont,
1257 const CFX_AffineMatrix* pMatrix, 1253 const CFX_AffineMatrix* pMatrix,
1258 CFX_ByteStringC& FaceGlyphsKey, 1254 CFX_ByteStringC& FaceGlyphsKey,
1259 FX_DWORD glyph_index, 1255 FX_DWORD glyph_index,
1260 FX_BOOL bFontStyle, 1256 FX_BOOL bFontStyle,
1261 int dest_width, 1257 int dest_width,
1262 int anti_alias) { 1258 int anti_alias) {
1263 CFX_SizeGlyphCache* pSizeCache = NULL; 1259 CFX_SizeGlyphCache* pSizeCache;
1264 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { 1260 auto it = m_SizeMap.find(FaceGlyphsKey);
1261 if (it == m_SizeMap.end()) {
1265 pSizeCache = new CFX_SizeGlyphCache; 1262 pSizeCache = new CFX_SizeGlyphCache;
1266 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); 1263 m_SizeMap[FaceGlyphsKey] = pSizeCache;
1264 } else {
1265 pSizeCache = it->second;
1267 } 1266 }
1268 CFX_GlyphBitmap* pGlyphBitmap = NULL; 1267 CFX_GlyphBitmap* pGlyphBitmap = NULL;
1269 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, 1268 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index,
1270 (void*&)pGlyphBitmap)) { 1269 (void*&)pGlyphBitmap)) {
1271 return pGlyphBitmap; 1270 return pGlyphBitmap;
1272 } 1271 }
1273 pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, pMatrix, 1272 pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, pMatrix,
1274 dest_width, anti_alias); 1273 dest_width, anti_alias);
1275 if (pGlyphBitmap == NULL) { 1274 if (pGlyphBitmap == NULL) {
1276 return NULL; 1275 return NULL;
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 void _CFX_UniqueKeyGen::Generate(int count, ...) { 1869 void _CFX_UniqueKeyGen::Generate(int count, ...) {
1871 va_list argList; 1870 va_list argList;
1872 va_start(argList, count); 1871 va_start(argList, count);
1873 for (int i = 0; i < count; i++) { 1872 for (int i = 0; i < count; i++) {
1874 int p = va_arg(argList, int); 1873 int p = va_arg(argList, int);
1875 ((FX_DWORD*)m_Key)[i] = p; 1874 ((FX_DWORD*)m_Key)[i] = p;
1876 } 1875 }
1877 va_end(argList); 1876 va_end(argList);
1878 m_KeyLen = count * sizeof(FX_DWORD); 1877 m_KeyLen = count * sizeof(FX_DWORD);
1879 } 1878 }
OLDNEW
« no previous file with comments | « core/src/fxge/ge/fx_ge_linux.cpp ('k') | fpdfsdk/include/fsdk_annothandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698