This lets the compiler generate AVX versions with wider writes.
Change-Id: Ia63825e70c72bdb4d14bef97d8b4ea4be54c9d84
Reviewed-on: https://skia-review.googlesource.com/17715
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
#include "SkChecksum_opts.h"
#include "SkMorphologyImageFilter_opts.h"
#include "SkSwizzler_opts.h"
+#include "SkUtils_opts.h"
#include "SkXfermode_opts.h"
namespace SkOpts {
DEFINE_DEFAULT(srcover_srgb_srgb);
+ DEFINE_DEFAULT(memset16);
+ DEFINE_DEFAULT(memset32);
+ DEFINE_DEFAULT(memset64);
+
DEFINE_DEFAULT(hash_fn);
DEFINE_DEFAULT(convolve_vertically);
// If nsrc < ndst, we loop over src to create a pattern.
extern void (*srcover_srgb_srgb)(uint32_t* dst, const uint32_t* src, int ndst, int nsrc);
+ extern void (*memset16)(uint16_t[], uint16_t, int);
+ extern void (*memset32)(uint32_t[], uint32_t, int);
+ extern void (*memset64)(uint64_t[], uint64_t, int);
+
// The fastest high quality 32-bit hash we can provide on this platform.
extern uint32_t (*hash_fn)(const void*, size_t, uint32_t seed);
static inline uint32_t hash(const void* data, size_t bytes, uint32_t seed=0) {
#include "SkUtils.h"
-void sk_memset16(uint16_t buffer[], uint16_t value, int count) {
- for (int i = 0; i < count; i++) {
- buffer[i] = value;
- }
-}
-void sk_memset32(uint32_t buffer[], uint32_t value, int count) {
- for (int i = 0; i < count; i++) {
- buffer[i] = value;
- }
-}
-void sk_memset64(uint64_t buffer[], uint64_t value, int count) {
- for (int i = 0; i < count; i++) {
- buffer[i] = value;
- }
-}
-
/* 0xxxxxxx 1 total
10xxxxxx // never a leading byte
110xxxxx 2 total
#include "SkTypes.h"
#include "SkMath.h"
+#include "SkOpts.h"
/** Similar to memset(), but it assigns a 16, 32, or 64-bit value into the buffer.
@param buffer The memory to have value copied into it
@param value The value to be copied into buffer
@param count The number of times value should be copied into the buffer.
*/
-void sk_memset16(uint16_t buffer[], uint16_t value, int count);
-void sk_memset32(uint32_t buffer[], uint32_t value, int count);
-void sk_memset64(uint64_t buffer[], uint64_t value, int count);
+static inline void sk_memset16(uint16_t buffer[], uint16_t value, int count) {
+ SkOpts::memset16(buffer, value, count);
+}
+static inline void sk_memset32(uint32_t buffer[], uint32_t value, int count) {
+ SkOpts::memset32(buffer, value, count);
+}
+static inline void sk_memset64(uint64_t buffer[], uint64_t value, int count) {
+ SkOpts::memset64(buffer, value, count);
+}
///////////////////////////////////////////////////////////////////////////////
#define kMaxBytesInUTF8Sequence 4
#include "SkSafe_math.h" // Keep this first.
#include "SkOpts.h"
-#define SK_OPTS_NS avx
-
#if defined(_INC_MATH) && !defined(INC_MATH_IS_SAFE_NOW)
#error We have included ucrt\math.h without protecting it against ODR violation.
#endif
+#define SK_OPTS_NS avx
+#include "SkUtils_opts.h"
+
namespace SkOpts {
- void Init_avx() { }
+ void Init_avx() {
+ memset16 = SK_OPTS_NS::memset16;
+ memset32 = SK_OPTS_NS::memset32;
+ memset64 = SK_OPTS_NS::memset64;
+ }
}
--- /dev/null
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkUtils_opts_DEFINED
+#define SkUtils_opts_DEFINED
+
+namespace SK_OPTS_NS {
+
+ static void memset16(uint16_t buffer[], uint16_t value, int count) {
+ for (int i = 0; i < count; i++) {
+ buffer[i] = value;
+ }
+ }
+ static void memset32(uint32_t buffer[], uint32_t value, int count) {
+ for (int i = 0; i < count; i++) {
+ buffer[i] = value;
+ }
+ }
+ static void memset64(uint64_t buffer[], uint64_t value, int count) {
+ for (int i = 0; i < count; i++) {
+ buffer[i] = value;
+ }
+ }
+
+}
+
+#endif//SkUtils_opts_DEFINED