| Index: src/gpu/GrAtlasTextContext.cpp
|
| diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
|
| index 8ea5f16ec29c921778d2a09b54c4e5360ee4defa..15c4a1544afc2cdf2cf33b9b9bd9e694c9e676ba 100644
|
| --- a/src/gpu/GrAtlasTextContext.cpp
|
| +++ b/src/gpu/GrAtlasTextContext.cpp
|
| @@ -60,10 +60,9 @@ static size_t get_vertex_stride(GrMaskFormat maskFormat) {
|
| };
|
|
|
| // TODO
|
| -// More tests
|
| -// move to SkCache
|
| -// handle textblobs where the whole run is larger than the cache size
|
| -// TODO implement micro speedy hash map for fast refing of glyphs
|
| +// Gamma slotting to preserve color
|
| +// Better reuse on regeneration
|
| +// Telemetry tests
|
|
|
| GrAtlasTextContext::GrAtlasTextContext(GrContext* context,
|
| SkGpuDevice* gpuDevice,
|
| @@ -157,17 +156,25 @@ void GrAtlasTextContext::drawTextBlob(GrRenderTarget* rt, const GrClip& clip,
|
| const SkPaint& skPaint, const SkMatrix& viewMatrix,
|
| const SkTextBlob* blob, SkScalar x, SkScalar y,
|
| SkDrawFilter* drawFilter, const SkIRect& clipBounds) {
|
| - uint32_t uniqueID = blob->uniqueID();
|
| SkAutoTUnref<BitmapTextBlob> cacheBlob;
|
| - // TODO start caching these, mix bits into the key
|
| +
|
| + BitmapTextBlob::Key key;
|
| + // It might be worth caching these things, but its not clear at this time
|
| + // TODO for animated mask filters, this will fill up our cache. We need a safeguard here
|
| + const SkMaskFilter* mf = skPaint.getMaskFilter();
|
| bool mustNotCache = skPaint.getPathEffect() ||
|
| - skPaint.getMaskFilter() ||
|
| - skPaint.getColorFilter() ||
|
| - skPaint.getStyle() != SkPaint::kFill_Style ||
|
| + (mf && !mf->asABlur(&key.fBlurRec)) ||
|
| drawFilter;
|
|
|
| if (!mustNotCache) {
|
| - cacheBlob.reset(SkSafeRef(fCache->find(uniqueID)));
|
| + key.fUniqueID = blob->uniqueID();
|
| + key.fStyle = skPaint.getStyle();
|
| + if (key.fStyle != SkPaint::kFill_Style) {
|
| + key.fStrokeInfo.fFrameWidth = skPaint.getStrokeWidth();
|
| + key.fStrokeInfo.fMiterLimit = skPaint.getStrokeMiter();
|
| + key.fStrokeInfo.fStrokeJoin = SkToU8(skPaint.getStrokeJoin());
|
| + }
|
| + cacheBlob.reset(SkSafeRef(fCache->find(key)));
|
| }
|
|
|
| SkIRect clipRect;
|
| @@ -182,7 +189,7 @@ void GrAtlasTextContext::drawTextBlob(GrRenderTarget* rt, const GrClip& clip,
|
| // TODO we could probably get away reuse most of the time if the pointer is unique,
|
| // but we'd have to clear the subrun information
|
| fCache->remove(cacheBlob);
|
| - cacheBlob.reset(SkRef(fCache->createCachedBlob(blob, kGrayTextVASize)));
|
| + cacheBlob.reset(SkRef(fCache->createCachedBlob(blob, key, kGrayTextVASize)));
|
| this->regenerateTextBlob(cacheBlob, skPaint, viewMatrix, blob, x, y, drawFilter,
|
| clipRect);
|
| } else {
|
| @@ -197,7 +204,7 @@ void GrAtlasTextContext::drawTextBlob(GrRenderTarget* rt, const GrClip& clip,
|
| if (mustNotCache) {
|
| cacheBlob.reset(fCache->createBlob(blob, kGrayTextVASize));
|
| } else {
|
| - cacheBlob.reset(SkRef(fCache->createCachedBlob(blob, kGrayTextVASize)));
|
| + cacheBlob.reset(SkRef(fCache->createCachedBlob(blob, key, kGrayTextVASize)));
|
| }
|
| this->regenerateTextBlob(cacheBlob, skPaint, viewMatrix, blob, x, y, drawFilter, clipRect);
|
| }
|
| @@ -219,7 +226,6 @@ void GrAtlasTextContext::regenerateTextBlob(BitmapTextBlob* cacheBlob,
|
| cacheBlob->fX = x;
|
| cacheBlob->fY = y;
|
| cacheBlob->fColor = skPaint.getColor();
|
| - cacheBlob->fStyle = skPaint.getStyle();
|
|
|
| // Regenerate textblob
|
| SkPaint runPaint = skPaint;
|
| @@ -297,7 +303,6 @@ void GrAtlasTextContext::onDrawText(GrRenderTarget* rt, const GrClip& clip,
|
| blob->fViewMatrix = viewMatrix;
|
| blob->fX = x;
|
| blob->fY = y;
|
| - blob->fStyle = skPaint.getStyle();
|
|
|
| SkIRect clipRect;
|
| clip.getConservativeBounds(rt->width(), rt->height(), &clipRect);
|
| @@ -408,7 +413,6 @@ void GrAtlasTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip& clip,
|
| const SkPoint& offset, const SkIRect& regionClipBounds) {
|
| int glyphCount = skPaint.countText(text, byteLength);
|
| SkAutoTUnref<BitmapTextBlob> blob(fCache->createBlob(glyphCount, 1, kGrayTextVASize));
|
| - blob->fStyle = skPaint.getStyle();
|
| blob->fViewMatrix = viewMatrix;
|
|
|
| SkIRect clipRect;
|
|
|