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

Side by Side Diff: src/core/SkGlyphCache.h

Issue 1383403003: Revert of Stop using SkScalerContext::getAdvance() in SkGlyphCache. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | src/core/SkGlyphCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 4 * Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
5 */ 5 */
6 6
7 #ifndef SkGlyphCache_DEFINED 7 #ifndef SkGlyphCache_DEFINED
8 #define SkGlyphCache_DEFINED 8 #define SkGlyphCache_DEFINED
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 void forget() { 174 void forget() {
175 fCache = nullptr; 175 fCache = nullptr;
176 } 176 }
177 private: 177 private:
178 const SkGlyphCache* fCache; 178 const SkGlyphCache* fCache;
179 }; 179 };
180 180
181 private: 181 private:
182 friend class SkGlyphCache_Globals; 182 friend class SkGlyphCache_Globals;
183 183
184 enum MetricsType {
185 kJustAdvance_MetricsType,
186 kFull_MetricsType
187 };
188
184 enum { 189 enum {
185 kHashBits = 8, 190 kHashBits = 8,
186 kHashCount = 1 << kHashBits, 191 kHashCount = 1 << kHashBits,
187 kHashMask = kHashCount - 1 192 kHashMask = kHashCount - 1
188 }; 193 };
189 194
190 typedef uint32_t PackedGlyphID; // glyph-index + subpixel-pos 195 typedef uint32_t PackedGlyphID; // glyph-index + subpixel-pos
191 typedef uint32_t PackedUnicharID; // unichar + subpixel-pos 196 typedef uint32_t PackedUnicharID; // unichar + subpixel-pos
192 197
193 struct CharGlyphRec { 198 struct CharGlyphRec {
194 PackedUnicharID fPackedUnicharID; 199 PackedUnicharID fPackedUnicharID;
195 PackedGlyphID fPackedGlyphID; 200 PackedGlyphID fPackedGlyphID;
196 }; 201 };
197 202
198 struct AuxProcRec { 203 struct AuxProcRec {
199 AuxProcRec* fNext; 204 AuxProcRec* fNext;
200 void (*fProc)(void*); 205 void (*fProc)(void*);
201 void* fData; 206 void* fData;
202 }; 207 };
203 208
204 // SkGlyphCache takes ownership of the scalercontext. 209 // SkGlyphCache takes ownership of the scalercontext.
205 SkGlyphCache(SkTypeface*, const SkDescriptor*, SkScalerContext*); 210 SkGlyphCache(SkTypeface*, const SkDescriptor*, SkScalerContext*);
206 ~SkGlyphCache(); 211 ~SkGlyphCache();
207 212
208 // Return the SkGlyph* associated with MakeID. The id parameter is the 213 // Return the SkGlyph* associated with MakeID. The id parameter is the
209 // combined glyph/x/y id generated by MakeID. If it is just a glyph id 214 // combined glyph/x/y id generated by MakeID. If it is just a glyph id
210 // then x and y are assumed to be zero. 215 // then x and y are assumed to be zero.
211 SkGlyph* lookupByPackedGlyphID(PackedGlyphID packedGlyphID); 216 SkGlyph* lookupByPackedGlyphID(PackedGlyphID packedGlyphID, MetricsType type );
212 217
213 // Return a SkGlyph* associated with unicode id and position x and y. 218 // Return a SkGlyph* associated with unicode id and position x and y.
214 SkGlyph* lookupByChar(SkUnichar id, SkFixed x = 0, SkFixed y = 0); 219 SkGlyph* lookupByChar(SkUnichar id, MetricsType type, SkFixed x = 0, SkFixed y = 0);
215 220
216 // Return a new SkGlyph for the glyph ID and subpixel position id. 221 // Return a new SkGlyph for the glyph ID and subpixel position id. Limit the amount
217 SkGlyph* allocateNewGlyph(PackedGlyphID packedGlyphID); 222 // of work
223 // using type.
224 SkGlyph* allocateNewGlyph(PackedGlyphID packedGlyphID, MetricsType type);
218 225
219 static bool DetachProc(const SkGlyphCache*, void*) { return true; } 226 static bool DetachProc(const SkGlyphCache*, void*) { return true; }
220 227
221 // The id arg is a combined id generated by MakeID. 228 // The id arg is a combined id generated by MakeID.
222 CharGlyphRec* getCharGlyphRec(PackedUnicharID id); 229 CharGlyphRec* getCharGlyphRec(PackedUnicharID id);
223 230
224 void invokeAndRemoveAuxProcs(); 231 void invokeAndRemoveAuxProcs();
225 232
226 inline static SkGlyphCache* FindTail(SkGlyphCache* head); 233 inline static SkGlyphCache* FindTail(SkGlyphCache* head);
227 234
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 const SkMatrix* matrix) { 315 const SkMatrix* matrix) {
309 fCache = paint.detachCache(surfaceProps, matrix, true); 316 fCache = paint.detachCache(surfaceProps, matrix, true);
310 } 317 }
311 318
312 private: 319 private:
313 SkAutoGlyphCacheNoGamma() : SkAutoGlyphCacheBase() {} 320 SkAutoGlyphCacheNoGamma() : SkAutoGlyphCacheBase() {}
314 }; 321 };
315 #define SkAutoGlyphCacheNoGamma(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCacheNoGamm a) 322 #define SkAutoGlyphCacheNoGamma(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCacheNoGamm a)
316 323
317 #endif 324 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkGlyphCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698