Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
opts
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
14
namespace
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
) {
39
memsetT
(
buffer
,
value
,
count
);
40
}
41
/*not static*/
inline
void
memset32(uint32_t
buffer
[], uint32_t value,
int
count
) {
42
memsetT
(
buffer
,
value
,
count
);
43
}
44
/*not static*/
inline
void
memset64(uint64_t
buffer
[], uint64_t value,
int
count
) {
45
memsetT
(
buffer
,
value
,
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) {
51
memsetT
(
buffer
,
value
,
count
);
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
count
int count
Definition
FontMgrTest.cpp:50
SkVx.h
buffer
static const uint8_t buffer[]
Definition
fl_pixel_buffer_texture_test.cc:44
value
uint8_t value
Definition
fl_standard_message_codec.cc:36
SK_OPTS_NS
Definition
SkBitmapProcState_opts.h:34
SK_OPTS_NS::rect_memsetT
static void rect_memsetT(T buffer[], T value, int count, size_t rowBytes, int height)
Definition
SkMemset_opts.h:49
SK_OPTS_NS::memsetT
static void memsetT(T buffer[], T value, int count)
Definition
SkMemset_opts.h:17
T
#define T
Definition
precompiler.cc:65
height
int32_t height
Definition
serialization_callbacks.cc:1
skvx::Vec
Definition
SkVx.h:83
skvx::Vec::store
SKVX_ALWAYS_INLINE void store(void *ptr) const
Definition
SkVx.h:112
Generated on Fri Apr 26 2024 06:17:22 for Flutter Engine by
1.9.8