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

Side by Side Diff: bench/XferF16Bench.cpp

Issue 1889753002: remove U16 support, just support F16 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address reviewer comments, mostly fixing class/function names Created 4 years, 8 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 | bench/XferU64Bench.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 XferD64Bench : public Benchmark { 18 class XferF16Bench : public Benchmark {
19 public: 19 public:
20 XferD64Bench(SkXfermode::Mode mode, const char name[], bool doN, uint32_t fl ags) 20 XferF16Bench(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 fXfer = SkXfermode::Make(mode); 24 fXfer = SkXfermode::Make(mode);
25 25
26 fProc1 = SkXfermode::GetD64Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle _D64Flag); 26 fProc1 = SkXfermode::GetF16Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle _F16Flag);
27 fProcN = SkXfermode::GetD64Proc(fXfer, fFlags); 27 fProcN = SkXfermode::GetF16Proc(fXfer, fFlags);
28 fName.printf("xferu64_%s_%s_%c_%s_%s", 28 fName.printf("xferF16_%s_%s_%c_%s",
29 name, 29 name,
30 (flags & USE_AA) ? "aa" : "bw", 30 (flags & USE_AA) ? "aa" : "bw",
31 fDoN ? 'N' : '1', 31 fDoN ? 'N' : '1',
32 (flags & SkXfermode::kSrcIsOpaque_D64Flag) ? "opaque" : "al pha", 32 (flags & SkXfermode::kSrcIsOpaque_F16Flag) ? "opaque" : "al pha");
33 (flags & SkXfermode::kDstIsFloat16_D64Flag) ? "f16" : "u16" );
34 33
35 for (int i = 0; i < N; ++i) { 34 for (int i = 0; i < N; ++i) {
36 fSrc[i] = {{ 1, 1, 1, 1 }}; 35 fSrc[i] = {{ 1, 1, 1, 1 }};
37 fDst[i] = 0; 36 fDst[i] = 0;
38 fAAStorage[i] = i * 255 / (N - 1); 37 fAAStorage[i] = i * 255 / (N - 1);
39 } 38 }
40 39
41 if (flags & USE_AA) { 40 if (flags & USE_AA) {
42 fAA = fAAStorage; 41 fAA = fAAStorage;
43 } else { 42 } else {
(...skipping 12 matching lines...) Expand all
56 fProcN(fXfer.get(), fDst, fSrc, N, fAA); 55 fProcN(fXfer.get(), fDst, fSrc, N, fAA);
57 } else { 56 } else {
58 fProc1(fXfer.get(), fDst, fSrc, N, fAA); 57 fProc1(fXfer.get(), fDst, fSrc, N, fAA);
59 } 58 }
60 } 59 }
61 } 60 }
62 61
63 private: 62 private:
64 sk_sp<SkXfermode> fXfer; 63 sk_sp<SkXfermode> fXfer;
65 SkString fName; 64 SkString fName;
66 SkXfermode::D64Proc fProc1; 65 SkXfermode::F16Proc fProc1;
67 SkXfermode::D64Proc fProcN; 66 SkXfermode::F16Proc fProcN;
68 const SkAlpha* fAA; 67 const SkAlpha* fAA;
69 bool fDoN; 68 bool fDoN;
70 uint32_t fFlags; 69 uint32_t fFlags;
71 70
72 enum { 71 enum {
73 N = 1000, 72 N = 1000,
74 }; 73 };
75 SkPM4f fSrc[N]; 74 SkPM4f fSrc[N];
76 uint64_t fDst[N]; 75 uint64_t fDst[N];
77 uint8_t fAAStorage[N]; 76 uint8_t fAAStorage[N];
78 77
79 typedef Benchmark INHERITED; 78 typedef Benchmark INHERITED;
80 }; 79 };
81 80
82 #define F00 0 81 #define F00 0
83 #define F01 (SkXfermode::kSrcIsOpaque_D64Flag) 82 #define F01 (SkXfermode::kSrcIsOpaque_F16Flag)
84 #define F10 (SkXfermode::kDstIsFloat16_D64Flag)
85 #define F11 (SkXfermode::kDstIsFloat16_D64Flag | SkXfermode::kSrcIsOpaque_D64Fla g)
86 83
87 #define MODE SkXfermode::kSrcOver_Mode 84 #define MODE SkXfermode::kSrcOver_Mode
88 #define NAME "srcover" 85 #define NAME "srcover"
89 86
90 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F10 | USE_AA); ) 87 DEF_BENCH( return new XferF16Bench(MODE, NAME, true, F00 | USE_AA); )
91 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F11 | USE_AA); ) 88 DEF_BENCH( return new XferF16Bench(MODE, NAME, true, F01 | USE_AA); )
92 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F10); ) 89 DEF_BENCH( return new XferF16Bench(MODE, NAME, true, F00); )
93 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F11); ) 90 DEF_BENCH( return new XferF16Bench(MODE, NAME, true, F01); )
94 91
95 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F00 | USE_AA); ) 92 DEF_BENCH( return new XferF16Bench(MODE, NAME, false, F00 | USE_AA); )
96 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F01 | USE_AA); ) 93 DEF_BENCH( return new XferF16Bench(MODE, NAME, false, F01 | USE_AA); )
97 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F00); ) 94 DEF_BENCH( return new XferF16Bench(MODE, NAME, false, F00); )
98 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F01); ) 95 DEF_BENCH( return new XferF16Bench(MODE, NAME, false, F01); )
99
100 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F10 | USE_AA); )
101 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F11 | USE_AA); )
102 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F10); )
103 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F11); )
104
105 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F00 | USE_AA); )
106 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F01 | USE_AA); )
107 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F00); )
108 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F01); )
OLDNEW
« no previous file with comments | « no previous file | bench/XferU64Bench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698