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

Side by Side Diff: gm/colortype.cpp

Issue 407183003: add portable and canonical font support for DM (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add atexit; rename to create_... Created 6 years, 4 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
« no previous file with comments | « gm/bigtext.cpp ('k') | gm/convexpolyclip.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
11 #include "../src/fonts/SkGScalerContext.h" 11 #include "../src/fonts/SkGScalerContext.h"
12 12
13 class ColorTypeGM : public skiagm::GM { 13 class ColorTypeGM : public skiagm::GM {
14 public: 14 public:
15 ColorTypeGM() { 15 ColorTypeGM() {
16 const SkColor colors[] = { 16 const SkColor colors[] = {
17 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, 17 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE,
18 SK_ColorMAGENTA, SK_ColorCYAN, SK_ColorYELLOW 18 SK_ColorMAGENTA, SK_ColorCYAN, SK_ColorYELLOW
19 }; 19 };
20 SkMatrix local; 20 SkMatrix local;
21 local.setRotate(180); 21 local.setRotate(180);
22 SkShader* s = SkGradientShader::CreateSweep(0,0, colors, NULL, 22 SkShader* s = SkGradientShader::CreateSweep(0,0, colors, NULL,
23 SK_ARRAY_COUNT(colors), 0, & local); 23 SK_ARRAY_COUNT(colors), 0, & local);
24 24
25 SkPaint paint; 25 SkPaint paint;
26 paint.setAntiAlias(true); 26 paint.setAntiAlias(true);
27 paint.setShader(s)->unref(); 27 paint.setShader(s)->unref();
28 28
29 SkTypeface* orig = SkTypeface::CreateFromName("Times", 29 SkTypeface* orig = sk_tool_utils::create_portable_typeface("Times",
30 SkTypeface::kBold); 30 SkTypeface::kBold);
31 if (NULL == orig) { 31 if (NULL == orig) {
32 orig = SkTypeface::RefDefault(); 32 orig = SkTypeface::RefDefault();
33 } 33 }
34 fColorType = SkNEW_ARGS(SkGTypeface, (orig, paint)); 34 fColorType = SkNEW_ARGS(SkGTypeface, (orig, paint));
35 orig->unref(); 35 orig->unref();
36 } 36 }
37 37
38 virtual ~ColorTypeGM() { 38 virtual ~ColorTypeGM() {
39 fColorType->unref(); 39 fColorType->unref();
40 } 40 }
(...skipping 23 matching lines...) Expand all
64 return kSkipPipe_Flag | kSkipPicture_Flag; 64 return kSkipPipe_Flag | kSkipPicture_Flag;
65 } 65 }
66 66
67 private: 67 private:
68 SkTypeface* fColorType; 68 SkTypeface* fColorType;
69 69
70 typedef skiagm::GM INHERITED; 70 typedef skiagm::GM INHERITED;
71 }; 71 };
72 72
73 DEF_GM( return SkNEW(ColorTypeGM); ) 73 DEF_GM( return SkNEW(ColorTypeGM); )
OLDNEW
« no previous file with comments | « gm/bigtext.cpp ('k') | gm/convexpolyclip.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698