669 static const SkGlyph& sk_getAdvance_utf8_next(SkGlyphCache* cache,
670 const char** text) {
671 SkASSERT(cache != NULL);
672 SkASSERT(text != NULL);
673
674 return cache->getUnicharAdvance(SkUTF8_NextUnichar(text));
675 }
676
677 static const SkGlyph& sk_getAdvance_utf8_prev(SkGlyphCache* cache,
678 const char** text) {
679 SkASSERT(cache != NULL);
680 SkASSERT(text != NULL);
681
682 return cache->getUnicharAdvance(SkUTF8_PrevUnichar(text));
683 }
684
685 static const SkGlyph& sk_getAdvance_utf16_next(SkGlyphCache* cache,
686 const char** text) {
687 SkASSERT(cache != NULL);
688 SkASSERT(text != NULL);
689
690 return cache->getUnicharAdvance(SkUTF16_NextUnichar((const uint16_t**)text));
691 }
692
693 static const SkGlyph& sk_getAdvance_utf16_prev(SkGlyphCache* cache,
694 const char** text) {
695 SkASSERT(cache != NULL);
696 SkASSERT(text != NULL);
697
698 return cache->getUnicharAdvance(SkUTF16_PrevUnichar((const uint16_t**)text));
699 }
700
701 static const SkGlyph& sk_getAdvance_glyph_next(SkGlyphCache* cache,
702 const char** text) {
703 SkASSERT(cache != NULL);
704 SkASSERT(text != NULL);
705
706 const uint16_t* ptr = *(const uint16_t**)text;
707 unsigned glyphID = *ptr;
708 ptr += 1;
709 *text = (const char*)ptr;
710 return cache->getGlyphIDAdvance(glyphID);
711 }
712
713 static const SkGlyph& sk_getAdvance_glyph_prev(SkGlyphCache* cache,
714 const char** text) {
715 SkASSERT(cache != NULL);
716 SkASSERT(text != NULL);
717
718 const uint16_t* ptr = *(const uint16_t**)text;
719 ptr -= 1;
720 unsigned glyphID = *ptr;
721 *text = (const char*)ptr;
722 return cache->getGlyphIDAdvance(glyphID);
723 }
725 SkMeasureCacheProc SkPaint::getMeasureCacheProc(TextBufferDirection tbd,
726 bool needFullMetrics) const {
727 static const SkMeasureCacheProc gMeasureCacheProcs[] = { <=============== 宣言
728 sk_getMetrics_utf8_next,
729 sk_getMetrics_utf16_next,
730 sk_getMetrics_glyph_next,
731
732 sk_getMetrics_utf8_prev,
733 sk_getMetrics_utf16_prev,
734 sk_getMetrics_glyph_prev,
735
736 sk_getAdvance_utf8_next,
737 sk_getAdvance_utf16_next,
738 sk_getAdvance_glyph_next,
739
740 sk_getAdvance_utf8_prev,
741 sk_getAdvance_utf16_prev,
742 sk_getAdvance_glyph_prev
743 };
744
745 unsigned index = this->getTextEncoding();
746
747 if (kBackward_TextBufferDirection == tbd) {
748 index += 3;
749 }
750 if (!needFullMetrics && !this->isDevKernText()) {
751 index += 6;
752 }
753
754 SkASSERT(index < SK_ARRAY_COUNT(gMeasureCacheProcs));
755 return gMeasureCacheProcs[index]; <============================= 実行
756 }