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 "SkBenchmark.h" | 8 #include "SkBenchmark.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { | 332 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { |
333 for (int i = 0; i < loops; ++i) { | 333 for (int i = 0; i < loops; ++i) { |
334 if (i % 1000 == 0) { | 334 if (i % 1000 == 0) { |
335 fPath.reset(); // PathRef memory can grow without bound otherwi
se. | 335 fPath.reset(); // PathRef memory can grow without bound otherwi
se. |
336 } | 336 } |
337 this->makePath(&fPath); | 337 this->makePath(&fPath); |
338 } | 338 } |
339 this->restartMakingPaths(); | 339 this->restartMakingPaths(); |
340 } | 340 } |
341 | 341 |
342 virtual void onPostDraw() SK_OVERRIDE { | |
343 this->finishedMakingPaths(); | |
344 } | |
345 | |
346 private: | 342 private: |
347 SkPath fPath; | 343 SkPath fPath; |
348 | 344 |
349 typedef RandomPathBench INHERITED; | 345 typedef RandomPathBench INHERITED; |
350 }; | 346 }; |
351 | 347 |
352 class PathCopyBench : public RandomPathBench { | 348 class PathCopyBench : public RandomPathBench { |
353 public: | 349 public: |
354 PathCopyBench() { | 350 PathCopyBench() { |
355 } | 351 } |
(...skipping 10 matching lines...) Expand all Loading... |
366 this->makePath(&fPaths[i]); | 362 this->makePath(&fPaths[i]); |
367 } | 363 } |
368 this->finishedMakingPaths(); | 364 this->finishedMakingPaths(); |
369 } | 365 } |
370 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { | 366 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { |
371 for (int i = 0; i < loops; ++i) { | 367 for (int i = 0; i < loops; ++i) { |
372 int idx = i & (kPathCnt - 1); | 368 int idx = i & (kPathCnt - 1); |
373 fCopies[idx] = fPaths[idx]; | 369 fCopies[idx] = fPaths[idx]; |
374 } | 370 } |
375 } | 371 } |
376 virtual void onPostDraw() SK_OVERRIDE { | |
377 fPaths.reset(0); | |
378 fCopies.reset(0); | |
379 } | |
380 | 372 |
381 private: | 373 private: |
382 enum { | 374 enum { |
383 // must be a pow 2 | 375 // must be a pow 2 |
384 kPathCnt = 1 << 5, | 376 kPathCnt = 1 << 5, |
385 }; | 377 }; |
386 SkAutoTArray<SkPath> fPaths; | 378 SkAutoTArray<SkPath> fPaths; |
387 SkAutoTArray<SkPath> fCopies; | 379 SkAutoTArray<SkPath> fCopies; |
388 | 380 |
389 typedef RandomPathBench INHERITED; | 381 typedef RandomPathBench INHERITED; |
(...skipping 27 matching lines...) Expand all Loading... |
417 fPaths[i & (kPathCnt - 1)].transform(fMatrix); | 409 fPaths[i & (kPathCnt - 1)].transform(fMatrix); |
418 } | 410 } |
419 } else { | 411 } else { |
420 for (int i = 0; i < loops; ++i) { | 412 for (int i = 0; i < loops; ++i) { |
421 int idx = i & (kPathCnt - 1); | 413 int idx = i & (kPathCnt - 1); |
422 fPaths[idx].transform(fMatrix, &fTransformed[idx]); | 414 fPaths[idx].transform(fMatrix, &fTransformed[idx]); |
423 } | 415 } |
424 } | 416 } |
425 } | 417 } |
426 | 418 |
427 virtual void onPostDraw() SK_OVERRIDE { | |
428 fPaths.reset(0); | |
429 fTransformed.reset(0); | |
430 } | |
431 | |
432 private: | 419 private: |
433 enum { | 420 enum { |
434 // must be a pow 2 | 421 // must be a pow 2 |
435 kPathCnt = 1 << 5, | 422 kPathCnt = 1 << 5, |
436 }; | 423 }; |
437 SkAutoTArray<SkPath> fPaths; | 424 SkAutoTArray<SkPath> fPaths; |
438 SkAutoTArray<SkPath> fTransformed; | 425 SkAutoTArray<SkPath> fTransformed; |
439 | 426 |
440 SkMatrix fMatrix; | 427 SkMatrix fMatrix; |
441 bool fInPlace; | 428 bool fInPlace; |
(...skipping 21 matching lines...) Expand all Loading... |
463 this->finishedMakingPaths(); | 450 this->finishedMakingPaths(); |
464 } | 451 } |
465 | 452 |
466 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { | 453 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { |
467 for (int i = 0; i < loops; ++i) { | 454 for (int i = 0; i < loops; ++i) { |
468 int idx = i & (kPathCnt - 1); | 455 int idx = i & (kPathCnt - 1); |
469 fParity ^= (fPaths[idx] == fCopies[idx & ~0x1]); | 456 fParity ^= (fPaths[idx] == fCopies[idx & ~0x1]); |
470 } | 457 } |
471 } | 458 } |
472 | 459 |
473 virtual void onPostDraw() SK_OVERRIDE { | |
474 fPaths.reset(0); | |
475 fCopies.reset(0); | |
476 } | |
477 | |
478 private: | 460 private: |
479 bool fParity; // attempt to keep compiler from optimizing out the == | 461 bool fParity; // attempt to keep compiler from optimizing out the == |
480 enum { | 462 enum { |
481 // must be a pow 2 | 463 // must be a pow 2 |
482 kPathCnt = 1 << 5, | 464 kPathCnt = 1 << 5, |
483 }; | 465 }; |
484 SkAutoTArray<SkPath> fPaths; | 466 SkAutoTArray<SkPath> fPaths; |
485 SkAutoTArray<SkPath> fCopies; | 467 SkAutoTArray<SkPath> fCopies; |
486 typedef RandomPathBench INHERITED; | 468 typedef RandomPathBench INHERITED; |
487 }; | 469 }; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 case kReversePathTo_AddType: | 547 case kReversePathTo_AddType: |
566 for (int i = 0; i < loops; ++i) { | 548 for (int i = 0; i < loops; ++i) { |
567 int idx = i & (kPathCnt - 1); | 549 int idx = i & (kPathCnt - 1); |
568 SkPath result = fPaths0[idx]; | 550 SkPath result = fPaths0[idx]; |
569 result.reversePathTo(fPaths1[idx]); | 551 result.reversePathTo(fPaths1[idx]); |
570 } | 552 } |
571 break; | 553 break; |
572 } | 554 } |
573 } | 555 } |
574 | 556 |
575 virtual void onPostDraw() SK_OVERRIDE { | |
576 fPaths0.reset(0); | |
577 fPaths1.reset(0); | |
578 } | |
579 | |
580 private: | 557 private: |
581 AddType fType; // or reverseAddPath | 558 AddType fType; // or reverseAddPath |
582 enum { | 559 enum { |
583 // must be a pow 2 | 560 // must be a pow 2 |
584 kPathCnt = 1 << 5, | 561 kPathCnt = 1 << 5, |
585 }; | 562 }; |
586 SkAutoTArray<SkPath> fPaths0; | 563 SkAutoTArray<SkPath> fPaths0; |
587 SkAutoTArray<SkPath> fPaths1; | 564 SkAutoTArray<SkPath> fPaths1; |
588 SkMatrix fMatrix; | 565 SkMatrix fMatrix; |
589 typedef RandomPathBench INHERITED; | 566 typedef RandomPathBench INHERITED; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 SkPoint xy; | 778 SkPoint xy; |
802 size.fWidth = rand.nextRangeScalar(kQueryMin.fWidth, kQueryMax.fWid
th); | 779 size.fWidth = rand.nextRangeScalar(kQueryMin.fWidth, kQueryMax.fWid
th); |
803 size.fHeight = rand.nextRangeScalar(kQueryMin.fHeight, kQueryMax.fHe
ight); | 780 size.fHeight = rand.nextRangeScalar(kQueryMin.fHeight, kQueryMax.fHe
ight); |
804 xy.fX = rand.nextRangeScalar(kBounds.fLeft, kBounds.fRight - size.fW
idth); | 781 xy.fX = rand.nextRangeScalar(kBounds.fLeft, kBounds.fRight - size.fW
idth); |
805 xy.fY = rand.nextRangeScalar(kBounds.fTop, kBounds.fBottom - size.fH
eight); | 782 xy.fY = rand.nextRangeScalar(kBounds.fTop, kBounds.fBottom - size.fH
eight); |
806 | 783 |
807 fQueryRects[i] = SkRect::MakeXYWH(xy.fX, xy.fY, size.fWidth, size.fH
eight); | 784 fQueryRects[i] = SkRect::MakeXYWH(xy.fX, xy.fY, size.fWidth, size.fH
eight); |
808 } | 785 } |
809 } | 786 } |
810 | 787 |
811 virtual void onPostDraw() SK_OVERRIDE { | |
812 fQueryRects.setCount(0); | |
813 } | |
814 | |
815 enum { | 788 enum { |
816 kQueryRectCnt = 400, | 789 kQueryRectCnt = 400, |
817 }; | 790 }; |
818 static const SkRect kBounds; // bounds for all random query rects | 791 static const SkRect kBounds; // bounds for all random query rects |
819 static const SkSize kQueryMin; // minimum query rect size, should be <= kQue
ryMax | 792 static const SkSize kQueryMin; // minimum query rect size, should be <= kQue
ryMax |
820 static const SkSize kQueryMax; // max query rect size, should < kBounds | 793 static const SkSize kQueryMax; // max query rect size, should < kBounds |
821 static const SkRect kBaseRect; // rect that is used to construct the path | 794 static const SkRect kBaseRect; // rect that is used to construct the path |
822 static const SkScalar kRRRadii[2]; // x and y radii for round rect | 795 static const SkScalar kRRRadii[2]; // x and y radii for round rect |
823 | 796 |
824 SkString fName; | 797 SkString fName; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 DEF_BENCH( return new ArbRoundRectBench(true); ) | 1010 DEF_BENCH( return new ArbRoundRectBench(true); ) |
1038 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
Rect_Type); ) | 1011 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
Rect_Type); ) |
1039 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
RoundRect_Type); ) | 1012 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
RoundRect_Type); ) |
1040 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
Oval_Type); ) | 1013 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
Oval_Type); ) |
1041 | 1014 |
1042 DEF_BENCH( return new ConicBench_Chop5() ) | 1015 DEF_BENCH( return new ConicBench_Chop5() ) |
1043 DEF_BENCH( return new ConicBench_ChopHalf() ) | 1016 DEF_BENCH( return new ConicBench_ChopHalf() ) |
1044 DEF_BENCH( return new ConicBench_ComputeError() ) | 1017 DEF_BENCH( return new ConicBench_ComputeError() ) |
1045 DEF_BENCH( return new ConicBench_asQuadTol() ) | 1018 DEF_BENCH( return new ConicBench_asQuadTol() ) |
1046 DEF_BENCH( return new ConicBench_quadPow2() ) | 1019 DEF_BENCH( return new ConicBench_quadPow2() ) |
OLD | NEW |