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