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 "SkNx.h"
13 
14 namespace SK_OPTS_NS {
15 
16     template <typename T>
memsetT(T buffer[],T value,int count)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 const int N = 32 / sizeof(T);
20     #else
21         static const int N = 16 / sizeof(T);
22     #endif
23         while (count >= N) {
24             SkNx<N,T>(value).store(buffer);
25             buffer += N;
26             count  -= N;
27         }
28         while (count --> 0) {
29             *buffer++ = value;
30         }
31     }
32 
memset16(uint16_t buffer[],uint16_t value,int count)33     /*not static*/ inline void memset16(uint16_t buffer[], uint16_t value, int count) {
34         memsetT(buffer, value, count);
35     }
memset32(uint32_t buffer[],uint32_t value,int count)36     /*not static*/ inline void memset32(uint32_t buffer[], uint32_t value, int count) {
37         memsetT(buffer, value, count);
38     }
memset64(uint64_t buffer[],uint64_t value,int count)39     /*not static*/ inline void memset64(uint64_t buffer[], uint64_t value, int count) {
40         memsetT(buffer, value, count);
41     }
42 
43 }
44 
45 #endif//SkUtils_opts_DEFINED
46