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.
9 #include "include/core/SkCanvas.h"
10 #include "include/core/SkColor.h"
11 #include "include/core/SkPaint.h"
12 #include "include/core/SkRect.h"
13 #include "include/core/SkSize.h"
14 #include "include/core/SkString.h"
16 class ClipStrokeRectGM : public skiagm::GM {
23 SkString onShortName() override {
24 return SkString("clip_strokerect");
27 SkISize onISize() override {
28 return SkISize::Make(200, 400);
31 void onDraw(SkCanvas* canvas) override {
33 p.setColor(SK_ColorRED);
35 p.setStyle(SkPaint::kStroke_Style);
38 SkRect r = SkRect::MakeXYWH(20, 20, 100, 100);
39 // setting the height of this to 19 causes failure
40 SkRect rect = SkRect::MakeXYWH(20, 0, 100, 20);
43 canvas->clipRect(rect, true);
44 canvas->drawRect(r, p);
47 p.setColor(SK_ColorBLUE);
49 canvas->drawRect(rect, p);
51 p.setColor(SK_ColorRED);
53 p.setStyle(SkPaint::kStroke_Style);
56 SkRect r2 = SkRect::MakeXYWH(20, 140, 100, 100);
57 // setting the height of this to 19 causes failure
58 SkRect rect2 = SkRect::MakeXYWH(20, 120, 100, 19);
61 canvas->clipRect(rect2, true);
62 canvas->drawRect(r2, p);
65 p.setColor(SK_ColorBLUE);
67 canvas->drawRect(rect2, p);
71 using INHERITED = skiagm::GM;
74 DEF_GM(return new ClipStrokeRectGM;)