herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 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 <memory> |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 9 | #include "Benchmark.h" |
Herb Derby | 83e939b | 2017-02-07 14:25:11 -0500 | [diff] [blame] | 10 | |
| 11 | #include "SkArenaAlloc.h" |
Herb Derby | dfa492e | 2016-11-17 21:12:36 -0500 | [diff] [blame] | 12 | #include "SkBitmapProcShader.h" |
| 13 | #include "SkColor.h" |
Herb Derby | ac04fef | 2017-01-13 17:34:33 -0500 | [diff] [blame] | 14 | #include "SkArenaAlloc.h" |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 15 | #include "SkImage.h" |
Herb Derby | dfa492e | 2016-11-17 21:12:36 -0500 | [diff] [blame] | 16 | #include "SkLinearBitmapPipeline.h" |
| 17 | #include "SkPM4f.h" |
| 18 | #include "SkShader.h" |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 19 | |
| 20 | struct CommonBitmapFPBenchmark : public Benchmark { |
| 21 | CommonBitmapFPBenchmark( |
| 22 | SkISize srcSize, |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 23 | bool isSRGB, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 24 | SkMatrix m, |
| 25 | bool useBilerp, |
| 26 | SkShader::TileMode xTile, |
| 27 | SkShader::TileMode yTile) |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 28 | : fIsSRGB(isSRGB) |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 29 | , fM{m} |
| 30 | , fUseBilerp{useBilerp} |
| 31 | , fXTile{xTile} |
| 32 | , fYTile{yTile} { |
| 33 | fSrcSize = srcSize; |
| 34 | } |
| 35 | |
| 36 | static SkString tileName(const char* pre, SkShader::TileMode mode) { |
| 37 | SkString name{pre}; |
| 38 | switch (mode) { |
| 39 | case SkShader::kClamp_TileMode: |
| 40 | name.append("Clamp"); |
| 41 | return name; |
| 42 | case SkShader::kRepeat_TileMode: |
| 43 | name.append("Repeat"); |
| 44 | return name; |
| 45 | case SkShader::kMirror_TileMode: |
| 46 | name.append("Mirror"); |
| 47 | return name; |
| 48 | default: |
| 49 | name.append("Unknown"); |
| 50 | return name; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | const char* onGetName() override { |
herb | 134ad3e | 2016-02-17 11:57:24 -0800 | [diff] [blame] | 55 | fName.set("SkBitmapFP"); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 56 | if (fM.getType() & SkMatrix::kPerspective_Mask) { |
herb | 134ad3e | 2016-02-17 11:57:24 -0800 | [diff] [blame] | 57 | fName.append("Perspective"); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 58 | } else if (fM.getType() & SkMatrix::kAffine_Mask) { |
herb | 134ad3e | 2016-02-17 11:57:24 -0800 | [diff] [blame] | 59 | fName.append("Affine"); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 60 | } else if (fM.getType() & SkMatrix::kScale_Mask) { |
herb | 134ad3e | 2016-02-17 11:57:24 -0800 | [diff] [blame] | 61 | fName.append("Scale"); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 62 | } else if (fM.getType() & SkMatrix::kTranslate_Mask) { |
herb | 134ad3e | 2016-02-17 11:57:24 -0800 | [diff] [blame] | 63 | fName.append("Translate"); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 64 | } else { |
herb | 134ad3e | 2016-02-17 11:57:24 -0800 | [diff] [blame] | 65 | fName.append("Identity"); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 66 | } |
| 67 | |
herb | 134ad3e | 2016-02-17 11:57:24 -0800 | [diff] [blame] | 68 | fName.append(tileName("X", fXTile)); |
| 69 | fName.append(tileName("Y", fYTile)); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 70 | |
| 71 | if (fUseBilerp) { |
herb | 134ad3e | 2016-02-17 11:57:24 -0800 | [diff] [blame] | 72 | fName.append("Filter"); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 73 | } else { |
herb | 134ad3e | 2016-02-17 11:57:24 -0800 | [diff] [blame] | 74 | fName.append("Nearest"); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 75 | } |
| 76 | |
herb | 134ad3e | 2016-02-17 11:57:24 -0800 | [diff] [blame] | 77 | fName.appendf("%s", BaseName().c_str()); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 78 | |
herb | 134ad3e | 2016-02-17 11:57:24 -0800 | [diff] [blame] | 79 | return fName.c_str(); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | void onPreDraw(SkCanvas*) override { |
| 83 | int width = fSrcSize.fWidth; |
| 84 | int height = fSrcSize.fHeight; |
| 85 | fBitmap.reset(new uint32_t[width * height]); |
| 86 | for (int y = 0; y < height; y++) { |
| 87 | for (int x = 0; x < width; x++) { |
| 88 | fBitmap[y * width + x] = (y << 8) + x + (128<<24); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | bool trash = fM.invert(&fInvert); |
| 93 | sk_ignore_unused_variable(trash); |
| 94 | |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 95 | fInfo = SkImageInfo::MakeN32Premul(width, height, fIsSRGB ? |
Matt Sarett | 77a7a1b | 2017-02-07 13:56:11 -0500 | [diff] [blame] | 96 | SkColorSpace::MakeSRGB() : nullptr); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | bool isSuitableFor(Backend backend) override { |
| 100 | return backend == kNonRendering_Backend; |
| 101 | } |
| 102 | |
| 103 | virtual SkString BaseName() = 0; |
| 104 | |
herb | 134ad3e | 2016-02-17 11:57:24 -0800 | [diff] [blame] | 105 | SkString fName; |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 106 | SkISize fSrcSize; |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 107 | bool fIsSRGB; |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 108 | SkMatrix fM; |
| 109 | SkMatrix fInvert; |
| 110 | bool fUseBilerp; |
| 111 | SkShader::TileMode fXTile; |
| 112 | SkShader::TileMode fYTile; |
| 113 | SkImageInfo fInfo; |
| 114 | std::unique_ptr<uint32_t[]> fBitmap; |
| 115 | }; |
| 116 | |
| 117 | struct SkBitmapFPGeneral final : public CommonBitmapFPBenchmark { |
| 118 | SkBitmapFPGeneral( |
| 119 | SkISize srcSize, |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 120 | bool isSRGB, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 121 | SkMatrix m, |
| 122 | bool useBilerp, |
| 123 | SkShader::TileMode xTile, |
| 124 | SkShader::TileMode yTile) |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 125 | : CommonBitmapFPBenchmark(srcSize, isSRGB, m, useBilerp, xTile, yTile) { } |
herb | 134ad3e | 2016-02-17 11:57:24 -0800 | [diff] [blame] | 126 | |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 127 | SkString BaseName() override { |
| 128 | SkString name; |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 129 | if (fInfo.gammaCloseToSRGB()) { |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 130 | name.set("sRGB"); |
| 131 | } else { |
| 132 | name.set("Linr"); |
| 133 | } |
| 134 | return name; |
| 135 | } |
| 136 | |
| 137 | void onDraw(int loops, SkCanvas*) override { |
| 138 | int width = fSrcSize.fWidth; |
| 139 | int height = fSrcSize.fHeight; |
| 140 | |
mtklein | b65fcd4 | 2016-02-17 13:50:46 -0800 | [diff] [blame] | 141 | SkAutoTMalloc<SkPM4f> FPbuffer(width*height); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 142 | |
herb | c5eddd7 | 2016-02-17 19:50:05 -0800 | [diff] [blame] | 143 | SkFilterQuality filterQuality; |
| 144 | if (fUseBilerp) { |
| 145 | filterQuality = SkFilterQuality::kLow_SkFilterQuality; |
| 146 | } else { |
| 147 | filterQuality = SkFilterQuality::kNone_SkFilterQuality; |
| 148 | } |
| 149 | |
herb | ed54504 | 2016-02-18 13:55:02 -0800 | [diff] [blame] | 150 | SkPixmap srcPixmap{fInfo, fBitmap.get(), static_cast<size_t>(4 * width)}; |
| 151 | |
Herb Derby | dfa492e | 2016-11-17 21:12:36 -0500 | [diff] [blame] | 152 | |
| 153 | char storage[600]; |
Herb Derby | 0497f08 | 2017-01-13 11:30:44 -0500 | [diff] [blame] | 154 | SkArenaAlloc allocator{storage, sizeof(storage), 512}; |
herb | c5eddd7 | 2016-02-17 19:50:05 -0800 | [diff] [blame] | 155 | SkLinearBitmapPipeline pipeline{ |
Herb Derby | dfa492e | 2016-11-17 21:12:36 -0500 | [diff] [blame] | 156 | fInvert, filterQuality, fXTile, fYTile, SK_ColorBLACK, srcPixmap, &allocator}; |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 157 | |
| 158 | int count = 100; |
| 159 | |
| 160 | for (int n = 0; n < 1000*loops; n++) { |
| 161 | pipeline.shadeSpan4f(3, 6, FPbuffer, count); |
| 162 | } |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 163 | } |
| 164 | }; |
| 165 | |
| 166 | struct SkBitmapFPOrigShader : public CommonBitmapFPBenchmark { |
| 167 | SkBitmapFPOrigShader( |
| 168 | SkISize srcSize, |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 169 | bool isSRGB, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 170 | SkMatrix m, |
| 171 | bool useBilerp, |
| 172 | SkShader::TileMode xTile, |
| 173 | SkShader::TileMode yTile) |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 174 | : CommonBitmapFPBenchmark(srcSize, isSRGB, m, useBilerp, xTile, yTile) { } |
herb | 134ad3e | 2016-02-17 11:57:24 -0800 | [diff] [blame] | 175 | |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 176 | SkString BaseName() override { |
| 177 | SkString name{"Orig"}; |
| 178 | return name; |
| 179 | } |
| 180 | |
| 181 | void onPreDraw(SkCanvas* c) override { |
| 182 | CommonBitmapFPBenchmark::onPreDraw(c); |
| 183 | |
reed | 9ce9d67 | 2016-03-17 10:51:11 -0700 | [diff] [blame] | 184 | fImage = SkImage::MakeRasterCopy( |
| 185 | SkPixmap(fInfo, fBitmap.get(), sizeof(SkPMColor) * fSrcSize.fWidth)); |
reed | 5671c5b | 2016-03-09 14:47:34 -0800 | [diff] [blame] | 186 | fPaint.setShader(fImage->makeShader(fXTile, fYTile)); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 187 | if (fUseBilerp) { |
| 188 | fPaint.setFilterQuality(SkFilterQuality::kLow_SkFilterQuality); |
| 189 | } else { |
| 190 | fPaint.setFilterQuality(SkFilterQuality::kNone_SkFilterQuality); |
| 191 | } |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | void onPostDraw(SkCanvas*) override { |
| 195 | |
| 196 | } |
| 197 | |
| 198 | void onDraw(int loops, SkCanvas*) override { |
| 199 | int width = fSrcSize.fWidth; |
| 200 | int height = fSrcSize.fHeight; |
| 201 | |
mtklein | b65fcd4 | 2016-02-17 13:50:46 -0800 | [diff] [blame] | 202 | SkAutoTMalloc<SkPMColor> buffer4b(width*height); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 203 | |
Herb Derby | 9852dc0 | 2017-02-07 17:57:47 -0500 | [diff] [blame] | 204 | SkArenaAlloc alloc{0}; |
fmalita | d0c4e09 | 2016-02-22 17:19:04 -0800 | [diff] [blame] | 205 | const SkShader::ContextRec rec(fPaint, fM, nullptr, |
Brian Osman | 11970e5 | 2016-12-05 15:26:50 -0500 | [diff] [blame] | 206 | SkShader::ContextRec::kPMColor_DstType, |
| 207 | nullptr); |
Herb Derby | 83e939b | 2017-02-07 14:25:11 -0500 | [diff] [blame] | 208 | SkShader::Context* ctx = fPaint.getShader()->makeContext(rec, &alloc); |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 209 | |
| 210 | int count = 100; |
| 211 | |
| 212 | for (int n = 0; n < 1000*loops; n++) { |
| 213 | ctx->shadeSpan(3, 6, buffer4b, count); |
| 214 | } |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 215 | } |
| 216 | SkPaint fPaint; |
reed | 9ce9d67 | 2016-03-17 10:51:11 -0700 | [diff] [blame] | 217 | sk_sp<SkImage> fImage; |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 218 | }; |
| 219 | |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 220 | const bool gSRGB = true; |
| 221 | const bool gLinearRGB = false; |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 222 | static SkISize srcSize = SkISize::Make(120, 100); |
| 223 | static SkMatrix mI = SkMatrix::I(); |
| 224 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 225 | srcSize, gSRGB, mI, false, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 226 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 227 | |
| 228 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 229 | srcSize, gLinearRGB, mI, false, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 230 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 231 | |
| 232 | DEF_BENCH(return new SkBitmapFPOrigShader( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 233 | srcSize, gLinearRGB, mI, false, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 234 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 235 | |
| 236 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 237 | srcSize, gSRGB, mI, true, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 238 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 239 | |
| 240 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 241 | srcSize, gLinearRGB, mI, true, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 242 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 243 | |
| 244 | DEF_BENCH(return new SkBitmapFPOrigShader( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 245 | srcSize, gLinearRGB, mI, true, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 246 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 247 | |
| 248 | static SkMatrix mS = SkMatrix::MakeScale(2.7f, 2.7f); |
| 249 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 250 | srcSize, gSRGB, mS, false, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 251 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 252 | |
| 253 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 254 | srcSize, gLinearRGB, mS, false, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 255 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 256 | |
| 257 | DEF_BENCH(return new SkBitmapFPOrigShader( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 258 | srcSize, gLinearRGB, mS, false, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 259 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 260 | |
| 261 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 262 | srcSize, gSRGB, mS, true, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 263 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 264 | |
| 265 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 266 | srcSize, gLinearRGB, mS, true, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 267 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 268 | |
| 269 | DEF_BENCH(return new SkBitmapFPOrigShader( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 270 | srcSize, gLinearRGB, mS, true, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 271 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 272 | |
herb | 6eff52a | 2016-03-23 09:00:33 -0700 | [diff] [blame] | 273 | // Repeat |
| 274 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 275 | srcSize, gSRGB, mS, false, |
herb | 6eff52a | 2016-03-23 09:00:33 -0700 | [diff] [blame] | 276 | SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);) |
| 277 | |
| 278 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 279 | srcSize, gLinearRGB, mS, false, |
herb | 6eff52a | 2016-03-23 09:00:33 -0700 | [diff] [blame] | 280 | SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);) |
| 281 | |
| 282 | DEF_BENCH(return new SkBitmapFPOrigShader( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 283 | srcSize, gLinearRGB, mS, false, |
herb | 6eff52a | 2016-03-23 09:00:33 -0700 | [diff] [blame] | 284 | SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);) |
| 285 | |
| 286 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 287 | srcSize, gSRGB, mS, true, |
herb | 6eff52a | 2016-03-23 09:00:33 -0700 | [diff] [blame] | 288 | SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);) |
| 289 | |
| 290 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 291 | srcSize, gLinearRGB, mS, true, |
herb | 6eff52a | 2016-03-23 09:00:33 -0700 | [diff] [blame] | 292 | SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);) |
| 293 | |
| 294 | DEF_BENCH(return new SkBitmapFPOrigShader( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 295 | srcSize, gLinearRGB, mS, true, |
herb | 6eff52a | 2016-03-23 09:00:33 -0700 | [diff] [blame] | 296 | SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);) |
| 297 | |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 298 | static SkMatrix rotate(SkScalar r) { |
| 299 | SkMatrix m; |
| 300 | m.setRotate(30); |
| 301 | return m; |
| 302 | } |
| 303 | |
| 304 | static SkMatrix mR = rotate(30); |
| 305 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 306 | srcSize, gSRGB, mR, false, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 307 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 308 | |
| 309 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 310 | srcSize, gLinearRGB, mR, false, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 311 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 312 | |
| 313 | DEF_BENCH(return new SkBitmapFPOrigShader( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 314 | srcSize, gLinearRGB, mR, false, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 315 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 316 | |
| 317 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 318 | srcSize, gSRGB, mR, true, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 319 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 320 | |
| 321 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 322 | srcSize, gLinearRGB, mR, true, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 323 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 324 | |
| 325 | DEF_BENCH(return new SkBitmapFPOrigShader( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 326 | srcSize, gLinearRGB, mR, true, |
herb | feec878 | 2016-02-17 10:00:07 -0800 | [diff] [blame] | 327 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);) |
| 328 | |
herb | 6eff52a | 2016-03-23 09:00:33 -0700 | [diff] [blame] | 329 | // Repeat |
| 330 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 331 | srcSize, gSRGB, mR, false, |
herb | 6eff52a | 2016-03-23 09:00:33 -0700 | [diff] [blame] | 332 | SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);) |
| 333 | |
| 334 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 335 | srcSize, gLinearRGB, mR, false, |
herb | 6eff52a | 2016-03-23 09:00:33 -0700 | [diff] [blame] | 336 | SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);) |
| 337 | |
| 338 | DEF_BENCH(return new SkBitmapFPOrigShader( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 339 | srcSize, gLinearRGB, mR, false, |
herb | 6eff52a | 2016-03-23 09:00:33 -0700 | [diff] [blame] | 340 | SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);) |
| 341 | |
| 342 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 343 | srcSize, gSRGB, mR, true, |
herb | 6eff52a | 2016-03-23 09:00:33 -0700 | [diff] [blame] | 344 | SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);) |
| 345 | |
| 346 | DEF_BENCH(return new SkBitmapFPGeneral( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 347 | srcSize, gLinearRGB, mR, true, |
herb | 6eff52a | 2016-03-23 09:00:33 -0700 | [diff] [blame] | 348 | SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);) |
| 349 | |
| 350 | DEF_BENCH(return new SkBitmapFPOrigShader( |
reed | dabe5d3 | 2016-06-21 10:28:14 -0700 | [diff] [blame] | 351 | srcSize, gLinearRGB, mR, true, |
herb | 6eff52a | 2016-03-23 09:00:33 -0700 | [diff] [blame] | 352 | SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);) |