| 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 #include "SkPaint.h" | 9 #include "SkPaint.h" |
| 10 #include "SkAnnotation.h" | 10 #include "SkAnnotation.h" |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 /////////////////////////////////////////////////////////////////////////////// | 508 /////////////////////////////////////////////////////////////////////////////// |
| 509 | 509 |
| 510 #include "SkGlyphCache.h" | 510 #include "SkGlyphCache.h" |
| 511 #include "SkUtils.h" | 511 #include "SkUtils.h" |
| 512 | 512 |
| 513 static void DetachDescProc(SkTypeface* typeface, const SkDescriptor* desc, | 513 static void DetachDescProc(SkTypeface* typeface, const SkDescriptor* desc, |
| 514 void* context) { | 514 void* context) { |
| 515 *((SkGlyphCache**)context) = SkGlyphCache::DetachCache(typeface, desc); | 515 *((SkGlyphCache**)context) = SkGlyphCache::DetachCache(typeface, desc); |
| 516 } | 516 } |
| 517 | 517 |
| 518 #ifdef SK_BUILD_FOR_ANDROID | |
| 519 const SkGlyph& SkPaint::getUnicharMetrics(SkUnichar text, | |
| 520 const SkMatrix* deviceMatrix) { | |
| 521 SkGlyphCache* cache; | |
| 522 descriptorProc(NULL, deviceMatrix, DetachDescProc, &cache, true); | |
| 523 | |
| 524 const SkGlyph& glyph = cache->getUnicharMetrics(text); | |
| 525 | |
| 526 SkGlyphCache::AttachCache(cache); | |
| 527 return glyph; | |
| 528 } | |
| 529 | |
| 530 const SkGlyph& SkPaint::getGlyphMetrics(uint16_t glyphId, | |
| 531 const SkMatrix* deviceMatrix) { | |
| 532 SkGlyphCache* cache; | |
| 533 descriptorProc(NULL, deviceMatrix, DetachDescProc, &cache, true); | |
| 534 | |
| 535 const SkGlyph& glyph = cache->getGlyphIDMetrics(glyphId); | |
| 536 | |
| 537 SkGlyphCache::AttachCache(cache); | |
| 538 return glyph; | |
| 539 } | |
| 540 | |
| 541 const void* SkPaint::findImage(const SkGlyph& glyph, | |
| 542 const SkMatrix* deviceMatrix) { | |
| 543 // See ::detachCache() | |
| 544 SkGlyphCache* cache; | |
| 545 descriptorProc(NULL, deviceMatrix, DetachDescProc, &cache, true); | |
| 546 | |
| 547 const void* image = cache->findImage(glyph); | |
| 548 | |
| 549 SkGlyphCache::AttachCache(cache); | |
| 550 return image; | |
| 551 } | |
| 552 #endif | |
| 553 | |
| 554 int SkPaint::textToGlyphs(const void* textData, size_t byteLength, | 518 int SkPaint::textToGlyphs(const void* textData, size_t byteLength, |
| 555 uint16_t glyphs[]) const { | 519 uint16_t glyphs[]) const { |
| 556 if (byteLength == 0) { | 520 if (byteLength == 0) { |
| 557 return 0; | 521 return 0; |
| 558 } | 522 } |
| 559 | 523 |
| 560 SkASSERT(textData != NULL); | 524 SkASSERT(textData != NULL); |
| 561 | 525 |
| 562 if (NULL == glyphs) { | 526 if (NULL == glyphs) { |
| 563 switch (this->getTextEncoding()) { | 527 switch (this->getTextEncoding()) { |
| (...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2688 } | 2652 } |
| 2689 #ifdef SK_BUILD_FOR_ANDROID | 2653 #ifdef SK_BUILD_FOR_ANDROID |
| 2690 if (dirty & kPaintOptionsAndroid_DirtyBit) { | 2654 if (dirty & kPaintOptionsAndroid_DirtyBit) { |
| 2691 SkPaintOptionsAndroid options; | 2655 SkPaintOptionsAndroid options; |
| 2692 options.unflatten(buffer); | 2656 options.unflatten(buffer); |
| 2693 paint->setPaintOptionsAndroid(options); | 2657 paint->setPaintOptionsAndroid(options); |
| 2694 } | 2658 } |
| 2695 #endif | 2659 #endif |
| 2696 SkASSERT(dirty == paint->fDirtyBits); | 2660 SkASSERT(dirty == paint->fDirtyBits); |
| 2697 } | 2661 } |
| OLD | NEW |