Stephen White | e7a364d | 2017-01-11 16:19:26 -0500 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "gm.h" |
| 9 | #include "SkCanvas.h" |
| 10 | #include "SkPath.h" |
| 11 | |
| 12 | #define WIDTH 400 |
| 13 | #define HEIGHT 400 |
| 14 | |
| 15 | namespace { |
| 16 | // Test thin stroked rect (stroked "by hand", not by stroking). |
| 17 | void draw_thin_stroked_rect(SkCanvas* canvas, const SkPaint& paint, SkScalar width) { |
| 18 | SkPath path; |
| 19 | path.moveTo(10 + width, 10 + width); |
| 20 | path.lineTo(40, 10 + width); |
| 21 | path.lineTo(40, 20); |
| 22 | path.lineTo(10 + width, 20); |
| 23 | path.moveTo(10, 10); |
| 24 | path.lineTo(10, 20 + width); |
| 25 | path.lineTo(40 + width, 20 + width); |
| 26 | path.lineTo(40 + width, 10); |
| 27 | canvas->drawPath(path, paint); |
| 28 | } |
| 29 | |
| 30 | }; |
| 31 | |
| 32 | class ThinConcavePathsGM : public skiagm::GM { |
| 33 | public: |
| 34 | ThinConcavePathsGM() {} |
| 35 | |
| 36 | protected: |
| 37 | SkString onShortName() override { |
| 38 | return SkString("thinconcavepaths"); |
| 39 | } |
| 40 | |
| 41 | SkISize onISize() override { |
| 42 | return SkISize::Make(WIDTH, HEIGHT); |
| 43 | } |
| 44 | |
| 45 | void onDraw(SkCanvas* canvas) override { |
| 46 | SkPaint paint; |
| 47 | |
| 48 | paint.setAntiAlias(true); |
| 49 | paint.setStyle(SkPaint::kFill_Style); |
| 50 | |
| 51 | canvas->save(); |
| 52 | for (SkScalar width = 1.0; width < 2.05; width += 0.25) { |
| 53 | draw_thin_stroked_rect(canvas, paint, width); |
| 54 | canvas->translate(0, 25); |
| 55 | } |
| 56 | canvas->restore(); |
| 57 | } |
| 58 | |
| 59 | private: |
| 60 | typedef skiagm::GM INHERITED; |
| 61 | }; |
| 62 | |
| 63 | DEF_GM( return new ThinConcavePathsGM; ) |