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

Side by Side Diff: bench/XferU64Bench.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 | « bench/XferF16Bench.cpp ('k') | gyp/core.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Benchmark.h"
9 #include "SkPM4f.h"
10 #include "SkString.h"
11 #include "SkXfermode.h"
12
13 #define USE_AA (1 << 31) // merge with Xfermode::PMFlags w/o conflict
14
15 #define INNER_LOOPS 1000
16
17 // Benchmark that draws non-AA rects or AA text with an SkXfermode::Mode.
18 class XferD64Bench : public Benchmark {
19 public:
20 XferD64Bench(SkXfermode::Mode mode, const char name[], bool doN, uint32_t fl ags)
21 : fDoN(doN)
22 , fFlags(flags & ~USE_AA)
23 {
24 fXfer = SkXfermode::Make(mode);
25
26 fProc1 = SkXfermode::GetD64Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle _D64Flag);
27 fProcN = SkXfermode::GetD64Proc(fXfer, fFlags);
28 fName.printf("xferu64_%s_%s_%c_%s_%s",
29 name,
30 (flags & USE_AA) ? "aa" : "bw",
31 fDoN ? 'N' : '1',
32 (flags & SkXfermode::kSrcIsOpaque_D64Flag) ? "opaque" : "al pha",
33 (flags & SkXfermode::kDstIsFloat16_D64Flag) ? "f16" : "u16" );
34
35 for (int i = 0; i < N; ++i) {
36 fSrc[i] = {{ 1, 1, 1, 1 }};
37 fDst[i] = 0;
38 fAAStorage[i] = i * 255 / (N - 1);
39 }
40
41 if (flags & USE_AA) {
42 fAA = fAAStorage;
43 } else {
44 fAA = nullptr;
45 }
46 }
47
48 protected:
49 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi ng_Backend; }
50
51 const char* onGetName() override { return fName.c_str(); }
52
53 void onDraw(int loops, SkCanvas*) override {
54 for (int i = 0; i < loops * INNER_LOOPS; ++i) {
55 if (fDoN) {
56 fProcN(fXfer.get(), fDst, fSrc, N, fAA);
57 } else {
58 fProc1(fXfer.get(), fDst, fSrc, N, fAA);
59 }
60 }
61 }
62
63 private:
64 sk_sp<SkXfermode> fXfer;
65 SkString fName;
66 SkXfermode::D64Proc fProc1;
67 SkXfermode::D64Proc fProcN;
68 const SkAlpha* fAA;
69 bool fDoN;
70 uint32_t fFlags;
71
72 enum {
73 N = 1000,
74 };
75 SkPM4f fSrc[N];
76 uint64_t fDst[N];
77 uint8_t fAAStorage[N];
78
79 typedef Benchmark INHERITED;
80 };
81
82 #define F00 0
83 #define F01 (SkXfermode::kSrcIsOpaque_D64Flag)
84 #define F10 (SkXfermode::kDstIsFloat16_D64Flag)
85 #define F11 (SkXfermode::kDstIsFloat16_D64Flag | SkXfermode::kSrcIsOpaque_D64Fla g)
86
87 #define MODE SkXfermode::kSrcOver_Mode
88 #define NAME "srcover"
89
90 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F10 | USE_AA); )
91 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F11 | USE_AA); )
92 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F10); )
93 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F11); )
94
95 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F00 | USE_AA); )
96 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F01 | USE_AA); )
97 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, F00); )
98 DEF_BENCH( return new XferD64Bench(MODE, NAME, true, 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 | « bench/XferF16Bench.cpp ('k') | gyp/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698