OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 #include "SkStream.h" | 27 #include "SkStream.h" |
28 #include "SkXMLParser.h" | 28 #include "SkXMLParser.h" |
29 #include "SkColorPriv.h" | 29 #include "SkColorPriv.h" |
30 #include "SkImageDecoder.h" | 30 #include "SkImageDecoder.h" |
31 | 31 |
32 static SkRandom gRand; | 32 static SkRandom gRand; |
33 | 33 |
34 static void test_chromium_9005() { | 34 static void test_chromium_9005() { |
35 SkBitmap bm; | 35 SkBitmap bm; |
36 bm.setConfig(SkBitmap::kARGB_8888_Config, 800, 600); | 36 bm.allocN32Pixels(800, 600); |
37 bm.allocPixels(); | |
38 | 37 |
39 SkCanvas canvas(bm); | 38 SkCanvas canvas(bm); |
40 | 39 |
41 SkPoint pt0 = { 799.33374f, 1.2360189f }; | 40 SkPoint pt0 = { 799.33374f, 1.2360189f }; |
42 SkPoint pt1 = { 808.49969f, -7.4338055f }; | 41 SkPoint pt1 = { 808.49969f, -7.4338055f }; |
43 | 42 |
44 SkPaint paint; | 43 SkPaint paint; |
45 paint.setAntiAlias(true); | 44 paint.setAntiAlias(true); |
46 canvas.drawLine(pt0.fX, pt0.fY, pt1.fX, pt1.fY, paint); | 45 canvas.drawLine(pt0.fX, pt0.fY, pt1.fX, pt1.fY, paint); |
47 } | 46 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 int fCounter; | 219 int fCounter; |
221 | 220 |
222 virtual void onDrawContent(SkCanvas* canvas) { | 221 virtual void onDrawContent(SkCanvas* canvas) { |
223 gRand.setSeed(fNow); | 222 gRand.setSeed(fNow); |
224 | 223 |
225 if (false) { // avoid bit rot, suppress warning | 224 if (false) { // avoid bit rot, suppress warning |
226 test_chromium_9005(); | 225 test_chromium_9005(); |
227 } | 226 } |
228 | 227 |
229 SkBitmap bm, bm2; | 228 SkBitmap bm, bm2; |
230 bm.setConfig(SkBitmap::kARGB_8888_Config, | 229 bm.allocN32Pixels(WIDTH + MARGIN*2, HEIGHT + MARGIN*2); |
231 WIDTH + MARGIN*2, | |
232 HEIGHT + MARGIN*2); | |
233 bm.allocPixels(); | |
234 // this will erase our margin, which we want to always stay 0 | 230 // this will erase our margin, which we want to always stay 0 |
235 bm.eraseColor(SK_ColorTRANSPARENT); | 231 bm.eraseColor(SK_ColorTRANSPARENT); |
236 | 232 |
237 bm2.setConfig(SkBitmap::kARGB_8888_Config, WIDTH, HEIGHT, | 233 bm2.installPixels(SkImageInfo::MakeN32Premul(WIDTH, HEIGHT), |
238 bm.rowBytes()); | 234 bm.getAddr32(MARGIN, MARGIN), bm.rowBytes(), |
239 bm2.setPixels(bm.getAddr32(MARGIN, MARGIN)); | 235 NULL, NULL); |
240 | 236 |
241 SkCanvas c2(bm2); | 237 SkCanvas c2(bm2); |
242 SkPaint paint; | 238 SkPaint paint; |
243 paint.setAntiAlias(fDoAA); | 239 paint.setAntiAlias(fDoAA); |
244 paint.setStyle(SkPaint::kStroke_Style); | 240 paint.setStyle(SkPaint::kStroke_Style); |
245 | 241 |
246 bm2.eraseColor(SK_ColorTRANSPARENT); | 242 bm2.eraseColor(SK_ColorTRANSPARENT); |
247 gProcs[fProcIndex].fProc(&c2, paint, bm); | 243 gProcs[fProcIndex].fProc(&c2, paint, bm); |
248 canvas->drawBitmap(bm2, SkIntToScalar(10), SkIntToScalar(10), NULL); | 244 canvas->drawBitmap(bm2, SkIntToScalar(10), SkIntToScalar(10), NULL); |
249 | 245 |
(...skipping 20 matching lines...) Expand all Loading... |
270 | 266 |
271 | 267 |
272 private: | 268 private: |
273 typedef SampleView INHERITED; | 269 typedef SampleView INHERITED; |
274 }; | 270 }; |
275 | 271 |
276 ////////////////////////////////////////////////////////////////////////////// | 272 ////////////////////////////////////////////////////////////////////////////// |
277 | 273 |
278 static SkView* MyFactory() { return new HairlineView; } | 274 static SkView* MyFactory() { return new HairlineView; } |
279 static SkViewRegister reg(MyFactory); | 275 static SkViewRegister reg(MyFactory); |
OLD | NEW |