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

Side by Side Diff: bench/XferU64Bench.cpp

Issue 1685203002: lots of sRGB and F16 blits (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use SkAutoTMalloc 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/xfermodes.cpp » ('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 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkPM4f.h" 9 #include "SkPM4f.h"
10 #include "SkString.h" 10 #include "SkString.h"
11 #include "SkXfermode.h" 11 #include "SkXfermode.h"
12 12
13 #define USE_AA (1 << 31) // merge with Xfermode::PMFlags w/o conflict 13 #define USE_AA (1 << 31) // merge with Xfermode::PMFlags w/o conflict
14 14
15 #define INNER_LOOPS 1000 15 #define INNER_LOOPS 1000
16 16
17 // Benchmark that draws non-AA rects or AA text with an SkXfermode::Mode. 17 // Benchmark that draws non-AA rects or AA text with an SkXfermode::Mode.
18 class XferU64Bench : public Benchmark { 18 class XferU64Bench : public Benchmark {
19 public: 19 public:
20 XferU64Bench(bool doN, uint32_t flags) 20 XferU64Bench(SkXfermode::Mode mode, const char name[], bool doN, uint32_t fl ags)
21 : fDoN(doN) 21 : fDoN(doN)
22 , fFlags(flags & ~USE_AA) 22 , fFlags(flags & ~USE_AA)
23 { 23 {
24 SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode; 24 fXfer.reset(SkXfermode::Create(mode));
25 25
26 fProc1 = SkXfermode::GetU64Proc1(mode, fFlags); 26 fProc1 = SkXfermode::GetU64Proc1(mode, fFlags);
27 fProcN = SkXfermode::GetU64ProcN(mode, fFlags); 27 fProcN = SkXfermode::GetU64ProcN(mode, fFlags);
28 fName.printf("xferu64_%s_%c_%s_%s", 28 fName.printf("xferu64_%s_%s_%c_%s_%s",
29 name,
29 (flags & USE_AA) ? "aa" : "bw", 30 (flags & USE_AA) ? "aa" : "bw",
30 fDoN ? 'N' : '1', 31 fDoN ? 'N' : '1',
31 (flags & SkXfermode::kSrcIsOpaque_U64Flag) ? "opaque" : "al pha", 32 (flags & SkXfermode::kSrcIsOpaque_U64Flag) ? "opaque" : "al pha",
32 (flags & SkXfermode::kDstIsFloat16_U64Flag) ? "f16" : "u16" ); 33 (flags & SkXfermode::kDstIsFloat16_U64Flag) ? "f16" : "u16" );
33 34
34 for (int i = 0; i < N; ++i) { 35 for (int i = 0; i < N; ++i) {
35 fSrc[i] = {{ 1, 1, 1, 1 }}; 36 fSrc[i] = {{ 1, 1, 1, 1 }};
36 fDst[i] = 0; 37 fDst[i] = 0;
37 fAAStorage[i] = i * 255 / (N - 1); 38 fAAStorage[i] = i * 255 / (N - 1);
38 } 39 }
39 40
40 if (flags & USE_AA) { 41 if (flags & USE_AA) {
41 fAA = fAAStorage; 42 fAA = fAAStorage;
42 } else { 43 } else {
43 fAA = nullptr; 44 fAA = nullptr;
44 } 45 }
45 } 46 }
46 47
47 protected: 48 protected:
48 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi ng_Backend; } 49 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi ng_Backend; }
49 50
50 const char* onGetName() override { return fName.c_str(); } 51 const char* onGetName() override { return fName.c_str(); }
51 52
52 void onDraw(int loops, SkCanvas*) override { 53 void onDraw(int loops, SkCanvas*) override {
53 const SkXfermode::U64State state{ nullptr, fFlags }; 54 const SkXfermode::U64State state{ fXfer, fFlags };
54 55
55 for (int i = 0; i < loops * INNER_LOOPS; ++i) { 56 for (int i = 0; i < loops * INNER_LOOPS; ++i) {
56 if (fDoN) { 57 if (fDoN) {
57 fProcN(state, fDst, fSrc, N, fAA); 58 fProcN(state, fDst, fSrc, N, fAA);
58 } else { 59 } else {
59 fProc1(state, fDst, fSrc[0], N, fAA); 60 fProc1(state, fDst, fSrc[0], N, fAA);
60 } 61 }
61 } 62 }
62 } 63 }
63 64
64 private: 65 private:
66 SkAutoTUnref<SkXfermode> fXfer;
65 SkString fName; 67 SkString fName;
66 SkXfermode::U64Proc1 fProc1; 68 SkXfermode::U64Proc1 fProc1;
67 SkXfermode::U64ProcN fProcN; 69 SkXfermode::U64ProcN fProcN;
68 const SkAlpha* fAA; 70 const SkAlpha* fAA;
69 bool fDoN; 71 bool fDoN;
70 uint32_t fFlags; 72 uint32_t fFlags;
71 73
72 enum { 74 enum {
73 N = 1000, 75 N = 1000,
74 }; 76 };
75 SkPM4f fSrc[N]; 77 SkPM4f fSrc[N];
76 uint64_t fDst[N]; 78 uint64_t fDst[N];
77 uint8_t fAAStorage[N]; 79 uint8_t fAAStorage[N];
78 80
79 typedef Benchmark INHERITED; 81 typedef Benchmark INHERITED;
80 }; 82 };
81 83
82 #define F00 0 84 #define F00 0
83 #define F01 (SkXfermode::kSrcIsOpaque_U64Flag) 85 #define F01 (SkXfermode::kSrcIsOpaque_U64Flag)
84 #define F10 (SkXfermode::kDstIsFloat16_U64Flag) 86 #define F10 (SkXfermode::kDstIsFloat16_U64Flag)
85 #define F11 (SkXfermode::kDstIsFloat16_U64Flag | SkXfermode::kSrcIsOpaque_U64Fla g) 87 #define F11 (SkXfermode::kDstIsFloat16_U64Flag | SkXfermode::kSrcIsOpaque_U64Fla g)
86 88
87 #if 0 89 #define MODE SkXfermode::kSrcOver_Mode
88 DEF_BENCH( return new XferU64Bench(true, F10 | USE_AA); ) 90 #define NAME "srcover"
89 DEF_BENCH( return new XferU64Bench(true, F11 | USE_AA); )
90 DEF_BENCH( return new XferU64Bench(true, F10); )
91 DEF_BENCH( return new XferU64Bench(true, F11); )
92 91
93 DEF_BENCH( return new XferU64Bench(true, F00 | USE_AA); ) 92 DEF_BENCH( return new XferU64Bench(MODE, NAME, true, F10 | USE_AA); )
94 DEF_BENCH( return new XferU64Bench(true, F01 | USE_AA); ) 93 DEF_BENCH( return new XferU64Bench(MODE, NAME, true, F11 | USE_AA); )
95 DEF_BENCH( return new XferU64Bench(true, F00); ) 94 DEF_BENCH( return new XferU64Bench(MODE, NAME, true, F10); )
96 DEF_BENCH( return new XferU64Bench(true, F01); ) 95 DEF_BENCH( return new XferU64Bench(MODE, NAME, true, F11); )
97 #endif
98 96
99 DEF_BENCH( return new XferU64Bench(false, F10 | USE_AA); ) 97 DEF_BENCH( return new XferU64Bench(MODE, NAME, true, F00 | USE_AA); )
100 DEF_BENCH( return new XferU64Bench(false, F11 | USE_AA); ) 98 DEF_BENCH( return new XferU64Bench(MODE, NAME, true, F01 | USE_AA); )
101 DEF_BENCH( return new XferU64Bench(false, F10); ) 99 DEF_BENCH( return new XferU64Bench(MODE, NAME, true, F00); )
102 DEF_BENCH( return new XferU64Bench(false, F11); ) 100 DEF_BENCH( return new XferU64Bench(MODE, NAME, true, F01); )
103 101
104 DEF_BENCH( return new XferU64Bench(false, F00 | USE_AA); ) 102 DEF_BENCH( return new XferU64Bench(MODE, NAME, false, F10 | USE_AA); )
105 DEF_BENCH( return new XferU64Bench(false, F01 | USE_AA); ) 103 DEF_BENCH( return new XferU64Bench(MODE, NAME, false, F11 | USE_AA); )
106 DEF_BENCH( return new XferU64Bench(false, F00); ) 104 DEF_BENCH( return new XferU64Bench(MODE, NAME, false, F10); )
107 DEF_BENCH( return new XferU64Bench(false, F01); ) 105 DEF_BENCH( return new XferU64Bench(MODE, NAME, false, F11); )
106
107 DEF_BENCH( return new XferU64Bench(MODE, NAME, false, F00 | USE_AA); )
108 DEF_BENCH( return new XferU64Bench(MODE, NAME, false, F01 | USE_AA); )
109 DEF_BENCH( return new XferU64Bench(MODE, NAME, false, F00); )
110 DEF_BENCH( return new XferU64Bench(MODE, NAME, false, F01); )
OLDNEW
« no previous file with comments | « no previous file | gm/xfermodes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698