aboutsummaryrefslogtreecommitdiffstats
path: root/gm/filltypes.cpp
diff options
context:
space:
mode:
authorMike Reed <reed@google.com>2009-09-14 11:53:40 -0400
committerMike Reed <reed@google.com>2009-09-14 15:01:10 -0400
commite32706edd70b0f847fe4d124a195cd2927dc8021 (patch)
treec5fb8da02dc56601068c0e3695cc7298cf1bd8e9 /gm/filltypes.cpp
parent7ca7644aeec45833638d2ce965f4c6ec62e71ade (diff)
downloadexternal_skia-e32706edd70b0f847fe4d124a195cd2927dc8021.zip
external_skia-e32706edd70b0f847fe4d124a195cd2927dc8021.tar.gz
external_skia-e32706edd70b0f847fe4d124a195cd2927dc8021.tar.bz2
add SkSize.h
add golden-master (gm) test app
Diffstat (limited to 'gm/filltypes.cpp')
-rw-r--r--gm/filltypes.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/gm/filltypes.cpp b/gm/filltypes.cpp
new file mode 100644
index 0000000..e723f16
--- /dev/null
+++ b/gm/filltypes.cpp
@@ -0,0 +1,83 @@
+#include "gm.h"
+
+namespace skiagm {
+
+class FillTypeGM : public GM {
+ SkPath fPath;
+public:
+ FillTypeGM() {
+ const SkScalar radius = SkIntToScalar(45);
+ fPath.addCircle(SkIntToScalar(50), SkIntToScalar(50), radius);
+ fPath.addCircle(SkIntToScalar(100), SkIntToScalar(100), radius);
+ }
+
+protected:
+ virtual SkString onShortName() {
+ return SkString("filltypes");
+ }
+
+ virtual SkISize onISize() {
+ return make_isize(835, 840);
+ }
+
+ void showPath(SkCanvas* canvas, int x, int y, SkPath::FillType ft,
+ SkScalar scale, const SkPaint& paint) {
+
+ const SkRect r = { 0, 0, SkIntToScalar(150), SkIntToScalar(150) };
+
+ canvas->save();
+ canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
+ canvas->clipRect(r);
+ canvas->drawColor(SK_ColorWHITE);
+ fPath.setFillType(ft);
+ canvas->translate(r.centerX(), r.centerY());
+ canvas->scale(scale, scale);
+ canvas->translate(-r.centerX(), -r.centerY());
+ canvas->drawPath(fPath, paint);
+ canvas->restore();
+ }
+
+ void showFour(SkCanvas* canvas, SkScalar scale, const SkPaint& paint) {
+ showPath(canvas, 0, 0, SkPath::kWinding_FillType,
+ scale, paint);
+ showPath(canvas, 200, 0, SkPath::kEvenOdd_FillType,
+ scale, paint);
+ showPath(canvas, 00, 200, SkPath::kInverseWinding_FillType,
+ scale, paint);
+ showPath(canvas, 200, 200, SkPath::kInverseEvenOdd_FillType,
+ scale, paint);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) {
+ canvas->drawColor(0xFFDDDDDD);
+
+ canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
+
+ SkPaint paint;
+ const SkScalar scale = SkIntToScalar(5)/4;
+
+ paint.setAntiAlias(false);
+
+ showFour(canvas, SK_Scalar1, paint);
+ canvas->translate(SkIntToScalar(450), 0);
+ showFour(canvas, scale, paint);
+
+ paint.setAntiAlias(true);
+
+ canvas->translate(SkIntToScalar(-450), SkIntToScalar(450));
+ showFour(canvas, SK_Scalar1, paint);
+ canvas->translate(SkIntToScalar(450), 0);
+ showFour(canvas, scale, paint);
+ }
+
+private:
+ typedef GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+static GM* MyFactory(void*) { return new FillTypeGM; }
+static GMRegistry reg(MyFactory);
+
+}
+