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

Side by Side Diff: gm/glyph_pos.cpp

Issue 1243493003: make glyph_pos imageblur* largeglyphblur portable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove unused field Created 5 years, 5 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 | « no previous file | gm/imageblur.cpp » ('j') | gm/imageblur.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 "SkTypeface.h" 10 #include "SkTypeface.h"
(...skipping 30 matching lines...) Expand all
41 str.append("_f"); 41 str.append("_f");
42 } else { 42 } else {
43 str.append("_b"); // b == Both. 43 str.append("_b"); // b == Both.
44 } 44 }
45 return str; 45 return str;
46 } 46 }
47 47
48 SkISize onISize() override { return SkISize::Make(800, 600); } 48 SkISize onISize() override { return SkISize::Make(800, 600); }
49 49
50 void onDraw(SkCanvas* canvas) override { 50 void onDraw(SkCanvas* canvas) override {
51 if (!fProp) {
52 fProp.reset(sk_tool_utils::create_portable_typeface("Helvetica", SkT ypeface::kNormal));
53 }
54 51
55 // There's a black pixel at 40, 40 for reference. 52 // There's a black pixel at 40, 40 for reference.
56 canvas->drawPoint(40.0f, 40.0f, SK_ColorBLACK); 53 canvas->drawPoint(40.0f, 40.0f, SK_ColorBLACK);
57 54
58 // Two reference images. 55 // Two reference images.
59 canvas->translate(50.0f, 50.0f); 56 canvas->translate(50.0f, 50.0f);
60 drawTestCase(canvas, 1.0f); 57 drawTestCase(canvas, 1.0f);
61 58
62 canvas->translate(0.0f, 50.0f); 59 canvas->translate(0.0f, 50.0f);
63 drawTestCase(canvas, 3.0f); 60 drawTestCase(canvas, 3.0f);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 canvas->concat(perspective); 98 canvas->concat(perspective);
102 drawTestCase(canvas, 1.0f); 99 drawTestCase(canvas, 1.0f);
103 canvas->restore(); 100 canvas->restore();
104 } 101 }
105 102
106 void drawTestCase(SkCanvas* canvas, SkScalar textScale) { 103 void drawTestCase(SkCanvas* canvas, SkScalar textScale) {
107 SkPaint paint; 104 SkPaint paint;
108 paint.setColor(SK_ColorBLACK); 105 paint.setColor(SK_ColorBLACK);
109 paint.setAntiAlias(true); 106 paint.setAntiAlias(true);
110 paint.setTextSize(kTextHeight * textScale); 107 paint.setTextSize(kTextHeight * textScale);
111 paint.setTypeface(fProp); 108 sk_tool_utils::set_portable_typeface_always(&paint);
112 paint.setDevKernText(true);
113 paint.setStrokeWidth(fStrokeWidth); 109 paint.setStrokeWidth(fStrokeWidth);
114 paint.setStyle(fStrokeStyle); 110 paint.setStyle(fStrokeStyle);
115 111
116 // This demonstrates that we can not measure the text if there's a devic e transform. The 112 // This demonstrates that we can not measure the text if there's a devic e transform. The
117 // canvas total matrix will end up being a device transform. 113 // canvas total matrix will end up being a device transform.
118 bool drawRef = !(canvas->getTotalMatrix().getType() & 114 bool drawRef = !(canvas->getTotalMatrix().getType() &
119 ~(SkMatrix::kIdentity_Mask | SkMatrix::kTranslate_Mask) ); 115 ~(SkMatrix::kIdentity_Mask | SkMatrix::kTranslate_Mask) );
120 116
121 SkRect bounds; 117 SkRect bounds;
122 if (drawRef) { 118 if (drawRef) {
(...skipping 28 matching lines...) Expand all
151 paint.setColor(SK_ColorMAGENTA); 147 paint.setColor(SK_ColorMAGENTA);
152 SkScalar w = bounds.x(); 148 SkScalar w = bounds.x();
153 for (size_t i = 0; i < sizeof(kText) - 1; ++i) { 149 for (size_t i = 0; i < sizeof(kText) - 1; ++i) {
154 canvas->drawLine(w, 0.0f, w, 5.0f, paint); 150 canvas->drawLine(w, 0.0f, w, 5.0f, paint);
155 w += widths[i]; 151 w += widths[i];
156 } 152 }
157 } 153 }
158 } 154 }
159 155
160 private: 156 private:
161 SkAutoTUnref<SkTypeface> fProp;
162 SkScalar fStrokeWidth; 157 SkScalar fStrokeWidth;
163 SkPaint::Style fStrokeStyle; 158 SkPaint::Style fStrokeStyle;
164 159
165 typedef GM INHERITED; 160 typedef GM INHERITED;
166 }; 161 };
167 162
168 ////////////////////////////////////////////////////////////////////////////// 163 //////////////////////////////////////////////////////////////////////////////
169 164
170 static GM* GlyphPosHairlineStrokeAndFillFactory(void*) { 165 static GM* GlyphPosHairlineStrokeAndFillFactory(void*) {
171 return new GlyphPosGM(0.0f, SkPaint::kStrokeAndFill_Style); 166 return new GlyphPosGM(0.0f, SkPaint::kStrokeAndFill_Style);
(...skipping 16 matching lines...) Expand all
188 183
189 static GMRegistry reg1(GlyphPosHairlineStrokeAndFillFactory); 184 static GMRegistry reg1(GlyphPosHairlineStrokeAndFillFactory);
190 static GMRegistry reg2(GlyphPosStrokeAndFillFactory); 185 static GMRegistry reg2(GlyphPosStrokeAndFillFactory);
191 static GMRegistry reg3(GlyphPosHairlineStrokeFactory); 186 static GMRegistry reg3(GlyphPosHairlineStrokeFactory);
192 static GMRegistry reg4(GlyphPosStrokeFactory); 187 static GMRegistry reg4(GlyphPosStrokeFactory);
193 static GMRegistry reg5(GlyphPosHairlineFillFactory); 188 static GMRegistry reg5(GlyphPosHairlineFillFactory);
194 static GMRegistry reg6(GlyphPosFillFactory); 189 static GMRegistry reg6(GlyphPosFillFactory);
195 190
196 191
197 } 192 }
OLDNEW
« no previous file with comments | « no previous file | gm/imageblur.cpp » ('j') | gm/imageblur.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698