class SkSurfaceProps;
class SkTypeface;
-typedef const SkGlyph& (*SkDrawCacheProc)(SkGlyphCache*, const char**,
- SkFixed x, SkFixed y);
-
-typedef const SkGlyph& (*SkMeasureCacheProc)(SkGlyphCache*, const char**);
-
#define kBicubicFilterBitmap_Flag kHighQualityFilterBitmap_Flag
/** \class SkPaint
return SetTextMatrix(matrix, fTextSize, fTextScaleX, fTextSkewX);
}
+ typedef const SkGlyph& (*GlyphCacheProc)(SkGlyphCache*, const char**);
+
SK_TO_STRING_NONVIRT()
private:
uint32_t fBitfieldsUInt;
};
- SkDrawCacheProc getDrawCacheProc() const;
- SkMeasureCacheProc getMeasureCacheProc(bool needFullMetrics) const;
+ GlyphCacheProc getGlyphCacheProc(bool needFullMetrics) const;
SkScalar measure_text(SkGlyphCache*, const char* text, size_t length,
int* count, SkRect* bounds) const;
paint.setStyle(SkPaint::kFill_Style);
paint.setPathEffect(nullptr);
- SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc();
- SkAutoGlyphCache cache(paint, &fDevice->surfaceProps(), this->fakeGamma(), nullptr);
+ SkPaint::GlyphCacheProc glyphCacheProc = paint.getGlyphCacheProc(true);
+ SkAutoGlyphCache cache(paint, &fDevice->surfaceProps(), this->fakeGamma(), nullptr);
const char* stop = text + byteLength;
SkTextAlignProc alignProc(paint.getTextAlign());
paint.setPathEffect(origPaint.getPathEffect());
while (text < stop) {
- const SkGlyph& glyph = glyphCacheProc(cache.get(), &text, 0, 0);
+ const SkGlyph& glyph = glyphCacheProc(cache.get(), &text);
if (glyph.fWidth) {
const SkPath* path = cache->findPath(glyph);
if (path) {
return cache->getGlyphIDAdvance(glyphID);
}
-SkMeasureCacheProc SkPaint::getMeasureCacheProc(bool needFullMetrics) const {
- static const SkMeasureCacheProc gMeasureCacheProcs[] = {
+SkPaint::GlyphCacheProc SkPaint::getGlyphCacheProc(bool needFullMetrics) const {
+ static const GlyphCacheProc gGlyphCacheProcs[] = {
sk_getMetrics_utf8_next,
sk_getMetrics_utf16_next,
sk_getMetrics_utf32_next,
index += 4;
}
- SkASSERT(index < SK_ARRAY_COUNT(gMeasureCacheProcs));
- return gMeasureCacheProcs[index];
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-static const SkGlyph& sk_getMetrics_utf8_00(SkGlyphCache* cache,
- const char** text, SkFixed, SkFixed) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- return cache->getUnicharMetrics(SkUTF8_NextUnichar(text));
-}
-
-static const SkGlyph& sk_getMetrics_utf8_xy(SkGlyphCache* cache,
- const char** text, SkFixed x, SkFixed y) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- return cache->getUnicharMetrics(SkUTF8_NextUnichar(text), x, y);
-}
-
-static const SkGlyph& sk_getMetrics_utf16_00(SkGlyphCache* cache,
- const char** text, SkFixed, SkFixed) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- return cache->getUnicharMetrics(SkUTF16_NextUnichar((const uint16_t**)text));
-}
-
-static const SkGlyph& sk_getMetrics_utf16_xy(SkGlyphCache* cache,
- const char** text, SkFixed x, SkFixed y) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- return cache->getUnicharMetrics(SkUTF16_NextUnichar((const uint16_t**)text),
- x, y);
-}
-
-static const SkGlyph& sk_getMetrics_utf32_00(SkGlyphCache* cache,
- const char** text, SkFixed, SkFixed) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- const int32_t* ptr = *(const int32_t**)text;
- SkUnichar uni = *ptr++;
- *text = (const char*)ptr;
- return cache->getUnicharMetrics(uni);
-}
-
-static const SkGlyph& sk_getMetrics_utf32_xy(SkGlyphCache* cache,
- const char** text, SkFixed x, SkFixed y) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- const int32_t* ptr = *(const int32_t**)text;
- SkUnichar uni = *ptr++;
- *text = (const char*)ptr;
- return cache->getUnicharMetrics(uni, x, y);
-}
-
-static const SkGlyph& sk_getMetrics_glyph_00(SkGlyphCache* cache,
- const char** text, SkFixed, SkFixed) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- const uint16_t* ptr = *(const uint16_t**)text;
- unsigned glyphID = *ptr;
- ptr += 1;
- *text = (const char*)ptr;
- return cache->getGlyphIDMetrics(glyphID);
-}
-
-static const SkGlyph& sk_getMetrics_glyph_xy(SkGlyphCache* cache,
- const char** text, SkFixed x, SkFixed y) {
- SkASSERT(cache != nullptr);
- SkASSERT(text != nullptr);
-
- const uint16_t* ptr = *(const uint16_t**)text;
- unsigned glyphID = *ptr;
- ptr += 1;
- *text = (const char*)ptr;
- return cache->getGlyphIDMetrics(glyphID, x, y);
-}
-
-SkDrawCacheProc SkPaint::getDrawCacheProc() const {
- static const SkDrawCacheProc gDrawCacheProcs[] = {
- sk_getMetrics_utf8_00,
- sk_getMetrics_utf16_00,
- sk_getMetrics_utf32_00,
- sk_getMetrics_glyph_00,
-
- sk_getMetrics_utf8_xy,
- sk_getMetrics_utf16_xy,
- sk_getMetrics_utf32_xy,
- sk_getMetrics_glyph_xy
- };
-
- unsigned index = this->getTextEncoding();
- if (fBitfields.fFlags & kSubpixelText_Flag) {
- index += 4;
- }
-
- SkASSERT(index < SK_ARRAY_COUNT(gDrawCacheProcs));
- return gDrawCacheProcs[index];
+ SkASSERT(index < SK_ARRAY_COUNT(gGlyphCacheProcs));
+ return gGlyphCacheProcs[index];
}
///////////////////////////////////////////////////////////////////////////////
return 0;
}
- SkMeasureCacheProc glyphCacheProc = this->getMeasureCacheProc(nullptr != bounds);
+ GlyphCacheProc glyphCacheProc = this->getGlyphCacheProc(nullptr != bounds);
int xyIndex;
JoinBoundsProc joinBoundsProc;
SkAutoGlyphCache autoCache(paint, nullptr, nullptr);
SkGlyphCache* cache = autoCache.getCache();
- SkMeasureCacheProc glyphCacheProc = paint.getMeasureCacheProc(false);
+ GlyphCacheProc glyphCacheProc = paint.getGlyphCacheProc(false);
const int xyIndex = paint.isVerticalText() ? 1 : 0;
// use 64bits for our accumulator, to avoid overflowing 16.16
Sk48Dot16 max = SkScalarToFixed(maxWidth);
SkAutoGlyphCache autoCache(paint, nullptr, nullptr);
SkGlyphCache* cache = autoCache.getCache();
- SkMeasureCacheProc glyphCacheProc;
- glyphCacheProc = paint.getMeasureCacheProc(nullptr != bounds);
+ GlyphCacheProc glyphCacheProc = paint.getGlyphCacheProc(nullptr != bounds);
const char* text = (const char*)textData;
const char* stop = text + byteLength;
const SkPaint& paint,
bool applyStrokeAndPathEffects)
: fPaint(paint) {
- fGlyphCacheProc = paint.getMeasureCacheProc(true);
+ fGlyphCacheProc = paint.getGlyphCacheProc(true);
fPaint.setLinearText(true);
fPaint.setMaskFilter(nullptr); // don't want this affecting our path-cache lookup
SkFixed fPrevAdvance;
const char* fText;
const char* fStop;
- SkMeasureCacheProc fGlyphCacheProc;
+ SkPaint::GlyphCacheProc fGlyphCacheProc;
SkScalar fXPos; // accumulated xpos, returned in next
SkAutoKern fAutoKern;
SkASSERT(byteLength == 0 || text != nullptr);
SkGlyphCache* glyphCache = this->getGlyphCache();
- SkDrawCacheProc glyphCacheProc = fFont.getDrawCacheProc();
+ SkPaint::GlyphCacheProc glyphCacheProc = fFont.getGlyphCacheProc(true);
fTotalGlyphCount = fFont.countText(text, byteLength);
fInstanceData.reset(InstanceData::Alloc(GrPathRendering::kTranslate_PathTransformType,
while (textPtr < stop) {
// We don't need x, y here, since all subpixel variants will have the
// same advance.
- const SkGlyph& glyph = glyphCacheProc(glyphCache, &textPtr, 0, 0);
+ const SkGlyph& glyph = glyphCacheProc(glyphCache, &textPtr);
stopX += glyph.fAdvanceX;
stopY += glyph.fAdvanceY;
SkFixed fy = SkScalarToFixed(y);
FallbackBlobBuilder fallback;
while (text < stop) {
- const SkGlyph& glyph = glyphCacheProc(glyphCache, &text, 0, 0);
+ const SkGlyph& glyph = glyphCacheProc(glyphCache, &text);
fx += SkFixedMul(autokern.adjust(glyph), fixedSizeRatio);
if (glyph.fWidth) {
this->appendGlyph(glyph, SkPoint::Make(SkFixedToScalar(fx), SkFixedToScalar(fy)),
SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
SkGlyphCache* glyphCache = this->getGlyphCache();
- SkDrawCacheProc glyphCacheProc = fFont.getDrawCacheProc();
+ SkPaint::GlyphCacheProc glyphCacheProc = fFont.getGlyphCacheProc(true);
fTotalGlyphCount = fFont.countText(text, byteLength);
fInstanceData.reset(InstanceData::Alloc(GrPathRendering::kTranslate_PathTransformType,
SkTextAlignProc alignProc(fFont.getTextAlign());
FallbackBlobBuilder fallback;
while (text < stop) {
- const SkGlyph& glyph = glyphCacheProc(glyphCache, &text, 0, 0);
+ const SkGlyph& glyph = glyphCacheProc(glyphCache, &text);
if (glyph.fWidth) {
SkPoint tmsLoc;
tmsProc(pos, &tmsLoc);
return;
}
- SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc();
+ SkPaint::GlyphCacheProc glyphCacheProc = skPaint.getGlyphCacheProc(true);
SkAutoDescriptor desc;
skPaint.getScalerContextDescriptor(&desc, props, SkPaint::FakeGamma::Off, nullptr);
SkGlyphCache* origPaintCache = SkGlyphCache::DetachCache(skPaint.getTypeface(),
while (textPtr < stop) {
// don't need x, y here, since all subpixel variants will have the
// same advance
- const SkGlyph& glyph = glyphCacheProc(origPaintCache, &textPtr, 0, 0);
+ const SkGlyph& glyph = glyphCacheProc(origPaintCache, &textPtr);
SkFixed width = glyph.fAdvanceX + autokern.adjust(glyph);
positions.push_back(SkFixedToScalar(stopX + SkFixedMul(origin, width)));
SkGlyphCache* cache = blob->setupCache(runIndex, props, SkPaint::FakeGamma::Off,
dfPaint, nullptr);
- SkDrawCacheProc glyphCacheProc = dfPaint.getDrawCacheProc();
+ SkPaint::GlyphCacheProc glyphCacheProc = dfPaint.getGlyphCacheProc(true);
GrFontScaler* fontScaler = GrTextUtils::GetGrFontScaler(cache);
const char* stop = text + byteLength;
while (text < stop) {
const char* lastText = text;
// the last 2 parameters are ignored
- const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
+ const SkGlyph& glyph = glyphCacheProc(cache, &text);
if (glyph.fWidth) {
SkScalar x = offset.x() + pos[0];
while (text < stop) {
const char* lastText = text;
// the last 2 parameters are ignored
- const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
+ const SkGlyph& glyph = glyphCacheProc(cache, &text);
if (glyph.fWidth) {
SkScalar x = offset.x() + pos[0];
paint.setStyle(SkPaint::kFill_Style);
paint.setPathEffect(nullptr);
- SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc();
- SkAutoGlyphCache autoCache(paint, &props, nullptr);
- SkGlyphCache* cache = autoCache.getCache();
+ SkPaint::GlyphCacheProc glyphCacheProc = paint.getGlyphCacheProc(true);
+ SkAutoGlyphCache autoCache(paint, &props, nullptr);
+ SkGlyphCache* cache = autoCache.getCache();
const char* stop = text + byteLength;
SkTextAlignProc alignProc(paint.getTextAlign());
paint.setPathEffect(origPaint.getPathEffect());
while (text < stop) {
- const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
+ const SkGlyph& glyph = glyphCacheProc(cache, &text);
if (glyph.fWidth) {
const SkPath* path = cache->findPath(glyph);
if (path) {
}
// Stolen from measure_text in SkDraw.cpp and then tweaked.
-static void align_text(SkDrawCacheProc glyphCacheProc, const SkPaint& paint,
+static void align_text(SkPaint::GlyphCacheProc glyphCacheProc, const SkPaint& paint,
const uint16_t* glyphs, size_t len,
SkScalar* x, SkScalar* y) {
if (paint.getTextAlign() == SkPaint::kLeft_Align) {
// TODO(vandebo): This probably needs to take kerning into account.
while (start < stop) {
- const SkGlyph& glyph = glyphCacheProc(cache, &start, 0, 0);
+ const SkGlyph& glyph = glyphCacheProc(cache, &start);
xAdv += glyph.fAdvanceX;
yAdv += glyph.fAdvanceY;
};
int numGlyphs = force_glyph_encoding(paint, text, len, &storage, &glyphIDs);
textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc();
+ SkPaint::GlyphCacheProc glyphCacheProc = textPaint.getGlyphCacheProc(true);
align_text(glyphCacheProc, textPaint, glyphIDs, numGlyphs, &x, &y);
content.entry()->fContent.writeText("BT\n");
set_text_transform(x, y, textPaint.getTextSkewX(),
size_t numGlyphs = force_glyph_encoding(paint, text, len, &storage, &glyphIDs);
textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc();
+ SkPaint::GlyphCacheProc glyphCacheProc = textPaint.getGlyphCacheProc(true);
content.entry()->fContent.writeText("BT\n");
this->updateFont(textPaint, glyphIDs[0], content.entry());
for (size_t i = 0; i < numGlyphs; i++) {