forked from servo/rust-azure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-c.h
424 lines (355 loc) · 11 KB
/
azure-c.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MOZILLA_GFX_AZURE_C_H_
#define MOZILLA_GFX_AZURE_C_H_
#include "GrContext.h"
#include "SkNativeSharedGLContext.h"
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
// A function that we use to test that our definitions match the C++
void AzSanityCheck();
// FIXME: This stuff is copy pasted from the azure headers
/* Types.h */
typedef float AzFloat;
enum AzSurfaceType
{
AZ_SURFACE_DATA, /* Data surface - bitmap in memory */
AZ_SURFACE_D2D1_BITMAP, /* Surface wrapping a ID2D1Bitmap */
AZ_SURFACE_D2D1_DRAWTARGET, /* Surface made from a D2D draw target */
AZ_SURFACE_CAIRO, /* Surface wrapping a cairo surface */
AZ_SURFACE_CAIRO_IMAGE, /* Data surface wrapping a cairo image surface */
AZ_SURFACE_COREGRAPHICS_IMAGE, /* Surface wrapping a CoreGraphics Image */
AZ_SURFACE_COREGRAPHICS_CGCONTEXT, /* Surface wrapping a CG context */
AZ_SURFACE_SKIA, /* Surface wrapping a Skia bitmap */
AZ_SURFACE_DUAL_DT /* Snapshot of a dual drawtarget */
};
enum AzSurfaceFormat
{
AZ_FORMAT_B8G8R8A8,
AZ_FORMAT_B8G8R8X8,
AZ_FORMAT_R5G6B5,
AZ_FORMAT_A8
};
enum AzBackendType
{
AZ_BACKEND_NONE,
AZ_BACKEND_DIRECT2D,
AZ_BACKEND_COREGRAPHICS,
AZ_BACKEND_COREGRAPHICS_ACCELERATED,
AZ_BACKEND_CAIRO,
AZ_BACKEND_SKIA
};
enum AzFontType
{
AZ_FONT_DWRITE,
AZ_FONT_GDI,
AZ_FONT_MAC,
AZ_FONT_SKIA,
AZ_FONT_CAIRO,
AZ_FONT_COREGRAPHICS
};
enum AzNativeSurfaceType
{
AZ_NATIVE_SURFACE_D3D10_TEXTURE,
AZ_NATIVE_SURFACE_CAIRO_SURFACE,
AZ_NATIVE_SURFACE_CGCONTEXT
};
enum AzNativeFontType
{
AZ_NATIVE_FONT_DWRITE_FONT_FACE,
AZ_NATIVE_FONT_GDI_FONT_FACE,
AZ_NATIVE_FONT_MAC_FONT_FACE,
AZ_NATIVE_FONT_SKIA_FONT_FACE,
AZ_NATIVE_FONT_CAIRO_FONT_FACE
};
enum AzFontStyle
{
AZ_FONT_STYLE_NORMAL,
AZ_FONT_STYLE_ITALIC,
AZ_FONT_STYLE_BOLD,
AZ_FONT_STYLE_BOLD_ITALIC
};
enum AzCompositionOp {
AZ_OP_OVER,
AZ_OP_ADD,
AZ_OP_ATOP,
AZ_OP_OUT,
AZ_OP_IN,
AZ_OP_SOURCE,
AZ_OP_DEST_IN,
AZ_OP_DEST_OUT,
AZ_OP_DEST_OVER,
AZ_OP_DEST_ATOP,
AZ_OP_XOR,
AZ_OP_MULTIPLY,
AZ_OP_SCREEN,
AZ_OP_OVERLAY,
AZ_OP_DARKEN,
AZ_OP_LIGHTEN,
AZ_OP_COLOR_DODGE,
AZ_OP_COLOR_BURN,
AZ_OP_HARD_LIGHT,
AZ_OP_SOFT_LIGHT,
AZ_OP_DIFFERENCE,
AZ_OP_EXCLUSION,
AZ_OP_HUE,
AZ_OP_SATURATION,
AZ_OP_COLOR,
AZ_OP_LUMINOSITY,
AZ_OP_COUNT
};
enum AzExtendMode {
AZ_EXTEND_CLAMP,
AZ_EXTEND_REPEAT,
AZ_EXTEND_REFLECT
};
enum AzFillRule {
AZ_FILL_WINDING,
AZ_FILL_EVEN_ODD
};
enum AzAntialiasMode {
AZ_AA_NONE,
AZ_AA_GRAY,
AZ_AA_SUBPIXEL,
AZ_AA_DEFAULT
};
enum AzSnapping {
AZ_SNAP_NONE,
AZ_SNAP_ALIGNED
};
enum AzFilter {
AZ_FILTER_LINEAR,
AZ_FILTER_POINT
};
enum AzPatternType {
AZ_PATTERN_COLOR,
AZ_PATTERN_SURFACE,
AZ_PATTERN_LINEAR_GRADIENT,
AZ_PATTERN_RADIAL_GRADIENT
};
enum AzJoinStyle {
AZ_JOIN_BEVEL,
AZ_JOIN_ROUND,
AZ_JOIN_MITER,
AZ_JOIN_MITER_OR_BEVEL
};
enum AzCapStyle {
AZ_CAP_BUTT,
AZ_CAP_ROUND,
AZ_CAP_SQUARE
};
enum AzSamplingBounds {
AZ_SAMPLING_UNBOUNDED,
AZ_SAMPLING_BOUNDED
};
enum AzSide {
AZ_eSideTop,
AZ_eSideRight,
AZ_eSideBottom,
AZ_eSideLeft
};
typedef struct _AzColor {
AzFloat r, g, b, a;
} AzColor;
typedef struct _AzGradientStop {
AzFloat offset;
AzColor color;
} AzGradientStop;
/* Rect.h */
typedef struct _AzIntRect {
int32_t x, y, width, height;
} AzIntRect;
typedef struct _AzRect {
AzFloat x, y, width, height;
} AzRect;
/* Point.h */
typedef struct _AzIntPoint {
int32_t x, y;
} AzIntPoint;
typedef struct _AzPoint {
AzFloat x, y;
} AzPoint;
typedef struct _AzIntSize {
int32_t width, height;
} AzIntSize;
typedef struct _AzSize {
AzFloat width, height;
} AzSize;
/* Matrix.h */
typedef struct _AzMatrix {
AzFloat _11, _12;
AzFloat _21, _22;
AzFloat _31, _32;
} AzMatrix;
/* 2D.h */
// FIXME: rust-bindgen can't handle bitfields
typedef struct _AzDrawOptions {
AzFloat mAlpha;
uint16_t fields;
/*
enum AzCompositionOp mCompositionOp : 8;
enum AzAntialiasMode mAntialiasMode : 3;
enum AzSnapping mSnapping : 1;
*/
} AzDrawOptions;
// FIXME: Again, bitfields
typedef struct _AzStrokeOptions {
AzFloat mLineWidth;
AzFloat mMiterLimit;
const AzFloat* mDashPattern;
size_t mDashLength;
AzFloat mDashOffset;
uint16_t fields;
/*
enum AzJoinStyle mLineJoin : 4;
enum AzCapStyle mLineCap : 3;
*/
} AzStrokeOptions;
// FIXME: Guess what? Bitfields
typedef struct _AzDrawSurfaceOptions {
uint32_t fields;
/*
enum Filter mFilter : 3;
enum Filter mSamplingBounds : 1;
*/
} AzDrawSurfaceOptions;
typedef struct _AzGlyph {
uint32_t mIndex;
AzPoint mPosition;
} AzGlyph;
typedef struct _AzGlyphBuffer {
const AzGlyph *mGlyphs;
uint32_t mNumGlyphs;
} AzGlyphBuffer;
typedef struct _AzNativeFont {
enum AzNativeFontType mType;
void *mFont;
} AzNativeFont;
typedef void* AzGradientStopsRef;
typedef void* AzSkiaSharedGLContextRef;
typedef void* AzSkiaGrContextRef;
typedef void* AzDrawTargetRef;
typedef void* AzPatternRef;
typedef void* AzColorPatternRef;
typedef void* AzScaledFontRef;
typedef void* AzGlyphRenderingOptionsRef;
typedef void* AzSourceSurfaceRef;
typedef void* AzDrawSurfaceOptionsRef;
typedef void* AzDataSourceSurfaceRef;
typedef void* AzPathBuilderRef;
typedef void* AzPathRef;
typedef GrGLSharedContext AzGLContext;
AzColorPatternRef AzCreateColorPattern(AzColor *aColor);
void AzReleaseColorPattern(AzColorPatternRef aColorPattern);
AzSkiaSharedGLContextRef AzCreateSkiaSharedGLContext(GrGLSharedContext aSharedContext, void *extra, AzIntSize *aSize);
void AzRetainSkiaSharedGLContext(AzSkiaSharedGLContextRef aGLContext);
void AzReleaseSkiaShareGLContext(AzSkiaSharedGLContextRef aGLContext);
unsigned int AzSkiaSharedGLContextGetFBOID(AzSkiaSharedGLContextRef aGLContext);
unsigned int AzSkiaSharedGLContextGetTextureID(AzSkiaSharedGLContextRef aGLContext);
AzSkiaGrContextRef AzSkiaSharedGLContextGetGrContext(AzSkiaSharedGLContextRef aGLContext);
void AzSkiaSharedGLContextMakeCurrent(AzSkiaSharedGLContextRef aGLContext);
void AzSkiaSharedGLContextFlush(AzSkiaSharedGLContextRef aGLContext);
AzDrawTargetRef AzCreateDrawTarget(AzBackendType aBackend,
AzIntSize *aSize,
AzSurfaceFormat aFormat);
AzDrawTargetRef AzCreateDrawTargetForData(AzBackendType aBackend,
unsigned char *aData,
AzIntSize *aSize,
int32_t aStride,
AzSurfaceFormat aFormat);
AzDrawTargetRef AzCreateSkiaDrawTragetForFBO(AzSkiaSharedGLContextRef aGLContext,
AzIntSize *aSize,
AzSurfaceFormat aFormat);
void AzRetainDrawTarget(AzDrawTargetRef aTarget);
void AzReleaseDrawTarget(AzDrawTargetRef aTarget);
AzIntSize AzDrawTargetGetSize(AzDrawTargetRef aDrawTarget);
void AzDrawTargetFlush(AzDrawTargetRef aDrawTarget);
void AzDrawTargetClearRect(AzDrawTargetRef aDrawTarget, AzRect *aRect);
void AzDrawTargetFillRect(AzDrawTargetRef aDrawTarget,
AzRect *aRect,
AzPatternRef aPattern);
void AzDrawTargetFillRect2(AzDrawTargetRef aDrawTarget,
AzRect *aRect,
AzPatternRef aPattern,
AzDrawOptions *aDrawOptions);
void AzDrawTargetStrokeRect(AzDrawTargetRef aDrawTarget,
AzRect *aRect,
AzPatternRef aPattern,
AzStrokeOptions *aStrokeOptions,
AzDrawOptions *aDrawOptions);
void AzDrawTargetStrokeLine(AzDrawTargetRef aDrawTarget,
AzPoint *aStart,
AzPoint *aEnd,
AzPatternRef aPattern,
AzStrokeOptions *aStrokeOptions,
AzDrawOptions *aDrawOptions);
void AzDrawTargetFillGlyphs(AzDrawTargetRef aDrawTarget,
AzScaledFontRef aFont,
AzGlyphBuffer *aGlyphBuffer,
AzPatternRef aPattern,
AzDrawOptions *aOptions,
AzGlyphRenderingOptionsRef aRenderingOptions);
void AzDrawTargetDrawSurface(AzDrawTargetRef aDrawTarget,
AzSourceSurfaceRef aSurface,
AzRect *aDest,
AzRect *aSource,
AzDrawSurfaceOptionsRef aSurfOptions,
AzDrawOptions *aOptions);
AzSourceSurfaceRef AzDrawTargetGetSnapshot(AzDrawTargetRef aDrawTarget);
AzSourceSurfaceRef AzDrawTargetCreateSourceSurfaceFromData(AzDrawTargetRef aDrawTarget,
unsigned char *aData,
AzIntSize *aSize,
int32_t aStride,
AzSurfaceFormat aFormat);
void AzReleaseSourceSurface(AzSourceSurfaceRef aSurface);
AzIntSize AzSourceSurfaceGetSize(AzSourceSurfaceRef aSurface);
AzSurfaceFormat AzSourceSurfaceGetFormat(AzSourceSurfaceRef aSurface);
AzDataSourceSurfaceRef AzSourceSurfaceGetDataSurface(AzSourceSurfaceRef aSurface);
uint8_t *AzDataSourceSurfaceGetData(AzDataSourceSurfaceRef aSurface);
int32_t AzDataSourceSurfaceGetStride(AzDataSourceSurfaceRef aSurface);
/* Factory.h */
void AzReleaseScaledFont(AzScaledFontRef aFont);
/* Helpers */
typedef void AzFontOptions;
AzFontOptions* AzCreateFontOptions(char *aName, AzFontStyle aStyle);
void AzDestroyFontOptions(AzFontOptions* aOptions);
AzGLContext AzSkiaGetCurrentGLContext();
/* Path */
AzPathBuilderRef AzCreatePathBuilder(AzDrawTargetRef aTarget, AzFillRule fillrule);
void AzReleasePathBuilder(AzPathBuilderRef aPathBuilder);
void AzPathBuilderClose(AzPathBuilderRef aPathBuilder);
void AzPathBuilderMoveTo(AzPathBuilderRef aPathBuilder, AzPoint* pt);
void AzPathBuilderLineTo(AzPathBuilderRef aPathBuilder, AzPoint* pt);
void AzPathBuilderQuadraticBezierTo(AzPathBuilderRef aPathBuilder,
AzPoint* ptc,
AzPoint* pt);
void AzPathBuilderBezierTo(AzPathBuilderRef aPathBuilder,
AzPoint* ptc1,
AzPoint* ptc2,
AzPoint* pt);
void AzPathBuilderArc(AzPathBuilderRef aPathBuilder,
AzPoint* pt,
AzFloat radius, AzFloat angle1, AzFloat angle2,
bool anticlockwise);
void AzPathBuilderCurrentPoint(AzPathBuilderRef aPathBuilder, AzPoint* pt);
AzPathRef AzPathBuilderFinish(AzPathBuilderRef aPathBuilder);
AzPathBuilderRef AzPathCopyToBuilder(AzPathRef aPath,AzFillRule fillrule);
void AzReleasePath(AzPathRef aPath);
bool AzPathContainsPoint(AzPathRef aPath, AzPoint* pt, AzMatrix* matrix);
void AzDrawTargetFill(AzDrawTargetRef aDrawTarget,
AzPathRef aPath,
AzPatternRef aPattern,
AzDrawOptions *aDrawOptions);
void AzDrawTargetStroke(AzDrawTargetRef aDrawTarget,
AzPathRef aPath,
AzPatternRef aPattern,
AzStrokeOptions *aStrokeOptions,
AzDrawOptions *aDrawOptions);
#ifdef __cplusplus
}
#endif
#endif /* MOZILLA_GFX_AZURE_C_H */