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

Side by Side Diff: samplecode/SampleMeasure.cpp

Issue 510433002: remove (unused) scale parameter from measureText (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove unused field from struct Created 6 years, 3 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 | « include/core/SkPaint.h ('k') | src/core/SkPaint.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkGradientShader.h" 11 #include "SkGradientShader.h"
12 #include "SkPath.h" 12 #include "SkPath.h"
13 #include "SkRegion.h" 13 #include "SkRegion.h"
14 #include "SkShader.h" 14 #include "SkShader.h"
15 #include "SkUtils.h" 15 #include "SkUtils.h"
16 #include "Sk1DPathEffect.h" 16 #include "Sk1DPathEffect.h"
17 #include "SkCornerPathEffect.h" 17 #include "SkCornerPathEffect.h"
18 #include "SkPathMeasure.h" 18 #include "SkPathMeasure.h"
19 #include "SkRandom.h" 19 #include "SkRandom.h"
20 #include "SkColorPriv.h" 20 #include "SkColorPriv.h"
21 #include "SkColorFilter.h" 21 #include "SkColorFilter.h"
22 #include "SkDither.h" 22 #include "SkDither.h"
23 23
24 // exercise scale/linear/devkern 24 // exercise scale/linear/devkern
25 struct Setting { 25 struct Setting {
26 SkScalar fScale;
27 bool fLinearText; 26 bool fLinearText;
28 bool fDevKernText; 27 bool fDevKernText;
29 }; 28 };
30 29
31 static const SkScalar ONE = SkIntToScalar(9999)/10000;
32
33 static const Setting gSettings[] = { 30 static const Setting gSettings[] = {
34 { 0, false, false }, 31 { false, false },
35 { 0, false, true }, 32 { false, true },
36 { 0, true, false }, 33 { true, false },
37 { 0, true, true }, 34 { true, true },
38 { ONE, false, false },
39 { ONE, false, true },
40 { ONE, true, false },
41 { ONE, true, true }
42 }; 35 };
43 36
44 static void doMeasure(SkCanvas* canvas, const SkPaint& paint, const char text[]) { 37 static void doMeasure(SkCanvas* canvas, const SkPaint& paint, const char text[]) {
45 SkScalar dy = paint.getFontMetrics(NULL); 38 SkScalar dy = paint.getFontMetrics(NULL);
46 39
47 size_t len = strlen(text); 40 size_t len = strlen(text);
48 SkAutoTMalloc<SkScalar> autoWidths(len); 41 SkAutoTMalloc<SkScalar> autoWidths(len);
49 SkScalar* widths = autoWidths.get(); 42 SkScalar* widths = autoWidths.get();
50 SkAutoTMalloc<SkRect> autoRects(len); 43 SkAutoTMalloc<SkRect> autoRects(len);
51 SkRect* rects = autoRects.get(); 44 SkRect* rects = autoRects.get();
52 SkRect bounds; 45 SkRect bounds;
53 46
54 SkPaint p(paint); 47 SkPaint p(paint);
55 for (size_t i = 0; i < SK_ARRAY_COUNT(gSettings); i++) { 48 for (size_t i = 0; i < SK_ARRAY_COUNT(gSettings); i++) {
56 p.setLinearText(gSettings[i].fLinearText); 49 p.setLinearText(gSettings[i].fLinearText);
57 p.setDevKernText(gSettings[i].fDevKernText); 50 p.setDevKernText(gSettings[i].fDevKernText);
58 SkScalar scale = gSettings[i].fScale;
59 51
60 int n = p.getTextWidths(text, len, widths, rects); 52 int n = p.getTextWidths(text, len, widths, rects);
61 SkScalar w = p.measureText(text, len, &bounds, scale); 53 SkScalar w = p.measureText(text, len, &bounds);
62 54
63 p.setStyle(SkPaint::kFill_Style); 55 p.setStyle(SkPaint::kFill_Style);
64 p.setColor(0x8888FF88); 56 p.setColor(0x8888FF88);
65 canvas->drawRect(bounds, p); 57 canvas->drawRect(bounds, p);
66 p.setColor(0xFF000000); 58 p.setColor(0xFF000000);
67 canvas->drawText(text, len, 0, 0, p); 59 canvas->drawText(text, len, 0, 0, p);
68 60
69 p.setStyle(SkPaint::kStroke_Style); 61 p.setStyle(SkPaint::kStroke_Style);
70 p.setStrokeWidth(0); 62 p.setStrokeWidth(0);
71 p.setColor(0xFFFF0000); 63 p.setColor(0xFFFF0000);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 104 }
113 105
114 private: 106 private:
115 typedef SampleView INHERITED; 107 typedef SampleView INHERITED;
116 }; 108 };
117 109
118 ////////////////////////////////////////////////////////////////////////////// 110 //////////////////////////////////////////////////////////////////////////////
119 111
120 static SkView* MyFactory() { return new MeasureView; } 112 static SkView* MyFactory() { return new MeasureView; }
121 static SkViewRegister reg(MyFactory); 113 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « include/core/SkPaint.h ('k') | src/core/SkPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698