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

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

Issue 1081443004: Remove checks in fxge/ge now that FX_NEW can't return 0. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix Typo. Created 5 years, 8 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_ps.cpp ('k') | no next file » | 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 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 CFX_FaceCache* CFX_FontCache::GetCachedFace(CFX_Font* pFont) 977 CFX_FaceCache* CFX_FontCache::GetCachedFace(CFX_Font* pFont)
978 { 978 {
979 FX_BOOL bExternal = pFont->GetFace() == NULL; 979 FX_BOOL bExternal = pFont->GetFace() == NULL;
980 void* face = bExternal ? pFont->GetSubstFont()->m_ExtHandle : pFont->GetFace (); 980 void* face = bExternal ? pFont->GetSubstFont()->m_ExtHandle : pFont->GetFace ();
981 CFX_FTCacheMap& map = bExternal ? m_ExtFaceMap : m_FTFaceMap; 981 CFX_FTCacheMap& map = bExternal ? m_ExtFaceMap : m_FTFaceMap;
982 CFX_CountedFaceCache* counted_face_cache = NULL; 982 CFX_CountedFaceCache* counted_face_cache = NULL;
983 if (map.Lookup((FXFT_Face)face, counted_face_cache)) { 983 if (map.Lookup((FXFT_Face)face, counted_face_cache)) {
984 counted_face_cache->m_nCount++; 984 counted_face_cache->m_nCount++;
985 return counted_face_cache->m_Obj; 985 return counted_face_cache->m_Obj;
986 } 986 }
987 CFX_FaceCache* face_cache = NULL; 987 CFX_FaceCache* face_cache = new CFX_FaceCache(bExternal ? NULL : (FXFT_Face) face);
988 face_cache = FX_NEW CFX_FaceCache(bExternal ? NULL : (FXFT_Face)face); 988 counted_face_cache = new CFX_CountedFaceCache;
989 if (face_cache == NULL)» {
990 return NULL;
991 }
992 counted_face_cache = FX_NEW CFX_CountedFaceCache;
993 if (!counted_face_cache) {
994 if (face_cache) {
995 delete face_cache;
996 face_cache = NULL;
997 }
998 return NULL;
999 }
1000 counted_face_cache->m_nCount = 2; 989 counted_face_cache->m_nCount = 2;
1001 counted_face_cache->m_Obj = face_cache; 990 counted_face_cache->m_Obj = face_cache;
1002 map.SetAt((FXFT_Face)face, counted_face_cache); 991 map.SetAt((FXFT_Face)face, counted_face_cache);
1003 return face_cache; 992 return face_cache;
1004 } 993 }
1005 void CFX_FontCache::ReleaseCachedFace(CFX_Font* pFont) 994 void CFX_FontCache::ReleaseCachedFace(CFX_Font* pFont)
1006 { 995 {
1007 FX_BOOL bExternal = pFont->GetFace() == NULL; 996 FX_BOOL bExternal = pFont->GetFace() == NULL;
1008 void* face = bExternal ? pFont->GetSubstFont()->m_ExtHandle : pFont->GetFace (); 997 void* face = bExternal ? pFont->GetSubstFont()->m_ExtHandle : pFont->GetFace ();
1009 CFX_FTCacheMap& map = bExternal ? m_ExtFaceMap : m_FTFaceMap; 998 CFX_FTCacheMap& map = bExternal ? m_ExtFaceMap : m_FTFaceMap;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 void CFX_FaceCache::InitPlatform() 1063 void CFX_FaceCache::InitPlatform()
1075 { 1064 {
1076 } 1065 }
1077 #endif 1066 #endif
1078 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(CFX_Font* pFont, const CFX_Aff ineMatrix* pMatrix, 1067 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(CFX_Font* pFont, const CFX_Aff ineMatrix* pMatrix,
1079 CFX_ByteStringC& FaceGlyphsKey, FX_DWORD glyph_index, FX_BOOL bFontStyle , 1068 CFX_ByteStringC& FaceGlyphsKey, FX_DWORD glyph_index, FX_BOOL bFontStyle ,
1080 int dest_width, int anti_alias) 1069 int dest_width, int anti_alias)
1081 { 1070 {
1082 CFX_SizeGlyphCache* pSizeCache = NULL; 1071 CFX_SizeGlyphCache* pSizeCache = NULL;
1083 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { 1072 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) {
1084 pSizeCache = FX_NEW CFX_SizeGlyphCache; 1073 pSizeCache = new CFX_SizeGlyphCache;
1085 if (pSizeCache == NULL)»{
1086 return NULL;
1087 }
1088 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); 1074 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache);
1089 } 1075 }
1090 CFX_GlyphBitmap* pGlyphBitmap = NULL; 1076 CFX_GlyphBitmap* pGlyphBitmap = NULL;
1091 if (pSizeCache->m_GlyphMap.Lookup((FX_LPVOID)(FX_UINTPTR)glyph_index, (void* &)pGlyphBitmap)) { 1077 if (pSizeCache->m_GlyphMap.Lookup((FX_LPVOID)(FX_UINTPTR)glyph_index, (void* &)pGlyphBitmap)) {
1092 return pGlyphBitmap; 1078 return pGlyphBitmap;
1093 } 1079 }
1094 pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, pMatrix, dest_wid th, anti_alias); 1080 pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, pMatrix, dest_wid th, anti_alias);
1095 if (pGlyphBitmap == NULL) { 1081 if (pGlyphBitmap == NULL) {
1096 return NULL; 1082 return NULL;
1097 } 1083 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 return pGlyphBitmap; 1132 return pGlyphBitmap;
1147 } 1133 }
1148 pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, d est_width, anti_alias); 1134 pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, d est_width, anti_alias);
1149 if (pGlyphBitmap) { 1135 if (pGlyphBitmap) {
1150 pSizeCache->m_GlyphMap.SetAt((FX_LPVOID)(FX_UINTPTR)glyph_index, pGlyphBitmap); 1136 pSizeCache->m_GlyphMap.SetAt((FX_LPVOID)(FX_UINTPTR)glyph_index, pGlyphBitmap);
1151 return pGlyphBitmap; 1137 return pGlyphBitmap;
1152 } 1138 }
1153 } else { 1139 } else {
1154 pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, d est_width, anti_alias); 1140 pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, d est_width, anti_alias);
1155 if (pGlyphBitmap) { 1141 if (pGlyphBitmap) {
1156 pSizeCache = FX_NEW CFX_SizeGlyphCache; 1142 pSizeCache = new CFX_SizeGlyphCache;
1157 if (pSizeCache == NULL)»{
1158 return NULL;
1159 }
1160 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); 1143 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache);
1161 pSizeCache->m_GlyphMap.SetAt((FX_LPVOID)(FX_UINTPTR)glyph_index, pGlyphBitmap); 1144 pSizeCache->m_GlyphMap.SetAt((FX_LPVOID)(FX_UINTPTR)glyph_index, pGlyphBitmap);
1162 return pGlyphBitmap; 1145 return pGlyphBitmap;
1163 } 1146 }
1164 } 1147 }
1165 if (pFont->GetSubstFont()) 1148 if (pFont->GetSubstFont())
1166 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100 00), 1149 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100 00),
1167 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000) , dest_width, anti_alias, 1150 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000) , dest_width, anti_alias,
1168 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont ()->m_ItalicAngle, pFont->IsVertical()); 1151 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont ()->m_ItalicAngle, pFont->IsVertical());
1169 else 1152 else
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 error = FXFT_Render_Glyph(m_Face, anti_alias); 1354 error = FXFT_Render_Glyph(m_Face, anti_alias);
1372 if (error) { 1355 if (error) {
1373 return NULL; 1356 return NULL;
1374 } 1357 }
1375 int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(m_Face)); 1358 int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(m_Face));
1376 int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(m_Face)); 1359 int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(m_Face));
1377 if (bmwidth > 2048 || bmheight > 2048) { 1360 if (bmwidth > 2048 || bmheight > 2048) {
1378 return NULL; 1361 return NULL;
1379 } 1362 }
1380 int dib_width = bmwidth; 1363 int dib_width = bmwidth;
1381 CFX_GlyphBitmap* pGlyphBitmap = FX_NEW CFX_GlyphBitmap; 1364 CFX_GlyphBitmap* pGlyphBitmap = new CFX_GlyphBitmap;
1382 if (!pGlyphBitmap) {
1383 return NULL;
1384 }
1385 pGlyphBitmap->m_Bitmap.Create(dib_width, bmheight, 1365 pGlyphBitmap->m_Bitmap.Create(dib_width, bmheight,
1386 anti_alias == FXFT_RENDER_MODE_MONO ? FXDIB_1b ppMask : FXDIB_8bppMask); 1366 anti_alias == FXFT_RENDER_MODE_MONO ? FXDIB_1b ppMask : FXDIB_8bppMask);
1387 pGlyphBitmap->m_Left = FXFT_Get_Glyph_BitmapLeft(m_Face); 1367 pGlyphBitmap->m_Left = FXFT_Get_Glyph_BitmapLeft(m_Face);
1388 pGlyphBitmap->m_Top = FXFT_Get_Glyph_BitmapTop(m_Face); 1368 pGlyphBitmap->m_Top = FXFT_Get_Glyph_BitmapTop(m_Face);
1389 int dest_pitch = pGlyphBitmap->m_Bitmap.GetPitch(); 1369 int dest_pitch = pGlyphBitmap->m_Bitmap.GetPitch();
1390 int src_pitch = FXFT_Get_Bitmap_Pitch(FXFT_Get_Glyph_Bitmap(m_Face)); 1370 int src_pitch = FXFT_Get_Bitmap_Pitch(FXFT_Get_Glyph_Bitmap(m_Face));
1391 FX_BYTE* pDestBuf = pGlyphBitmap->m_Bitmap.GetBuffer(); 1371 FX_BYTE* pDestBuf = pGlyphBitmap->m_Bitmap.GetBuffer();
1392 FX_BYTE* pSrcBuf = (FX_BYTE*)FXFT_Get_Bitmap_Buffer(FXFT_Get_Glyph_Bitmap(m_ Face)); 1372 FX_BYTE* pSrcBuf = (FX_BYTE*)FXFT_Get_Bitmap_Buffer(FXFT_Get_Glyph_Bitmap(m_ Face));
1393 if (anti_alias != FXFT_RENDER_MODE_MONO && FXFT_Get_Bitmap_PixelMode(FXFT_Ge t_Glyph_Bitmap(m_Face)) == FXFT_PIXEL_MODE_MONO) { 1373 if (anti_alias != FXFT_RENDER_MODE_MONO && FXFT_Get_Bitmap_PixelMode(FXFT_Ge t_Glyph_Bitmap(m_Face)) == FXFT_PIXEL_MODE_MONO) {
1394 int bytes = anti_alias == FXFT_RENDER_MODE_LCD ? 3 : 1; 1374 int bytes = anti_alias == FXFT_RENDER_MODE_LCD ? 3 : 1;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 funcs.cubic_to = _Outline_CubicTo; 1649 funcs.cubic_to = _Outline_CubicTo;
1670 funcs.shift = 0; 1650 funcs.shift = 0;
1671 funcs.delta = 0; 1651 funcs.delta = 0;
1672 OUTLINE_PARAMS params; 1652 OUTLINE_PARAMS params;
1673 params.m_bCount = TRUE; 1653 params.m_bCount = TRUE;
1674 params.m_PointCount = 0; 1654 params.m_PointCount = 0;
1675 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, &params); 1655 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, &params);
1676 if (params.m_PointCount == 0) { 1656 if (params.m_PointCount == 0) {
1677 return NULL; 1657 return NULL;
1678 } 1658 }
1679 CFX_PathData* pPath = FX_NEW CFX_PathData; 1659 CFX_PathData* pPath = new CFX_PathData;
1680 if (!pPath) {
1681 return NULL;
1682 }
1683 pPath->SetPointCount(params.m_PointCount); 1660 pPath->SetPointCount(params.m_PointCount);
1684 params.m_bCount = FALSE; 1661 params.m_bCount = FALSE;
1685 params.m_PointCount = 0; 1662 params.m_PointCount = 0;
1686 params.m_pPoints = pPath->GetPoints(); 1663 params.m_pPoints = pPath->GetPoints();
1687 params.m_CurX = params.m_CurY = 0; 1664 params.m_CurX = params.m_CurY = 0;
1688 params.m_CoordUnit = 64 * 64.0; 1665 params.m_CoordUnit = 64 * 64.0;
1689 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, &params); 1666 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, &params);
1690 _Outline_CheckEmptyContour(&params); 1667 _Outline_CheckEmptyContour(&params);
1691 pPath->TrimPoints(params.m_PointCount); 1668 pPath->TrimPoints(params.m_PointCount);
1692 if (params.m_PointCount) { 1669 if (params.m_PointCount) {
1693 pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE; 1670 pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE;
1694 } 1671 }
1695 return pPath; 1672 return pPath;
1696 } 1673 }
1697 void _CFX_UniqueKeyGen::Generate(int count, ...) 1674 void _CFX_UniqueKeyGen::Generate(int count, ...)
1698 { 1675 {
1699 va_list argList; 1676 va_list argList;
1700 va_start(argList, count); 1677 va_start(argList, count);
1701 for (int i = 0; i < count; i ++) { 1678 for (int i = 0; i < count; i ++) {
1702 int p = va_arg(argList, int); 1679 int p = va_arg(argList, int);
1703 ((FX_DWORD*)m_Key)[i] = p; 1680 ((FX_DWORD*)m_Key)[i] = p;
1704 } 1681 }
1705 va_end(argList); 1682 va_end(argList);
1706 m_KeyLen = count * sizeof(FX_DWORD); 1683 m_KeyLen = count * sizeof(FX_DWORD);
1707 } 1684 }
OLDNEW
« no previous file with comments | « core/src/fxge/ge/fx_ge_ps.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698