aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/strokerect.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-20 21:32:30 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-20 21:32:30 +0000
commit9903395a5a9c813f1ae207e4d4a2429e5c085266 (patch)
tree03703092cf3f2b607f2622f9ee2ae8ef747b37d6 /gm/strokerect.cpp
parent6bb92bc0b52d31f3ded38927cdefbeb13a3df87a (diff)
test for StrokeAndFill as well in this GM
git-svn-id: http://skia.googlecode.com/svn/trunk@6515 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/strokerect.cpp')
-rw-r--r--gm/strokerect.cpp41
1 files changed, 23 insertions, 18 deletions
diff --git a/gm/strokerect.cpp b/gm/strokerect.cpp
index f075600e47..99a50ef4f4 100644
--- a/gm/strokerect.cpp
+++ b/gm/strokerect.cpp
@@ -11,16 +11,18 @@
#define STROKE_WIDTH SkIntToScalar(20)
-static void draw_path(SkCanvas* canvas, const SkPath& path, const SkRect& rect, SkPaint::Join join) {
+static void draw_path(SkCanvas* canvas, const SkPath& path, const SkRect& rect,
+ SkPaint::Join join, int doFill) {
SkPaint paint;
paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStyle(doFill ? SkPaint::kStrokeAndFill_Style : SkPaint::kStroke_Style);
paint.setColor(SK_ColorGRAY);
paint.setStrokeWidth(STROKE_WIDTH);
paint.setStrokeJoin(join);
canvas->drawRect(rect, paint);
+ paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(0);
paint.setColor(SK_ColorRED);
canvas->drawPath(path, paint);
@@ -49,7 +51,7 @@ protected:
}
virtual SkISize onISize() {
- return SkISize::Make(1024, 480);
+ return SkISize::Make(1024, 740);
}
virtual void onDraw(SkCanvas* canvas) {
@@ -65,7 +67,7 @@ protected:
};
static const SkScalar W = 80;
- static const SkScalar H = 110;
+ static const SkScalar H = 80;
static const SkRect gRects[] = {
{ 0, 0, W, H },
{ W, 0, 0, H },
@@ -77,24 +79,27 @@ protected:
{ 0, 0, 0, H },
{ 0, 0, 0, 0 },
};
-
- for (size_t i = 0; i < SK_ARRAY_COUNT(gJoins); ++i) {
- SkPaint::Join join = gJoins[i];
- paint.setStrokeJoin(join);
- SkAutoCanvasRestore acr(canvas, true);
- for (size_t j = 0; j < SK_ARRAY_COUNT(gRects); ++j) {
- const SkRect& r = gRects[j];
+ for (int doFill = 0; doFill <= 1; ++doFill) {
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gJoins); ++i) {
+ SkPaint::Join join = gJoins[i];
+ paint.setStrokeJoin(join);
+
+ SkAutoCanvasRestore acr(canvas, true);
+ for (size_t j = 0; j < SK_ARRAY_COUNT(gRects); ++j) {
+ const SkRect& r = gRects[j];
- SkPath path, fillPath;
- path.addRect(r);
- paint.getFillPath(path, &fillPath);
- draw_path(canvas, fillPath, r, join);
+ SkPath path, fillPath;
+ path.addRect(r);
+ paint.getFillPath(path, &fillPath);
+ draw_path(canvas, fillPath, r, join, doFill);
- canvas->translate(W + 2 * STROKE_WIDTH, 0);
+ canvas->translate(W + 2 * STROKE_WIDTH, 0);
+ }
+ acr.restore();
+ canvas->translate(0, H + 2 * STROKE_WIDTH);
}
- acr.restore();
- canvas->translate(0, H + 2 * STROKE_WIDTH);
+ paint.setStyle(SkPaint::kStrokeAndFill_Style);
}
}