| OLD | NEW |
| 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 Loading... |
| 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 | |
| 189 enum { | 184 enum { |
| 190 kHashBits = 8, | 185 kHashBits = 8, |
| 191 kHashCount = 1 << kHashBits, | 186 kHashCount = 1 << kHashBits, |
| 192 kHashMask = kHashCount - 1 | 187 kHashMask = kHashCount - 1 |
| 193 }; | 188 }; |
| 194 | 189 |
| 195 typedef uint32_t PackedGlyphID; // glyph-index + subpixel-pos | 190 typedef uint32_t PackedGlyphID; // glyph-index + subpixel-pos |
| 196 typedef uint32_t PackedUnicharID; // unichar + subpixel-pos | 191 typedef uint32_t PackedUnicharID; // unichar + subpixel-pos |
| 197 | 192 |
| 198 struct CharGlyphRec { | 193 struct CharGlyphRec { |
| 199 PackedUnicharID fPackedUnicharID; | 194 PackedUnicharID fPackedUnicharID; |
| 200 PackedGlyphID fPackedGlyphID; | 195 PackedGlyphID fPackedGlyphID; |
| 201 }; | 196 }; |
| 202 | 197 |
| 203 struct AuxProcRec { | 198 struct AuxProcRec { |
| 204 AuxProcRec* fNext; | 199 AuxProcRec* fNext; |
| 205 void (*fProc)(void*); | 200 void (*fProc)(void*); |
| 206 void* fData; | 201 void* fData; |
| 207 }; | 202 }; |
| 208 | 203 |
| 209 // SkGlyphCache takes ownership of the scalercontext. | 204 // SkGlyphCache takes ownership of the scalercontext. |
| 210 SkGlyphCache(SkTypeface*, const SkDescriptor*, SkScalerContext*); | 205 SkGlyphCache(SkTypeface*, const SkDescriptor*, SkScalerContext*); |
| 211 ~SkGlyphCache(); | 206 ~SkGlyphCache(); |
| 212 | 207 |
| 213 // Return the SkGlyph* associated with MakeID. The id parameter is the | 208 // Return the SkGlyph* associated with MakeID. The id parameter is the |
| 214 // combined glyph/x/y id generated by MakeID. If it is just a glyph id | 209 // combined glyph/x/y id generated by MakeID. If it is just a glyph id |
| 215 // then x and y are assumed to be zero. | 210 // then x and y are assumed to be zero. |
| 216 SkGlyph* lookupByPackedGlyphID(PackedGlyphID packedGlyphID, MetricsType type
); | 211 SkGlyph* lookupByPackedGlyphID(PackedGlyphID packedGlyphID); |
| 217 | 212 |
| 218 // Return a SkGlyph* associated with unicode id and position x and y. | 213 // Return a SkGlyph* associated with unicode id and position x and y. |
| 219 SkGlyph* lookupByChar(SkUnichar id, MetricsType type, SkFixed x = 0, SkFixed
y = 0); | 214 SkGlyph* lookupByChar(SkUnichar id, SkFixed x = 0, SkFixed y = 0); |
| 220 | 215 |
| 221 // Return a new SkGlyph for the glyph ID and subpixel position id. Limit the
amount | 216 // Return a new SkGlyph for the glyph ID and subpixel position id. |
| 222 // of work | 217 SkGlyph* allocateNewGlyph(PackedGlyphID packedGlyphID); |
| 223 // using type. | |
| 224 SkGlyph* allocateNewGlyph(PackedGlyphID packedGlyphID, MetricsType type); | |
| 225 | 218 |
| 226 static bool DetachProc(const SkGlyphCache*, void*) { return true; } | 219 static bool DetachProc(const SkGlyphCache*, void*) { return true; } |
| 227 | 220 |
| 228 // The id arg is a combined id generated by MakeID. | 221 // The id arg is a combined id generated by MakeID. |
| 229 CharGlyphRec* getCharGlyphRec(PackedUnicharID id); | 222 CharGlyphRec* getCharGlyphRec(PackedUnicharID id); |
| 230 | 223 |
| 231 void invokeAndRemoveAuxProcs(); | 224 void invokeAndRemoveAuxProcs(); |
| 232 | 225 |
| 233 inline static SkGlyphCache* FindTail(SkGlyphCache* head); | 226 inline static SkGlyphCache* FindTail(SkGlyphCache* head); |
| 234 | 227 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 const SkMatrix* matrix) { | 308 const SkMatrix* matrix) { |
| 316 fCache = paint.detachCache(surfaceProps, matrix, true); | 309 fCache = paint.detachCache(surfaceProps, matrix, true); |
| 317 } | 310 } |
| 318 | 311 |
| 319 private: | 312 private: |
| 320 SkAutoGlyphCacheNoGamma() : SkAutoGlyphCacheBase() {} | 313 SkAutoGlyphCacheNoGamma() : SkAutoGlyphCacheBase() {} |
| 321 }; | 314 }; |
| 322 #define SkAutoGlyphCacheNoGamma(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCacheNoGamm
a) | 315 #define SkAutoGlyphCacheNoGamma(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCacheNoGamm
a) |
| 323 | 316 |
| 324 #endif | 317 #endif |
| OLD | NEW |