OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkGlyphCache.h" | 10 #include "SkGlyphCache.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 // init to 0 so that all of the pointers will be null | 81 // init to 0 so that all of the pointers will be null |
82 memset(fGlyphHash, 0, sizeof(fGlyphHash)); | 82 memset(fGlyphHash, 0, sizeof(fGlyphHash)); |
83 // init with 0xFF so that the charCode field will be -1, which is invalid | 83 // init with 0xFF so that the charCode field will be -1, which is invalid |
84 memset(fCharToGlyphHash, 0xFF, sizeof(fCharToGlyphHash)); | 84 memset(fCharToGlyphHash, 0xFF, sizeof(fCharToGlyphHash)); |
85 | 85 |
86 fMemoryUsed = sizeof(*this); | 86 fMemoryUsed = sizeof(*this); |
87 | 87 |
88 fGlyphArray.setReserve(kMinGlyphCount); | 88 fGlyphArray.setReserve(kMinGlyphCount); |
89 | 89 |
90 fMetricsCount = 0; | |
91 fAdvanceCount = 0; | |
92 fAuxProcList = NULL; | 90 fAuxProcList = NULL; |
93 } | 91 } |
94 | 92 |
95 SkGlyphCache::~SkGlyphCache() { | 93 SkGlyphCache::~SkGlyphCache() { |
96 #if 0 | 94 #if 0 |
97 { | 95 { |
98 size_t ptrMem = fGlyphArray.count() * sizeof(SkGlyph*); | 96 size_t ptrMem = fGlyphArray.count() * sizeof(SkGlyph*); |
99 size_t glyphAlloc = fGlyphAlloc.totalCapacity(); | 97 size_t glyphAlloc = fGlyphAlloc.totalCapacity(); |
100 size_t glyphHashUsed = 0; | 98 size_t glyphHashUsed = 0; |
101 size_t uniHashUsed = 0; | 99 size_t uniHashUsed = 0; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 // not found, but hi tells us where to inser the new glyph | 311 // not found, but hi tells us where to inser the new glyph |
314 fMemoryUsed += sizeof(SkGlyph); | 312 fMemoryUsed += sizeof(SkGlyph); |
315 | 313 |
316 glyph = (SkGlyph*)fGlyphAlloc.alloc(sizeof(SkGlyph), | 314 glyph = (SkGlyph*)fGlyphAlloc.alloc(sizeof(SkGlyph), |
317 SkChunkAlloc::kThrow_AllocFailType); | 315 SkChunkAlloc::kThrow_AllocFailType); |
318 glyph->init(id); | 316 glyph->init(id); |
319 *fGlyphArray.insert(hi) = glyph; | 317 *fGlyphArray.insert(hi) = glyph; |
320 | 318 |
321 if (kJustAdvance_MetricsType == mtype) { | 319 if (kJustAdvance_MetricsType == mtype) { |
322 fScalerContext->getAdvance(glyph); | 320 fScalerContext->getAdvance(glyph); |
323 fAdvanceCount += 1; | |
324 } else { | 321 } else { |
325 SkASSERT(kFull_MetricsType == mtype); | 322 SkASSERT(kFull_MetricsType == mtype); |
326 fScalerContext->getMetrics(glyph); | 323 fScalerContext->getMetrics(glyph); |
327 fMetricsCount += 1; | |
328 } | 324 } |
329 | 325 |
330 return glyph; | 326 return glyph; |
331 } | 327 } |
332 | 328 |
333 const void* SkGlyphCache::findImage(const SkGlyph& glyph) { | 329 const void* SkGlyphCache::findImage(const SkGlyph& glyph) { |
334 if (glyph.fWidth > 0 && glyph.fWidth < kMaxGlyphWidth) { | 330 if (glyph.fWidth > 0 && glyph.fWidth < kMaxGlyphWidth) { |
335 if (glyph.fImage == NULL) { | 331 if (glyph.fImage == NULL) { |
336 size_t size = glyph.computeImageSize(); | 332 size_t size = glyph.computeImageSize(); |
337 const_cast<SkGlyph&>(glyph).fImage = fGlyphAlloc.alloc(size, | 333 const_cast<SkGlyph&>(glyph).fImage = fGlyphAlloc.alloc(size, |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 return tls ? tls->getCacheSizeLimit() : 0; | 709 return tls ? tls->getCacheSizeLimit() : 0; |
714 } | 710 } |
715 | 711 |
716 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { | 712 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { |
717 if (0 == bytes) { | 713 if (0 == bytes) { |
718 SkGlyphCache_Globals::DeleteTLS(); | 714 SkGlyphCache_Globals::DeleteTLS(); |
719 } else { | 715 } else { |
720 SkGlyphCache_Globals::GetTLS().setCacheSizeLimit(bytes); | 716 SkGlyphCache_Globals::GetTLS().setCacheSizeLimit(bytes); |
721 } | 717 } |
722 } | 718 } |
OLD | NEW |