Flutter Engine
The Flutter Engine
SwizzleBench.cpp
Go to the documentation of this file.
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 "bench/Benchmark.h"
11
12class SwizzleBench : public Benchmark {
13public:
14
15 SwizzleBench(const char* name, SkOpts::Swizzle_8888_u32 fn) : fName(name), fFn_u32(fn) {}
16 SwizzleBench(const char* name, SkOpts::Swizzle_8888_u8 fn) : fName(name), fFn_u8 (fn) {}
17
19 const char* onGetName() override { return fName; }
20 void onDraw(int loops, SkCanvas*) override {
21 static const int K = 1023; // Arbitrary, but nice to be a non-power-of-two to trip up SIMD.
22 uint32_t dst[K], src[K];
23 while (loops --> 0) {
24 if (fFn_u32) { fFn_u32(dst, src, K); }
25 if (fFn_u8) { fFn_u8 (dst, (const uint8_t*)src, K); }
26 }
27 }
28private:
29 const char* fName;
30 SkOpts::Swizzle_8888_u32 fFn_u32 = nullptr;
31 SkOpts::Swizzle_8888_u8 fFn_u8 = nullptr;
32};
33
34
35DEF_BENCH(return new SwizzleBench("SkOpts::RGBA_to_rgbA", SkOpts::RGBA_to_rgbA));
36DEF_BENCH(return new SwizzleBench("SkOpts::RGBA_to_bgrA", SkOpts::RGBA_to_bgrA));
37DEF_BENCH(return new SwizzleBench("SkOpts::RGBA_to_BGRA", SkOpts::RGBA_to_BGRA));
38DEF_BENCH(return new SwizzleBench("SkOpts::RGB_to_RGB1", SkOpts::RGB_to_RGB1));
39DEF_BENCH(return new SwizzleBench("SkOpts::RGB_to_BGR1", SkOpts::RGB_to_BGR1));
40DEF_BENCH(return new SwizzleBench("SkOpts::gray_to_RGB1", SkOpts::gray_to_RGB1));
41DEF_BENCH(return new SwizzleBench("SkOpts::grayA_to_RGBA", SkOpts::grayA_to_RGBA));
42DEF_BENCH(return new SwizzleBench("SkOpts::grayA_to_rgbA", SkOpts::grayA_to_rgbA));
43DEF_BENCH(return new SwizzleBench("SkOpts::inverted_CMYK_to_RGB1", SkOpts::inverted_CMYK_to_RGB1));
44DEF_BENCH(return new SwizzleBench("SkOpts::inverted_CMYK_to_BGR1", SkOpts::inverted_CMYK_to_BGR1));
const char * backend
DEF_BENCH(return new SwizzleBench("SkOpts::RGBA_to_rgbA", SkOpts::RGBA_to_rgbA))
void onDraw(int loops, SkCanvas *) override
SwizzleBench(const char *name, SkOpts::Swizzle_8888_u32 fn)
bool isSuitableFor(Backend backend) override
SwizzleBench(const char *name, SkOpts::Swizzle_8888_u8 fn)
const char * onGetName() override
static const int K
Definition: daa.cpp:21
void(*)(uint32_t *, const uint8_t *, int) Swizzle_8888_u8
Definition: SkSwizzlePriv.h:27
void(*)(uint32_t *, const uint32_t *, int) Swizzle_8888_u32
Definition: SkSwizzlePriv.h:18
Swizzle_8888_u8 gray_to_RGB1
Definition: SkSwizzlePriv.h:30
Swizzle_8888_u32 RGBA_to_rgbA
Definition: SkSwizzlePriv.h:20
Swizzle_8888_u8 RGB_to_RGB1
Swizzle_8888_u8 grayA_to_rgbA
Definition: SkSwizzlePriv.h:32
Swizzle_8888_u8 RGB_to_BGR1
Definition: SkSwizzlePriv.h:29
Swizzle_8888_u8 grayA_to_RGBA
Definition: SkSwizzlePriv.h:31
Swizzle_8888_u32 RGBA_to_BGRA
Swizzle_8888_u32 RGBA_to_bgrA
Definition: SkSwizzlePriv.h:21
Swizzle_8888_u32 inverted_CMYK_to_BGR1
Definition: SkSwizzlePriv.h:25
Swizzle_8888_u32 inverted_CMYK_to_RGB1
Definition: SkSwizzlePriv.h:24
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
dst
Definition: cp.py:12