reed@google.com | 63d7374 | 2012-01-10 15:33:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "gm/gm.h" |
| 9 | #include "include/core/SkCanvas.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 10 | #include "include/core/SkColor.h" |
| 11 | #include "include/core/SkFont.h" |
| 12 | #include "include/core/SkFontStyle.h" |
| 13 | #include "include/core/SkPaint.h" |
| 14 | #include "include/core/SkPath.h" |
| 15 | #include "include/core/SkRect.h" |
| 16 | #include "include/core/SkScalar.h" |
| 17 | #include "include/core/SkString.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 18 | #include "include/core/SkTypeface.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 19 | #include "include/core/SkTypes.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 20 | #include "src/core/SkPathPriv.h" |
| 21 | #include "src/core/SkTextFormatParams.h" |
| 22 | #include "tools/ToolUtils.h" |
reed@google.com | 63d7374 | 2012-01-10 15:33:12 +0000 | [diff] [blame] | 23 | |
caryclark | 52b6461 | 2016-02-05 13:59:31 -0800 | [diff] [blame] | 24 | DEF_SIMPLE_GM(bug339297, canvas, 640, 480) { |
| 25 | SkPath path; |
| 26 | path.moveTo(-469515, -10354890); |
| 27 | path.cubicTo(771919.62f, -10411179, 2013360.1f, -10243774, 3195542.8f, -9860664); |
| 28 | path.lineTo(3195550, -9860655); |
| 29 | path.lineTo(3195539, -9860652); |
| 30 | path.lineTo(3195539, -9860652); |
| 31 | path.lineTo(3195539, -9860652); |
| 32 | path.cubicTo(2013358.1f, -10243761, 771919.25f, -10411166, -469513.84f, -10354877); |
| 33 | path.lineTo(-469515, -10354890); |
| 34 | path.close(); |
| 35 | |
| 36 | canvas->translate(258, 10365663); |
| 37 | |
| 38 | SkPaint paint; |
| 39 | paint.setAntiAlias(true); |
| 40 | paint.setColor(SK_ColorBLACK); |
| 41 | paint.setStyle(SkPaint::kFill_Style); |
| 42 | canvas->drawPath(path, paint); |
| 43 | |
| 44 | paint.setColor(SK_ColorRED); |
| 45 | paint.setStyle(SkPaint::kStroke_Style); |
| 46 | paint.setStrokeWidth(1); |
| 47 | canvas->drawPath(path, paint); |
| 48 | } |
Stephen White | 2cee283 | 2017-08-23 09:37:16 -0400 | [diff] [blame] | 49 | |
Chris Dalton | a32a3c3 | 2017-12-05 10:05:21 -0700 | [diff] [blame] | 50 | DEF_SIMPLE_GM(bug339297_as_clip, canvas, 640, 480) { |
| 51 | SkPath path; |
| 52 | path.moveTo(-469515, -10354890); |
| 53 | path.cubicTo(771919.62f, -10411179, 2013360.1f, -10243774, 3195542.8f, -9860664); |
| 54 | path.lineTo(3195550, -9860655); |
| 55 | path.lineTo(3195539, -9860652); |
| 56 | path.lineTo(3195539, -9860652); |
| 57 | path.lineTo(3195539, -9860652); |
| 58 | path.cubicTo(2013358.1f, -10243761, 771919.25f, -10411166, -469513.84f, -10354877); |
| 59 | path.lineTo(-469515, -10354890); |
| 60 | path.close(); |
| 61 | |
| 62 | canvas->translate(258, 10365663); |
| 63 | |
| 64 | canvas->save(); |
| 65 | canvas->clipPath(path, true); |
| 66 | canvas->clear(SK_ColorBLACK); |
| 67 | canvas->restore(); |
| 68 | |
| 69 | SkPaint paint; |
| 70 | paint.setAntiAlias(true); |
| 71 | paint.setStyle(SkPaint::kFill_Style); |
| 72 | paint.setColor(SK_ColorRED); |
| 73 | paint.setStyle(SkPaint::kStroke_Style); |
| 74 | paint.setStrokeWidth(1); |
| 75 | canvas->drawPath(path, paint); |
| 76 | } |
| 77 | |
Stephen White | 2cee283 | 2017-08-23 09:37:16 -0400 | [diff] [blame] | 78 | DEF_SIMPLE_GM(bug6987, canvas, 200, 200) { |
| 79 | SkPaint paint; |
| 80 | paint.setStyle(SkPaint::kStroke_Style); |
| 81 | paint.setStrokeWidth(0.0001f); |
| 82 | paint.setAntiAlias(true); |
| 83 | SkPath path; |
| 84 | canvas->save(); |
| 85 | canvas->scale(50000.0f, 50000.0f); |
| 86 | path.moveTo(0.0005f, 0.0004f); |
| 87 | path.lineTo(0.0008f, 0.0010f); |
| 88 | path.lineTo(0.0002f, 0.0010f); |
| 89 | path.close(); |
| 90 | canvas->drawPath(path, paint); |
| 91 | canvas->restore(); |
| 92 | } |