Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(94)

Side by Side Diff: samplecode/SampleMeasure.cpp

Issue 96099: Whitespace fix: remove whitespace from the end of lines.
Patch Set: Created 16 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « samplecode/SampleLines.cpp ('k') | samplecode/SampleMipMap.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 #include "SampleCode.h" 1 #include "SampleCode.h"
2 #include "SkView.h" 2 #include "SkView.h"
3 #include "SkCanvas.h" 3 #include "SkCanvas.h"
4 #include "SkGradientShader.h" 4 #include "SkGradientShader.h"
5 #include "SkPath.h" 5 #include "SkPath.h"
6 #include "SkRegion.h" 6 #include "SkRegion.h"
7 #include "SkShader.h" 7 #include "SkShader.h"
8 #include "SkUtils.h" 8 #include "SkUtils.h"
9 #include "Sk1DPathEffect.h" 9 #include "Sk1DPathEffect.h"
10 #include "SkCornerPathEffect.h" 10 #include "SkCornerPathEffect.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 SkScalar* widths = autoWidths.get(); 43 SkScalar* widths = autoWidths.get();
44 SkAutoTMalloc<SkRect> autoRects(len); 44 SkAutoTMalloc<SkRect> autoRects(len);
45 SkRect* rects = autoRects.get(); 45 SkRect* rects = autoRects.get();
46 SkRect bounds; 46 SkRect bounds;
47 47
48 SkPaint p(paint); 48 SkPaint p(paint);
49 for (int i = 0; i < SK_ARRAY_COUNT(gSettings); i++) { 49 for (int i = 0; i < SK_ARRAY_COUNT(gSettings); i++) {
50 p.setLinearText(gSettings[i].fLinearText); 50 p.setLinearText(gSettings[i].fLinearText);
51 p.setDevKernText(gSettings[i].fDevKernText); 51 p.setDevKernText(gSettings[i].fDevKernText);
52 SkScalar scale = gSettings[i].fScale; 52 SkScalar scale = gSettings[i].fScale;
53 53
54 int n = p.getTextWidths(text, len, widths, rects); 54 int n = p.getTextWidths(text, len, widths, rects);
55 SkScalar w = p.measureText(text, len, &bounds, scale); 55 SkScalar w = p.measureText(text, len, &bounds, scale);
56 56
57 p.setStyle(SkPaint::kFill_Style); 57 p.setStyle(SkPaint::kFill_Style);
58 p.setColor(0x8888FF88); 58 p.setColor(0x8888FF88);
59 canvas->drawRect(bounds, p); 59 canvas->drawRect(bounds, p);
60 p.setColor(0xFF000000); 60 p.setColor(0xFF000000);
61 canvas->drawText(text, len, 0, 0, p); 61 canvas->drawText(text, len, 0, 0, p);
62 62
63 p.setStyle(SkPaint::kStroke_Style); 63 p.setStyle(SkPaint::kStroke_Style);
64 p.setStrokeWidth(0); 64 p.setStrokeWidth(0);
65 p.setColor(0xFFFF0000); 65 p.setColor(0xFFFF0000);
66 SkScalar x = 0; 66 SkScalar x = 0;
67 for (int j = 0; j < n; j++) { 67 for (int j = 0; j < n; j++) {
68 SkRect r = rects[j]; 68 SkRect r = rects[j];
69 r.offset(x, 0); 69 r.offset(x, 0);
70 canvas->drawRect(r, p); 70 canvas->drawRect(r, p);
71 x += widths[j]; 71 x += widths[j];
72 } 72 }
73 73
74 p.setColor(0xFF0000FF); 74 p.setColor(0xFF0000FF);
75 canvas->drawLine(0, 0, w, 0, p); 75 canvas->drawLine(0, 0, w, 0, p);
76 p.setStrokeWidth(SkIntToScalar(4)); 76 p.setStrokeWidth(SkIntToScalar(4));
77 canvas->drawPoint(x, 0, p); 77 canvas->drawPoint(x, 0, p);
78 78
79 canvas->translate(0, dy); 79 canvas->translate(0, dy);
80 } 80 }
81 } 81 }
82 82
83 class MeasureView : public SkView { 83 class MeasureView : public SkView {
84 public: 84 public:
85 SkPaint fPaint; 85 SkPaint fPaint;
86 86
87 MeasureView() 87 MeasureView()
88 { 88 {
89 fPaint.setAntiAlias(true); 89 fPaint.setAntiAlias(true);
90 fPaint.setTextSize(SkIntToScalar(64)); 90 fPaint.setTextSize(SkIntToScalar(64));
91 } 91 }
92 92
93 protected: 93 protected:
94 // overrides from SkEventSink 94 // overrides from SkEventSink
95 virtual bool onQuery(SkEvent* evt) 95 virtual bool onQuery(SkEvent* evt)
96 { 96 {
97 if (SampleCode::TitleQ(*evt)) 97 if (SampleCode::TitleQ(*evt))
98 { 98 {
99 SampleCode::TitleR(evt, "Measure"); 99 SampleCode::TitleR(evt, "Measure");
100 return true; 100 return true;
101 } 101 }
102 return this->INHERITED::onQuery(evt); 102 return this->INHERITED::onQuery(evt);
103 } 103 }
104 104
105 void drawBG(SkCanvas* canvas) 105 void drawBG(SkCanvas* canvas)
106 { 106 {
107 canvas->drawColor(0xFFDDDDDD); 107 canvas->drawColor(0xFFDDDDDD);
108 } 108 }
109 109
110 virtual void onDraw(SkCanvas* canvas) 110 virtual void onDraw(SkCanvas* canvas)
111 { 111 {
112 this->drawBG(canvas); 112 this->drawBG(canvas);
113 113
114 canvas->translate(fPaint.getTextSize(), fPaint.getTextSize()); 114 canvas->translate(fPaint.getTextSize(), fPaint.getTextSize());
115 doMeasure(canvas, fPaint, "Hamburgefons"); 115 doMeasure(canvas, fPaint, "Hamburgefons");
116 } 116 }
117 117
118 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) 118 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y)
119 { 119 {
120 // fSweep += SK_Scalar1; 120 // fSweep += SK_Scalar1;
121 this->inval(NULL); 121 this->inval(NULL);
122 return this->INHERITED::onFindClickHandler(x, y); 122 return this->INHERITED::onFindClickHandler(x, y);
123 } 123 }
124 124
125 virtual bool onClick(Click* click) 125 virtual bool onClick(Click* click)
126 { 126 {
127 return this->INHERITED::onClick(click); 127 return this->INHERITED::onClick(click);
128 } 128 }
129 129
130 private: 130 private:
131 typedef SkView INHERITED; 131 typedef SkView INHERITED;
132 }; 132 };
133 133
134 ////////////////////////////////////////////////////////////////////////////// 134 //////////////////////////////////////////////////////////////////////////////
135 135
136 static SkView* MyFactory() { return new MeasureView; } 136 static SkView* MyFactory() { return new MeasureView; }
137 static SkViewRegister reg(MyFactory); 137 static SkViewRegister reg(MyFactory);
138 138
OLDNEW
« no previous file with comments | « samplecode/SampleLines.cpp ('k') | samplecode/SampleMipMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b