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" |
| 11 | #include "SkPath.h" |
| 12 | |
| 13 | /** |
| 14 | * Skia may draw from outlines when the size is very large, so we exercise that |
| 15 | * here. |
| 16 | */ |
| 17 | |
| 18 | class BigTextGM : public skiagm::GM { |
| 19 | public: |
| 20 | BigTextGM() {} |
| 21 | |
| 22 | protected: |
commit-bot@chromium.org | a90c680 | 2014-04-30 13:20:45 +0000 | [diff] [blame] | 23 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 24 | SkString onShortName() override { |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 25 | return SkString("bigtext"); |
| 26 | } |
| 27 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 28 | SkISize onISize() override { |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 29 | return SkISize::Make(640, 480); |
| 30 | } |
| 31 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 32 | void onDraw(SkCanvas* canvas) override { |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 33 | SkPaint paint; |
| 34 | paint.setAntiAlias(true); |
caryclark | 1818acb | 2015-07-24 12:09:25 -0700 | [diff] [blame] | 35 | sk_tool_utils::set_portable_typeface(&paint); |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 36 | paint.setTextSize(1500); |
| 37 | |
| 38 | SkRect r; |
| 39 | (void)paint.measureText("/", 1, &r); |
| 40 | SkPoint pos = { |
| 41 | this->width()/2 - r.centerX(), |
| 42 | this->height()/2 - r.centerY() |
| 43 | }; |
| 44 | |
| 45 | paint.setColor(SK_ColorRED); |
Cary Clark | 2a475ea | 2017-04-28 15:35:12 -0400 | [diff] [blame] | 46 | canvas->drawString("/", pos.fX, pos.fY, 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); |
| 49 | canvas->drawPosText("\\", 1, &pos, paint); |
| 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;) |