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

Side by Side Diff: gm/shadertext3.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/shadertext2.cpp ('k') | gm/simpleaaclip.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 2011 Google Inc. 2 * Copyright 2011 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"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 69 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
70 70
71 SkPaint bmpPaint; 71 SkPaint bmpPaint;
72 bmpPaint.setAntiAlias(true); 72 bmpPaint.setAntiAlias(true);
73 bmpPaint.setFilterLevel(SkPaint::kLow_FilterLevel); 73 bmpPaint.setFilterLevel(SkPaint::kLow_FilterLevel);
74 bmpPaint.setAlpha(0x80); 74 bmpPaint.setAlpha(0x80);
75 canvas->drawBitmap(fBmp, 5.f, 5.f, &bmpPaint); 75 canvas->drawBitmap(fBmp, 5.f, 5.f, &bmpPaint);
76 76
77 SkPaint outlinePaint; 77 SkPaint outlinePaint;
78 outlinePaint.setAntiAlias(true); 78 outlinePaint.setAntiAlias(true);
79 sk_tool_utils::set_portable_typeface(&outlinePaint);
79 outlinePaint.setTextSize(SkIntToScalar(kPointSize)); 80 outlinePaint.setTextSize(SkIntToScalar(kPointSize));
80 outlinePaint.setStyle(SkPaint::kStroke_Style); 81 outlinePaint.setStyle(SkPaint::kStroke_Style);
81 outlinePaint.setStrokeWidth(0.f); 82 outlinePaint.setStrokeWidth(0.f);
82 83
83 canvas->translate(15.f, 15.f); 84 canvas->translate(15.f, 15.f);
84 85
85 // draw glyphs scaled up 86 // draw glyphs scaled up
86 canvas->scale(2.f, 2.f); 87 canvas->scale(2.f, 2.f);
87 88
88 static const SkShader::TileMode kTileModes[] = { 89 static const SkShader::TileMode kTileModes[] = {
(...skipping 13 matching lines...) Expand all
102 localM.postRotate(20); 103 localM.postRotate(20);
103 localM.postScale(1.15f, .85f); 104 localM.postScale(1.15f, .85f);
104 105
105 SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(fBmp, 106 SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(fBmp,
106 kTile Modes[tm0], 107 kTile Modes[tm0],
107 kTile Modes[tm1], 108 kTile Modes[tm1],
108 &loca lM)); 109 &loca lM));
109 110
110 SkPaint fillPaint; 111 SkPaint fillPaint;
111 fillPaint.setAntiAlias(true); 112 fillPaint.setAntiAlias(true);
113 sk_tool_utils::set_portable_typeface(&fillPaint);
112 fillPaint.setTextSize(SkIntToScalar(kPointSize)); 114 fillPaint.setTextSize(SkIntToScalar(kPointSize));
113 fillPaint.setFilterLevel(SkPaint::kLow_FilterLevel); 115 fillPaint.setFilterLevel(SkPaint::kLow_FilterLevel);
114 fillPaint.setShader(shader); 116 fillPaint.setShader(shader);
115 117
116 canvas->drawText(kText, kTextLen, 0, 0, fillPaint); 118 canvas->drawText(kText, kTextLen, 0, 0, fillPaint);
117 canvas->drawText(kText, kTextLen, 0, 0, outlinePaint); 119 canvas->drawText(kText, kTextLen, 0, 0, outlinePaint);
118 SkScalar w = fillPaint.measureText(kText, kTextLen); 120 SkScalar w = fillPaint.measureText(kText, kTextLen);
119 canvas->translate(w + 10.f, 0.f); 121 canvas->translate(w + 10.f, 0.f);
120 ++i; 122 ++i;
121 if (!(i % 2)) { 123 if (!(i % 2)) {
122 canvas->restore(); 124 canvas->restore();
123 canvas->translate(0, 0.75f * kPointSize); 125 canvas->translate(0, 0.75f * kPointSize);
124 canvas->save(); 126 canvas->save();
125 } 127 }
126 } 128 }
127 } 129 }
128 canvas->restore(); 130 canvas->restore();
129 } 131 }
130 132
131 private: 133 private:
132 SkBitmap fBmp; 134 SkBitmap fBmp;
133 typedef GM INHERITED; 135 typedef GM INHERITED;
134 }; 136 };
135 137
136 /////////////////////////////////////////////////////////////////////////////// 138 ///////////////////////////////////////////////////////////////////////////////
137 139
138 static GM* MyFactory(void*) { return new ShaderText3GM; } 140 static GM* MyFactory(void*) { return new ShaderText3GM; }
139 static GMRegistry reg(MyFactory); 141 static GMRegistry reg(MyFactory);
140 } 142 }
OLDNEW
« no previous file with comments | « gm/shadertext2.cpp ('k') | gm/simpleaaclip.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698