Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkMemset_opts.h
Go to the documentation of this file.
1/*
2 * Copyright 2017 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#ifndef SkUtils_opts_DEFINED
9#define SkUtils_opts_DEFINED
10
11#include <stdint.h>
12#include "src/base/SkVx.h"
13
14namespace SK_OPTS_NS {
15
16 template <typename T>
17 static void memsetT(T buffer[], T value, int count) {
18 #if defined(SK_CPU_SSE_LEVEL) && SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_AVX
19 static constexpr int VecSize = 32 / sizeof(T);
20 #else
21 static constexpr int VecSize = 16 / sizeof(T);
22 #endif
23 static_assert(VecSize > 0, "T is too big for memsetT");
24 // Create an vectorized version of value
25 skvx::Vec<VecSize,T> wideValue(value);
26 while (count >= VecSize) {
27 // Copy the value into the destination buffer (VecSize elements at a time)
28 wideValue.store(buffer);
29 buffer += VecSize;
30 count -= VecSize;
31 }
32 // If count was not an even multiple of VecSize, take care of the last few.
33 while (count-- > 0) {
34 *buffer++ = value;
35 }
36 }
37
38 /*not static*/ inline void memset16(uint16_t buffer[], uint16_t value, int count) {
40 }
41 /*not static*/ inline void memset32(uint32_t buffer[], uint32_t value, int count) {
43 }
44 /*not static*/ inline void memset64(uint64_t buffer[], uint64_t value, int count) {
46 }
47
48 template <typename T>
49 static void rect_memsetT(T buffer[], T value, int count, size_t rowBytes, int height) {
50 while (height --> 0) {
52 buffer = (T*)((char*)buffer + rowBytes);
53 }
54 }
55
56 /*not static*/ inline void rect_memset16(uint16_t buffer[], uint16_t value, int count,
57 size_t rowBytes, int height) {
58 rect_memsetT(buffer, value, count, rowBytes, height);
59 }
60 /*not static*/ inline void rect_memset32(uint32_t buffer[], uint32_t value, int count,
61 size_t rowBytes, int height) {
62 rect_memsetT(buffer, value, count, rowBytes, height);
63 }
64 /*not static*/ inline void rect_memset64(uint64_t buffer[], uint64_t value, int count,
65 size_t rowBytes, int height) {
66 rect_memsetT(buffer, value, count, rowBytes, height);
67 }
68
69} // namespace SK_OPTS_NS
70
71#endif//SkUtils_opts_DEFINED
int count
static const uint8_t buffer[]
uint8_t value
static void rect_memsetT(T buffer[], T value, int count, size_t rowBytes, int height)
static void memsetT(T buffer[], T value, int count)
#define T
int32_t height
SKVX_ALWAYS_INLINE void store(void *ptr) const
Definition SkVx.h:112