Loading...
Searching...
No Matches
CAPI_Defines.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_Defines.h
11///
12/// Various defines and utility functions for the C API.
13///
14/// `#include <Ultralight/CAPI/CAPI_Defines.h>`
15///
16/// This file contains various defines, structures, and utility functions for the C API.
17///
18#ifndef ULTRALIGHT_CAPI_DEFINES_H
19#define ULTRALIGHT_CAPI_DEFINES_H
20
21#include <stddef.h>
22#include <stdint.h>
24#ifdef __OBJC__
25#import <AppKit/NSEvent.h>
26#endif
27
28#if defined(ULTRALIGHT_STATIC_BUILD)
29#define ULExport
30#else
31#if defined(__WIN32__) || defined(_WIN32)
32#if defined(ULTRALIGHT_IMPLEMENTATION)
33#define ULExport __declspec(dllexport)
34#else
35#define ULExport __declspec(dllimport)
36#endif
37#else
38#define ULExport __attribute__((visibility("default")))
39#endif
40#endif
41
42#if defined(__WIN32__) || defined(_WIN32)
43#define _thread_local __declspec(thread)
44#ifndef _NATIVE_WCHAR_T_DEFINED
45#define DISABLE_NATIVE_WCHAR_T
46typedef unsigned short ULChar16;
47#else
48typedef wchar_t ULChar16;
49#endif
50#else
51#define _thread_local __thread
52typedef unsigned short ULChar16;
53#endif
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59typedef struct C_Config* ULConfig;
60typedef struct C_Renderer* ULRenderer;
61typedef struct C_Session* ULSession;
62typedef struct C_ViewConfig* ULViewConfig;
63typedef struct C_View* ULView;
64typedef struct C_Bitmap* ULBitmap;
65typedef struct C_String* ULString;
66typedef struct C_Buffer* ULBuffer;
67typedef struct C_KeyEvent* ULKeyEvent;
68typedef struct C_MouseEvent* ULMouseEvent;
69typedef struct C_ScrollEvent* ULScrollEvent;
70typedef struct C_GamepadEvent* ULGamepadEvent;
71typedef struct C_GamepadAxisEvent* ULGamepadAxisEvent;
72typedef struct C_GamepadButtonEvent* ULGamepadButtonEvent;
73typedef struct C_Surface* ULSurface;
74typedef struct C_Surface* ULBitmapSurface;
75typedef struct C_FontFile* ULFontFile;
76typedef struct C_ImageSource* ULImageSource;
77
97
105
152
153typedef enum {
154 ///
155 /// Alpha channel only, 8-bits per pixel.
156 ///
157 /// Encoding: 8-bits per channel, unsigned normalized.
158 ///
159 /// Color-space: Linear (no gamma), alpha-coverage only.
160 ///
162
163 ///
164 /// Blue Green Red Alpha channels, 32-bits per pixel.
165 ///
166 /// Encoding: 8-bits per channel, unsigned normalized.
167 ///
168 /// Color-space: sRGB gamma with premultiplied linear alpha channel.
169 ///
172
173typedef enum {
174 ///
175 /// Key-Down event type. This type does **not** trigger accelerator commands in WebCore (eg,
176 /// Ctrl+C for copy is an accelerator command).
177 ///
178 /// @warning You should probably use kKeyEventType_RawKeyDown instead. This type is only here for
179 /// historic compatibility with WebCore's key event types.
180 ///
182
183 ///
184 /// Key-Up event type. Use this when a physical key is released.
185 ///
187
188 ///
189 /// Raw Key-Down type. Use this when a physical key is pressed.
190 ///
192
193 ///
194 /// Character input event type. Use this when the OS generates text from
195 /// a physical key being pressed (eg, WM_CHAR on Windows).
196 ///
199
205
212
217
222
227
228typedef enum {
229 ///
230 /// Lighter hinting algorithm-- glyphs are slightly fuzzier but better
231 /// resemble their original shape. This is achieved by snapping glyphs to the
232 /// pixel grid only vertically which better preserves inter-glyph spacing.
233 ///
235
236 ///
237 /// Default hinting algorithm-- offers a good balance between sharpness and
238 /// shape at smaller font sizes.
239 ///
241
242 ///
243 /// Strongest hinting algorithm-- outputs only black/white glyphs. The result
244 /// is usually unpleasant if the underlying TTF does not contain hints for
245 /// this type of rendering.
246 ///
249
250typedef struct {
251 float left;
252 float top;
253 float right;
254 float bottom;
255} ULRect;
256
257typedef struct {
258 int left;
259 int top;
260 int right;
262} ULIntRect;
263
264///
265/// Offscreen render target, used when rendering Views via the GPU renderer.
266///
267/// When a View is rendered via the GPU renderer (see ulViewIsAccelerated()), it will be rendered to
268/// an offscreen render target (ulViewGetRenderTarget()) that you can display in your application.
269///
270/// This is intended to be used with a custom ULGPUDriver implementation in a game or similar
271/// application (ulPlatformSetGPUDriver()).
272///
273typedef struct {
275 unsigned int width;
276 unsigned int height;
277 unsigned int texture_id;
278 unsigned int texture_width;
279 unsigned int texture_height;
282 unsigned int render_buffer_id;
284
285/******************************************************************************
286 * Version
287 *****************************************************************************/
288
289///
290/// Get the version string of the library in MAJOR.MINOR.PATCH format.
291///
293
294///
295/// Get the numeric major version of the library.
296///
298
299///
300/// Get the numeric minor version of the library.
301///
303
304///
305/// Get the numeric patch version of the library.
306///
308
309///
310/// Get the full WebKit version string.
311///
313
314#ifdef __cplusplus
315} // extern "C"
316#endif
317
318#endif // ULTRALIGHT_CAPI_DEFINES_H
struct C_ImageSource * ULImageSource
Definition CAPI_Defines.h:76
ULExport unsigned int ulVersionMinor()
Get the numeric minor version of the library.
ULExport unsigned int ulVersionMajor()
Get the numeric major version of the library.
ULExport const char * ulWebKitVersionString()
Get the full WebKit version string.
ULMessageSource
Definition CAPI_Defines.h:78
@ kMessageSource_CSS
Definition CAPI_Defines.h:86
@ kMessageSource_JS
Definition CAPI_Defines.h:80
@ kMessageSource_Network
Definition CAPI_Defines.h:81
@ kMessageSource_Media
Definition CAPI_Defines.h:89
@ kMessageSource_PaymentRequest
Definition CAPI_Defines.h:94
@ kMessageSource_AppCache
Definition CAPI_Defines.h:84
@ kMessageSource_WebRTC
Definition CAPI_Defines.h:91
@ kMessageSource_ContentBlocker
Definition CAPI_Defines.h:88
@ kMessageSource_MediaSource
Definition CAPI_Defines.h:90
@ kMessageSource_ITPDebug
Definition CAPI_Defines.h:92
@ kMessageSource_XML
Definition CAPI_Defines.h:79
@ kMessageSource_Rendering
Definition CAPI_Defines.h:85
@ kMessageSource_Security
Definition CAPI_Defines.h:87
@ kMessageSource_Storage
Definition CAPI_Defines.h:83
@ kMessageSource_ConsoleAPI
Definition CAPI_Defines.h:82
@ kMessageSource_Other
Definition CAPI_Defines.h:95
@ kMessageSource_PrivateClickMeasurement
Definition CAPI_Defines.h:93
ULFaceWinding
Definition CAPI_Defines.h:223
@ kFaceWinding_Clockwise
Definition CAPI_Defines.h:224
@ kFaceWinding_CounterClockwise
Definition CAPI_Defines.h:225
struct C_GamepadButtonEvent * ULGamepadButtonEvent
Definition CAPI_Defines.h:72
struct C_View * ULView
Definition CAPI_Defines.h:63
unsigned short ULChar16
Definition CAPI_Defines.h:52
ULGamepadEventType
Definition CAPI_Defines.h:218
@ kGamepadEventType_Disconnected
Definition CAPI_Defines.h:220
@ kGamepadEventType_Connected
Definition CAPI_Defines.h:219
struct C_FontFile * ULFontFile
Definition CAPI_Defines.h:75
struct C_String * ULString
Definition CAPI_Defines.h:65
ULScrollEventType
Definition CAPI_Defines.h:213
@ kScrollEventType_ScrollByPixel
Definition CAPI_Defines.h:214
@ kScrollEventType_ScrollByPage
Definition CAPI_Defines.h:215
struct C_Session * ULSession
Definition CAPI_Defines.h:61
struct C_Surface * ULBitmapSurface
Definition CAPI_Defines.h:74
struct C_Config * ULConfig
Definition CAPI_Defines.h:59
#define ULExport
Definition CAPI_Defines.h:38
ULMouseEventType
Definition CAPI_Defines.h:200
@ kMouseEventType_MouseDown
Definition CAPI_Defines.h:202
@ kMouseEventType_MouseMoved
Definition CAPI_Defines.h:201
@ kMouseEventType_MouseUp
Definition CAPI_Defines.h:203
struct C_Surface * ULSurface
Definition CAPI_Defines.h:73
ULMessageLevel
Definition CAPI_Defines.h:98
@ kMessageLevel_Debug
Definition CAPI_Defines.h:102
@ kMessageLevel_Warning
Definition CAPI_Defines.h:100
@ kMessageLevel_Info
Definition CAPI_Defines.h:103
@ kMessageLevel_Error
Definition CAPI_Defines.h:101
@ kMessageLevel_Log
Definition CAPI_Defines.h:99
ULMouseButton
Definition CAPI_Defines.h:206
@ kMouseButton_Right
Definition CAPI_Defines.h:210
@ kMouseButton_None
Definition CAPI_Defines.h:207
@ kMouseButton_Left
Definition CAPI_Defines.h:208
@ kMouseButton_Middle
Definition CAPI_Defines.h:209
ULCursor
Definition CAPI_Defines.h:106
@ kCursor_NorthEastSouthWestResize
Definition CAPI_Defines.h:123
@ kCursor_NorthWestSouthEastResize
Definition CAPI_Defines.h:124
@ kCursor_Cell
Definition CAPI_Defines.h:138
@ kCursor_SouthWestPanning
Definition CAPI_Defines.h:134
@ kCursor_Cross
Definition CAPI_Defines.h:108
@ kCursor_Progress
Definition CAPI_Defines.h:141
@ kCursor_Copy
Definition CAPI_Defines.h:143
@ kCursor_SouthEastPanning
Definition CAPI_Defines.h:133
@ kCursor_ZoomIn
Definition CAPI_Defines.h:146
@ kCursor_SouthWestResize
Definition CAPI_Defines.h:119
@ kCursor_NorthWestResize
Definition CAPI_Defines.h:116
@ kCursor_MiddlePanning
Definition CAPI_Defines.h:127
@ kCursor_ContextMenu
Definition CAPI_Defines.h:139
@ kCursor_Hand
Definition CAPI_Defines.h:109
@ kCursor_ZoomOut
Definition CAPI_Defines.h:147
@ kCursor_Wait
Definition CAPI_Defines.h:111
@ kCursor_Grabbing
Definition CAPI_Defines.h:149
@ kCursor_NoDrop
Definition CAPI_Defines.h:142
@ kCursor_SouthPanning
Definition CAPI_Defines.h:132
@ kCursor_Grab
Definition CAPI_Defines.h:148
@ kCursor_VerticalText
Definition CAPI_Defines.h:137
@ kCursor_Move
Definition CAPI_Defines.h:136
@ kCursor_WestPanning
Definition CAPI_Defines.h:135
@ kCursor_SouthEastResize
Definition CAPI_Defines.h:118
@ kCursor_EastResize
Definition CAPI_Defines.h:113
@ kCursor_EastPanning
Definition CAPI_Defines.h:128
@ kCursor_None
Definition CAPI_Defines.h:144
@ kCursor_EastWestResize
Definition CAPI_Defines.h:122
@ kCursor_RowResize
Definition CAPI_Defines.h:126
@ kCursor_NorthEastPanning
Definition CAPI_Defines.h:130
@ kCursor_SouthResize
Definition CAPI_Defines.h:117
@ kCursor_ColumnResize
Definition CAPI_Defines.h:125
@ kCursor_NorthResize
Definition CAPI_Defines.h:114
@ kCursor_IBeam
Definition CAPI_Defines.h:110
@ kCursor_NorthEastResize
Definition CAPI_Defines.h:115
@ kCursor_WestResize
Definition CAPI_Defines.h:120
@ kCursor_NorthSouthResize
Definition CAPI_Defines.h:121
@ kCursor_Pointer
Definition CAPI_Defines.h:107
@ kCursor_NorthWestPanning
Definition CAPI_Defines.h:131
@ kCursor_Custom
Definition CAPI_Defines.h:150
@ kCursor_NotAllowed
Definition CAPI_Defines.h:145
@ kCursor_Alias
Definition CAPI_Defines.h:140
@ kCursor_NorthPanning
Definition CAPI_Defines.h:129
@ kCursor_Help
Definition CAPI_Defines.h:112
ULExport const char * ulVersionString()
Get the version string of the library in MAJOR.MINOR.PATCH format.
struct C_GamepadAxisEvent * ULGamepadAxisEvent
Definition CAPI_Defines.h:71
struct C_MouseEvent * ULMouseEvent
Definition CAPI_Defines.h:68
struct C_Bitmap * ULBitmap
Definition CAPI_Defines.h:64
struct C_ViewConfig * ULViewConfig
Definition CAPI_Defines.h:62
struct C_ScrollEvent * ULScrollEvent
Definition CAPI_Defines.h:69
ULKeyEventType
Definition CAPI_Defines.h:173
@ kKeyEventType_RawKeyDown
Raw Key-Down type.
Definition CAPI_Defines.h:191
@ kKeyEventType_KeyUp
Key-Up event type.
Definition CAPI_Defines.h:186
@ kKeyEventType_KeyDown
Key-Down event type.
Definition CAPI_Defines.h:181
@ kKeyEventType_Char
Character input event type.
Definition CAPI_Defines.h:197
struct C_Buffer * ULBuffer
Definition CAPI_Defines.h:66
struct C_Renderer * ULRenderer
Definition CAPI_Defines.h:60
ULFontHinting
Definition CAPI_Defines.h:228
@ kFontHinting_Normal
Default hinting algorithm– offers a good balance between sharpness and shape at smaller font sizes.
Definition CAPI_Defines.h:240
@ kFontHinting_Smooth
Lighter hinting algorithm– glyphs are slightly fuzzier but better resemble their original shape.
Definition CAPI_Defines.h:234
@ kFontHinting_Monochrome
Strongest hinting algorithm– outputs only black/white glyphs.
Definition CAPI_Defines.h:247
struct C_GamepadEvent * ULGamepadEvent
Definition CAPI_Defines.h:70
struct C_KeyEvent * ULKeyEvent
Definition CAPI_Defines.h:67
ULExport unsigned int ulVersionPatch()
Get the numeric patch version of the library.
ULBitmapFormat
Definition CAPI_Defines.h:153
@ kBitmapFormat_A8_UNORM
Alpha channel only, 8-bits per pixel.
Definition CAPI_Defines.h:161
@ kBitmapFormat_BGRA8_UNORM_SRGB
Blue Green Red Alpha channels, 32-bits per pixel.
Definition CAPI_Defines.h:170
Definition CAPI_Defines.h:257
int right
Definition CAPI_Defines.h:260
int bottom
Definition CAPI_Defines.h:261
int left
Definition CAPI_Defines.h:258
int top
Definition CAPI_Defines.h:259
Definition CAPI_Defines.h:250
float bottom
Definition CAPI_Defines.h:254
float right
Definition CAPI_Defines.h:253
float left
Definition CAPI_Defines.h:251
float top
Definition CAPI_Defines.h:252
Offscreen render target, used when rendering Views via the GPU renderer.
Definition CAPI_Defines.h:273
unsigned int texture_width
Definition CAPI_Defines.h:278
unsigned int texture_height
Definition CAPI_Defines.h:279
ULRect uv_coords
Definition CAPI_Defines.h:281
unsigned int render_buffer_id
Definition CAPI_Defines.h:282
bool is_empty
Definition CAPI_Defines.h:274
unsigned int height
Definition CAPI_Defines.h:276
unsigned int width
Definition CAPI_Defines.h:275
unsigned int texture_id
Definition CAPI_Defines.h:277
ULBitmapFormat texture_format
Definition CAPI_Defines.h:280