blob: 5490a6c44b8f2ab417728ff6aaa87d2cd0b0a86c [file] [log] [blame]
mtklein55c86ab2016-01-08 06:32:52 -08001/*
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 "SkOpts.h"
10
11class SwizzleBench : public Benchmark {
12public:
mtklein8bf7b792016-01-22 07:42:53 -080013 SwizzleBench(const char* name, SkOpts::Swizzle_8888 fn) : fName(name), fFn(fn) {}
mtklein55c86ab2016-01-08 06:32:52 -080014
15 bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
16 const char* onGetName() override { return fName; }
17 void onDraw(int loops, SkCanvas*) override {
18 static const int K = 1023; // Arbitrary, but nice to be a non-power-of-two to trip up SIMD.
19 uint32_t dst[K], src[K];
20 while (loops --> 0) {
21 fFn(dst, src, K);
22 }
23 }
24private:
25 const char* fName;
mtklein8bf7b792016-01-22 07:42:53 -080026 SkOpts::Swizzle_8888 fFn;
mtklein55c86ab2016-01-08 06:32:52 -080027};
28
29
mtklein8bf7b792016-01-22 07:42:53 -080030DEF_BENCH(return new SwizzleBench("SkOpts::RGBA_to_rgbA", SkOpts::RGBA_to_rgbA));
31DEF_BENCH(return new SwizzleBench("SkOpts::RGBA_to_bgrA", SkOpts::RGBA_to_bgrA));
32DEF_BENCH(return new SwizzleBench("SkOpts::RGBA_to_BGRA", SkOpts::RGBA_to_BGRA));
msarettf1b8b6a2016-01-22 09:54:21 -080033DEF_BENCH(return new SwizzleBench("SkOpts::RGB_to_RGB1", SkOpts::RGB_to_RGB1));
34DEF_BENCH(return new SwizzleBench("SkOpts::RGB_to_BGR1", SkOpts::RGB_to_BGR1));
msarett2eff71c2016-02-02 12:59:45 -080035DEF_BENCH(return new SwizzleBench("SkOpts::gray_to_RGB1", SkOpts::gray_to_RGB1));
msarett09574242016-02-03 15:28:35 -080036DEF_BENCH(return new SwizzleBench("SkOpts::grayA_to_RGBA", SkOpts::grayA_to_RGBA));
37DEF_BENCH(return new SwizzleBench("SkOpts::grayA_to_rgbA", SkOpts::grayA_to_rgbA));
msarettc5c322d2016-02-08 13:26:25 -080038DEF_BENCH(return new SwizzleBench("SkOpts::inverted_CMYK_to_RGB1", SkOpts::inverted_CMYK_to_RGB1));
39DEF_BENCH(return new SwizzleBench("SkOpts::inverted_CMYK_to_BGR1", SkOpts::inverted_CMYK_to_BGR1));