From 30f64e4512e05c779ebf3d56f98309eeea9e3755 Mon Sep 17 00:00:00 2001 From: Jim Van Verth Date: Thu, 24 May 2018 14:32:26 -0400 Subject: Clean up textblobrandomfont. The middle set of text is generated by rendering into a surface and then blitting that to the canvas to generate a certain kind of text generation. However, we are rendering with a -0.05 rotation and using nearest-neighbor sampling, which produces nasty artifacts unrelated to text. Changed the sample to render into the surface with the rotation, and blit back with no rotation. Bug: skia:7115 Change-Id: Iac1338f556cacc6c617ca14a625c649a6e7b9a48 Reviewed-on: https://skia-review.googlesource.com/130027 Reviewed-by: Robert Phillips Commit-Queue: Jim Van Verth --- gm/textblobrandomfont.cpp | 52 ++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'gm/textblobrandomfont.cpp') diff --git a/gm/textblobrandomfont.cpp b/gm/textblobrandomfont.cpp index 4aad888dbc..acde46887d 100644 --- a/gm/textblobrandomfont.cpp +++ b/gm/textblobrandomfont.cpp @@ -120,33 +120,39 @@ protected: SkPaint paint; paint.setAntiAlias(true); - SkCanvas* c = surface->getCanvas(); + SkCanvas* surfaceCanvas = surface->getCanvas(); SkScalar stride = SkScalarCeilToScalar(fBlob->bounds().height()); SkScalar yOffset = 5; - for (int i = 0; i < 1; i++) { - // fiddle the canvas to force regen of textblobs - canvas->rotate(i % 2 ? 0.0f : -0.05f); - - canvas->drawTextBlob(fBlob, 10, yOffset, paint); - yOffset += stride; - - // this will test lcd masks when not requested - // on cpu this currently causes unspecified behavior, so avoid until it is fixed - if (canvas->getGrContext()) { - c->drawTextBlob(fBlob, 10, yOffset, paint); - surface->draw(canvas, 0, 0, nullptr); - } - yOffset += stride; - - // free gpu resources and verify - if (canvas->getGrContext()) { - canvas->getGrContext()->freeGpuResources(); - } - - canvas->drawTextBlob(fBlob, 10, yOffset, paint); - yOffset += stride; + + canvas->save(); + // Originally we would alternate between rotating and not to force blob regeneration, + // but that code seems to have rotted. Keeping the rotate to match the old GM as + // much as possible, and it seems like a reasonable stress test for transformed + // color emoji. + canvas->rotate(-0.05f); + canvas->drawTextBlob(fBlob, 10, yOffset, paint); + yOffset += stride; + canvas->restore(); + + // this will test lcd masks when not requested + // on cpu this currently causes unspecified behavior, so avoid until it is fixed + if (canvas->getGrContext()) { + // Rotate in the surface canvas, not the final canvas, to avoid aliasing + surfaceCanvas->rotate(-0.05f); + surfaceCanvas->drawTextBlob(fBlob, 10, yOffset, paint); + surface->draw(canvas, 0, 0, nullptr); + } + yOffset += stride; + + // free gpu resources and verify + if (canvas->getGrContext()) { + canvas->getGrContext()->freeGpuResources(); } + + canvas->rotate(-0.05f); + canvas->drawTextBlob(fBlob, 10, yOffset, paint); + yOffset += stride; } private: -- cgit v1.2.3