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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 int fCount; | 137 int fCount; |
138 SkPoint* fVerts; | 138 SkPoint* fVerts; |
139 SkPoint* fTexs; | 139 SkPoint* fTexs; |
140 | 140 |
141 Rec() : fCount(0), fVerts(NULL), fTexs(NULL) {} | 141 Rec() : fCount(0), fVerts(NULL), fTexs(NULL) {} |
142 ~Rec() { delete[] fVerts; delete[] fTexs; } | 142 ~Rec() { delete[] fVerts; delete[] fTexs; } |
143 }; | 143 }; |
144 | 144 |
145 void make_tris(Rec* rec) { | 145 void make_tris(Rec* rec) { |
146 int n = 10; | 146 int n = 10; |
147 SkMWCRandom rand; | 147 SkRandom rand; |
148 | 148 |
149 rec->fMode = SkCanvas::kTriangles_VertexMode; | 149 rec->fMode = SkCanvas::kTriangles_VertexMode; |
150 rec->fCount = n * 3; | 150 rec->fCount = n * 3; |
151 rec->fVerts = new SkPoint[rec->fCount]; | 151 rec->fVerts = new SkPoint[rec->fCount]; |
152 | 152 |
153 for (int i = 0; i < n; i++) { | 153 for (int i = 0; i < n; i++) { |
154 SkPoint* v = &rec->fVerts[i*3]; | 154 SkPoint* v = &rec->fVerts[i*3]; |
155 for (int j = 0; j < 3; j++) { | 155 for (int j = 0; j < 3; j++) { |
156 v[j].set(rand.nextUScalar1() * 250, rand.nextUScalar1() * 250); | 156 v[j].set(rand.nextUScalar1() * 250, rand.nextUScalar1() * 250); |
157 } | 157 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 224 |
225 Rec fRecs[3]; | 225 Rec fRecs[3]; |
226 | 226 |
227 typedef SampleView INHERITED; | 227 typedef SampleView INHERITED; |
228 }; | 228 }; |
229 | 229 |
230 ////////////////////////////////////////////////////////////////////////////// | 230 ////////////////////////////////////////////////////////////////////////////// |
231 | 231 |
232 static SkView* MyFactory() { return new VerticesView; } | 232 static SkView* MyFactory() { return new VerticesView; } |
233 static SkViewRegister reg(MyFactory); | 233 static SkViewRegister reg(MyFactory); |
OLD | NEW |