blob: 4d5005e2da9e8c613c30286d1e71cd0acc1c105e [file] [log] [blame]
reed@google.com5a649022013-06-05 18:00:30 +00001/*
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 Klein33d20552017-03-22 13:47:51 -04009#include "sk_tool_utils.h"
reed@google.com5a649022013-06-05 18:00:30 +000010#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
18class BigTextGM : public skiagm::GM {
19public:
20 BigTextGM() {}
21
22protected:
commit-bot@chromium.orga90c6802014-04-30 13:20:45 +000023
mtklein36352bf2015-03-25 18:17:31 -070024 SkString onShortName() override {
reed@google.com5a649022013-06-05 18:00:30 +000025 return SkString("bigtext");
26 }
27
mtklein36352bf2015-03-25 18:17:31 -070028 SkISize onISize() override {
reed@google.com5a649022013-06-05 18:00:30 +000029 return SkISize::Make(640, 480);
30 }
31
mtklein36352bf2015-03-25 18:17:31 -070032 void onDraw(SkCanvas* canvas) override {
reed@google.com5a649022013-06-05 18:00:30 +000033 SkPaint paint;
34 paint.setAntiAlias(true);
caryclark1818acb2015-07-24 12:09:25 -070035 sk_tool_utils::set_portable_typeface(&paint);
reed@google.com5a649022013-06-05 18:00:30 +000036 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);
46 canvas->drawText("/", 1, pos.fX, pos.fY, paint);
skia.committer@gmail.comc5fd0932013-06-06 07:01:37 +000047
reed@google.com5a649022013-06-05 18:00:30 +000048 paint.setColor(SK_ColorBLUE);
49 canvas->drawPosText("\\", 1, &pos, paint);
50 }
51
52private:
53 typedef skiagm::GM INHERITED;
54};
55
halcanary385fe4d2015-08-26 13:07:48 -070056DEF_GM(return new BigTextGM;)