diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-08 14:30:41 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-12 13:49:54 +0200 |
commit | ab0a50979b9eb4dfa3320eff7e187e41efedf7a9 (patch) | |
tree | 498dfb8a97ff3361a9f7486863a52bb4e26bb898 /chromium/third_party/skia/src/gpu/GrTextContext.cpp | |
parent | 4ce69f7403811819800e7c5ae1318b2647e778d1 (diff) |
Update Chromium to beta version 37.0.2062.68
Change-Id: I188e3b5aff1bec75566014291b654eb19f5bc8ca
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/third_party/skia/src/gpu/GrTextContext.cpp')
-rw-r--r-- | chromium/third_party/skia/src/gpu/GrTextContext.cpp | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/chromium/third_party/skia/src/gpu/GrTextContext.cpp b/chromium/third_party/skia/src/gpu/GrTextContext.cpp index 9e9162878df..bc116714dad 100644 --- a/chromium/third_party/skia/src/gpu/GrTextContext.cpp +++ b/chromium/third_party/skia/src/gpu/GrTextContext.cpp @@ -5,23 +5,73 @@ * found in the LICENSE file. */ - #include "GrTextContext.h" +#include "GrContext.h" + +#include "SkAutoKern.h" +#include "SkGlyphCache.h" +#include "SkGr.h" -GrTextContext::GrTextContext(GrContext* context, const GrPaint& paint) : fPaint(paint) { - fContext = context; +GrTextContext::GrTextContext(GrContext* context, const SkDeviceProperties& properties) : + fContext(context), fDeviceProperties(properties), fDrawTarget(NULL) { +} - const GrClipData* clipData = context->getClip(); +void GrTextContext::init(const GrPaint& grPaint, const SkPaint& skPaint) { + const GrClipData* clipData = fContext->getClip(); SkRect devConservativeBound; clipData->fClipStack->getConservativeBounds( -clipData->fOrigin.fX, -clipData->fOrigin.fY, - context->getRenderTarget()->width(), - context->getRenderTarget()->height(), + fContext->getRenderTarget()->width(), + fContext->getRenderTarget()->height(), &devConservativeBound); devConservativeBound.roundOut(&fClipRect); fDrawTarget = fContext->getTextTarget(); + + fPaint = grPaint; + fSkPaint = skPaint; +} + +//*** change to output positions? +void GrTextContext::MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, + const char text[], size_t byteLength, SkVector* stopVector) { + SkFixed x = 0, y = 0; + const char* stop = text + byteLength; + + SkAutoKern autokern; + + while (text < stop) { + // don't need x, y here, since all subpixel variants will have the + // same advance + const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); + + x += autokern.adjust(glyph) + glyph.fAdvanceX; + y += glyph.fAdvanceY; + } + stopVector->set(SkFixedToScalar(x), SkFixedToScalar(y)); + + SkASSERT(text == stop); +} + +static void GlyphCacheAuxProc(void* data) { + GrFontScaler* scaler = (GrFontScaler*)data; + SkSafeUnref(scaler); +} + +GrFontScaler* GrTextContext::GetGrFontScaler(SkGlyphCache* cache) { + void* auxData; + GrFontScaler* scaler = NULL; + + if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) { + scaler = (GrFontScaler*)auxData; + } + if (NULL == scaler) { + scaler = SkNEW_ARGS(SkGrFontScaler, (cache)); + cache->setAuxProc(GlyphCacheAuxProc, scaler); + } + + return scaler; } |