OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "gm.h" | 8 #include "gm.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 SkIntToScalar(330)); | 306 SkIntToScalar(330)); |
307 this->drawDashedLines(canvas, 100, SkIntToScalar(phase), SkIntTo
Scalar(3), 1, false); | 307 this->drawDashedLines(canvas, 100, SkIntToScalar(phase), SkIntTo
Scalar(3), 1, false); |
308 canvas->restore(); | 308 canvas->restore(); |
309 } | 309 } |
310 } | 310 } |
311 | 311 |
312 }; | 312 }; |
313 | 313 |
314 ////////////////////////////////////////////////////////////////////////////// | 314 ////////////////////////////////////////////////////////////////////////////// |
315 | 315 |
| 316 class Dashing4GM : public skiagm::GM { |
| 317 public: |
| 318 Dashing4GM() {} |
| 319 |
| 320 protected: |
| 321 virtual uint32_t onGetFlags() const SK_OVERRIDE { |
| 322 return kSkipTiled_Flag; |
| 323 } |
| 324 |
| 325 SkString onShortName() { |
| 326 return SkString("dashing4"); |
| 327 } |
| 328 |
| 329 SkISize onISize() { return skiagm::make_isize(640, 730); } |
| 330 |
| 331 virtual void onDraw(SkCanvas* canvas) { |
| 332 static const struct { |
| 333 int fOnInterval; |
| 334 int fOffInterval; |
| 335 } gData[] = { |
| 336 { 1, 1 }, |
| 337 { 4, 2 }, |
| 338 { 0, 4 }, // test for zero length on interval |
| 339 }; |
| 340 |
| 341 SkPaint paint; |
| 342 paint.setStyle(SkPaint::kStroke_Style); |
| 343 |
| 344 canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); |
| 345 canvas->translate(0, SK_ScalarHalf); |
| 346 |
| 347 for (int width = 0; width <= 2; ++width) { |
| 348 for (size_t data = 0; data < SK_ARRAY_COUNT(gData); ++data) { |
| 349 for (int aa = 0; aa <= 1; ++aa) { |
| 350 for (int cap = 0; cap <= 1; ++cap) { |
| 351 int w = width * width * width; |
| 352 paint.setAntiAlias(SkToBool(aa)); |
| 353 paint.setStrokeWidth(SkIntToScalar(w)); |
| 354 |
| 355 SkToBool(cap) ? paint.setStrokeCap(SkPaint::kSquare_Cap) |
| 356 : paint.setStrokeCap(SkPaint::kRound_Cap); |
| 357 |
| 358 int scale = w ? w : 1; |
| 359 |
| 360 drawline(canvas, gData[data].fOnInterval * scale, |
| 361 gData[data].fOffInterval * scale, |
| 362 paint); |
| 363 canvas->translate(0, SkIntToScalar(20)); |
| 364 } |
| 365 } |
| 366 } |
| 367 } |
| 368 } |
| 369 }; |
| 370 |
| 371 ////////////////////////////////////////////////////////////////////////////// |
| 372 |
316 static skiagm::GM* F0(void*) { return new DashingGM; } | 373 static skiagm::GM* F0(void*) { return new DashingGM; } |
317 static skiagm::GM* F1(void*) { return new Dashing2GM; } | 374 static skiagm::GM* F1(void*) { return new Dashing2GM; } |
318 static skiagm::GM* F2(void*) { return new Dashing3GM; } | 375 static skiagm::GM* F2(void*) { return new Dashing3GM; } |
| 376 static skiagm::GM* F3(void*) { return new Dashing4GM; } |
319 | 377 |
320 static skiagm::GMRegistry gR0(F0); | 378 static skiagm::GMRegistry gR0(F0); |
321 static skiagm::GMRegistry gR1(F1); | 379 static skiagm::GMRegistry gR1(F1); |
322 static skiagm::GMRegistry gR2(F2); | 380 static skiagm::GMRegistry gR2(F2); |
| 381 static skiagm::GMRegistry gR3(F3); |
OLD | NEW |