Ultralight C++ API 1.3.0
Loading...
Searching...
No Matches
Config.h
Go to the documentation of this file.
1/******************************************************************************
2 * This file is a part of Ultralight, an ultra-portable web-browser engine. *
3 * *
4 * See <https://ultralig.ht> for licensing and more. *
5 * *
6 * (C) 2023 Ultralight, Inc. *
7 *****************************************************************************/
8#pragma once
10#include <Ultralight/String.h>
11
12namespace ultralight {
13
14///
15/// The winding order for front-facing triangles. (Only used when the GPU renderer is used)
16///
17enum class UExport FaceWinding : uint8_t {
18 ///
19 /// Clockwise Winding (Direct3D, etc.)
20 ///
22
23 ///
24 /// Counter-Clockwise Winding (OpenGL, etc.)
25 ///
27};
28
29enum class UExport FontHinting : uint8_t {
30 ///
31 /// Lighter hinting algorithm-- glyphs are slightly fuzzier but better resemble their original
32 /// shape. This is achieved by snapping glyphs to the pixel grid only vertically which better
33 /// preserves inter-glyph spacing.
34 ///
35 Smooth,
36
37 ///
38 /// Default hinting algorithm-- offers a good balance between sharpness and shape at smaller font
39 /// sizes.
40 ///
41 Normal,
42
43 ///
44 /// Strongest hinting algorithm-- outputs only black/white glyphs. The result is usually
45 /// unpleasant if the underlying TTF does not contain hints for this type of rendering.
46 ///
48
49 ///
50 /// No hinting is performed-- fonts may be blurry at smaller font sizes.
51 ///
52 None,
53};
54
55///
56/// Global config for Ultralight.
57///
58/// This can be used to configure the library by calling Platform::set_config() before creating the
59/// Renderer or App singletons.
60///
61/// @par Example usage
62/// ```
63/// Config config;
64/// config.user_stylesheet = "body { background: purple; }";
65///
66/// Platform::instance().set_config(config);
67/// // (Setup other Platform interfaces here.)
68///
69/// auto renderer = Renderer::Create();
70/// ```
71///
73 ///
74 /// A writable OS file path to store persistent Session data in.
75 ///
76 /// This data may include cookies, cached network resources, indexed DB, etc.
77 ///
78 /// @note Files are only written to the path when using a persistent Session.
79 ///
80 /// @see Renderer::CreateSession()
81 ///
83
84 ///
85 /// The relative path to the resources folder (loaded via the FileSystem API).
86 ///
87 /// The library loads certain resources (SSL certs, ICU data, etc.) from the FileSystem API
88 /// during runtime (eg, `file:///resources/cacert.pem`).
89 ///
90 /// You can customize the relative file path to the resources folder by modifying this setting.
91 ///
92 /// @see FileSystem
93 ///
94 String resource_path_prefix = "resources/";
95
96 ///
97 /// The winding order for front-facing triangles.
98 ///
99 /// @pre Only used when GPU rendering is enabled for the View.
100 ///
101 /// @see FaceWinding
102 ///
103 FaceWinding face_winding = FaceWinding::CounterClockwise;
104
105 ///
106 /// The hinting algorithm to use when rendering fonts.
107 ///
108 /// @see FontHinting
109 ///
110 FontHinting font_hinting = FontHinting::Normal;
111
112 ///
113 /// The gamma to use when compositing font glyphs.
114 ///
115 /// You can change this value to adjust font contrast (Adobe and Apple prefer 1.8).
116 ///
117 double font_gamma = 1.8;
118
119 ///
120 /// Global user-defined CSS string (included before any CSS on the page).
121 ///
122 /// You can use this to override default styles for various elements on the page.
123 ///
124 /// @note This is an actual string of CSS, not a file path.
125 ///
127
128 ///
129 /// Whether or not to continuously repaint any Views, regardless if they are dirty.
130 ///
131 /// This is mainly used to diagnose painting/shader issues and profile performance.
132 ///
133 bool force_repaint = false;
134
135 ///
136 /// The delay (in seconds) between every tick of a CSS animation. (Default: 60 FPS)
137 ///
138 double animation_timer_delay = 1.0 / 60.0;
139
140 ///
141 /// The delay (in seconds) between every tick of a smooth scroll animation. (Default: 60 FPS)
142 ///
143 double scroll_timer_delay = 1.0 / 60.0;
144
145 ///
146 /// The delay (in seconds) between every call to the recycler.
147 ///
148 /// The library attempts to reclaim excess memory during calls to the internal recycler. You can
149 /// change how often this is run by modifying this value.
150 ///
151 double recycle_delay = 4.0;
152
153 ///
154 /// The size of WebCore's memory cache in bytes.
155 ///
156 /// @note You should increase this if you anticipate handling pages with large resources, Safari
157 /// typically uses 128+ MiB for its cache.
158 ///
159 uint32_t memory_cache_size = 64 * 1024 * 1024;
160
161 ///
162 /// The number of pages to keep in the cache. (Default: 0, none)
163 ///
164 /// @note
165 /// \parblock
166 ///
167 /// Safari typically caches about 5 pages and maintains an on-disk cache to support typical
168 /// web-browsing activities.
169 ///
170 /// If you increase this, you should probably increase the memory cache size as well.
171 ///
172 /// \endparblock
173 ///
174 uint32_t page_cache_size = 0;
175
176 ///
177 /// The system's physical RAM size in bytes.
178 ///
179 /// JavaScriptCore tries to detect the system's physical RAM size to set reasonable allocation
180 /// limits. Set this to anything other than 0 to override the detected value. Size is in bytes.
181 ///
182 /// This can be used to force JavaScriptCore to be more conservative with its allocation strategy
183 /// (at the cost of some performance).
184 ///
185 uint32_t override_ram_size = 0;
186
187 ///
188 /// The minimum size of large VM heaps in JavaScriptCore.
189 ///
190 /// Set this to a lower value to make these heaps start with a smaller initial value.
191 ///
192 uint32_t min_large_heap_size = 32 * 1024 * 1024;
193
194 ///
195 /// The minimum size of small VM heaps in JavaScriptCore.
196 ///
197 /// Set this to a lower value to make these heaps start with a smaller initial value.
198 ///
199 uint32_t min_small_heap_size = 1 * 1024 * 1024;
200
201 ///
202 /// The number of threads to use in the Renderer (for parallel painting on the CPU, etc.).
203 ///
204 /// You can set this to a certain number to limit the number of threads to spawn.
205 ///
206 /// @note
207 /// \parblock
208 ///
209 /// If this value is 0, the number of threads will be determined at runtime using the following
210 /// formula:
211 ///
212 /// ```
213 /// max(PhysicalProcessorCount() - 1, 1)
214 /// ```
215 ///
216 /// \endparblock
217 ///
218 uint32_t num_renderer_threads = 0;
219
220 ///
221 /// The max amount of time (in seconds) to allow repeating timers to run during each call to
222 /// Renderer::Update.
223 ///
224 /// The library will attempt to throttle timers if this time budget is exceeded.
225 ///
226 double max_update_time = 1.0 / 200.0;
227
228 ///
229 /// The alignment (in bytes) of the BitmapSurface when using the CPU renderer.
230 ///
231 /// The underlying bitmap associated with each BitmapSurface will have row_bytes padded to reach
232 /// this alignment.
233 ///
234 /// Aligning the bitmap helps improve performance when using the CPU renderer. Determining the
235 /// proper value to use depends on the CPU architecture and max SIMD instruction set used.
236 ///
237 /// We generally target the 128-bit SSE2 instruction set across most PC platforms so '16' is
238 /// a safe value to use.
239 ///
240 /// You can set this to '0' to perform no padding (row_bytes will always be width * 4) at a
241 /// slight cost to performance.
242 ///
243 uint32_t bitmap_alignment = 16;
244};
245
246} // namespace ultralight
#define UExport
Definition Defines.h:65
UTF-8 String container with conversions for UTF-16 and UTF-32.
Definition String.h:21
Definition App.h:14
FaceWinding
The winding order for front-facing triangles.
Definition Config.h:17
@ CounterClockwise
Counter-Clockwise Winding (OpenGL, etc.)
@ Clockwise
Clockwise Winding (Direct3D, etc.)
FontHinting
Definition Config.h:29
@ None
No hinting is performed– fonts may be blurry at smaller font sizes.
@ Monochrome
Strongest hinting algorithm– outputs only black/white glyphs.
@ Normal
Default hinting algorithm– offers a good balance between sharpness and shape at smaller font sizes.
@ Smooth
Lighter hinting algorithm– glyphs are slightly fuzzier but better resemble their original shape.
Global config for Ultralight.
Definition Config.h:72
String cache_path
A writable OS file path to store persistent Session data in.
Definition Config.h:82
String user_stylesheet
Global user-defined CSS string (included before any CSS on the page).
Definition Config.h:126