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

Side by Side Diff: gm/filterbitmap.cpp

Issue 1818043002: SkTypeface::MakeFromName to take SkFontStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Android fix + nit fix Created 4 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
« no previous file with comments | « gm/downsamplebitmap.cpp ('k') | gm/fontcache.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 9
10 #include "Resources.h" 10 #include "Resources.h"
11 #include "SkGradientShader.h" 11 #include "SkGradientShader.h"
12 #include "SkStream.h" 12 #include "SkStream.h"
13 #include "SkTypeface.h" 13 #include "SkTypeface.h"
14 14
15 static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style sty le) { 15 static void setTypeface(SkPaint* paint, const char name[], SkFontStyle style) {
16 sk_tool_utils::set_portable_typeface(paint, name, style); 16 sk_tool_utils::set_portable_typeface(paint, name, style);
17 } 17 }
18 18
19 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) { 19 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) {
20 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()), 20 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()),
21 SkIntToScalar(bm.height())); 21 SkIntToScalar(bm.height()));
22 mat.mapRect(&bounds); 22 mat.mapRect(&bounds);
23 return SkSize::Make(bounds.width(), bounds.height()); 23 return SkSize::Make(bounds.width(), bounds.height());
24 } 24 }
25 25
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 void makeBitmap() override { 116 void makeBitmap() override {
117 fBM.allocN32Pixels(int(fTextSize * 8), int(fTextSize * 6)); 117 fBM.allocN32Pixels(int(fTextSize * 8), int(fTextSize * 6));
118 SkCanvas canvas(fBM); 118 SkCanvas canvas(fBM);
119 canvas.drawColor(SK_ColorWHITE); 119 canvas.drawColor(SK_ColorWHITE);
120 120
121 SkPaint paint; 121 SkPaint paint;
122 paint.setAntiAlias(true); 122 paint.setAntiAlias(true);
123 paint.setSubpixelText(true); 123 paint.setSubpixelText(true);
124 paint.setTextSize(fTextSize); 124 paint.setTextSize(fTextSize);
125 125
126 setTypeface(&paint, "serif", SkTypeface::kNormal); 126 setTypeface(&paint, "serif", SkFontStyle());
127 canvas.drawText("Hamburgefons", 12, fTextSize/2, 1.2f*fTextSize, paint ); 127 canvas.drawText("Hamburgefons", 12, fTextSize/2, 1.2f*fTextSize, paint );
128 setTypeface(&paint, "serif", SkTypeface::kBold); 128 setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBo ld));
129 canvas.drawText("Hamburgefons", 12, fTextSize/2, 2.4f*fTextSize, paint ); 129 canvas.drawText("Hamburgefons", 12, fTextSize/2, 2.4f*fTextSize, paint );
130 setTypeface(&paint, "serif", SkTypeface::kItalic); 130 setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kIt alic));
131 canvas.drawText("Hamburgefons", 12, fTextSize/2, 3.6f*fTextSize, paint ); 131 canvas.drawText("Hamburgefons", 12, fTextSize/2, 3.6f*fTextSize, paint );
132 setTypeface(&paint, "serif", SkTypeface::kBoldItalic); 132 setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBo ldItalic));
133 canvas.drawText("Hamburgefons", 12, fTextSize/2, 4.8f*fTextSize, paint ); 133 canvas.drawText("Hamburgefons", 12, fTextSize/2, 4.8f*fTextSize, paint );
134 } 134 }
135 private: 135 private:
136 typedef FilterBitmapGM INHERITED; 136 typedef FilterBitmapGM INHERITED;
137 }; 137 };
138 138
139 class FilterBitmapCheckerboardGM: public FilterBitmapGM { 139 class FilterBitmapCheckerboardGM: public FilterBitmapGM {
140 public: 140 public:
141 FilterBitmapCheckerboardGM(int size, int num_checks, bool convertToG8 = fals e) 141 FilterBitmapCheckerboardGM(int size, int num_checks, bool convertToG8 = fals e)
142 : fSize(size), fNumChecks(num_checks), fConvertToG8(convertToG8) 142 : fSize(size), fNumChecks(num_checks), fConvertToG8(convertToG8)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 DEF_GM( return new FilterBitmapCheckerboardGM(32,2); ) 224 DEF_GM( return new FilterBitmapCheckerboardGM(32,2); )
225 DEF_GM( return new FilterBitmapCheckerboardGM(192,192); ) 225 DEF_GM( return new FilterBitmapCheckerboardGM(192,192); )
226 DEF_GM( return new FilterBitmapImageGM("mandrill_16.png"); ) 226 DEF_GM( return new FilterBitmapImageGM("mandrill_16.png"); )
227 DEF_GM( return new FilterBitmapImageGM("mandrill_32.png"); ) 227 DEF_GM( return new FilterBitmapImageGM("mandrill_32.png"); )
228 DEF_GM( return new FilterBitmapImageGM("mandrill_64.png"); ) 228 DEF_GM( return new FilterBitmapImageGM("mandrill_64.png"); )
229 DEF_GM( return new FilterBitmapImageGM("mandrill_64.png", true); ) 229 DEF_GM( return new FilterBitmapImageGM("mandrill_64.png", true); )
230 DEF_GM( return new FilterBitmapImageGM("mandrill_128.png"); ) 230 DEF_GM( return new FilterBitmapImageGM("mandrill_128.png"); )
231 DEF_GM( return new FilterBitmapImageGM("mandrill_256.png"); ) 231 DEF_GM( return new FilterBitmapImageGM("mandrill_256.png"); )
232 DEF_GM( return new FilterBitmapImageGM("mandrill_512.png"); ) 232 DEF_GM( return new FilterBitmapImageGM("mandrill_512.png"); )
233 DEF_GM( return new FilterBitmapImageGM("color_wheel.png"); ) 233 DEF_GM( return new FilterBitmapImageGM("color_wheel.png"); )
OLDNEW
« no previous file with comments | « gm/downsamplebitmap.cpp ('k') | gm/fontcache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698