Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: gm/typeface.cpp

Issue 2142033002: Factor code to rotate a canvas about a point. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gm/typeface.cpp
diff --git a/gm/typeface.cpp b/gm/typeface.cpp
index 34420dbee1868d177ec256977528cafb72546933..c611dca211401ed8d48663455f11c31530ff2914 100644
--- a/gm/typeface.cpp
+++ b/gm/typeface.cpp
@@ -12,6 +12,7 @@
#include "SkSurfaceProps.h"
#include "SkTypeface.h"
#include "SkTypes.h"
+#include "sk_tool_utils.h"
static void getGlyphPositions(const SkPaint& paint, const uint16_t glyphs[],
int count, SkScalar x, SkScalar y, SkPoint pos[]) {
@@ -154,20 +155,9 @@ private:
typedef skiagm::GM INHERITED;
};
-static void rotate_about(SkCanvas* canvas,
- SkScalar degrees,
- SkScalar px, SkScalar py) {
- canvas->translate(px, py);
- canvas->rotate(degrees);
- canvas->translate(-px, -py);
-}
-
class TypefaceRenderingGM : public skiagm::GM {
sk_sp<SkTypeface> fFace;
-public:
- TypefaceRenderingGM() { }
-
protected:
void onOnceBeforeDraw() override {
fFace = MakeResourceAsTypeface("/fonts/hintgasp.ttf");
@@ -256,8 +246,8 @@ protected:
for (const bool& rotateABit : rotateABitTypes) {
SkAutoCanvasRestore acr(canvas, true);
if (rotateABit) {
- rotate_about(canvas, 2, x + subpixel.offset.x(),
- y + subpixel.offset.y());
+ sk_tool_utils::rotate_about(canvas, 2, x + subpixel.offset.x(),
+ y + subpixel.offset.y());
}
canvas->drawText("A", 1, x + subpixel.offset.x(),
y + subpixel.offset.y(), paint);
« gm/strokes.cpp ('K') | « gm/strokes.cpp ('k') | samplecode/SampleApp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698