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