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

Unified Diff: bench/Xfer4fBench.cpp

Issue 1642703003: starter procs for blending with pm4f (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: int to float Created 4 years, 11 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 | gm/xfer4f.cpp » ('j') | gm/xfer4f.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/Xfer4fBench.cpp
diff --git a/bench/Xfer4fBench.cpp b/bench/Xfer4fBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2c281695ef02a8090834e476944135f47f8646db
--- /dev/null
+++ b/bench/Xfer4fBench.cpp
@@ -0,0 +1,73 @@
+
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Benchmark.h"
+#include "SkString.h"
+#include "SkXfer4f.h"
+
+#define INNER_LOOPS 100
+
+// Benchmark that draws non-AA rects or AA text with an SkXfermode::Mode.
+class Xfer4fBench : public Benchmark {
+public:
+ Xfer4fBench(SkXfermode::Mode mode, const char name[], bool doN, uint32_t flags) : fDoN(doN) {
+ fProc1 = SkPM4fXfer1ProcFactory(mode, flags);
+ fProcN = SkPM4fXferNProcFactory(mode, flags);
+ fName.printf("xfer4f_%s_%c_%s_%s", name, fDoN ? 'N' : '1',
+ (flags & kSrcIsOpaque_SkXfer4fFlag) ? "opaque" : "alpha",
+ (flags & kDstIsSRGB_SkXfer4fFlag) ? "srgb" : "linear");
+
+ SkPM4f c;
+ c.fVec[0] = 1; c.fVec[1] = 1; c.fVec[2] = 1; c.fVec[3] = 1;
mtklein 2016/01/29 15:23:00 This can also be SkPM4f c = {{ 1,1,1,1 }};
reed1 2016/01/29 22:35:27 Done.
+ for (int i = 0; i < N; ++i) {
+ fSrc[i] = c;
+ fDst[i] = 0;
+ }
+ }
+
+protected:
+ bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
+
+ const char* onGetName() override { return fName.c_str(); }
+
+ void onDraw(int loops, SkCanvas*) override {
+ for (int i = 0; i < loops; ++i) {
mtklein 2016/01/29 15:23:00 Generally, you can also write for (int i = 0; i
reed1 2016/01/29 22:35:27 Ah, so you never pass 0 for loops?
mtklein 2016/01/30 01:18:19 Um, it's true that nanobench happens to never pass
+ for (int j = 0; j < INNER_LOOPS; ++j) {
+ if (fDoN) {
+ fProcN(fDst, fSrc, N);
+ } else {
+ fProc1(fDst, fSrc[0], N);
+ }
+ }
+ }
+ }
+
+private:
+ SkString fName;
+ SkPM4fXfer1Proc fProc1;
+ SkPM4fXferNProc fProcN;
+ bool fDoN;
+
+ enum {
+ N = 1000,
+ };
+ SkPM4f fSrc[N];
+ SkPMColor fDst[N];
+
+ typedef Benchmark INHERITED;
+};
+
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, kDstIsSRGB_SkXfer4fFlag); )
mtklein 2016/01/29 15:23:00 Wanna throw in equal-pixel-count 8888 benchmarks h
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, 0); )
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, kDstIsSRGB_SkXfer4fFlag | kSrcIsOpaque_SkXfer4fFlag); )
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, kSrcIsOpaque_SkXfer4fFlag); )
+
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, kDstIsSRGB_SkXfer4fFlag); )
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, 0); )
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, kDstIsSRGB_SkXfer4fFlag | kSrcIsOpaque_SkXfer4fFlag); )
+DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, kSrcIsOpaque_SkXfer4fFlag); )
« no previous file with comments | « no previous file | gm/xfer4f.cpp » ('j') | gm/xfer4f.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698