Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: bench/PathBench.cpp

Issue 1035943002: use new faster/vector impl for chopping conics (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix bench Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/core/SkGeometry.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 bool fParity; 799 bool fParity;
800 SkTDArray<SkRect> fQueryRects; 800 SkTDArray<SkRect> fQueryRects;
801 801
802 typedef Benchmark INHERITED; 802 typedef Benchmark INHERITED;
803 }; 803 };
804 804
805 /////////////////////////////////////////////////////////////////////////////// 805 ///////////////////////////////////////////////////////////////////////////////
806 806
807 #include "SkGeometry.h" 807 #include "SkGeometry.h"
808 808
809 class ConicBench_Chop5 : public Benchmark { 809 class ConicBench_Chop : public Benchmark {
810 SkConic fRQ; 810 protected:
811 SkConic fRQ, fDst[2];
812 SkString fName;
811 public: 813 public:
812 ConicBench_Chop5() { 814 ConicBench_Chop() : fName("conic-chop") {
813 fRQ.fPts[0].set(0, 0); 815 fRQ.fPts[0].set(0, 0);
814 fRQ.fPts[1].set(100, 0); 816 fRQ.fPts[1].set(100, 0);
815 fRQ.fPts[2].set(100, 100); 817 fRQ.fPts[2].set(100, 100);
816 fRQ.fW = SkScalarCos(SK_ScalarPI/4); 818 fRQ.fW = SkScalarCos(SK_ScalarPI/4);
817 } 819 }
818 820
819 private:
820 const char* onGetName() override {
821 return "ratquad-chop-0.5";
822 }
823
824 void onDraw(const int loops, SkCanvas*) override {
825 SkConic dst[2];
826 for (int i = 0; i < loops; ++i) {
827 fRQ.chopAt(0.5f, dst);
828 }
829 }
830
831 typedef Benchmark INHERITED;
832 };
833
834 class ConicBench_ChopHalf : public Benchmark {
835 protected:
836 SkConic fRQ, fDst[2];
837 SkString fName;
838 const bool fUseV2;
839 public:
840 ConicBench_ChopHalf(bool useV2) : fUseV2(useV2) {
841 fRQ.fPts[0].set(0, 0);
842 fRQ.fPts[1].set(100, 0);
843 fRQ.fPts[2].set(100, 100);
844 fRQ.fW = SkScalarCos(SK_ScalarPI/4);
845
846 fName.printf("conic-chop-half%d", useV2);
847 }
848
849 bool isSuitableFor(Backend backend) override { 821 bool isSuitableFor(Backend backend) override {
850 return backend == kNonRendering_Backend; 822 return backend == kNonRendering_Backend;
851 } 823 }
852 824
853 private: 825 private:
854 const char* onGetName() override { return fName.c_str(); } 826 const char* onGetName() override { return fName.c_str(); }
855 827
856 void onDraw(const int loops, SkCanvas*) override { 828 void onDraw(const int loops, SkCanvas*) override {
857 if (fUseV2) { 829 for (int i = 0; i < loops; ++i) {
858 for (int i = 0; i < loops; ++i) { 830 fRQ.chop(fDst);
859 fRQ.chop2(fDst);
860 }
861 } else {
862 for (int i = 0; i < loops; ++i) {
863 fRQ.chop(fDst);
864 }
865 } 831 }
866 } 832 }
867 833
868 typedef Benchmark INHERITED; 834 typedef Benchmark INHERITED;
869 }; 835 };
870 DEF_BENCH( return new ConicBench_ChopHalf(false); ) 836 DEF_BENCH( return new ConicBench_Chop; )
871 DEF_BENCH( return new ConicBench_ChopHalf(true); )
872 837
873 class ConicBench_EvalPos : public ConicBench_ChopHalf { 838 class ConicBench_EvalPos : public ConicBench_Chop {
839 const bool fUseV2;
874 public: 840 public:
875 ConicBench_EvalPos(bool useV2) : ConicBench_ChopHalf(useV2) { 841 ConicBench_EvalPos(bool useV2) : fUseV2(useV2) {
876 fName.printf("conic-eval-pos%d", useV2); 842 fName.printf("conic-eval-pos%d", useV2);
877 } 843 }
878 void onDraw(const int loops, SkCanvas*) override { 844 void onDraw(const int loops, SkCanvas*) override {
879 if (fUseV2) { 845 if (fUseV2) {
880 for (int i = 0; i < loops; ++i) { 846 for (int i = 0; i < loops; ++i) {
881 for (int j = 0; j < 1000; ++j) { 847 for (int j = 0; j < 1000; ++j) {
882 fDst[0].fPts[0] = fRQ.evalAt(0.4f); 848 fDst[0].fPts[0] = fRQ.evalAt(0.4f);
883 } 849 }
884 } 850 }
885 } else { 851 } else {
886 for (int i = 0; i < loops; ++i) { 852 for (int i = 0; i < loops; ++i) {
887 for (int j = 0; j < 1000; ++j) { 853 for (int j = 0; j < 1000; ++j) {
888 fRQ.evalAt(0.4f, &fDst[0].fPts[0], NULL); 854 fRQ.evalAt(0.4f, &fDst[0].fPts[0], NULL);
889 } 855 }
890 } 856 }
891 } 857 }
892 } 858 }
893 }; 859 };
894 DEF_BENCH( return new ConicBench_EvalPos(false); ) 860 DEF_BENCH( return new ConicBench_EvalPos(false); )
895 DEF_BENCH( return new ConicBench_EvalPos(true); ) 861 DEF_BENCH( return new ConicBench_EvalPos(true); )
896 862
897 class ConicBench_EvalTan : public ConicBench_ChopHalf { 863 class ConicBench_EvalTan : public ConicBench_Chop {
864 const bool fUseV2;
898 public: 865 public:
899 ConicBench_EvalTan(bool useV2) : ConicBench_ChopHalf(useV2) { 866 ConicBench_EvalTan(bool useV2) : fUseV2(useV2) {
900 fName.printf("conic-eval-tan%d", useV2); 867 fName.printf("conic-eval-tan%d", useV2);
901 } 868 }
902 void onDraw(const int loops, SkCanvas*) override { 869 void onDraw(const int loops, SkCanvas*) override {
903 if (fUseV2) { 870 if (fUseV2) {
904 for (int i = 0; i < loops; ++i) { 871 for (int i = 0; i < loops; ++i) {
905 for (int j = 0; j < 1000; ++j) { 872 for (int j = 0; j < 1000; ++j) {
906 fDst[0].fPts[0] = fRQ.evalTangentAt(0.4f); 873 fDst[0].fPts[0] = fRQ.evalTangentAt(0.4f);
907 } 874 }
908 } 875 }
909 } else { 876 } else {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k Oval_Type); ) 1042 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k Oval_Type); )
1076 1043
1077 1044
1078 // These seem to be optimized away, which is troublesome for timing. 1045 // These seem to be optimized away, which is troublesome for timing.
1079 /* 1046 /*
1080 DEF_BENCH( return new ConicBench_Chop5() ) 1047 DEF_BENCH( return new ConicBench_Chop5() )
1081 DEF_BENCH( return new ConicBench_ComputeError() ) 1048 DEF_BENCH( return new ConicBench_ComputeError() )
1082 DEF_BENCH( return new ConicBench_asQuadTol() ) 1049 DEF_BENCH( return new ConicBench_asQuadTol() )
1083 DEF_BENCH( return new ConicBench_quadPow2() ) 1050 DEF_BENCH( return new ConicBench_quadPow2() )
1084 */ 1051 */
OLDNEW
« no previous file with comments | « no previous file | src/core/SkGeometry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698