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" |
| 9 | #include "SkCanvas.h" |
| 10 | #include "SkPath.h" |
| 11 | |
| 12 | /** |
| 13 | * Skia may draw from outlines when the size is very large, so we exercise that |
| 14 | * here. |
| 15 | */ |
| 16 | |
| 17 | class BigTextGM : public skiagm::GM { |
| 18 | public: |
| 19 | BigTextGM() {} |
| 20 | |
| 21 | protected: |
mtklein | 72c9faa | 2015-01-09 10:06:39 -0800 | [diff] [blame^] | 22 | uint32_t onGetFlags() const SK_OVERRIDE { |
commit-bot@chromium.org | a90c680 | 2014-04-30 13:20:45 +0000 | [diff] [blame] | 23 | return kSkipTiled_Flag; |
| 24 | } |
| 25 | |
mtklein | 72c9faa | 2015-01-09 10:06:39 -0800 | [diff] [blame^] | 26 | SkString onShortName() SK_OVERRIDE { |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 27 | return SkString("bigtext"); |
| 28 | } |
| 29 | |
mtklein | 72c9faa | 2015-01-09 10:06:39 -0800 | [diff] [blame^] | 30 | SkISize onISize() SK_OVERRIDE { |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 31 | return SkISize::Make(640, 480); |
| 32 | } |
| 33 | |
mtklein | 72c9faa | 2015-01-09 10:06:39 -0800 | [diff] [blame^] | 34 | void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 35 | SkPaint paint; |
| 36 | paint.setAntiAlias(true); |
Cary Clark | 992c7b0 | 2014-07-31 08:58:44 -0400 | [diff] [blame] | 37 | sk_tool_utils::set_portable_typeface(&paint); |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 38 | paint.setTextSize(1500); |
| 39 | |
| 40 | SkRect r; |
| 41 | (void)paint.measureText("/", 1, &r); |
| 42 | SkPoint pos = { |
| 43 | this->width()/2 - r.centerX(), |
| 44 | this->height()/2 - r.centerY() |
| 45 | }; |
| 46 | |
| 47 | paint.setColor(SK_ColorRED); |
| 48 | canvas->drawText("/", 1, pos.fX, pos.fY, paint); |
skia.committer@gmail.com | c5fd093 | 2013-06-06 07:01:37 +0000 | [diff] [blame] | 49 | |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 50 | paint.setColor(SK_ColorBLUE); |
| 51 | canvas->drawPosText("\\", 1, &pos, paint); |
| 52 | } |
| 53 | |
| 54 | private: |
| 55 | typedef skiagm::GM INHERITED; |
| 56 | }; |
| 57 | |
| 58 | DEF_GM( return SkNEW(BigTextGM); ) |