OLD | NEW |
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" |
(...skipping 23 matching lines...) Expand all Loading... |
34 m2.set(SkMatrix::kMScaleX, dst[1].fX - dst[0].fX); | 34 m2.set(SkMatrix::kMScaleX, dst[1].fX - dst[0].fX); |
35 m2.set(SkMatrix::kMSkewX, dst[2].fX - dst[0].fX); | 35 m2.set(SkMatrix::kMSkewX, dst[2].fX - dst[0].fX); |
36 m2.set(SkMatrix::kMTransX, dst[0].fX); | 36 m2.set(SkMatrix::kMTransX, dst[0].fX); |
37 m2.set(SkMatrix::kMSkewY, dst[1].fY - dst[0].fY); | 37 m2.set(SkMatrix::kMSkewY, dst[1].fY - dst[0].fY); |
38 m2.set(SkMatrix::kMScaleY, dst[2].fY - dst[0].fY); | 38 m2.set(SkMatrix::kMScaleY, dst[2].fY - dst[0].fY); |
39 m2.set(SkMatrix::kMTransY, dst[0].fY); | 39 m2.set(SkMatrix::kMTransY, dst[0].fY); |
40 | 40 |
41 m1.reset(); | 41 m1.reset(); |
42 | 42 |
43 const SkScalar src1[] = { | 43 const SkScalar src1[] = { |
44 0, 0, 0, SkFloatToScalar(427), SkFloatToScalar(316), SkFloatToSc
alar(427), SkFloatToScalar(316), 0 | 44 0, 0, 0, 427, 316, 427, 316, 0 |
45 }; | 45 }; |
46 const SkScalar dst1[] = { | 46 const SkScalar dst1[] = { |
47 SkFloatToScalar(158), SkFloatToScalar(177.5f), SkFloatToScalar(1
58), SkFloatToScalar(249.5f), | 47 158, 177.5f, 158, 249.5f, |
48 SkFloatToScalar(158), SkFloatToScalar(604.5f), SkFloatToScalar(1
58), SkFloatToScalar(-177.5f) | 48 158, 604.5f, 158, -177.5f |
49 }; | 49 }; |
50 | 50 |
51 (void) m2.setPolyToPoly((const SkPoint*)src1, (SkPoint*)dst1, 4); | 51 (void) m2.setPolyToPoly((const SkPoint*)src1, (SkPoint*)dst1, 4); |
52 | 52 |
53 { | 53 { |
54 const SkPoint src[] = { | 54 const SkPoint src[] = { |
55 { SkIntToScalar(1), SkIntToScalar(0) }, | 55 { SkIntToScalar(1), SkIntToScalar(0) }, |
56 { SkIntToScalar(4), SkIntToScalar(7) }, | 56 { SkIntToScalar(4), SkIntToScalar(7) }, |
57 { SkIntToScalar(10), SkIntToScalar(2) } | 57 { SkIntToScalar(10), SkIntToScalar(2) } |
58 }; | 58 }; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 SkPaint::FontMetrics fm; | 106 SkPaint::FontMetrics fm; |
107 paint->getFontMetrics(&fm); | 107 paint->getFontMetrics(&fm); |
108 paint->setColor(SK_ColorRED); | 108 paint->setColor(SK_ColorRED); |
109 paint->setStyle(SkPaint::kFill_Style); | 109 paint->setStyle(SkPaint::kFill_Style); |
110 SkScalar x = D/2; | 110 SkScalar x = D/2; |
111 float y = D/2 - (fm.fAscent + fm.fDescent)/2; | 111 float y = D/2 - (fm.fAscent + fm.fDescent)/2; |
112 SkString str; | 112 SkString str; |
113 str.appendS32(count); | 113 str.appendS32(count); |
114 canvas->drawText(str.c_str(), str.size(), | 114 canvas->drawText(str.c_str(), str.size(), |
115 x, SkFloatToScalar(y), | 115 x, y, |
116 *paint); | 116 *paint); |
117 | 117 |
118 canvas->restore(); | 118 canvas->restore(); |
119 } | 119 } |
120 | 120 |
121 virtual void onDrawContent(SkCanvas* canvas) { | 121 virtual void onDrawContent(SkCanvas* canvas) { |
122 SkPaint paint; | 122 SkPaint paint; |
123 paint.setAntiAlias(true); | 123 paint.setAntiAlias(true); |
124 paint.setStrokeWidth(SkIntToScalar(4)); | 124 paint.setStrokeWidth(SkIntToScalar(4)); |
125 paint.setTextSize(SkIntToScalar(40)); | 125 paint.setTextSize(SkIntToScalar(40)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 159 } |
160 | 160 |
161 private: | 161 private: |
162 typedef SampleView INHERITED; | 162 typedef SampleView INHERITED; |
163 }; | 163 }; |
164 | 164 |
165 ////////////////////////////////////////////////////////////////////////////// | 165 ////////////////////////////////////////////////////////////////////////////// |
166 | 166 |
167 static SkView* MyFactory() { return new PolyToPolyView; } | 167 static SkView* MyFactory() { return new PolyToPolyView; } |
168 static SkViewRegister reg(MyFactory); | 168 static SkViewRegister reg(MyFactory); |
OLD | NEW |