reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 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 | 6a34f3a | 2019-05-01 10:59:30 -0400 | [diff] [blame] | 10 | #include "include/core/SkColor.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkFont.h" |
Ben Wagner | 6a34f3a | 2019-05-01 10:59:30 -0400 | [diff] [blame] | 12 | #include "include/core/SkFontTypes.h" |
| 13 | #include "include/core/SkPaint.h" |
| 14 | #include "include/core/SkPoint.h" |
| 15 | #include "include/core/SkRect.h" |
| 16 | #include "include/core/SkSize.h" |
| 17 | #include "include/core/SkString.h" |
| 18 | #include "include/core/SkTypeface.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 19 | #include "tools/ToolUtils.h" |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * Skia may draw from outlines when the size is very large, so we exercise that |
| 23 | * here. |
| 24 | */ |
| 25 | |
| 26 | class BigTextGM : public skiagm::GM { |
| 27 | public: |
| 28 | BigTextGM() {} |
| 29 | |
| 30 | protected: |
commit-bot@chromium.org | a90c680 | 2014-04-30 13:20:45 +0000 | [diff] [blame] | 31 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 32 | SkString onShortName() override { |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 33 | return SkString("bigtext"); |
| 34 | } |
| 35 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 36 | SkISize onISize() override { |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 37 | return SkISize::Make(640, 480); |
| 38 | } |
| 39 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 40 | void onDraw(SkCanvas* canvas) override { |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 41 | SkPaint paint; |
| 42 | paint.setAntiAlias(true); |
Mike Klein | ea3f014 | 2019-03-20 11:12:10 -0500 | [diff] [blame] | 43 | SkFont font(ToolUtils::create_portable_typeface(), 1500); |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 44 | |
| 45 | SkRect r; |
Ben Wagner | 51e15a6 | 2019-05-07 15:38:46 -0400 | [diff] [blame] | 46 | (void)font.measureText("/", 1, SkTextEncoding::kUTF8, &r); |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 47 | SkPoint pos = { |
| 48 | this->width()/2 - r.centerX(), |
| 49 | this->height()/2 - r.centerY() |
| 50 | }; |
| 51 | |
| 52 | paint.setColor(SK_ColorRED); |
Ben Wagner | 51e15a6 | 2019-05-07 15:38:46 -0400 | [diff] [blame] | 53 | canvas->drawSimpleText("/", 1, SkTextEncoding::kUTF8, pos.fX, pos.fY, font, paint); |
skia.committer@gmail.com | c5fd093 | 2013-06-06 07:01:37 +0000 | [diff] [blame] | 54 | |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 55 | paint.setColor(SK_ColorBLUE); |
Ben Wagner | 51e15a6 | 2019-05-07 15:38:46 -0400 | [diff] [blame] | 56 | canvas->drawSimpleText("\\", 1, SkTextEncoding::kUTF8, pos.fX, pos.fY, font, paint); |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | private: |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 60 | using INHERITED = skiagm::GM; |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 63 | DEF_GM(return new BigTextGM;) |