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 | |
| 8 | #include "gm.h" |
Mike Klein | 33d2055 | 2017-03-22 13:47:51 -0400 | [diff] [blame] | 9 | #include "sk_tool_utils.h" |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 10 | #include "SkCanvas.h" |
Mike Reed | 4ca0145 | 2018-12-13 10:08:05 -0500 | [diff] [blame] | 11 | #include "SkFont.h" |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 12 | #include "SkPath.h" |
| 13 | |
| 14 | /** |
| 15 | * Skia may draw from outlines when the size is very large, so we exercise that |
| 16 | * here. |
| 17 | */ |
| 18 | |
| 19 | class BigTextGM : public skiagm::GM { |
| 20 | public: |
| 21 | BigTextGM() {} |
| 22 | |
| 23 | protected: |
commit-bot@chromium.org | a90c680 | 2014-04-30 13:20:45 +0000 | [diff] [blame] | 24 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 25 | SkString onShortName() override { |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 26 | return SkString("bigtext"); |
| 27 | } |
| 28 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 29 | SkISize onISize() override { |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 30 | return SkISize::Make(640, 480); |
| 31 | } |
| 32 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 33 | void onDraw(SkCanvas* canvas) override { |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 34 | SkPaint paint; |
| 35 | paint.setAntiAlias(true); |
Mike Reed | 4ca0145 | 2018-12-13 10:08:05 -0500 | [diff] [blame] | 36 | SkFont font(sk_tool_utils::create_portable_typeface(), 1500); |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 37 | |
| 38 | SkRect r; |
Mike Reed | 4ca0145 | 2018-12-13 10:08:05 -0500 | [diff] [blame] | 39 | (void)font.measureText("/", 1, kUTF8_SkTextEncoding, &r); |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 40 | SkPoint pos = { |
| 41 | this->width()/2 - r.centerX(), |
| 42 | this->height()/2 - r.centerY() |
| 43 | }; |
| 44 | |
| 45 | paint.setColor(SK_ColorRED); |
Mike Reed | 4ca0145 | 2018-12-13 10:08:05 -0500 | [diff] [blame] | 46 | canvas->drawSimpleText("/", 1, kUTF8_SkTextEncoding, pos.fX, pos.fY, font, paint); |
skia.committer@gmail.com | c5fd093 | 2013-06-06 07:01:37 +0000 | [diff] [blame] | 47 | |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 48 | paint.setColor(SK_ColorBLUE); |
Mike Reed | 4ca0145 | 2018-12-13 10:08:05 -0500 | [diff] [blame] | 49 | canvas->drawSimpleText("\\", 1, kUTF8_SkTextEncoding, pos.fX, pos.fY, font, paint); |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | private: |
| 53 | typedef skiagm::GM INHERITED; |
| 54 | }; |
| 55 | |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 56 | DEF_GM(return new BigTextGM;) |