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: |
| 22 | virtual SkString onShortName() SK_OVERRIDE { |
| 23 | return SkString("bigtext"); |
| 24 | } |
| 25 | |
| 26 | virtual SkISize onISize() SK_OVERRIDE { |
| 27 | return SkISize::Make(640, 480); |
| 28 | } |
| 29 | |
| 30 | virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 31 | SkPaint paint; |
| 32 | paint.setAntiAlias(true); |
| 33 | paint.setTextSize(1500); |
| 34 | |
| 35 | SkRect r; |
| 36 | (void)paint.measureText("/", 1, &r); |
| 37 | SkPoint pos = { |
| 38 | this->width()/2 - r.centerX(), |
| 39 | this->height()/2 - r.centerY() |
| 40 | }; |
| 41 | |
| 42 | paint.setColor(SK_ColorRED); |
| 43 | canvas->drawText("/", 1, pos.fX, pos.fY, paint); |
skia.committer@gmail.com | c5fd093 | 2013-06-06 07:01:37 +0000 | [diff] [blame] | 44 | |
reed@google.com | 5a64902 | 2013-06-05 18:00:30 +0000 | [diff] [blame] | 45 | paint.setColor(SK_ColorBLUE); |
| 46 | canvas->drawPosText("\\", 1, &pos, paint); |
| 47 | } |
| 48 | |
| 49 | private: |
| 50 | typedef skiagm::GM INHERITED; |
| 51 | }; |
| 52 | |
| 53 | DEF_GM( return SkNEW(BigTextGM); ) |