Debian Codegraph @

include/core/SkTypes.h

raw
1 /*
2 * Copyright 2006 The Android Open Source Project
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 SkTypes_DEFINED
9 #define SkTypes_DEFINED
10
11 // All of these files should be independent of things users can set via the user config file.
12 // They should also be able to be included in any order.
13 // IWYU pragma: begin_exports
14 #include "include/private/base/SkFeatures.h"
15
16 // Load and verify defines from the user config file.
17 #include "include/private/base/SkLoadUserConfig.h"
18
19 // Any includes or defines below can be configured by the user config file.
20 #include "include/private/base/SkAPI.h"
21 #include "include/private/base/SkAssert.h"
22 #include "include/private/base/SkAttributes.h"
23 #include "include/private/base/SkDebug.h"
24 // IWYU pragma: end_exports
25
26 #include <cstdint>
27
28 #if !defined(SK_GANESH) && !defined(SK_GRAPHITE)
29 # undef SK_GL
30 # undef SK_VULKAN
31 # undef SK_METAL
32 # undef SK_DAWN
33 # undef SK_DIRECT3D
34 #endif
35
36 // If SK_R32_SHIFT is set, we'll use that to choose RGBA or BGRA.
37 // If not, we'll default to RGBA everywhere except BGRA on Windows.
38 #if defined(SK_R32_SHIFT)
39 static_assert(SK_R32_SHIFT == 0 || SK_R32_SHIFT == 16, "");
40 #elif defined(SK_BUILD_FOR_WIN)
41 #define SK_R32_SHIFT 16
42 #else
43 #define SK_R32_SHIFT 0
44 #endif
45
46 #if defined(SK_B32_SHIFT)
47 static_assert(SK_B32_SHIFT == (16-SK_R32_SHIFT), "");
48 #else
49 #define SK_B32_SHIFT (16-SK_R32_SHIFT)
50 #endif
51
52 #define SK_G32_SHIFT 8
53 #define SK_A32_SHIFT 24
54
55 /**
56 * SK_PMCOLOR_BYTE_ORDER can be used to query the byte order of SkPMColor at compile time.
57 */
58 #ifdef SK_CPU_BENDIAN
59 # define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \
60 (SK_ ## C3 ## 32_SHIFT == 0 && \
61 SK_ ## C2 ## 32_SHIFT == 8 && \
62 SK_ ## C1 ## 32_SHIFT == 16 && \
63 SK_ ## C0 ## 32_SHIFT == 24)
64 #else
65 # define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \
66 (SK_ ## C0 ## 32_SHIFT == 0 && \
67 SK_ ## C1 ## 32_SHIFT == 8 && \
68 SK_ ## C2 ## 32_SHIFT == 16 && \
69 SK_ ## C3 ## 32_SHIFT == 24)
70 #endif
71
72 #if defined SK_DEBUG && defined SK_BUILD_FOR_WIN
73 #ifdef free
74 #undef free
75 #endif
76 #include <crtdbg.h>
77 #undef free
78 #endif
79
80 #ifndef SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
81 #define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 0
82 #endif
83
84 #if !defined(SK_GAMMA_EXPONENT)
85 #define SK_GAMMA_EXPONENT (0.0f) // SRGB
86 #endif
87
88 #if !defined(SK_GAMMA_CONTRAST)
89 // A value of 0.5 for SK_GAMMA_CONTRAST appears to be a good compromise.
90 // With lower values small text appears washed out (though correctly so).
91 // With higher values lcd fringing is worse and the smoothing effect of
92 // partial coverage is diminished.
93 #define SK_GAMMA_CONTRAST (0.5f)
94 #endif
95
96 #if defined(SK_HISTOGRAM_ENUMERATION) || \
97 defined(SK_HISTOGRAM_BOOLEAN) || \
98 defined(SK_HISTOGRAM_EXACT_LINEAR) || \
99 defined(SK_HISTOGRAM_CUSTOM_EXACT_LINEAR) || \
100 defined(SK_HISTOGRAM_MEMORY_KB) || \
101 defined(SK_HISTOGRAM_CUSTOM_COUNTS)|| \
102 defined(SK_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES)
103 # define SK_HISTOGRAMS_ENABLED 1
104 #else
105 # define SK_HISTOGRAMS_ENABLED 0
106 #endif
107
108 #ifndef SK_HISTOGRAM_BOOLEAN
109 # define SK_HISTOGRAM_BOOLEAN(name, sample)
110 #endif
111
112 #ifndef SK_HISTOGRAM_ENUMERATION
113 # define SK_HISTOGRAM_ENUMERATION(name, sampleEnum, enumSize)
114 #endif
115
116 #ifndef SK_HISTOGRAM_EXACT_LINEAR
117 # define SK_HISTOGRAM_EXACT_LINEAR(name, sample, valueMax)
118 #endif
119
120 #ifndef SK_HISTOGRAM_CUSTOM_EXACT_LINEAR
121 # define SK_HISTOGRAM_CUSTOM_EXACT_LINEAR(name, sample, value_min, \
122 value_max, bucket_count)
123 #endif
124
125 #ifndef SK_HISTOGRAM_MEMORY_KB
126 # define SK_HISTOGRAM_MEMORY_KB(name, sample)
127 #endif
128
129 #ifndef SK_HISTOGRAM_CUSTOM_COUNTS
130 # define SK_HISTOGRAM_CUSTOM_COUNTS(name, sample, countMin, countMax, bucketCount)
131 #endif
132
133 #ifndef SK_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES
134 # define SK_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(name, sampleUSec, minUSec, maxUSec, bucketCount)
135 #endif
136
137 #define SK_HISTOGRAM_PERCENTAGE(name, percent_as_int) \
138 SK_HISTOGRAM_EXACT_LINEAR(name, percent_as_int, 101)
139
140 // The top-level define SK_ENABLE_OPTIMIZE_SIZE can be used to remove several large features at once
141 #if defined(SK_ENABLE_OPTIMIZE_SIZE)
142 #if !defined(SK_FORCE_RASTER_PIPELINE_BLITTER)
143 #define SK_FORCE_RASTER_PIPELINE_BLITTER
144 #endif
145 #define SK_DISABLE_SDF_TEXT
146 #endif
147
148 #if defined(SK_BUILD_FOR_LIBFUZZER) || defined(SK_BUILD_FOR_AFL_FUZZ)
149 #if !defined(SK_BUILD_FOR_FUZZER)
150 #define SK_BUILD_FOR_FUZZER
151 #endif
152 #endif
153
154 /**
155 * These defines are set to 0 or 1, rather than being undefined or defined
156 * TODO: consider updating these for consistency
157 */
158
159 #if !defined(GR_CACHE_STATS)
160 #if defined(SK_DEBUG) || defined(SK_DUMP_STATS)
161 #define GR_CACHE_STATS 1
162 #else
163 #define GR_CACHE_STATS 0
164 #endif
165 #endif
166
167 #if !defined(GR_GPU_STATS)
168 #if defined(SK_DEBUG) || defined(SK_DUMP_STATS) || defined(GPU_TEST_UTILS)
169 #define GR_GPU_STATS 1
170 #else
171 #define GR_GPU_STATS 0
172 #endif
173 #endif
174
175 ////////////////////////////////////////////////////////////////////////////////
176
177 /** 32 bit integer to hold a unicode value
178 */
179 typedef int32_t SkUnichar;
180
181 /** 16 bit unsigned integer to hold a glyph index
182 */
183 typedef uint16_t SkGlyphID;
184
185 /** The generation IDs in Skia reserve 0 has an invalid marker.
186 */
187 static constexpr uint32_t SK_InvalidGenID = 0;
188
189 /** The unique IDs in Skia reserve 0 has an invalid marker.
190 */
191 static constexpr uint32_t SK_InvalidUniqueID = 0;
192
193 #endif