Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1144)

Side by Side Diff: gm/colortype.cpp

Issue 14890016: start a wrapper for color fonts (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | include/core/SkTypeface.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 "SkGradientShader.h"
11 #include "../src/fonts/SkGScalerContext.h"
12
13 class ColorTypeGM : public skiagm::GM {
14 public:
15 ColorTypeGM() {
16 const SkColor colors[] = {
17 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE,
18 SK_ColorMAGENTA, SK_ColorCYAN, SK_ColorYELLOW
19 };
20 SkShader* s = SkGradientShader::CreateSweep(0,0, colors, NULL,
21 SK_ARRAY_COUNT(colors));
22 SkMatrix local;
23 local.setRotate(180);
24 s->setLocalMatrix(local);
25
26 SkPaint paint;
27 paint.setAntiAlias(true);
28 paint.setShader(s)->unref();
29
30 SkAutoTUnref<SkTypeface> orig(SkTypeface::CreateFromName("Times",
31 SkTypeface::kBold));
32 fColorType = SkNEW_ARGS(SkGTypeface, (orig, paint));
33 }
34
35 virtual ~ColorTypeGM() {
36 fColorType->unref();
37 }
38
39 protected:
40 virtual SkString onShortName() SK_OVERRIDE {
41 return SkString("colortype");
42 }
43
44 virtual SkISize onISize() SK_OVERRIDE {
45 return SkISize::Make(640, 480);
46 }
47
48 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
49 SkPaint paint;
50 paint.setAntiAlias(true);
51 paint.setTypeface(fColorType);
52
53 for (int size = 10; size <= 100; size += 10) {
54 paint.setTextSize(size);
55 canvas->translate(0, paint.getFontMetrics(NULL));
56 canvas->drawText("Hamburgefons", 12, 10, 10, paint);
57 }
58 }
59
60 virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; }
61
62 private:
63 SkTypeface* fColorType;
64
65 typedef skiagm::GM INHERITED;
66 };
67
68 DEF_GM( return SkNEW(ColorTypeGM); )
OLDNEW
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | include/core/SkTypeface.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698