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

Side by Side Diff: bench/Xfer4fBench.cpp

Issue 1634273002: float components in xfermodes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: disable blitter for official checkin Created 4 years, 10 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 | gm/color4f.cpp » ('j') | include/core/SkXfermode.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2016 Google Inc. 3 * Copyright 2016 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 8
9 #include "Benchmark.h" 9 #include "Benchmark.h"
10 #include "SkString.h" 10 #include "SkString.h"
11 #include "SkXfer4f.h" 11 #include "SkXfermode.h"
12 12
13 #define INNER_LOOPS 100 13 #define INNER_LOOPS 100
14 14
15 // Benchmark that draws non-AA rects or AA text with an SkXfermode::Mode. 15 // Benchmark that draws non-AA rects or AA text with an SkXfermode::Mode.
16 class Xfer4fBench : public Benchmark { 16 class Xfer4fBench : public Benchmark {
17 public: 17 public:
18 Xfer4fBench(SkXfermode::Mode mode, const char name[], bool doN, uint32_t fla gs) : fDoN(doN) { 18 Xfer4fBench(SkXfermode::Mode mode, const char name[], bool doN, uint32_t fla gs)
19 fProc1 = SkPM4fXfer1ProcFactory(mode, flags); 19 : fDoN(doN)
20 fProcN = SkPM4fXferNProcFactory(mode, flags); 20 , fFlags(flags)
21 {
22 fProc1 = SkXfermode::GetPM4fProc1(mode, flags);
23 fProcN = SkXfermode::GetPM4fProcN(mode, flags);
21 fName.printf("xfer4f_%s_%c_%s_%s", name, fDoN ? 'N' : '1', 24 fName.printf("xfer4f_%s_%c_%s_%s", name, fDoN ? 'N' : '1',
22 (flags & kSrcIsOpaque_SkXfer4fFlag) ? "opaque" : "alpha", 25 (flags & SkXfermode::kSrcIsOpaque_PM4fFlag) ? "opaque" : "a lpha",
23 (flags & kDstIsSRGB_SkXfer4fFlag) ? "srgb" : "linear"); 26 (flags & SkXfermode::kDstIsSRGB_PM4fFlag) ? "srgb" : "linea r");
24 27
25 SkPM4f c;
26 c.fVec[0] = 1; c.fVec[1] = 1; c.fVec[2] = 1; c.fVec[3] = 1;
27 for (int i = 0; i < N; ++i) { 28 for (int i = 0; i < N; ++i) {
28 fSrc[i] = c; 29 fSrc[i] = {{ 1, 1, 1, 1 }};
29 fDst[i] = 0; 30 fDst[i] = 0;
30 } 31 }
31 } 32 }
32 33
33 protected: 34 protected:
34 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi ng_Backend; } 35 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi ng_Backend; }
35 36
36 const char* onGetName() override { return fName.c_str(); } 37 const char* onGetName() override { return fName.c_str(); }
37 38
38 void onDraw(int loops, SkCanvas*) override { 39 void onDraw(int loops, SkCanvas*) override {
39 for (int i = 0; i < loops; ++i) { 40 const SkXfermode::PM4fState state{ nullptr, fFlags };
40 for (int j = 0; j < INNER_LOOPS; ++j) { 41 const uint8_t* aa = nullptr;
41 if (fDoN) { 42
42 fProcN(fDst, fSrc, N); 43 for (int i = 0; i < loops * INNER_LOOPS; ++i) {
43 } else { 44 if (fDoN) {
44 fProc1(fDst, fSrc[0], N); 45 fProcN(state, fDst, fSrc, N, aa);
45 } 46 } else {
47 fProc1(state, fDst, fSrc[0], N, aa);
46 } 48 }
47 } 49 }
48 } 50 }
49 51
50 private: 52 private:
51 SkString fName; 53 SkString fName;
52 SkPM4fXfer1Proc fProc1; 54 SkXfermode::PM4fProc1 fProc1;
53 SkPM4fXferNProc fProcN; 55 SkXfermode::PM4fProcN fProcN;
54 bool fDoN; 56 bool fDoN;
57 uint32_t fFlags;
55 58
56 enum { 59 enum {
57 N = 1000, 60 N = 1000,
58 }; 61 };
59 SkPM4f fSrc[N]; 62 SkPM4f fSrc[N];
60 SkPMColor fDst[N]; 63 SkPMColor fDst[N];
61 64
62 typedef Benchmark INHERITED; 65 typedef Benchmark INHERITED;
63 }; 66 };
64 67
65 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, k DstIsSRGB_SkXfer4fFlag); ) 68 #define F00 0
66 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, 0 ); ) 69 #define F01 (SkXfermode::kSrcIsOpaque_PM4fFlag)
67 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, k DstIsSRGB_SkXfer4fFlag | kSrcIsOpaque_SkXfer4fFlag); ) 70 #define F10 (SkXfermode::kDstIsSRGB_PM4fFlag)
68 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, k SrcIsOpaque_SkXfer4fFlag); ) 71 #define F11 (SkXfermode::kSrcIsOpaque_PM4fFlag | SkXfermode::kDstIsSRGB_PM4fFlag )
69 72
70 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, k DstIsSRGB_SkXfer4fFlag); ) 73 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, F 10); )
71 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, 0 ); ) 74 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, F 00); )
72 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, k DstIsSRGB_SkXfer4fFlag | kSrcIsOpaque_SkXfer4fFlag); ) 75 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, F 11); )
73 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, k SrcIsOpaque_SkXfer4fFlag); ) 76 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", false, F 01); )
77
78 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, F 10); )
79 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, F 00); )
80 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, F 11); )
81 DEF_BENCH( return new Xfer4fBench(SkXfermode::kSrcOver_Mode, "srcover", true, F 01); )
OLDNEW
« no previous file with comments | « no previous file | gm/color4f.cpp » ('j') | include/core/SkXfermode.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698