Ultralight C API 1.3.0
Loading...
Searching...
No Matches
CAPI_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
9///
10/// @file CAPI_Config.h
11///
12/// Global config for Ultralight.
13///
14/// This can be used to configure the library when calling ulCreateRenderer() or ulCreateApp().
15///
16#ifndef ULTRALIGHT_CAPI_CONFIG_H
17#define ULTRALIGHT_CAPI_CONFIG_H
18
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/******************************************************************************
26 * Config
27 *****************************************************************************/
28
29///
30/// Create config with default values (see <Ultralight/platform/Config.h>).
31///
33
34///
35/// Destroy config.
36///
38
39///
40/// A writable OS file path to store persistent Session data in.
41///
42/// This data may include cookies, cached network resources, indexed DB, etc.
43///
44/// @note Files are only written to the path when using a persistent Session.
45///
47
48///
49/// The relative path to the resources folder (loaded via the FileSystem API).
50///
51/// The library loads certain resources (SSL certs, ICU data, etc.) from the FileSystem API
52/// during runtime (eg, `file:///resources/cacert.pem`).
53///
54/// You can customize the relative file path to the resources folder by modifying this setting.
55///
56/// (Default = "resources/")
57///
58ULExport void ulConfigSetResourcePathPrefix(ULConfig config, ULString resource_path_prefix);
59
60///
61/// The winding order for front-facing triangles.
62///
63/// @pre Only used when GPU rendering is enabled for the View.
64///
65/// (Default = kFaceWinding_CounterClockwise)
66///
68
69///
70/// The hinting algorithm to use when rendering fonts. (Default = kFontHinting_Normal)
71///
72/// @see ULFontHinting
73///
75
76///
77/// The gamma to use when compositing font glyphs, change this value to adjust contrast (Adobe and
78/// Apple prefer 1.8, others may prefer 2.2). (Default = 1.8)
79///
80ULExport void ulConfigSetFontGamma(ULConfig config, double font_gamma);
81
82///
83/// Global user-defined CSS string (included before any CSS on the page).
84///
85/// You can use this to override default styles for various elements on the page.
86///
87/// @note This is an actual string of CSS, not a file path.
88///
90
91///
92/// Whether or not to continuously repaint any Views, regardless if they are dirty.
93///
94/// This is mainly used to diagnose painting/shader issues and profile performance.
95///
96/// (Default = False)
97///
98ULExport void ulConfigSetForceRepaint(ULConfig config, bool enabled);
99
100///
101/// The delay (in seconds) between every tick of a CSS animation.
102///
103/// (Default = 1.0 / 60.0)
104///
106
107///
108/// The delay (in seconds) between every tick of a smooth scroll animation.
109///
110/// (Default = 1.0 / 60.0)
111///
113
114///
115/// The delay (in seconds) between every call to the recycler.
116///
117/// The library attempts to reclaim excess memory during calls to the internal recycler. You can
118/// change how often this is run by modifying this value.
119///
120/// (Default = 4.0)
121///
122ULExport void ulConfigSetRecycleDelay(ULConfig config, double delay);
123
124///
125/// The size of WebCore's memory cache in bytes.
126///
127/// @note You should increase this if you anticipate handling pages with large resources, Safari
128/// typically uses 128+ MiB for its cache.
129///
130/// (Default = 64 * 1024 * 1024)
131///
132ULExport void ulConfigSetMemoryCacheSize(ULConfig config, unsigned int size);
133
134///
135/// The number of pages to keep in the cache. (Default: 0, none)
136///
137/// @note
138/// \parblock
139///
140/// Safari typically caches about 5 pages and maintains an on-disk cache to support typical
141/// web-browsing activities.
142///
143/// If you increase this, you should probably increase the memory cache size as well.
144///
145/// \endparblock
146///
147/// (Default = 0)
148///
149ULExport void ulConfigSetPageCacheSize(ULConfig config, unsigned int size);
150
151///
152/// The system's physical RAM size in bytes.
153///
154/// JavaScriptCore tries to detect the system's physical RAM size to set reasonable allocation
155/// limits. Set this to anything other than 0 to override the detected value. Size is in bytes.
156///
157/// This can be used to force JavaScriptCore to be more conservative with its allocation strategy
158/// (at the cost of some performance).
159///
160ULExport void ulConfigSetOverrideRAMSize(ULConfig config, unsigned int size);
161
162///
163/// The minimum size of large VM heaps in JavaScriptCore.
164///
165/// Set this to a lower value to make these heaps start with a smaller initial value.
166///
167/// (Default = 32 * 1024 * 1024)
168///
169ULExport void ulConfigSetMinLargeHeapSize(ULConfig config, unsigned int size);
170
171///
172/// The minimum size of small VM heaps in JavaScriptCore.
173///
174/// Set this to a lower value to make these heaps start with a smaller initial value.
175///
176/// (Default = 1 * 1024 * 1024)
177///
178ULExport void ulConfigSetMinSmallHeapSize(ULConfig config, unsigned int size);
179
180///
181/// The number of threads to use in the Renderer (for parallel painting on the CPU, etc.).
182///
183/// You can set this to a certain number to limit the number of threads to spawn.
184///
185/// @note
186/// \parblock
187///
188/// If this value is 0, the number of threads will be determined at runtime using the following
189/// formula:
190///
191/// ```
192/// max(PhysicalProcessorCount() - 1, 1)
193/// ```
194///
195/// \endparblock
196///
197ULExport void ulConfigSetNumRendererThreads(ULConfig config, unsigned int num_renderer_threads);
198
199///
200/// The max amount of time (in seconds) to allow repeating timers to run during each call to
201/// Renderer::Update.
202///
203/// The library will attempt to throttle timers if this time budget is exceeded.
204///
205/// (Default = 1.0 / 200.0)
206///
207ULExport void ulConfigSetMaxUpdateTime(ULConfig config, double max_update_time);
208
209///
210/// The alignment (in bytes) of the BitmapSurface when using the CPU renderer.
211///
212/// The underlying bitmap associated with each BitmapSurface will have row_bytes padded to reach
213/// this alignment.
214///
215/// Aligning the bitmap helps improve performance when using the CPU renderer. Determining the
216/// proper value to use depends on the CPU architecture and max SIMD instruction set used.
217///
218/// We generally target the 128-bit SSE2 instruction set across most PC platforms so '16' is a safe
219/// value to use.
220///
221/// You can set this to '0' to perform no padding (row_bytes will always be width * 4) at a slight
222/// cost to performance.
223///
224/// (Default = 16)
225///
226ULExport void ulConfigSetBitmapAlignment(ULConfig config, unsigned int bitmap_alignment);
227
228#ifdef __cplusplus
229} // extern "C"
230#endif
231
232#endif // ULTRALIGHT_CAPI_CONFIG_H
ULExport void ulConfigSetCachePath(ULConfig config, ULString cache_path)
A writable OS file path to store persistent Session data in.
ULExport void ulConfigSetFontGamma(ULConfig config, double font_gamma)
The gamma to use when compositing font glyphs, change this value to adjust contrast (Adobe and Apple ...
ULExport void ulConfigSetMaxUpdateTime(ULConfig config, double max_update_time)
The max amount of time (in seconds) to allow repeating timers to run during each call to Renderer::Up...
ULExport void ulConfigSetScrollTimerDelay(ULConfig config, double delay)
The delay (in seconds) between every tick of a smooth scroll animation.
ULExport void ulConfigSetResourcePathPrefix(ULConfig config, ULString resource_path_prefix)
The relative path to the resources folder (loaded via the FileSystem API).
ULExport void ulConfigSetRecycleDelay(ULConfig config, double delay)
The delay (in seconds) between every call to the recycler.
ULExport void ulConfigSetBitmapAlignment(ULConfig config, unsigned int bitmap_alignment)
The alignment (in bytes) of the BitmapSurface when using the CPU renderer.
ULExport void ulConfigSetMemoryCacheSize(ULConfig config, unsigned int size)
The size of WebCore's memory cache in bytes.
ULExport void ulConfigSetMinLargeHeapSize(ULConfig config, unsigned int size)
The minimum size of large VM heaps in JavaScriptCore.
ULExport void ulConfigSetFontHinting(ULConfig config, ULFontHinting font_hinting)
The hinting algorithm to use when rendering fonts.
ULExport void ulConfigSetPageCacheSize(ULConfig config, unsigned int size)
The number of pages to keep in the cache.
ULExport void ulConfigSetFaceWinding(ULConfig config, ULFaceWinding winding)
The winding order for front-facing triangles.
ULExport void ulConfigSetForceRepaint(ULConfig config, bool enabled)
Whether or not to continuously repaint any Views, regardless if they are dirty.
ULExport void ulConfigSetUserStylesheet(ULConfig config, ULString css_string)
Global user-defined CSS string (included before any CSS on the page).
ULExport void ulDestroyConfig(ULConfig config)
Destroy config.
ULExport void ulConfigSetOverrideRAMSize(ULConfig config, unsigned int size)
The system's physical RAM size in bytes.
ULExport void ulConfigSetMinSmallHeapSize(ULConfig config, unsigned int size)
The minimum size of small VM heaps in JavaScriptCore.
ULExport void ulConfigSetAnimationTimerDelay(ULConfig config, double delay)
The delay (in seconds) between every tick of a CSS animation.
ULExport void ulConfigSetNumRendererThreads(ULConfig config, unsigned int num_renderer_threads)
The number of threads to use in the Renderer (for parallel painting on the CPU, etc....
ULExport ULConfig ulCreateConfig()
Create config with default values (see <Ultralight/platform/Config.h>).
ULFaceWinding
Definition CAPI_Defines.h:208
struct C_String * ULString
Definition CAPI_Defines.h:54
struct C_Config * ULConfig
Definition CAPI_Defines.h:48
#define ULExport
Definition CAPI_Defines.h:27
ULFontHinting
Definition CAPI_Defines.h:213