From 9903395a5a9c813f1ae207e4d4a2429e5c085266 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Tue, 20 Nov 2012 21:32:30 +0000 Subject: [PATCH] test for StrokeAndFill as well in this GM git-svn-id: http://skia.googlecode.com/svn/trunk@6515 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gm/strokerect.cpp | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/gm/strokerect.cpp b/gm/strokerect.cpp index f075600..99a50ef 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); } } -- 2.7.4