diff options
author | Jim Van Verth <jvanverth@google.com> | 2018-05-24 14:32:26 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-24 19:38:49 +0000 |
commit | 30f64e4512e05c779ebf3d56f98309eeea9e3755 (patch) | |
tree | 25a38dda80e24e969c0ba62c94f37752e4a89280 | |
parent | 8a8dd33e18ce6946913247732273b1cd48ba0433 (diff) |
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 <robertphillips@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
-rw-r--r-- | gm/textblobrandomfont.cpp | 52 |
1 files changed, 29 insertions, 23 deletions
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: |