Don't create GrAtlasTextBlobs for zero glyph count text draws.

Bug: chromium:749472

Change-Id: I709889dd6bb06032e30cbf820ca67e7534cfac58
Reviewed-on: https://skia-review.googlesource.com/28540
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2017-07-31 08:00:25 -04:00 committed by Skia Commit-Bot
parent 1eace2db48
commit b3f6ac44db

View File

@ -241,7 +241,9 @@ GrAtlasTextContext::MakeDrawTextBlob(GrTextBlobCache* blobCache,
const char text[], size_t byteLength,
SkScalar x, SkScalar y) {
int glyphCount = paint.skPaint().countText(text, byteLength);
if (!glyphCount) {
return nullptr;
}
sk_sp<GrAtlasTextBlob> blob = blobCache->makeBlob(glyphCount, 1);
blob->initThrowawayBlob(viewMatrix, x, y);
@ -267,6 +269,9 @@ GrAtlasTextContext::MakeDrawPosTextBlob(GrTextBlobCache* blobCache,
const SkScalar pos[], int scalarsPerPosition, const
SkPoint& offset) {
int glyphCount = paint.skPaint().countText(text, byteLength);
if (!glyphCount) {
return nullptr;
}
sk_sp<GrAtlasTextBlob> blob = blobCache->makeBlob(glyphCount, 1);
blob->initThrowawayBlob(viewMatrix, offset.x(), offset.y());
@ -297,8 +302,10 @@ void GrAtlasTextContext::drawText(GrContext* context, GrRenderTargetContext* rtc
paint, ComputeScalerContextFlags(rtc),
viewMatrix, props,
text, byteLength, x, y));
blob->flushThrowaway(context, rtc, props, fDistanceAdjustTable.get(), paint, clip,
viewMatrix, regionClipBounds, x, y);
if (blob) {
blob->flushThrowaway(context, rtc, props, fDistanceAdjustTable.get(), paint, clip,
viewMatrix, regionClipBounds, x, y);
}
return;
}
@ -325,8 +332,10 @@ void GrAtlasTextContext::drawPosText(GrContext* context, GrRenderTargetContext*
text, byteLength,
pos, scalarsPerPosition,
offset));
blob->flushThrowaway(context, rtc, props, fDistanceAdjustTable.get(), paint, clip,
viewMatrix, regionClipBounds, offset.fX, offset.fY);
if (blob) {
blob->flushThrowaway(context, rtc, props, fDistanceAdjustTable.get(), paint, clip,
viewMatrix, regionClipBounds, offset.fX, offset.fY);
}
return;
}