OLD | NEW |
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 <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "core/fxcodec/include/fx_codec.h" | 10 #include "core/fxcodec/include/fx_codec.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 return rect; | 106 return rect; |
107 } | 107 } |
108 | 108 |
109 CFX_FontCache::CFX_FontCache() {} | 109 CFX_FontCache::CFX_FontCache() {} |
110 | 110 |
111 CFX_FontCache::~CFX_FontCache() { | 111 CFX_FontCache::~CFX_FontCache() { |
112 FreeCache(TRUE); | 112 FreeCache(TRUE); |
113 } | 113 } |
114 | 114 |
115 CFX_FaceCache* CFX_FontCache::GetCachedFace(CFX_Font* pFont) { | 115 CFX_FaceCache* CFX_FontCache::GetCachedFace(CFX_Font* pFont) { |
116 FXFT_Face internal_face = pFont->GetFace(); | 116 FXFT_Face face = pFont->GetFace(); |
117 const bool bExternal = !internal_face; | 117 const bool bExternal = !face; |
118 FXFT_Face face = | |
119 bExternal ? (FXFT_Face)pFont->GetSubstFont()->m_ExtHandle : internal_face; | |
120 CFX_FTCacheMap& map = bExternal ? m_ExtFaceMap : m_FTFaceMap; | 118 CFX_FTCacheMap& map = bExternal ? m_ExtFaceMap : m_FTFaceMap; |
121 auto it = map.find(face); | 119 auto it = map.find(face); |
122 if (it != map.end()) { | 120 if (it != map.end()) { |
123 CFX_CountedFaceCache* counted_face_cache = it->second; | 121 CFX_CountedFaceCache* counted_face_cache = it->second; |
124 counted_face_cache->m_nCount++; | 122 counted_face_cache->m_nCount++; |
125 return counted_face_cache->m_Obj; | 123 return counted_face_cache->m_Obj; |
126 } | 124 } |
127 | 125 |
128 CFX_FaceCache* face_cache = new CFX_FaceCache(bExternal ? nullptr : face); | 126 CFX_FaceCache* face_cache = new CFX_FaceCache(bExternal ? nullptr : face); |
129 CFX_CountedFaceCache* counted_face_cache = new CFX_CountedFaceCache; | 127 CFX_CountedFaceCache* counted_face_cache = new CFX_CountedFaceCache; |
(...skipping 13 matching lines...) Expand all Loading... |
143 m_pTypeface = | 141 m_pTypeface = |
144 SkTypeface::MakeFromStream( | 142 SkTypeface::MakeFromStream( |
145 new SkMemoryStream(pFont->GetFontData(), pFont->GetSize())) | 143 new SkMemoryStream(pFont->GetFontData(), pFont->GetSize())) |
146 .release(); | 144 .release(); |
147 } | 145 } |
148 return m_pTypeface; | 146 return m_pTypeface; |
149 } | 147 } |
150 #endif | 148 #endif |
151 | 149 |
152 void CFX_FontCache::ReleaseCachedFace(CFX_Font* pFont) { | 150 void CFX_FontCache::ReleaseCachedFace(CFX_Font* pFont) { |
153 FXFT_Face internal_face = pFont->GetFace(); | 151 FXFT_Face face = pFont->GetFace(); |
154 const bool bExternal = !internal_face; | 152 const bool bExternal = !face; |
155 FXFT_Face face = | |
156 bExternal ? (FXFT_Face)pFont->GetSubstFont()->m_ExtHandle : internal_face; | |
157 CFX_FTCacheMap& map = bExternal ? m_ExtFaceMap : m_FTFaceMap; | 153 CFX_FTCacheMap& map = bExternal ? m_ExtFaceMap : m_FTFaceMap; |
158 | 154 |
159 auto it = map.find(face); | 155 auto it = map.find(face); |
160 if (it == map.end()) | 156 if (it == map.end()) |
161 return; | 157 return; |
162 | 158 |
163 CFX_CountedFaceCache* counted_face_cache = it->second; | 159 CFX_CountedFaceCache* counted_face_cache = it->second; |
164 if (counted_face_cache->m_nCount > 1) { | 160 if (counted_face_cache->m_nCount > 1) { |
165 counted_face_cache->m_nCount--; | 161 counted_face_cache->m_nCount--; |
166 } | 162 } |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 void _CFX_UniqueKeyGen::Generate(int count, ...) { | 836 void _CFX_UniqueKeyGen::Generate(int count, ...) { |
841 va_list argList; | 837 va_list argList; |
842 va_start(argList, count); | 838 va_start(argList, count); |
843 for (int i = 0; i < count; i++) { | 839 for (int i = 0; i < count; i++) { |
844 int p = va_arg(argList, int); | 840 int p = va_arg(argList, int); |
845 ((uint32_t*)m_Key)[i] = p; | 841 ((uint32_t*)m_Key)[i] = p; |
846 } | 842 } |
847 va_end(argList); | 843 va_end(argList); |
848 m_KeyLen = count * sizeof(uint32_t); | 844 m_KeyLen = count * sizeof(uint32_t); |
849 } | 845 } |
OLD | NEW |