Loading...
Searching...
No Matches
Config.h
Go to the documentation of this file.
1/**************************************************************************************************
2 * This file is a part of Ultralight. *
3 * *
4 * See <https://ultralig.ht> for licensing and more. *
5 * *
6 * (C) 2024 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 FaceWinding : uint8_t {
18 ///
19 /// Clockwise Winding (Direct3D, etc.)
20 ///
22
23 ///
24 /// Counter-Clockwise Winding (OpenGL, etc.)
25 ///
27};
28
29enum class 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
55enum class EffectQuality : uint8_t {
56 ///
57 /// Fastest effect quality-- uses the lowest quality effects (half-resolution, fewer passes, etc.)
58 ///
59 Low,
60
61 ///
62 /// Default effect quality-- strikes a good balance between quality and performance.
63 ///
64 Medium,
65
66 ///
67 /// Highest effect quality-- favors quality over performance.
68 ///
69 High,
70};
71
72///
73/// Core configuration for the renderer.
74///
75/// These are various configuration options that can be used to customize the behavior of the
76/// library. These options can only be set once before creating the Renderer.
77///
78/// ## Setting the Config
79///
80/// You should create an instance of the Config struct, set its members, and then call
81/// Platform::set_config() before creating the Renderer at the beginning of your
82/// application's lifetime.
83///
84/// @par Example usage
85/// ```
86/// Config config;
87/// config.user_stylesheet = "body { background: purple; }";
88///
89/// Platform::instance().set_config(config);
90/// // (Setup other Platform interfaces here.)
91///
92/// auto renderer = Renderer::Create();
93/// ```
94///
96 ///
97 /// A writable OS file path to store persistent Session data in.
98 ///
99 /// This data may include cookies, cached network resources, indexed DB, etc.
100 ///
101 /// @note Files are only written to the path when using a persistent Session.
102 ///
103 /// @see Renderer::CreateSession()
104 ///
106
107 ///
108 /// The relative path to the resources folder (loaded via the FileSystem API).
109 ///
110 /// The library loads certain resources (SSL certs, ICU data, etc.) from the FileSystem API
111 /// during runtime (eg, `file:///resources/cacert.pem`).
112 ///
113 /// You can customize the relative file path to the resources folder by modifying this setting.
114 ///
115 /// @see FileSystem
116 ///
117 String resource_path_prefix = "resources/";
118
119 ///
120 /// The winding order for front-facing triangles.
121 ///
122 /// @pre Only used when GPU rendering is enabled for the View.
123 ///
124 /// @see FaceWinding
125 ///
126 FaceWinding face_winding = FaceWinding::CounterClockwise;
127
128 ///
129 /// The hinting algorithm to use when rendering fonts.
130 ///
131 /// @see FontHinting
132 ///
133 FontHinting font_hinting = FontHinting::Normal;
134
135 ///
136 /// The gamma to use when compositing font glyphs.
137 ///
138 /// You can change this value to adjust font contrast (Adobe and Apple prefer 1.8).
139 ///
140 double font_gamma = 1.8;
141
142 ///
143 /// Global user-defined CSS string (included before any CSS on the page).
144 ///
145 /// You can use this to override default styles for various elements on the page.
146 ///
147 /// @note This is an actual string of CSS, not a file path.
148 ///
150
151 ///
152 /// Whether or not to continuously repaint any Views, regardless if they are dirty.
153 ///
154 /// This is mainly used to diagnose painting/shader issues and profile performance.
155 ///
156 bool force_repaint = false;
157
158 ///
159 /// The delay (in seconds) between every tick of a CSS animation. (Default: 60 FPS)
160 ///
161 double animation_timer_delay = 1.0 / 60.0;
162
163 ///
164 /// The delay (in seconds) between every tick of a smooth scroll animation. (Default: 60 FPS)
165 ///
166 double scroll_timer_delay = 1.0 / 60.0;
167
168 ///
169 /// The delay (in seconds) between every call to the recycler.
170 ///
171 /// The library attempts to reclaim excess memory during calls to the internal recycler. You can
172 /// change how often this is run by modifying this value.
173 ///
174 double recycle_delay = 4.0;
175
176 ///
177 /// The size of WebCore's memory cache in bytes.
178 ///
179 /// @note You should increase this if you anticipate handling pages with large resources, Safari
180 /// typically uses 128+ MiB for its cache.
181 ///
182 uint32_t memory_cache_size = 64 * 1024 * 1024;
183
184 ///
185 /// The number of pages to keep in the cache. (Default: 0, none)
186 ///
187 /// @note
188 /// \parblock
189 ///
190 /// Safari typically caches about 5 pages and maintains an on-disk cache to support typical
191 /// web-browsing activities.
192 ///
193 /// If you increase this, you should probably increase the memory cache size as well.
194 ///
195 /// \endparblock
196 ///
197 uint32_t page_cache_size = 0;
198
199 ///
200 /// The system's physical RAM size in bytes.
201 ///
202 /// JavaScriptCore tries to detect the system's physical RAM size to set reasonable allocation
203 /// limits. Set this to anything other than 0 to override the detected value. Size is in bytes.
204 ///
205 /// This can be used to force JavaScriptCore to be more conservative with its allocation strategy
206 /// (at the cost of some performance).
207 ///
208 uint32_t override_ram_size = 0;
209
210 ///
211 /// The minimum size of large VM heaps in JavaScriptCore.
212 ///
213 /// Set this to a lower value to make these heaps start with a smaller initial value.
214 ///
215 uint32_t min_large_heap_size = 32 * 1024 * 1024;
216
217 ///
218 /// The minimum size of small VM heaps in JavaScriptCore.
219 ///
220 /// Set this to a lower value to make these heaps start with a smaller initial value.
221 ///
222 uint32_t min_small_heap_size = 1 * 1024 * 1024;
223
224 ///
225 /// The number of threads to use in the Renderer (for parallel painting on the CPU, etc.).
226 ///
227 /// You can set this to a certain number to limit the number of threads to spawn.
228 ///
229 /// @note
230 /// \parblock
231 ///
232 /// If this value is 0, the number of threads will be determined at runtime using the following
233 /// formula:
234 ///
235 /// ```
236 /// max(PhysicalProcessorCount() - 1, 1)
237 /// ```
238 ///
239 /// \endparblock
240 ///
241 uint32_t num_renderer_threads = 0;
242
243 ///
244 /// The max amount of time (in seconds) to allow repeating timers to run during each call to
245 /// Renderer::Update.
246 ///
247 /// The library will attempt to throttle timers if this time budget is exceeded.
248 ///
249 double max_update_time = 1.0 / 200.0;
250
251 ///
252 /// The alignment (in bytes) of the BitmapSurface when using the CPU renderer.
253 ///
254 /// The underlying bitmap associated with each BitmapSurface will have row_bytes padded to reach
255 /// this alignment.
256 ///
257 /// Aligning the bitmap helps improve performance when using the CPU renderer. Determining the
258 /// proper value to use depends on the CPU architecture and max SIMD instruction set used.
259 ///
260 /// We generally target the 128-bit SSE2 instruction set across most PC platforms so '16' is
261 /// a safe value to use.
262 ///
263 /// You can set this to '0' to perform no padding (row_bytes will always be width * 4) at a
264 /// slight cost to performance.
265 ///
266 uint32_t bitmap_alignment = 16;
267
268 ///
269 /// The quality of effects (blurs, CSS filters, SVG filters, etc.) to use when rendering.
270 ///
271 EffectQuality effect_quality = EffectQuality::Medium;
272};
273
274} // namespace ultralight
#define UExport
Definition Exports.h:25
Unicode string container with conversions for UTF-8, UTF-16, and UTF-32.
Definition String.h:34
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.)
EffectQuality
Definition Config.h:55
@ Low
Fastest effect quality– uses the lowest quality effects (half-resolution, fewer passes,...
@ High
Highest effect quality– favors quality over performance.
@ Medium
Default effect quality– strikes a good balance between quality and performance.
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.
Core configuration for the renderer.
Definition Config.h:95
String cache_path
A writable OS file path to store persistent Session data in.
Definition Config.h:105
String user_stylesheet
Global user-defined CSS string (included before any CSS on the page).
Definition Config.h:149