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

Unified Diff: bench/RectBench.cpp

Issue 2136343002: Revert of try to speed-up maprect + round2i + contains (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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 | gyp/core.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/RectBench.cpp
diff --git a/bench/RectBench.cpp b/bench/RectBench.cpp
index 0f757a2b5fc7ac261a563d2d695c0b7142eb833d..46a515de299705f5c7ce77222057929aee28e5bc 100644
--- a/bench/RectBench.cpp
+++ b/bench/RectBench.cpp
@@ -302,93 +302,3 @@
DEF_BENCH(return new BlitMaskBench(SkCanvas::kPoints_PointMode,
BlitMaskBench::KMaskShader,
"maskshader");)
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-typedef int (*RectMathProc)(const SkMatrix&, const SkRect[], const SkIRect[], int count);
-
-class RectMathBench : public Benchmark {
- SkString fName;
- SkRandom fRand;
- SkString fSuffix;
- RectMathProc fProc;
-
-public:
- enum {
- N = 300,
- OUTER = 10000,
- };
- SkRect fRects[N];
- SkIRect fIRects[N];
- volatile int fCounter;
-
- RectMathBench(RectMathProc proc, const char* suffix) {
- fProc = proc;
- fSuffix.set(suffix);
- SkRandom rand;
- for (int i = 0; i < N; ++i) {
- fRects[i].setXYWH(rand.nextUScalar1() * 100, rand.nextUScalar1() * 100,
- rand.nextUScalar1() * 100, rand.nextUScalar1() * 100);
- fIRects[i].setXYWH(i, i, 10, 10);
- }
- }
-
- bool isVisual() override { return false; }
-
-protected:
- const char* onGetName() override {
- fName.printf("rect_math_%s", fSuffix.c_str());
- return fName.c_str();
- }
-
- void onDraw(int loops, SkCanvas* canvas) override {
- SkMatrix mat;
- for (int j = 0; j < OUTER; ++j) {
- mat.setScaleTranslate(fRand.nextUScalar1(), fRand.nextUScalar1(),
- fRand.nextUScalar1(), fRand.nextUScalar1());
- fCounter += fProc(mat, fRects, fIRects, N);
- }
- }
-
-private:
- typedef Benchmark INHERITED;
-};
-
-static int rectmath0(const SkMatrix& mat, const SkRect rr[], const SkIRect ir[], int count) {
- int counter = 0;
- for (int i = 0; i < count; ++i) {
- SkRect dst;
- mat.mapRectScaleTranslate(&dst, rr[i]);
- counter += dst.round().contains(ir[i]);
- }
- return counter;
-}
-
-static int rectmath1(const SkMatrix& mat, const SkRect rr[], const SkIRect ir[], int count) {
- int counter = 0;
- for (int i = 0; i < count; ++i) {
- SkRect dst;
- mat.mapRectScaleTranslate(&dst, rr[i]);
- counter += dst.round2i().contains(ir[i]);
- }
- return counter;
-}
-
-#if 0
-static bool contains(SkIRect outer, SkIRect inner) {
- Sk4i le(outer.fLeft, outer.fTop, inner.fRight, inner.fBottom);
- Sk4i ge(inner.fLeft, inner.fTop, outer.fRight, outer.fBottom);
- return (le <= ge).allTrue();
-}
-
-static int rectmath3(const SkMatrix& mat, const SkRect rr[], const SkIRect ir[], int count) {
- int counter = 0;
- for (int i = 0; i < count; ++i) {
- counter += contains(mat.mapRectScaleTranslate(rr[i]).round2i(), ir[i]);
- }
- return counter;
-}
-#endif
-
-DEF_BENCH(return new RectMathBench(rectmath0, "0");)
-DEF_BENCH(return new RectMathBench(rectmath1, "1");)
« no previous file with comments | « no previous file | gyp/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698