blob: 839609e86b45d20be1a5c3f9a663097ae296955e [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"
Mike Reed4ca01452018-12-13 10:08:05 -050011#include "SkFont.h"
reed@google.com5a649022013-06-05 18:00:30 +000012#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
19class BigTextGM : public skiagm::GM {
20public:
21 BigTextGM() {}
22
23protected:
commit-bot@chromium.orga90c6802014-04-30 13:20:45 +000024
mtklein36352bf2015-03-25 18:17:31 -070025 SkString onShortName() override {
reed@google.com5a649022013-06-05 18:00:30 +000026 return SkString("bigtext");
27 }
28
mtklein36352bf2015-03-25 18:17:31 -070029 SkISize onISize() override {
reed@google.com5a649022013-06-05 18:00:30 +000030 return SkISize::Make(640, 480);
31 }
32
mtklein36352bf2015-03-25 18:17:31 -070033 void onDraw(SkCanvas* canvas) override {
reed@google.com5a649022013-06-05 18:00:30 +000034 SkPaint paint;
35 paint.setAntiAlias(true);
Mike Reed4ca01452018-12-13 10:08:05 -050036 SkFont font(sk_tool_utils::create_portable_typeface(), 1500);
reed@google.com5a649022013-06-05 18:00:30 +000037
38 SkRect r;
Mike Reed4ca01452018-12-13 10:08:05 -050039 (void)font.measureText("/", 1, kUTF8_SkTextEncoding, &r);
reed@google.com5a649022013-06-05 18:00:30 +000040 SkPoint pos = {
41 this->width()/2 - r.centerX(),
42 this->height()/2 - r.centerY()
43 };
44
45 paint.setColor(SK_ColorRED);
Mike Reed4ca01452018-12-13 10:08:05 -050046 canvas->drawSimpleText("/", 1, kUTF8_SkTextEncoding, pos.fX, pos.fY, font, paint);
skia.committer@gmail.comc5fd0932013-06-06 07:01:37 +000047
reed@google.com5a649022013-06-05 18:00:30 +000048 paint.setColor(SK_ColorBLUE);
Mike Reed4ca01452018-12-13 10:08:05 -050049 canvas->drawSimpleText("\\", 1, kUTF8_SkTextEncoding, pos.fX, pos.fY, font, paint);
reed@google.com5a649022013-06-05 18:00:30 +000050 }
51
52private:
53 typedef skiagm::GM INHERITED;
54};
55
halcanary385fe4d2015-08-26 13:07:48 -070056DEF_GM(return new BigTextGM;)