• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "sk_tool_utils.h"
10 #include "SkCanvas.h"
11 #include "SkFont.h"
12 #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 
19 class BigTextGM : public skiagm::GM {
20 public:
BigTextGM()21     BigTextGM() {}
22 
23 protected:
24 
onShortName()25     SkString onShortName() override {
26         return SkString("bigtext");
27     }
28 
onISize()29     SkISize onISize() override {
30         return SkISize::Make(640, 480);
31     }
32 
onDraw(SkCanvas * canvas)33     void onDraw(SkCanvas* canvas) override {
34         SkPaint paint;
35         paint.setAntiAlias(true);
36         SkFont font(sk_tool_utils::create_portable_typeface(), 1500);
37 
38         SkRect r;
39         (void)font.measureText("/", 1, kUTF8_SkTextEncoding, &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->drawSimpleText("/", 1, kUTF8_SkTextEncoding, pos.fX, pos.fY, font, paint);
47 
48         paint.setColor(SK_ColorBLUE);
49         canvas->drawSimpleText("\\", 1, kUTF8_SkTextEncoding, pos.fX, pos.fY, font, paint);
50     }
51 
52 private:
53     typedef skiagm::GM INHERITED;
54 };
55 
56 DEF_GM(return new BigTextGM;)
57