Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: include/core/SkUtils.h

Issue 1270573002: Port SkUtils opts to SkOpts. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: always inline armv8 Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gyp/opts.gypi ('k') | src/core/SkOpts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkUtils_DEFINED 8 #ifndef SkUtils_DEFINED
9 #define SkUtils_DEFINED 9 #define SkUtils_DEFINED
10 10
11 #include "SkTypes.h" 11 #include "SkTypes.h"
12 12
13 namespace SkOpts {
14 extern void (*memset16)(uint16_t[], uint16_t, int);
djsollen 2015/07/31 17:25:23 does this mean that SkOpts.h should be in include/
mtklein_C 2015/07/31 17:36:25 Yeah, borderline case. Done.
15 extern void (*memset32)(uint32_t[], uint32_t, int);
16 }
17
13 /////////////////////////////////////////////////////////////////////////////// 18 ///////////////////////////////////////////////////////////////////////////////
14 19
15 // Determined empirically using bench/MemsetBench.cpp on a Nexus 7, Nexus 9, and desktop. 20 // The inlining heuristics below were determined using bench/MemsetBench.cpp
16 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 || defined(SK_ARM_HAS_NEON) 21 // on a x86 desktop, a Nexus 7 with and without NEON, and a Nexus 9.
17 // Platforms where we can assume an autovectorizer will give us a good inlin e memset.
18 #define SK_SMALL_MEMSET 1000
19 #else
20 // Platforms like Chrome on ARMv7 that don't typically compile with NEON glo bally.
21 #define SK_SMALL_MEMSET 10
22 #endif
23
24 22
25 /** Similar to memset(), but it assigns a 16bit value into the buffer. 23 /** Similar to memset(), but it assigns a 16bit value into the buffer.
26 @param buffer The memory to have value copied into it 24 @param buffer The memory to have value copied into it
27 @param value The 16bit value to be copied into buffer 25 @param value The 16bit value to be copied into buffer
28 @param count The number of times value should be copied into the buffer. 26 @param count The number of times value should be copied into the buffer.
29 */ 27 */
30 void sk_memset16_large(uint16_t dst[], uint16_t value, int count); 28 static inline void sk_memset16(uint16_t buffer[], uint16_t value, int count) {
31 inline void sk_memset16(uint16_t dst[], uint16_t value, int count) { 29 #if defined(SK_CPU_ARM64)
djsollen 2015/07/31 17:25:23 can you add some comments as to why we don't just
mtklein_C 2015/07/31 17:36:25 Done.
32 if (count <= SK_SMALL_MEMSET) { 30 while (count --> 0) { *buffer++ = value; } return;
33 for (int i = 0; i < count; i++) { 31 #elif defined(SK_CPU_ARM32)
34 dst[i] = value; 32 if (count <= 10) { while (count --> 0) { *buffer++ = value; } return; }
35 } 33 #endif
36 } else { 34 SkOpts::memset16(buffer, value, count);
37 sk_memset16_large(dst, value, count);
38 }
39 } 35 }
40 typedef void (*SkMemset16Proc)(uint16_t dst[], uint16_t value, int count);
41 SkMemset16Proc SkMemset16GetPlatformProc();
42 36
43 /** Similar to memset(), but it assigns a 32bit value into the buffer. 37 /** Similar to memset(), but it assigns a 32bit value into the buffer.
44 @param buffer The memory to have value copied into it 38 @param buffer The memory to have value copied into it
45 @param value The 32bit value to be copied into buffer 39 @param value The 32bit value to be copied into buffer
46 @param count The number of times value should be copied into the buffer. 40 @param count The number of times value should be copied into the buffer.
47 */ 41 */
48 void sk_memset32_large(uint32_t dst[], uint32_t value, int count); 42 static inline void sk_memset32(uint32_t buffer[], uint32_t value, int count) {
49 inline void sk_memset32(uint32_t dst[], uint32_t value, int count) { 43 #if defined(SK_CPU_ARM64)
djsollen 2015/07/31 17:25:23 further why not put this logic in the neon opts fi
mtklein_C 2015/07/31 17:36:25 Done.
50 if (count <= SK_SMALL_MEMSET) { 44 while (count --> 0) { *buffer++ = value; } return;
51 for (int i = 0; i < count; i++) { 45 #elif defined(SK_CPU_ARM32)
52 dst[i] = value; 46 if (count <= 10) { while (count --> 0) { *buffer++ = value; } return; }
53 } 47 #endif
54 } else { 48 SkOpts::memset32(buffer, value, count);
55 sk_memset32_large(dst, value, count);
56 }
57 } 49 }
58 50
59 typedef void (*SkMemset32Proc)(uint32_t dst[], uint32_t value, int count);
60 SkMemset32Proc SkMemset32GetPlatformProc();
61
62 #undef SK_SMALL_MEMSET
63 51
64 /////////////////////////////////////////////////////////////////////////////// 52 ///////////////////////////////////////////////////////////////////////////////
65 53
66 #define kMaxBytesInUTF8Sequence 4 54 #define kMaxBytesInUTF8Sequence 4
67 55
68 #ifdef SK_DEBUG 56 #ifdef SK_DEBUG
69 int SkUTF8_LeadByteToCount(unsigned c); 57 int SkUTF8_LeadByteToCount(unsigned c);
70 #else 58 #else
71 #define SkUTF8_LeadByteToCount(c) ((((0xE5 << 24) >> ((unsigned)c >> 4 << 1)) & 3) + 1) 59 #define SkUTF8_LeadByteToCount(c) ((((0xE5 << 24) >> ((unsigned)c >> 4 << 1)) & 3) + 1)
72 #endif 60 #endif
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 119 }
132 ~SkAutoTrace() { 120 ~SkAutoTrace() {
133 SkDebugf("--- trace: %s Leave\n", fLabel); 121 SkDebugf("--- trace: %s Leave\n", fLabel);
134 } 122 }
135 private: 123 private:
136 const char* fLabel; 124 const char* fLabel;
137 }; 125 };
138 #define SkAutoTrace(...) SK_REQUIRE_LOCAL_VAR(SkAutoTrace) 126 #define SkAutoTrace(...) SK_REQUIRE_LOCAL_VAR(SkAutoTrace)
139 127
140 #endif 128 #endif
OLDNEW
« no previous file with comments | « gyp/opts.gypi ('k') | src/core/SkOpts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698