diff options
author | senorblanco <senorblanco@chromium.org> | 2014-10-23 15:00:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-23 15:00:12 -0700 |
commit | cbf6b6ecd5edca74aa9f78ea5b9a73fb955b8654 (patch) | |
tree | ddff4f7653fd952ba3cbf7606216cf5d8ac81cfe /gm/imagemagnifier.cpp | |
parent | 14e4d392d4ffa50c0ddf359a426668d1718d7f92 (diff) |
Fix imagemagnifier GM quality and speed.
The imagemagnifier GM was applying the filter both to a saveLayer()
restore() around the whole scene, as well as to each individual
text draw.
Applying the filter only in the saveLayer() makes it run ~20x faster
on my Linux box, and the quality is improved as well (since the
primitives are not double-filtered).
BUG=skia:
Review URL: https://codereview.chromium.org/637283009
Diffstat (limited to 'gm/imagemagnifier.cpp')
-rw-r--r-- | gm/imagemagnifier.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/gm/imagemagnifier.cpp b/gm/imagemagnifier.cpp index e2847b4c67..371b3088f9 100644 --- a/gm/imagemagnifier.cpp +++ b/gm/imagemagnifier.cpp @@ -35,23 +35,24 @@ protected: } virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { - SkPaint paint; - paint.setImageFilter( + SkPaint filterPaint; + filterPaint.setImageFilter( SkMagnifierImageFilter::Create( SkRect::MakeXYWH(SkIntToScalar(100), SkIntToScalar(100), SkIntToScalar(WIDTH / 2), SkIntToScalar(HEIGHT / 2)), 100))->unref(); - canvas->saveLayer(NULL, &paint); - paint.setAntiAlias(true); - sk_tool_utils::set_portable_typeface(&paint); + canvas->saveLayer(NULL, &filterPaint); const char* str = "The quick brown fox jumped over the lazy dog."; SkRandom rand; for (int i = 0; i < 25; ++i) { int x = rand.nextULessThan(WIDTH); int y = rand.nextULessThan(HEIGHT); + SkPaint paint; + sk_tool_utils::set_portable_typeface(&paint); paint.setColor(rand.nextBits(24) | 0xFF000000); paint.setTextSize(rand.nextRangeScalar(0, 300)); + paint.setAntiAlias(true); canvas->drawText(str, strlen(str), SkIntToScalar(x), SkIntToScalar(y), paint); } |