diff options
author | bungeman <bungeman@google.com> | 2016-07-12 15:01:19 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-12 15:01:19 -0700 |
commit | 7438bfc0804d021aa92cdd5ea644994a4248f3db (patch) | |
tree | 0b801d131d01d45e83160a6d0d877949590908de /gm/dftext.cpp | |
parent | 2edf0c6a719b8dff4365628cf3b4481c5035f07a (diff) | |
download | platform_external_skqp-7438bfc0804d021aa92cdd5ea644994a4248f3db.tar.gz platform_external_skqp-7438bfc0804d021aa92cdd5ea644994a4248f3db.tar.bz2 platform_external_skqp-7438bfc0804d021aa92cdd5ea644994a4248f3db.zip |
Factor code to rotate a canvas about a point.
SkMatrix::scale and ::rotate take a point around which to scale or rotate.
Canvas lacks these helpers, so the code to rotate a canvas around a
point has been duplicated many times. Factor all of these
implementations into SkCanvas::rotate.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2142033002
Review-Url: https://codereview.chromium.org/2142033002
Diffstat (limited to 'gm/dftext.cpp')
-rw-r--r-- | gm/dftext.cpp | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/gm/dftext.cpp b/gm/dftext.cpp index 42d650ed2f..8ab2df71ba 100644 --- a/gm/dftext.cpp +++ b/gm/dftext.cpp @@ -33,14 +33,6 @@ protected: return SkISize::Make(1024, 768); } - static void rotate_about(SkCanvas* canvas, - SkScalar degrees, - SkScalar px, SkScalar py) { - canvas->translate(px, py); - canvas->rotate(degrees); - canvas->translate(-px, -py); - } - virtual void onDraw(SkCanvas* inputCanvas) override { SkScalar textSizes[] = { 9.0f, 9.0f*2.0f, 9.0f*5.0f, 9.0f*2.0f*5.0f }; SkScalar scales[] = { 2.0f*5.0f, 5.0f, 2.0f, 1.0f }; @@ -95,7 +87,7 @@ protected: SkAutoCanvasRestore acr(canvas, true); canvas->translate(SkIntToScalar(10 + i * 200), -80); - rotate_about(canvas, SkIntToScalar(i * 5), rotX, rotY); + canvas->rotate(SkIntToScalar(i * 5), rotX, rotY); for (int ps = 6; ps <= 32; ps += 3) { paint.setTextSize(SkIntToScalar(ps)); canvas->drawText(text, textLen, rotX, rotY, paint); |