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

Unified Diff: bench/PathBench.cpp

Issue 1025033002: use Sk2s for conics (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkGeometry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/PathBench.cpp
diff --git a/bench/PathBench.cpp b/bench/PathBench.cpp
index b597f919f8f9ebbb9831f7f627999f3f9dd929f7..3a4eb63830ddb2e8e2c6ee325f0735184ac155fc 100644
--- a/bench/PathBench.cpp
+++ b/bench/PathBench.cpp
@@ -832,29 +832,91 @@ private:
};
class ConicBench_ChopHalf : public Benchmark {
- SkConic fRQ;
+protected:
+ SkConic fRQ, fDst[2];
+ SkString fName;
+ const bool fUseV2;
public:
- ConicBench_ChopHalf() {
+ ConicBench_ChopHalf(bool useV2) : fUseV2(useV2) {
fRQ.fPts[0].set(0, 0);
fRQ.fPts[1].set(100, 0);
fRQ.fPts[2].set(100, 100);
fRQ.fW = SkScalarCos(SK_ScalarPI/4);
+
+ fName.printf("conic-chop-half%d", useV2);
}
-private:
- const char* onGetName() SK_OVERRIDE {
- return "ratquad-chop-half";
+ bool isSuitableFor(Backend backend) SK_OVERRIDE {
+ return backend == kNonRendering_Backend;
}
+private:
+ const char* onGetName() SK_OVERRIDE { return fName.c_str(); }
+
void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
- SkConic dst[2];
- for (int i = 0; i < loops; ++i) {
- fRQ.chop(dst);
+ if (fUseV2) {
+ for (int i = 0; i < loops; ++i) {
+ fRQ.chop2(fDst);
+ }
+ } else {
+ for (int i = 0; i < loops; ++i) {
+ fRQ.chop(fDst);
+ }
}
}
typedef Benchmark INHERITED;
};
+DEF_BENCH( return new ConicBench_ChopHalf(false); )
+DEF_BENCH( return new ConicBench_ChopHalf(true); )
+
+class ConicBench_EvalPos : public ConicBench_ChopHalf {
+public:
+ ConicBench_EvalPos(bool useV2) : ConicBench_ChopHalf(useV2) {
+ fName.printf("conic-eval-pos%d", useV2);
+ }
+ void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
+ if (fUseV2) {
+ for (int i = 0; i < loops; ++i) {
+ for (int j = 0; j < 1000; ++j) {
+ fDst[0].fPts[0] = fRQ.evalAt(0.4f);
+ }
+ }
+ } else {
+ for (int i = 0; i < loops; ++i) {
+ for (int j = 0; j < 1000; ++j) {
+ fRQ.evalAt(0.4f, &fDst[0].fPts[0], NULL);
+ }
+ }
+ }
+ }
+};
+DEF_BENCH( return new ConicBench_EvalPos(false); )
+DEF_BENCH( return new ConicBench_EvalPos(true); )
+
+class ConicBench_EvalTan : public ConicBench_ChopHalf {
+public:
+ ConicBench_EvalTan(bool useV2) : ConicBench_ChopHalf(useV2) {
+ fName.printf("conic-eval-tan%d", useV2);
+ }
+ void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
+ if (fUseV2) {
+ for (int i = 0; i < loops; ++i) {
+ for (int j = 0; j < 1000; ++j) {
+ fDst[0].fPts[0] = fRQ.evalTangentAt(0.4f);
+ }
+ }
+ } else {
+ for (int i = 0; i < loops; ++i) {
+ for (int j = 0; j < 1000; ++j) {
+ fRQ.evalAt(0.4f, NULL, &fDst[0].fPts[0]);
+ }
+ }
+ }
+ }
+};
+DEF_BENCH( return new ConicBench_EvalTan(false); )
+DEF_BENCH( return new ConicBench_EvalTan(true); )
///////////////////////////////////////////////////////////////////////////////
@@ -1012,10 +1074,10 @@ DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k
DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::kRoundRect_Type); )
DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::kOval_Type); )
+
// These seem to be optimized away, which is troublesome for timing.
/*
DEF_BENCH( return new ConicBench_Chop5() )
-DEF_BENCH( return new ConicBench_ChopHalf() )
DEF_BENCH( return new ConicBench_ComputeError() )
DEF_BENCH( return new ConicBench_asQuadTol() )
DEF_BENCH( return new ConicBench_quadPow2() )
« 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