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

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: Separate reload & delete. 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
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 auto it = m_SizeMap.begin();
1236 CFX_ByteString Key; 1236 while (it != m_SizeMap.end()) {
Lei Zhang 2015/08/15 00:35:44 Range-Based For Loop?
1237 CFX_SizeGlyphCache* pSizeCache = NULL; 1237 auto temp = it++;
1238 while (pos) { 1238 delete temp->second;
1239 m_SizeMap.GetNextAssoc(pos, Key, (void*&)pSizeCache); 1239 m_SizeMap.erase(temp);
1240 delete pSizeCache;
1241 } 1240 }
1242 m_SizeMap.RemoveAll(); 1241 FX_POSITION pos = m_PathMap.GetStartPosition();
1243 pos = m_PathMap.GetStartPosition();
1244 void* key1; 1242 void* key1;
1245 CFX_PathData* pPath; 1243 CFX_PathData* pPath;
1246 while (pos) { 1244 while (pos) {
1247 m_PathMap.GetNextAssoc(pos, key1, (void*&)pPath); 1245 m_PathMap.GetNextAssoc(pos, key1, (void*&)pPath);
1248 delete pPath; 1246 delete pPath;
1249 } 1247 }
1250 m_PathMap.RemoveAll(); 1248 m_PathMap.RemoveAll();
1251 } 1249 }
1252 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ 1250 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
1253 void CFX_FaceCache::InitPlatform() {} 1251 void CFX_FaceCache::InitPlatform() {}
1254 #endif 1252 #endif
1255 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap( 1253 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(
1256 CFX_Font* pFont, 1254 CFX_Font* pFont,
1257 const CFX_AffineMatrix* pMatrix, 1255 const CFX_AffineMatrix* pMatrix,
1258 CFX_ByteStringC& FaceGlyphsKey, 1256 CFX_ByteStringC& FaceGlyphsKey,
1259 FX_DWORD glyph_index, 1257 FX_DWORD glyph_index,
1260 FX_BOOL bFontStyle, 1258 FX_BOOL bFontStyle,
1261 int dest_width, 1259 int dest_width,
1262 int anti_alias) { 1260 int anti_alias) {
1263 CFX_SizeGlyphCache* pSizeCache = NULL; 1261 CFX_SizeGlyphCache* pSizeCache;
1264 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { 1262 auto it = m_SizeMap.find(FaceGlyphsKey);
1263 if (it == m_SizeMap.end()) {
1265 pSizeCache = new CFX_SizeGlyphCache; 1264 pSizeCache = new CFX_SizeGlyphCache;
1266 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); 1265 m_SizeMap[FaceGlyphsKey] = pSizeCache;
1266 } else {
1267 pSizeCache = it->second;
1267 } 1268 }
1268 CFX_GlyphBitmap* pGlyphBitmap = NULL; 1269 CFX_GlyphBitmap* pGlyphBitmap = NULL;
1269 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, 1270 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index,
1270 (void*&)pGlyphBitmap)) { 1271 (void*&)pGlyphBitmap)) {
1271 return pGlyphBitmap; 1272 return pGlyphBitmap;
1272 } 1273 }
1273 pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, pMatrix, 1274 pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, pMatrix,
1274 dest_width, anti_alias); 1275 dest_width, anti_alias);
1275 if (pGlyphBitmap == NULL) { 1276 if (pGlyphBitmap == NULL) {
1276 return NULL; 1277 return NULL;
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 void _CFX_UniqueKeyGen::Generate(int count, ...) { 1871 void _CFX_UniqueKeyGen::Generate(int count, ...) {
1871 va_list argList; 1872 va_list argList;
1872 va_start(argList, count); 1873 va_start(argList, count);
1873 for (int i = 0; i < count; i++) { 1874 for (int i = 0; i < count; i++) {
1874 int p = va_arg(argList, int); 1875 int p = va_arg(argList, int);
1875 ((FX_DWORD*)m_Key)[i] = p; 1876 ((FX_DWORD*)m_Key)[i] = p;
1876 } 1877 }
1877 va_end(argList); 1878 va_end(argList);
1878 m_KeyLen = count * sizeof(FX_DWORD); 1879 m_KeyLen = count * sizeof(FX_DWORD);
1879 } 1880 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698