2 * Copyright 2011 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
11 #include "SkTypeface.h"
13 static void test_path(SkCanvas* canvas, const SkPath& path) {
15 paint.setAntiAlias(true);
16 canvas->drawPath(path, paint);
18 paint.setStyle(SkPaint::kStroke_Style);
19 paint.setColor(SK_ColorRED);
20 canvas->drawPath(path, paint);
23 static void test_rev(SkCanvas* canvas, const SkPath& path) {
24 test_path(canvas, path);
27 rev.reverseAddPath(path);
29 canvas->translate(150, 0);
30 test_path(canvas, rev);
34 static void test_rev(SkCanvas* canvas) {
35 SkRect r = { 10, 10, 100, 60 };
39 path.addRect(r); test_rev(canvas, path);
41 canvas->translate(0, 100);
43 path.addRect(r); test_rev(canvas, path);
45 canvas->translate(0, 100);
47 path.moveTo(10, 10); path.lineTo(30, 30);
51 test_rev(canvas, path);
54 paint.setTextSize(SkIntToScalar(100));
55 sk_tool_utils::set_portable_typeface(&paint, "Hiragino Maru Gothic Pro");
57 paint.getTextPath("e", 1, 50, 50, &path);
58 canvas->translate(0, 100);
59 test_rev(canvas, path);
64 class PathReverseGM : public GM {
72 SkString onShortName() SK_OVERRIDE {
73 return SkString("path-reverse");
76 SkISize onISize() SK_OVERRIDE {
77 return SkISize::Make(640, 480);
80 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
81 if (false) test_rev(canvas); // avoid bit rot, suppress warning
82 SkRect r = { 10, 10, 100, 60 };
86 path.addRect(r); test_rev(canvas, path);
88 canvas->translate(0, 100);
90 path.addRect(r); test_rev(canvas, path);
92 canvas->translate(0, 100);
94 path.moveTo(10, 10); path.lineTo(30, 30);
98 test_rev(canvas, path);
101 paint.setTextSize(SkIntToScalar(100));
102 sk_tool_utils::set_portable_typeface(&paint, "Hiragino Maru Gothic Pro");
104 paint.getTextPath("e", 1, 50, 50, &path);
105 canvas->translate(0, 100);
106 test_rev(canvas, path);
110 typedef GM INHERITED;
113 //////////////////////////////////////////////////////////////////////////////
115 static GM* MyFactory(void*) { return new PathReverseGM; }
116 static GMRegistry reg(MyFactory);