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

Side by Side Diff: bench/SkBlend_optsBench.cpp

Issue 2145833002: Update SkOpts namespaces. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: static, just in case Created 4 years, 5 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 | src/core/SkOpts.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 <tuple> 8 #include <tuple>
9 9
10 #include "Benchmark.h" 10 #include "Benchmark.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 for (int i = 0; i < n; i++) { 76 for (int i = 0; i < n; i++) {
77 srcover_srgb8888_srgb_1(dst++, src[i]); 77 srcover_srgb8888_srgb_1(dst++, src[i]);
78 } 78 }
79 ndst -= n; 79 ndst -= n;
80 } 80 }
81 } 81 }
82 82
83 class SrcOverVSkOptsBruteForce { 83 class SrcOverVSkOptsBruteForce {
84 public: 84 public:
85 static SkString Name() { return SkString{"VSkOptsBruteForce"}; } 85 static SkString Name() { return SkString{"VSkOptsBruteForce"}; }
86 static bool WorksOnCpu() { return true; }
87 static void BlendN(uint32_t* dst, const uint32_t* src, int count) { 86 static void BlendN(uint32_t* dst, const uint32_t* src, int count) {
88 brute_force_srcover_srgb_srgb(dst, src, count, count); 87 brute_force_srcover_srgb_srgb(dst, src, count, count);
89 } 88 }
90 }; 89 };
91 90
92 class SrcOverVSkOptsTrivial { 91 class SrcOverVSkOptsTrivial {
93 public: 92 public:
94 static SkString Name() { return SkString{"VSkOptsTrivial"}; } 93 static SkString Name() { return SkString{"VSkOptsTrivial"}; }
95 static bool WorksOnCpu() { return true; }
96 static void BlendN(uint32_t* dst, const uint32_t* src, int count) { 94 static void BlendN(uint32_t* dst, const uint32_t* src, int count) {
97 trivial_srcover_srgb_srgb(dst, src, count, count); 95 trivial_srcover_srgb_srgb(dst, src, count, count);
98 } 96 }
99 }; 97 };
100 98
101 class SrcOverVSkOptsNonSimdCore { 99 class SrcOverVSkOptsNonSimdCore {
102 public: 100 public:
103 static SkString Name() { return SkString{"VSkOptsNonSimdCore"}; } 101 static SkString Name() { return SkString{"VSkOptsNonSimdCore"}; }
104 static bool WorksOnCpu() { return true; }
105 static void BlendN(uint32_t* dst, const uint32_t* src, int count) { 102 static void BlendN(uint32_t* dst, const uint32_t* src, int count) {
106 best_non_simd_srcover_srgb_srgb(dst, src, count, count); 103 best_non_simd_srcover_srgb_srgb(dst, src, count, count);
107 } 104 }
108 }; 105 };
109 106
110 namespace sk_default {
111 extern void srcover_srgb_srgb(
112 uint32_t* dst, const uint32_t* const srcStart, int ndst, const int nsrc);
113 }
114
115 class SrcOverVSkOptsDefault { 107 class SrcOverVSkOptsDefault {
116 public: 108 public:
117 static SkString Name() { return SkString{"VSkOptsDefault"}; } 109 static SkString Name() { return SkString{"VSkOptsDefault"}; }
118 static bool WorksOnCpu() { return true; }
119 static void BlendN(uint32_t* dst, const uint32_t* src, int count) { 110 static void BlendN(uint32_t* dst, const uint32_t* src, int count) {
120 sk_default::srcover_srgb_srgb(dst, src, count, count); 111 SkOpts::srcover_srgb_srgb(dst, src, count, count);
121 } 112 }
122 }; 113 };
123 114
124 namespace sk_sse41 {
125 extern void srcover_srgb_srgb(
126 uint32_t* dst, const uint32_t* const srcStart, int ndst, const int nsrc);
127 }
128
129 class SrcOverVSkOptsSSE41 {
130 public:
131 static SkString Name() { return SkString{"VSkOptsSSE41"}; }
132 static bool WorksOnCpu() { return SkCpu::Supports(SkCpu::SSE41); }
133 static void BlendN(uint32_t* dst, const uint32_t* src, int count) {
134 sk_sse41::srcover_srgb_srgb(dst, src, count, count);
135 }
136 };
137
138 //////////////////////////////////////////////////////////////////////////////// /////////////////// 115 //////////////////////////////////////////////////////////////////////////////// ///////////////////
139 116
140 template <typename Blender> 117 template <typename Blender>
141 class LinearSrcOverBench : public Benchmark { 118 class LinearSrcOverBench : public Benchmark {
142 public: 119 public:
143 LinearSrcOverBench(const char* fileName) : fFileName(fileName) { 120 LinearSrcOverBench(const char* fileName) : fFileName(fileName) {
144 fName = "LinearSrcOver_"; 121 fName = "LinearSrcOver_";
145 fName.append(fileName); 122 fName.append(fileName);
146 fName.append(Blender::Name()); 123 fName.append(Blender::Name());
147 } 124 }
148 125
149 protected: 126 protected:
150 bool isSuitableFor(Backend backend) override { 127 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi ng_Backend; }
151 return backend == kNonRendering_Backend && Blender::WorksOnCpu();
152 }
153 const char* onGetName() override { return fName.c_str(); } 128 const char* onGetName() override { return fName.c_str(); }
154 129
155 void onPreDraw(SkCanvas*) override { 130 void onPreDraw(SkCanvas*) override {
156 if (!fPixmap.addr()) { 131 if (!fPixmap.addr()) {
157 sk_sp<SkImage> image = GetResourceAsImage(fFileName.c_str()); 132 sk_sp<SkImage> image = GetResourceAsImage(fFileName.c_str());
158 SkBitmap bm; 133 SkBitmap bm;
159 if (!as_IB(image)->getROPixels(&bm)) { 134 if (!as_IB(image)->getROPixels(&bm)) {
160 SkFAIL("Could not read resource"); 135 SkFAIL("Could not read resource");
161 } 136 }
162 bm.peekPixels(&fPixmap); 137 bm.peekPixels(&fPixmap);
(...skipping 28 matching lines...) Expand all
191 private: 166 private:
192 int fCount; 167 int fCount;
193 SkAutoTArray<uint32_t> fDst; 168 SkAutoTArray<uint32_t> fDst;
194 SkString fFileName; 169 SkString fFileName;
195 SkString fName; 170 SkString fName;
196 SkPixmap fPixmap; 171 SkPixmap fPixmap;
197 172
198 typedef Benchmark INHERITED; 173 typedef Benchmark INHERITED;
199 }; 174 };
200 175
201 #if defined(SK_CPU_X86) && !defined(SK_BUILD_NO_OPTS) 176 #define BENCHES(fileName) \
202 #define BENCHES(fileName) \ 177 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsBruteForce>(fileName) ; ) \
203 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsBruteForce>(fileName); ) \ 178 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsTrivial>(fileName); ) \
204 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsTrivial>(fileName); ) \ 179 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsNonSimdCore>(fileName ); ) \
205 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsNonSimdCore>(fileName); ) \ 180 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsDefault>(fileName); )
206 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsDefault>(fileName); ) \
207 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsSSE41>(fileName); )
208 #else
209 #define BENCHES(fileName) \
210 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsBruteForce>(fileName); ) \
211 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsTrivial>(fileName); ) \
212 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsNonSimdCore>(fileName); ) \
213 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsDefault>(fileName); )
214 #endif
215 181
216 BENCHES("yellow_rose.png") 182 BENCHES("yellow_rose.png")
217 BENCHES("baby_tux.png") 183 BENCHES("baby_tux.png")
218 BENCHES("plane.png") 184 BENCHES("plane.png")
219 BENCHES("mandrill_512.png") 185 BENCHES("mandrill_512.png")
220 BENCHES("iconstrip.png") 186 BENCHES("iconstrip.png")
OLDNEW
« no previous file with comments | « no previous file | src/core/SkOpts.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698