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

Side by Side Diff: bench/XferU64Bench.cpp

Issue 1832223002: switch xfermodes over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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
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 XferD64Bench : public Benchmark {
19 public: 19 public:
20 XferD64Bench(SkXfermode::Mode mode, const char name[], bool doN, uint32_t fl ags) 20 XferD64Bench(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.reset(SkXfermode::Create(mode)); 24 fXfer = SkXfermode::Make(mode);
25 25
26 fProc1 = SkXfermode::GetD64Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle _D64Flag); 26 fProc1 = SkXfermode::GetD64Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle _D64Flag);
27 fProcN = SkXfermode::GetD64Proc(fXfer, fFlags); 27 fProcN = SkXfermode::GetD64Proc(fXfer, fFlags);
28 fName.printf("xferu64_%s_%s_%c_%s_%s", 28 fName.printf("xferu64_%s_%s_%c_%s_%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_D64Flag) ? "opaque" : "al pha",
33 (flags & SkXfermode::kDstIsFloat16_D64Flag) ? "f16" : "u16" ); 33 (flags & SkXfermode::kDstIsFloat16_D64Flag) ? "f16" : "u16" );
34 34
(...skipping 11 matching lines...) Expand all
46 } 46 }
47 47
48 protected: 48 protected:
49 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi ng_Backend; } 49 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi ng_Backend; }
50 50
51 const char* onGetName() override { return fName.c_str(); } 51 const char* onGetName() override { return fName.c_str(); }
52 52
53 void onDraw(int loops, SkCanvas*) override { 53 void onDraw(int loops, SkCanvas*) override {
54 for (int i = 0; i < loops * INNER_LOOPS; ++i) { 54 for (int i = 0; i < loops * INNER_LOOPS; ++i) {
55 if (fDoN) { 55 if (fDoN) {
56 fProcN(fXfer, fDst, fSrc, N, fAA); 56 fProcN(fXfer.get(), fDst, fSrc, N, fAA);
57 } else { 57 } else {
58 fProc1(fXfer, fDst, fSrc, N, fAA); 58 fProc1(fXfer.get(), fDst, fSrc, N, fAA);
59 } 59 }
60 } 60 }
61 } 61 }
62 62
63 private: 63 private:
64 SkAutoTUnref<SkXfermode> fXfer; 64 sk_sp<SkXfermode> fXfer;
65 SkString fName; 65 SkString fName;
66 SkXfermode::D64Proc fProc1; 66 SkXfermode::D64Proc fProc1;
67 SkXfermode::D64Proc fProcN; 67 SkXfermode::D64Proc fProcN;
68 const SkAlpha* fAA; 68 const SkAlpha* fAA;
69 bool fDoN; 69 bool fDoN;
70 uint32_t fFlags; 70 uint32_t fFlags;
71 71
72 enum { 72 enum {
73 N = 1000, 73 N = 1000,
74 }; 74 };
(...skipping 24 matching lines...) Expand all
99 99
100 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F10 | USE_AA); ) 100 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F10 | USE_AA); )
101 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F11 | USE_AA); ) 101 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F11 | USE_AA); )
102 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F10); ) 102 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F10); )
103 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F11); ) 103 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F11); )
104 104
105 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F00 | USE_AA); ) 105 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F00 | USE_AA); )
106 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F01 | USE_AA); ) 106 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F01 | USE_AA); )
107 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F00); ) 107 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F00); )
108 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F01); ) 108 DEF_BENCH( return new XferD64Bench(MODE, NAME, false, F01); )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698