Other Tools

1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
/* Generated with cbindgen:0.9.1 */
6
7
/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.
8
* To generate this file:
9
* 1. Get the latest cbindgen using `cargo install --force cbindgen`
10
* a. Alternatively, you can clone `https://github.com/eqrion/cbindgen` and use a tagged release
11
* 2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate webrender_bindings -o gfx/webrender_bindings/webrender_ffi_generated.h`
12
*/
13
14
#include <cstdarg>
15
#include <cstdint>
16
#include <cstdlib>
17
#include <new>
18
19
namespace mozilla {
20
namespace wr {
21
22
static const uintptr_t GlyphCache_DEFAULT_MAX_BYTES_USED = 6 * 1024 * 1024;
23
24
/// Whether a border should be antialiased.
25
enum class AntialiasBorder {
26
No = 0,
27
Yes,
28
29
Sentinel /* this must be last for serialization purposes. */
30
};
31
32
enum class BorderStyle : uint32_t {
33
None = 0,
34
Solid = 1,
35
Double = 2,
36
Dotted = 3,
37
Dashed = 4,
38
Hidden = 5,
39
Groove = 6,
40
Ridge = 7,
41
Inset = 8,
42
Outset = 9,
43
44
Sentinel /* this must be last for serialization purposes. */
45
};
46
47
enum class BoxShadowClipMode : uint8_t {
48
Outset = 0,
49
Inset = 1,
50
51
Sentinel /* this must be last for serialization purposes. */
52
};
53
54
enum class Checkpoint : uint32_t {
55
SceneBuilt,
56
FrameBuilt,
57
FrameTexturesUpdated,
58
FrameRendered,
59
/// NotificationRequests get notified with this if they get dropped without having been
60
/// notified. This provides the guarantee that if a request is created it will get notified.
61
TransactionDropped,
62
63
Sentinel /* this must be last for serialization purposes. */
64
};
65
66
enum class ClipMode {
67
Clip,
68
ClipOut,
69
70
Sentinel /* this must be last for serialization purposes. */
71
};
72
73
/// Specifies the color depth of an image. Currently only used for YUV images.
74
enum class ColorDepth : uint8_t {
75
/// 8 bits image (most common)
76
Color8,
77
/// 10 bits image
78
Color10,
79
/// 12 bits image
80
Color12,
81
/// 16 bits image
82
Color16,
83
84
Sentinel /* this must be last for serialization purposes. */
85
};
86
87
enum class ColorRange : uint8_t {
88
Limited = 0,
89
Full = 1,
90
91
Sentinel /* this must be last for serialization purposes. */
92
};
93
94
enum class ComponentTransferFuncType : uint8_t {
95
Identity = 0,
96
Table = 1,
97
Discrete = 2,
98
Linear = 3,
99
Gamma = 4,
100
101
Sentinel /* this must be last for serialization purposes. */
102
};
103
104
enum class ExtendMode : uint8_t {
105
Clamp,
106
Repeat,
107
108
Sentinel /* this must be last for serialization purposes. */
109
};
110
111
#if !(defined(XP_MACOSX) || defined(XP_WIN))
112
enum class FontHinting : uint8_t {
113
None,
114
Mono,
115
Light,
116
Normal,
117
LCD,
118
119
Sentinel /* this must be last for serialization purposes. */
120
};
121
#endif
122
123
#if !(defined(XP_MACOSX) || defined(XP_WIN))
124
enum class FontLCDFilter : uint8_t {
125
None,
126
Default,
127
Light,
128
Legacy,
129
130
Sentinel /* this must be last for serialization purposes. */
131
};
132
#endif
133
134
enum class FontRenderMode : uint8_t {
135
Mono = 0,
136
Alpha,
137
Subpixel,
138
139
Sentinel /* this must be last for serialization purposes. */
140
};
141
142
/// Specifies the format of a series of pixels, in driver terms.
143
enum class ImageFormat : uint8_t {
144
/// One-channel, byte storage. The "red" doesn't map to the color
145
/// red per se, and is just the way that OpenGL has historically referred
146
/// to single-channel buffers.
147
R8 = 1,
148
/// One-channel, short storage
149
R16 = 2,
150
/// Four channels, byte storage.
151
BGRA8 = 3,
152
/// Four channels, float storage.
153
RGBAF32 = 4,
154
/// Two-channels, byte storage. Similar to `R8`, this just means
155
/// "two channels" rather than "red and green".
156
RG8 = 5,
157
/// Two-channels, byte storage. Similar to `R16`, this just means
158
/// "two channels" rather than "red and green".
159
RG16 = 6,
160
/// Four channels, signed integer storage.
161
RGBAI32 = 7,
162
/// Four channels, byte storage.
163
RGBA8 = 8,
164
165
Sentinel /* this must be last for serialization purposes. */
166
};
167
168
enum class ImageRendering : uint8_t {
169
Auto = 0,
170
CrispEdges = 1,
171
Pixelated = 2,
172
173
Sentinel /* this must be last for serialization purposes. */
174
};
175
176
enum class LineOrientation : uint8_t {
177
Vertical,
178
Horizontal,
179
180
Sentinel /* this must be last for serialization purposes. */
181
};
182
183
enum class LineStyle : uint8_t {
184
Solid,
185
Dotted,
186
Dashed,
187
Wavy,
188
189
Sentinel /* this must be last for serialization purposes. */
190
};
191
192
enum class MixBlendMode : uint8_t {
193
Normal = 0,
194
Multiply = 1,
195
Screen = 2,
196
Overlay = 3,
197
Darken = 4,
198
Lighten = 5,
199
ColorDodge = 6,
200
ColorBurn = 7,
201
HardLight = 8,
202
SoftLight = 9,
203
Difference = 10,
204
Exclusion = 11,
205
Hue = 12,
206
Saturation = 13,
207
Color = 14,
208
Luminosity = 15,
209
210
Sentinel /* this must be last for serialization purposes. */
211
};
212
213
/// Used to indicate if an image is opaque, or has an alpha channel.
214
enum class OpacityType : uint8_t {
215
Opaque = 0,
216
HasAlphaChannel = 1,
217
218
Sentinel /* this must be last for serialization purposes. */
219
};
220
221
enum class RepeatMode : uint8_t {
222
Stretch,
223
Repeat,
224
Round,
225
Space,
226
227
Sentinel /* this must be last for serialization purposes. */
228
};
229
230
enum class TelemetryProbe {
231
SceneBuildTime = 0,
232
SceneSwapTime = 1,
233
FrameBuildTime = 2,
234
235
Sentinel /* this must be last for serialization purposes. */
236
};
237
238
/// Specifies the type of texture target in driver terms.
239
enum class TextureTarget : uint8_t {
240
/// Standard texture. This maps to GL_TEXTURE_2D in OpenGL.
241
Default = 0,
242
/// Array texture. This maps to GL_TEXTURE_2D_ARRAY in OpenGL. See
244
/// on Array textures.
245
Array = 1,
246
/// Rectangle texture. This maps to GL_TEXTURE_RECTANGLE in OpenGL. This
247
/// is similar to a standard texture, with a few subtle differences
248
/// (no mipmaps, non-power-of-two dimensions, different coordinate space)
249
/// that make it useful for representing the kinds of textures we use
251
/// for background on Rectangle textures.
252
Rect = 2,
253
/// External texture. This maps to GL_TEXTURE_EXTERNAL_OES in OpenGL, which
254
/// is an extension. This is used for image formats that OpenGL doesn't
255
/// understand, particularly YUV. See
257
External = 3,
258
259
Sentinel /* this must be last for serialization purposes. */
260
};
261
262
enum class TransformStyle : uint8_t {
263
Flat = 0,
264
Preserve3D = 1,
265
266
Sentinel /* this must be last for serialization purposes. */
267
};
268
269
enum class WrAnimationType : uint32_t {
270
Transform = 0,
271
Opacity = 1,
272
273
Sentinel /* this must be last for serialization purposes. */
274
};
275
276
enum class WrExternalImageType : uint32_t {
277
RawData,
278
NativeTexture,
279
Invalid,
280
281
Sentinel /* this must be last for serialization purposes. */
282
};
283
284
enum class WrReferenceFrameKind : uint8_t {
285
Transform,
286
Perspective,
287
288
Sentinel /* this must be last for serialization purposes. */
289
};
290
291
enum class YuvColorSpace : uint8_t {
292
Rec601 = 0,
293
Rec709 = 1,
294
Rec2020 = 2,
295
296
Sentinel /* this must be last for serialization purposes. */
297
};
298
299
template<typename T>
300
struct Arc;
301
302
/// Features of the batch that, if not requested, may allow a fast-path.
303
///
304
/// Rather than breaking batches when primitives request different features,
305
/// we always request the minimum amount of features to satisfy all items in
306
/// the batch.
307
/// The goal is to let the renderer be optionally select more specialized
308
/// versions of a shader if the batch doesn't require code certain code paths.
309
/// Not all shaders necessarily implement all of these features.
310
struct BatchFeatures;
311
312
/// A set of flags describing why a picture may need a backing surface.
313
struct BlitReason;
314
315
/// Flags that define how the common brush shader
316
/// code should process this instance.
317
struct BrushFlags;
318
319
/// Bit flags for WR stages to store in a capture.
320
struct CaptureBits;
321
322
/// Mask for clearing caches in debug commands.
323
struct ClearCache;
324
325
struct ClipNodeFlags;
326
327
/// A set of flags describing why a picture may need a backing surface.
328
struct ClusterFlags;
329
330
struct Device;
331
332
/// Geometry in the coordinate system of the render target (screen or intermediate
333
/// surface) in physical pixels.
334
struct DevicePixel;
335
336
struct DocumentHandle;
337
338
/// Each bit of the edge AA mask is:
339
/// 0, when the edge of the primitive needs to be considered for AA
340
/// 1, when the edge of the segment needs to be considered for AA
341
///
342
/// *Note*: the bit values have to match the shader logic in
343
/// `write_transform_vertex()` function.
344
struct EdgeAaSegmentMask;
345
346
struct HitTestFlags;
347
348
struct ItemFlags;
349
350
/// Geometry in a stacking context's local coordinate space (logical pixels).
351
struct LayoutPixel;
352
353
/// The renderer is responsible for submitting to the GPU the work prepared by the
354
/// RenderBackend.
355
///
356
/// We have a separate `Renderer` instance for each instance of WebRender (generally
357
/// one per OS window), and all instances share the same thread.
358
struct Renderer;
359
360
/// Flags that control how shaders are pre-cached, if at all.
361
struct ShaderPrecacheFlags;
362
363
struct TextureFlags;
364
365
/// Unit for tile coordinates.
366
struct TileCoordinate;
367
368
/// Represents the work associated to a transaction before scene building.
369
struct Transaction;
370
371
template<typename T>
372
struct Vec;
373
374
/// Geometry in the document's coordinate space (logical pixels).
375
struct WorldPixel;
376
377
struct WrProgramCache;
378
379
struct WrShaders;
380
381
struct WrState;
382
383
struct WrThreadPool;
384
385
struct IdNamespace {
386
uint32_t mHandle;
387
388
bool operator==(const IdNamespace& aOther) const {
389
return mHandle == aOther.mHandle;
390
}
391
bool operator!=(const IdNamespace& aOther) const {
392
return mHandle != aOther.mHandle;
393
}
394
bool operator<(const IdNamespace& aOther) const {
395
return mHandle < aOther.mHandle;
396
}
397
bool operator<=(const IdNamespace& aOther) const {
398
return mHandle <= aOther.mHandle;
399
}
400
};
401
402
struct FontInstanceKey {
403
IdNamespace mNamespace;
404
uint32_t mHandle;
405
406
bool operator==(const FontInstanceKey& aOther) const {
407
return mNamespace == aOther.mNamespace &&
408
mHandle == aOther.mHandle;
409
}
410
};
411
412
using WrFontInstanceKey = FontInstanceKey;
413
414
struct FontKey {
415
IdNamespace mNamespace;
416
uint32_t mHandle;
417
418
bool operator==(const FontKey& aOther) const {
419
return mNamespace == aOther.mNamespace &&
420
mHandle == aOther.mHandle;
421
}
422
};
423
424
using WrFontKey = FontKey;
425
426
struct FontInstanceFlags {
427
uint32_t bits;
428
429
explicit operator bool() const {
430
return !!bits;
431
}
432
FontInstanceFlags operator|(const FontInstanceFlags& aOther) const {
433
return {static_cast<decltype(bits)>(this->bits | aOther.bits)};
434
}
435
FontInstanceFlags& operator|=(const FontInstanceFlags& aOther) {
436
*this = (*this | aOther);
437
return *this;
438
}
439
FontInstanceFlags operator&(const FontInstanceFlags& aOther) const {
440
return {static_cast<decltype(bits)>(this->bits & aOther.bits)};
441
}
442
FontInstanceFlags& operator&=(const FontInstanceFlags& aOther) {
443
*this = (*this & aOther);
444
return *this;
445
}
446
bool operator==(const FontInstanceFlags& aOther) const {
447
return bits == aOther.bits;
448
}
449
};
450
static const FontInstanceFlags FontInstanceFlags_SYNTHETIC_BOLD = (FontInstanceFlags){ .bits = 1 << 1 };
451
static const FontInstanceFlags FontInstanceFlags_EMBEDDED_BITMAPS = (FontInstanceFlags){ .bits = 1 << 2 };
452
static const FontInstanceFlags FontInstanceFlags_SUBPIXEL_BGR = (FontInstanceFlags){ .bits = 1 << 3 };
453
static const FontInstanceFlags FontInstanceFlags_TRANSPOSE = (FontInstanceFlags){ .bits = 1 << 4 };
454
static const FontInstanceFlags FontInstanceFlags_FLIP_X = (FontInstanceFlags){ .bits = 1 << 5 };
455
static const FontInstanceFlags FontInstanceFlags_FLIP_Y = (FontInstanceFlags){ .bits = 1 << 6 };
456
static const FontInstanceFlags FontInstanceFlags_SUBPIXEL_POSITION = (FontInstanceFlags){ .bits = 1 << 7 };
457
static const FontInstanceFlags FontInstanceFlags_FORCE_GDI = (FontInstanceFlags){ .bits = 1 << 16 };
458
static const FontInstanceFlags FontInstanceFlags_FORCE_SYMMETRIC = (FontInstanceFlags){ .bits = 1 << 17 };
459
static const FontInstanceFlags FontInstanceFlags_NO_SYMMETRIC = (FontInstanceFlags){ .bits = 1 << 18 };
460
static const FontInstanceFlags FontInstanceFlags_FONT_SMOOTHING = (FontInstanceFlags){ .bits = 1 << 16 };
461
static const FontInstanceFlags FontInstanceFlags_FORCE_AUTOHINT = (FontInstanceFlags){ .bits = 1 << 16 };
462
static const FontInstanceFlags FontInstanceFlags_NO_AUTOHINT = (FontInstanceFlags){ .bits = 1 << 17 };
463
static const FontInstanceFlags FontInstanceFlags_VERTICAL_LAYOUT = (FontInstanceFlags){ .bits = 1 << 18 };
464
static const FontInstanceFlags FontInstanceFlags_LCD_VERTICAL = (FontInstanceFlags){ .bits = 1 << 19 };
465
466
/// Represents RGBA screen colors with one byte per channel.
467
///
468
/// If the alpha value `a` is 255 the color is opaque.
469
struct ColorU {
470
uint8_t r;
471
uint8_t g;
472
uint8_t b;
473
uint8_t a;
474
475
bool operator==(const ColorU& aOther) const {
476
return r == aOther.r &&
477
g == aOther.g &&
478
b == aOther.b &&
479
a == aOther.a;
480
}
481
};
482
483
struct SyntheticItalics {
484
int16_t angle;
485
486
bool operator==(const SyntheticItalics& aOther) const {
487
return angle == aOther.angle;
488
}
489
};
490
static const float SyntheticItalics_ANGLE_SCALE = 256.0;
491
492
struct FontInstanceOptions {
493
FontRenderMode render_mode;
494
FontInstanceFlags flags;
495
/// When bg_color.a is != 0 and render_mode is FontRenderMode::Subpixel,
496
/// the text will be rendered with bg_color.r/g/b as an opaque estimated
497
/// background color.
498
ColorU bg_color;
499
SyntheticItalics synthetic_italics;
500
501
bool operator==(const FontInstanceOptions& aOther) const {
502
return render_mode == aOther.render_mode &&
503
flags == aOther.flags &&
504
bg_color == aOther.bg_color &&
505
synthetic_italics == aOther.synthetic_italics;
506
}
507
};
508
509
#if defined(XP_WIN)
510
struct FontInstancePlatformOptions {
511
uint16_t gamma;
512
uint16_t contrast;
513
514
bool operator==(const FontInstancePlatformOptions& aOther) const {
515
return gamma == aOther.gamma &&
516
contrast == aOther.contrast;
517
}
518
};
519
#endif
520
521
#if defined(XP_MACOSX)
522
struct FontInstancePlatformOptions {
523
uint32_t unused;
524
525
bool operator==(const FontInstancePlatformOptions& aOther) const {
526
return unused == aOther.unused;
527
}
528
};
529
#endif
530
531
#if !(defined(XP_MACOSX) || defined(XP_WIN))
532
struct FontInstancePlatformOptions {
533
FontLCDFilter lcd_filter;
534
FontHinting hinting;
535
536
bool operator==(const FontInstancePlatformOptions& aOther) const {
537
return lcd_filter == aOther.lcd_filter &&
538
hinting == aOther.hinting;
539
}
540
};
541
#endif
542
543
struct FontVariation {
544
uint32_t tag;
545
float value;
546
547
bool operator==(const FontVariation& aOther) const {
548
return tag == aOther.tag &&
549
value == aOther.value;
550
}
551
};
552
553
using VecU8 = Vec<uint8_t>;
554
555
using ArcVecU8 = Arc<VecU8>;
556
557
using WrIdNamespace = IdNamespace;
558
559
struct WrWindowId {
560
uint64_t mHandle;
561
562
bool operator==(const WrWindowId& aOther) const {
563
return mHandle == aOther.mHandle;
564
}
565
bool operator<(const WrWindowId& aOther) const {
566
return mHandle < aOther.mHandle;
567
}
568
bool operator<=(const WrWindowId& aOther) const {
569
return mHandle <= aOther.mHandle;
570
}
571
};
572
573
/// This type carries no valuable semantics for WR. However, it reflects the fact that
574
/// clients (Servo) may generate pipelines by different semi-independent sources.
575
/// These pipelines still belong to the same `IdNamespace` and the same `DocumentId`.
576
/// Having this extra Id field enables them to generate `PipelineId` without collision.
577
using PipelineSourceId = uint32_t;
578
579
/// From the point of view of WR, `PipelineId` is completely opaque and generic as long as
580
/// it's clonable, serializable, comparable, and hashable.
581
struct PipelineId {
582
PipelineSourceId mNamespace;
583
uint32_t mHandle;
584
585
bool operator==(const PipelineId& aOther) const {
586
return mNamespace == aOther.mNamespace &&
587
mHandle == aOther.mHandle;
588
}
589
};
590
591
using WrPipelineId = PipelineId;
592
593
struct DocumentId {
594
IdNamespace mNamespace;
595
uint32_t mHandle;
596
597
bool operator==(const DocumentId& aOther) const {
598
return mNamespace == aOther.mNamespace &&
599
mHandle == aOther.mHandle;
600
}
601
};
602
603
using WrDocumentId = DocumentId;
604
605
struct Epoch {
606
uint32_t mHandle;
607
608
bool operator==(const Epoch& aOther) const {
609
return mHandle == aOther.mHandle;
610
}
611
bool operator!=(const Epoch& aOther) const {
612
return mHandle != aOther.mHandle;
613
}
614
bool operator<(const Epoch& aOther) const {
615
return mHandle < aOther.mHandle;
616
}
617
bool operator<=(const Epoch& aOther) const {
618
return mHandle <= aOther.mHandle;
619
}
620
};
621
622
using WrEpoch = Epoch;
623
624
struct WrPipelineEpoch {
625
WrPipelineId pipeline_id;
626
WrDocumentId document_id;
627
WrEpoch epoch;
628
629
bool operator==(const WrPipelineEpoch& aOther) const {
630
return pipeline_id == aOther.pipeline_id &&
631
document_id == aOther.document_id &&
632
epoch == aOther.epoch;
633
}
634
};
635
636
template<typename T>
637
struct FfiVec {
638
const T *data;
639
uintptr_t length;
640
uintptr_t capacity;
641
642
bool operator==(const FfiVec& aOther) const {
643
return data == aOther.data &&
644
length == aOther.length &&
645
capacity == aOther.capacity;
646
}
647
};
648
649
struct WrRemovedPipeline {
650
WrPipelineId pipeline_id;
651
WrDocumentId document_id;
652
653
bool operator==(const WrRemovedPipeline& aOther) const {
654
return pipeline_id == aOther.pipeline_id &&
655
document_id == aOther.document_id;
656
}
657
};
658
659
struct WrPipelineInfo {
660
FfiVec<WrPipelineEpoch> epochs;
661
FfiVec<WrRemovedPipeline> removed_pipelines;
662
663
bool operator==(const WrPipelineInfo& aOther) const {
664
return epochs == aOther.epochs &&
665
removed_pipelines == aOther.removed_pipelines;
666
}
667
};
668
669
/// Memory report for interning-related data structures.
670
struct InterningMemoryReport {
671
InternerSubReport interners;
672
InternerSubReport data_stores;
673
};
674
675
/// Collection of heap sizes, in bytes.
676
struct MemoryReport {
677
uintptr_t clip_stores;
678
uintptr_t gpu_cache_metadata;
679
uintptr_t gpu_cache_cpu_mirror;
680
uintptr_t render_tasks;
681
uintptr_t hit_testers;
682
uintptr_t fonts;
683
uintptr_t images;
684
uintptr_t rasterized_blobs;
685
uintptr_t shader_cache;
686
InterningMemoryReport interning;
687
uintptr_t gpu_cache_textures;
688
uintptr_t vertex_data_textures;
689
uintptr_t render_target_textures;
690
uintptr_t texture_cache_textures;
691
uintptr_t depth_target_textures;
692
uintptr_t swap_chain;
693
};
694
695
/// A 2d size tagged with a unit.
696
template<typename T, typename U>
697
struct Size2D {
698
T width;
699
T height;
700
701
bool operator==(const Size2D& aOther) const {
702
return width == aOther.width &&
703
height == aOther.height;
704
}
705
};
706
707
using DeviceIntSize = Size2D<int32_t, DevicePixel>;
708
709
using LayoutSize = Size2D<float, LayoutPixel>;
710
711
/// Describes the memory layout of a display list.
712
///
713
/// A display list consists of some number of display list items, followed by a number of display
714
/// items.
715
struct BuiltDisplayListDescriptor {
716
/// The first IPC time stamp: before any work has been done
717
uint64_t builder_start_time;
718
/// The second IPC time stamp: after serialization
719
uint64_t builder_finish_time;
720
/// The third IPC time stamp: just before sending
721
uint64_t send_start_time;
722
/// The amount of clipping nodes created while building this display list.
723
uintptr_t total_clip_nodes;
724
/// The amount of spatial nodes created while building this display list.
725
uintptr_t total_spatial_nodes;
726
727
bool operator==(const BuiltDisplayListDescriptor& aOther) const {
728
return builder_start_time == aOther.builder_start_time &&
729
builder_finish_time == aOther.builder_finish_time &&
730
send_start_time == aOther.send_start_time &&
731
total_clip_nodes == aOther.total_clip_nodes &&
732
total_spatial_nodes == aOther.total_spatial_nodes;
733
}
734
};
735
736
struct WrVecU8 {
737
uint8_t *data;
738
uintptr_t length;
739
uintptr_t capacity;
740
741
bool operator==(const WrVecU8& aOther) const {
742
return data == aOther.data &&
743
length == aOther.length &&
744
capacity == aOther.capacity;
745
}
746
};
747
748
/// A 2d Point tagged with a unit.
749
template<typename T, typename U>
750
struct Point2D {
751
T x;
752
T y;
753
754
bool operator==(const Point2D& aOther) const {
755
return x == aOther.x &&
756
y == aOther.y;
757
}
758
};
759
760
using WorldPoint = Point2D<float, WorldPixel>;
761
762
struct DebugFlags {
763
uint32_t bits;
764
765
explicit operator bool() const {
766
return !!bits;
767
}
768
DebugFlags operator|(const DebugFlags& aOther) const {
769
return {static_cast<decltype(bits)>(this->bits | aOther.bits)};
770
}
771
DebugFlags& operator|=(const DebugFlags& aOther) {
772
*this = (*this | aOther);
773
return *this;
774
}
775
DebugFlags operator&(const DebugFlags& aOther) const {
776
return {static_cast<decltype(bits)>(this->bits & aOther.bits)};
777
}
778
DebugFlags& operator&=(const DebugFlags& aOther) {
779
*this = (*this & aOther);
780
return *this;
781
}
782
bool operator==(const DebugFlags& aOther) const {
783
return bits == aOther.bits;
784
}
785
};
786
static const DebugFlags DebugFlags_PROFILER_DBG = (DebugFlags){ .bits = 1 << 0 };
787
static const DebugFlags DebugFlags_RENDER_TARGET_DBG = (DebugFlags){ .bits = 1 << 1 };
788
static const DebugFlags DebugFlags_TEXTURE_CACHE_DBG = (DebugFlags){ .bits = 1 << 2 };
789
static const DebugFlags DebugFlags_GPU_TIME_QUERIES = (DebugFlags){ .bits = 1 << 3 };
790
static const DebugFlags DebugFlags_GPU_SAMPLE_QUERIES = (DebugFlags){ .bits = 1 << 4 };
791
static const DebugFlags DebugFlags_DISABLE_BATCHING = (DebugFlags){ .bits = 1 << 5 };
792
static const DebugFlags DebugFlags_EPOCHS = (DebugFlags){ .bits = 1 << 6 };
793
static const DebugFlags DebugFlags_COMPACT_PROFILER = (DebugFlags){ .bits = 1 << 7 };
794
static const DebugFlags DebugFlags_ECHO_DRIVER_MESSAGES = (DebugFlags){ .bits = 1 << 8 };
795
static const DebugFlags DebugFlags_NEW_FRAME_INDICATOR = (DebugFlags){ .bits = 1 << 9 };
796
static const DebugFlags DebugFlags_NEW_SCENE_INDICATOR = (DebugFlags){ .bits = 1 << 10 };
797
static const DebugFlags DebugFlags_SHOW_OVERDRAW = (DebugFlags){ .bits = 1 << 11 };
798
static const DebugFlags DebugFlags_GPU_CACHE_DBG = (DebugFlags){ .bits = 1 << 12 };
799
static const DebugFlags DebugFlags_SLOW_FRAME_INDICATOR = (DebugFlags){ .bits = 1 << 13 };
800
static const DebugFlags DebugFlags_TEXTURE_CACHE_DBG_CLEAR_EVICTED = (DebugFlags){ .bits = 1 << 14 };
801
static const DebugFlags DebugFlags_PICTURE_CACHING_DBG = (DebugFlags){ .bits = 1 << 15 };
802
static const DebugFlags DebugFlags_PRIMITIVE_DBG = (DebugFlags){ .bits = 1 << 16 };
803
static const DebugFlags DebugFlags_ZOOM_DBG = (DebugFlags){ .bits = 1 << 17 };
804
static const DebugFlags DebugFlags_SMALL_SCREEN = (DebugFlags){ .bits = 1 << 18 };
805
static const DebugFlags DebugFlags_DISABLE_OPAQUE_PASS = (DebugFlags){ .bits = 1 << 19 };
806
static const DebugFlags DebugFlags_DISABLE_ALPHA_PASS = (DebugFlags){ .bits = 1 << 20 };
807
static const DebugFlags DebugFlags_DISABLE_CLIP_MASKS = (DebugFlags){ .bits = 1 << 21 };
808
static const DebugFlags DebugFlags_DISABLE_TEXT_PRIMS = (DebugFlags){ .bits = 1 << 22 };
809
static const DebugFlags DebugFlags_DISABLE_GRADIENT_PRIMS = (DebugFlags){ .bits = 1 << 23 };
810
static const DebugFlags DebugFlags_OBSCURE_IMAGES = (DebugFlags){ .bits = 1 << 24 };
811
static const DebugFlags DebugFlags_SMART_PROFILER = (DebugFlags){ .bits = 1 << 26 };
812
813
struct WrClipId {
814
uintptr_t id;
815
816
bool operator==(const WrClipId& aOther) const {
817
return id == aOther.id;
818
}
819
};
820
821
struct WrSpatialId {
822
uintptr_t id;
823
824
bool operator==(const WrSpatialId& aOther) const {
825
return id == aOther.id;
826
}
827
};
828
829
struct WrSpaceAndClip {
830
WrSpatialId space;
831
WrClipId clip;
832
833
bool operator==(const WrSpaceAndClip& aOther) const {
834
return space == aOther.space &&
835
clip == aOther.clip;
836
}
837
};
838
839
/// A 2d Rectangle optionally tagged with a unit.
840
template<typename T, typename U>
841
struct Rect {
842
Point2D<T, U> origin;
843
Size2D<T, U> size;
844
845
bool operator==(const Rect& aOther) const {
846
return origin == aOther.origin &&
847
size == aOther.size;
848
}
849
};
850
851
using LayoutRect = Rect<float, LayoutPixel>;
852
853
struct BorderRadius {
854
LayoutSize top_left;
855
LayoutSize top_right;
856
LayoutSize bottom_left;
857
LayoutSize bottom_right;
858
859
bool operator==(const BorderRadius& aOther) const {
860
return top_left == aOther.top_left &&
861
top_right == aOther.top_right &&
862
bottom_left == aOther.bottom_left &&
863
bottom_right == aOther.bottom_right;
864
}
865
};
866
867
struct ComplexClipRegion {
868
/// The boundaries of the rectangle.
869
LayoutRect rect;
870
/// Border radii of this rectangle.
871
BorderRadius radii;
872
/// Whether we are clipping inside or outside
873
/// the region.
874
ClipMode mode;
875
876
bool operator==(const ComplexClipRegion& aOther) const {
877
return rect == aOther.rect &&
878
radii == aOther.radii &&
879
mode == aOther.mode;
880
}
881
};
882
883
/// An opaque identifier describing an image registered with WebRender.
884
/// This is used as a handle to reference images, and is used as the
885
/// hash map key for the actual image storage in the `ResourceCache`.
886
struct ImageKey {
887
IdNamespace mNamespace;
888
uint32_t mHandle;
889
890
bool operator==(const ImageKey& aOther) const {
891
return mNamespace == aOther.mNamespace &&
892
mHandle == aOther.mHandle;
893
}
894
bool operator!=(const ImageKey& aOther) const {
895
return mNamespace != aOther.mNamespace ||
896
mHandle != aOther.mHandle;
897
}
898
};
899
900
struct ImageMask {
901
ImageKey image;
902
LayoutRect rect;
903
bool repeat;
904
905
bool operator==(const ImageMask& aOther) const {
906
return image == aOther.image &&
907
rect == aOther.rect &&
908
repeat == aOther.repeat;
909
}
910
};
911
912
struct WrSpaceAndClipChain {
913
WrSpatialId space;
914
uint64_t clip_chain;
915
916
bool operator==(const WrSpaceAndClipChain& aOther) const {
917
return space == aOther.space &&
918
clip_chain == aOther.clip_chain;
919
}
920
};
921
922
using LayoutPoint = Point2D<float, LayoutPixel>;
923
924
/// The minimum and maximum allowable offset for a sticky frame in a single dimension.
925
struct StickyOffsetBounds {
926
/// The minimum offset for this frame, typically a negative value, which specifies how
927
/// far in the negative direction the sticky frame can offset its contents in this
928
/// dimension.
929
float min;
930
/// The maximum offset for this frame, typically a positive value, which specifies how
931
/// far in the positive direction the sticky frame can offset its contents in this
932
/// dimension.
933
float max;
934
935
bool operator==(const StickyOffsetBounds& aOther) const {
936
return min == aOther.min &&
937
max == aOther.max;
938
}
939
};
940
941
/// A 2d Vector tagged with a unit.
942
template<typename T, typename U>
943
struct Vector2D {
944
T x;
945
T y;
946
947
bool operator==(const Vector2D& aOther) const {
948
return x == aOther.x &&
949
y == aOther.y;
950
}
951
};
952
953
using LayoutVector2D = Vector2D<float, LayoutPixel>;
954
955
struct PropertyBindingId {
956
IdNamespace namespace_;
957
uint32_t uid;
958
959
bool operator==(const PropertyBindingId& aOther) const {
960
return namespace_ == aOther.namespace_ &&
961
uid == aOther.uid;
962
}
963
};
964
965
/// A unique key that is used for connecting animated property
966
/// values to bindings in the display list.
967
template<typename T>
968
struct PropertyBindingKey {
969
PropertyBindingId id;
970
971
bool operator==(const PropertyBindingKey& aOther) const {
972
return id == aOther.id;
973
}
974
};
975
976
/// A binding property can either be a specific value
977
/// (the normal, non-animated case) or point to a binding location
978
/// to fetch the current value from.
979
/// Note that Binding has also a non-animated value, the value is
980
/// used for the case where the animation is still in-delay phase
981
/// (i.e. the animation doesn't produce any animation values).
982
template<typename T>
983
struct PropertyBinding {
984
enum class Tag {
985
Value,
986
Binding,
987
988
Sentinel /* this must be last for serialization purposes. */
989
};
990
991
struct Value_Body {
992
T _0;
993
994
bool operator==(const Value_Body& aOther) const {
995
return _0 == aOther._0;
996
}
997
};
998
999
struct Binding_Body {
1000
PropertyBindingKey<T> _0;
1001
T _1;
1002
1003
bool operator==(const Binding_Body& aOther) const {
1004
return _0 == aOther._0 &&
1005
_1 == aOther._1;
1006
}
1007
};
1008
1009
Tag tag;
1010
union {
1011
Value_Body value;
1012
Binding_Body binding;
1013
};
1014
1015
static PropertyBinding Value(const T &a0) {
1016
PropertyBinding result;
1017
::new (&result.value._0) (T)(a0);
1018
result.tag = Tag::Value;
1019
return result;
1020
}
1021
1022
static PropertyBinding Binding(const PropertyBindingKey<T> &a0,
1023
const T &a1) {
1024
PropertyBinding result;
1025
::new (&result.binding._0) (PropertyBindingKey<T>)(a0);
1026
::new (&result.binding._1) (T)(a1);
1027
result.tag = Tag::Binding;
1028
return result;
1029
}
1030
1031
bool IsValue() const {
1032
return tag == Tag::Value;
1033
}
1034
1035
bool IsBinding() const {
1036
return tag == Tag::Binding;
1037
}
1038
1039
bool operator==(const PropertyBinding& aOther) const {
1040
if (tag != aOther.tag) {
1041
return false;
1042
}
1043
switch (tag) {
1044
case Tag::Value: return value == aOther.value;
1045
case Tag::Binding: return binding == aOther.binding;
1046
default: return true;
1047
}
1048
}
1049
};
1050
1051
/// Represents RGBA screen colors with floating point numbers.
1052
///
1053
/// All components must be between 0.0 and 1.0.
1054
/// An alpha value of 1.0 is opaque while 0.0 is fully transparent.
1055
struct ColorF {
1056
float r;
1057
float g;
1058
float b;
1059
float a;
1060
1061
bool operator==(const ColorF& aOther) const {
1062
return r == aOther.r &&
1063
g == aOther.g &&
1064
b == aOther.b &&
1065
a == aOther.a;
1066
}
1067
};
1068
static const ColorF ColorF_BLACK = (ColorF){ .r = 0.0, .g = 0.0, .b = 0.0, .a = 1.0 };
1069
static const ColorF ColorF_TRANSPARENT = (ColorF){ .r = 0.0, .g = 0.0, .b = 0.0, .a = 0.0 };
1070
static const ColorF ColorF_WHITE = (ColorF){ .r = 1.0, .g = 1.0, .b = 1.0, .a = 1.0 };
1071
1072
struct Shadow {
1073
LayoutVector2D offset;
1074
ColorF color;
1075
float blur_radius;
1076
1077
bool operator==(const Shadow& aOther) const {
1078
return offset == aOther.offset &&
1079
color == aOther.color &&
1080
blur_radius == aOther.blur_radius;
1081
}
1082
};
1083
1084
/// CSS filter.
1085
struct FilterOp {
1086
enum class Tag {
1087
/// Filter that does no transformation of the colors, needed for
1088
/// debug purposes only.
1089
Identity,
1090
Blur,
1091
Brightness,
1092
Contrast,
1093
Grayscale,
1094
HueRotate,
1095
Invert,
1096
Opacity,
1097
Saturate,
1098
Sepia,
1099
DropShadow,
1100
ColorMatrix,
1101
SrgbToLinear,
1102
LinearToSrgb,
1103
ComponentTransfer,
1104
Flood,
1105
1106
Sentinel /* this must be last for serialization purposes. */
1107
};
1108
1109
struct Blur_Body {
1110
float _0;
1111
1112
bool operator==(const Blur_Body& aOther) const {
1113
return _0 == aOther._0;
1114
}
1115
};
1116
1117
struct Brightness_Body {
1118
float _0;
1119
1120
bool operator==(const Brightness_Body& aOther) const {
1121
return _0 == aOther._0;
1122
}
1123
};
1124
1125
struct Contrast_Body {
1126
float _0;
1127
1128
bool operator==(const Contrast_Body& aOther) const {
1129
return _0 == aOther._0;
1130
}
1131
};
1132
1133
struct Grayscale_Body {
1134
float _0;
1135
1136
bool operator==(const Grayscale_Body& aOther) const {
1137
return _0 == aOther._0;
1138
}
1139
};
1140
1141
struct HueRotate_Body {
1142
float _0;
1143
1144
bool operator==(const HueRotate_Body& aOther) const {
1145
return _0 == aOther._0;
1146
}
1147
};
1148
1149
struct Invert_Body {
1150
float _0;
1151
1152
bool operator==(const Invert_Body& aOther) const {
1153
return _0 == aOther._0;
1154
}
1155
};
1156
1157
struct Opacity_Body {
1158
PropertyBinding<float> _0;
1159
float _1;
1160
1161
bool operator==(const Opacity_Body& aOther) const {
1162
return _0 == aOther._0 &&
1163
_1 == aOther._1;
1164
}
1165
};
1166
1167
struct Saturate_Body {
1168
float _0;
1169
1170
bool operator==(const Saturate_Body& aOther) const {
1171
return _0 == aOther._0;
1172
}
1173
};
1174
1175
struct Sepia_Body {
1176
float _0;
1177
1178
bool operator==(const Sepia_Body& aOther) const {
1179
return _0 == aOther._0;
1180
}
1181
};
1182
1183
struct DropShadow_Body {
1184
Shadow _0;
1185
1186
bool operator==(const DropShadow_Body& aOther) const {
1187
return _0 == aOther._0;
1188
}
1189
};
1190
1191
struct ColorMatrix_Body {
1192
float _0[20];
1193
};
1194
1195
struct Flood_Body {
1196
ColorF _0;
1197
1198
bool operator==(const Flood_Body& aOther) const {
1199
return _0 == aOther._0;
1200
}
1201
};
1202
1203
Tag tag;
1204
union {
1205
Blur_Body blur;
1206
Brightness_Body brightness;
1207
Contrast_Body contrast;
1208
Grayscale_Body grayscale;
1209
HueRotate_Body hue_rotate;
1210
Invert_Body invert;
1211
Opacity_Body opacity;
1212
Saturate_Body saturate;
1213
Sepia_Body sepia;
1214
DropShadow_Body drop_shadow;
1215
ColorMatrix_Body color_matrix;
1216
Flood_Body flood;
1217
};
1218
1219
static FilterOp Identity() {
1220
FilterOp result;
1221
result.tag = Tag::Identity;
1222
return result;
1223
}
1224
1225
static FilterOp Blur(const float &a0) {
1226
FilterOp result;
1227
::new (&result.blur._0) (float)(a0);
1228
result.tag = Tag::Blur;
1229
return result;
1230
}
1231
1232
static FilterOp Brightness(const float &a0) {
1233
FilterOp result;
1234
::new (&result.brightness._0) (float)(a0);
1235
result.tag = Tag::Brightness;
1236
return result;
1237
}
1238
1239
static FilterOp Contrast(const float &a0) {
1240
FilterOp result;
1241
::new (&result.contrast._0) (float)(a0);
1242
result.tag = Tag::Contrast;
1243
return result;
1244
}
1245
1246
static FilterOp Grayscale(const float &a0) {
1247
FilterOp result;
1248
::new (&result.grayscale._0) (float)(a0);
1249
result.tag = Tag::Grayscale;
1250
return result;
1251
}
1252
1253
static FilterOp HueRotate(const float &a0) {
1254
FilterOp result;
1255
::new (&result.hue_rotate._0) (float)(a0);
1256
result.tag = Tag::HueRotate;
1257
return result;
1258
}
1259
1260
static FilterOp Invert(const float &a0) {
1261
FilterOp result;
1262
::new (&result.invert._0) (float)(a0);
1263
result.tag = Tag::Invert;
1264
return result;
1265
}
1266
1267
static FilterOp Opacity(const PropertyBinding<float> &a0,
1268
const float &a1) {
1269
FilterOp result;
1270
::new (&result.opacity._0) (PropertyBinding<float>)(a0);
1271
::new (&result.opacity._1) (float)(a1);
1272
result.tag = Tag::Opacity;
1273
return result;
1274
}
1275
1276
static FilterOp Saturate(const float &a0) {
1277
FilterOp result;
1278
::new (&result.saturate._0) (float)(a0);
1279
result.tag = Tag::Saturate;
1280
return result;
1281
}
1282
1283
static FilterOp Sepia(const float &a0) {
1284
FilterOp result;
1285
::new (&result.sepia._0) (float)(a0);
1286
result.tag = Tag::Sepia;
1287
return result;
1288
}
1289
1290
static FilterOp DropShadow(const Shadow &a0) {
1291
FilterOp result;
1292
::new (&result.drop_shadow._0) (Shadow)(a0);
1293
result.tag = Tag::DropShadow;
1294
return result;
1295
}
1296
1297
static FilterOp ColorMatrix(const float (&a0)[20]) {
1298
FilterOp result;
1299
for (int i = 0; i < 20; i++) {
1300
::new (&result.color_matrix._0[i]) (float)(a0[i]);
1301
}
1302
result.tag = Tag::ColorMatrix;
1303
return result;
1304
}
1305
1306
static FilterOp SrgbToLinear() {
1307
FilterOp result;
1308
result.tag = Tag::SrgbToLinear;
1309
return result;
1310
}
1311
1312
static FilterOp LinearToSrgb() {
1313
FilterOp result;
1314
result.tag = Tag::LinearToSrgb;
1315
return result;
1316
}
1317
1318
static FilterOp ComponentTransfer() {
1319
FilterOp result;
1320
result.tag = Tag::ComponentTransfer;
1321
return result;
1322
}
1323
1324
static FilterOp Flood(const ColorF &a0) {
1325
FilterOp result;
1326
::new (&result.flood._0) (ColorF)(a0);
1327
result.tag = Tag::Flood;
1328
return result;
1329
}
1330
1331
bool IsIdentity() const {
1332
return tag == Tag::Identity;
1333
}
1334
1335
bool IsBlur() const {
1336
return tag == Tag::Blur;
1337
}
1338
1339
bool IsBrightness() const {
1340
return tag == Tag::Brightness;
1341
}
1342
1343
bool IsContrast() const {
1344
return tag == Tag::Contrast;
1345
}
1346
1347
bool IsGrayscale() const {
1348
return tag == Tag::Grayscale;
1349
}
1350
1351
bool IsHueRotate() const {
1352
return tag == Tag::HueRotate;
1353
}
1354
1355
bool IsInvert() const {
1356
return tag == Tag::Invert;
1357
}
1358
1359
bool IsOpacity() const {
1360
return tag == Tag::Opacity;
1361
}
1362
1363
bool IsSaturate() const {
1364
return tag == Tag::Saturate;
1365
}
1366
1367
bool IsSepia() const {
1368
return tag == Tag::Sepia;
1369
}
1370
1371
bool IsDropShadow() const {
1372
return tag == Tag::DropShadow;
1373
}
1374
1375
bool IsColorMatrix() const {
1376
return tag == Tag::ColorMatrix;
1377
}
1378
1379
bool IsSrgbToLinear() const {
1380
return tag == Tag::SrgbToLinear;
1381
}
1382
1383
bool IsLinearToSrgb() const {
1384
return tag == Tag::LinearToSrgb;
1385
}
1386
1387
bool IsComponentTransfer() const {
1388
return tag == Tag::ComponentTransfer;
1389
}
1390
1391
bool IsFlood() const {
1392
return tag == Tag::Flood;
1393
}
1394
};
1395
1396
struct WrFilterData {
1397
ComponentTransferFuncType funcR_type;
1398
float *R_values;
1399
uintptr_t R_values_count;
1400
ComponentTransferFuncType funcG_type;
1401
float *G_values;
1402
uintptr_t G_values_count;
1403
ComponentTransferFuncType funcB_type;
1404
float *B_values;
1405
uintptr_t B_values_count;
1406
ComponentTransferFuncType funcA_type;
1407
float *A_values;
1408
uintptr_t A_values_count;
1409
1410
bool operator==(const WrFilterData& aOther) const {
1411
return funcR_type == aOther.funcR_type &&
1412
R_values == aOther.R_values &&
1413
R_values_count == aOther.R_values_count &&
1414
funcG_type == aOther.funcG_type &&
1415
G_values == aOther.G_values &&
1416
G_values_count == aOther.G_values_count &&
1417
funcB_type == aOther.funcB_type &&
1418
B_values == aOther.B_values &&
1419
B_values_count == aOther.B_values_count &&
1420
funcA_type == aOther.funcA_type &&
1421
A_values == aOther.A_values &&
1422
A_values_count == aOther.A_values_count;
1423
}
1424
};
1425
1426
/// A group of 2D side offsets, which correspond to top/left/bottom/right for borders, padding,
1427
/// and margins in CSS, optionally tagged with a unit.
1428
template<typename T, typename U>
1429
struct SideOffsets2D {
1430
T top;
1431
T right;
1432
T bottom;
1433
T left;
1434
1435
bool operator==(const SideOffsets2D& aOther) const {
1436
return top == aOther.top &&
1437
right == aOther.right &&
1438
bottom == aOther.bottom &&
1439
left == aOther.left;
1440
}
1441
};
1442
1443
using LayoutSideOffsets = SideOffsets2D<float, LayoutPixel>;
1444
1445
struct BorderSide {
1446
ColorF color;
1447
BorderStyle style;
1448
1449
bool operator==(const BorderSide& aOther) const {
1450
return color == aOther.color &&
1451
style == aOther.style;
1452
}
1453
};
1454
1455
using DeviceIntSideOffsets = SideOffsets2D<int32_t, DevicePixel>;
1456
1457
struct GradientStop {
1458
float offset;
1459
ColorF color;
1460
1461
bool operator==(const GradientStop& aOther) const {
1462
return offset == aOther.offset &&
1463
color == aOther.color;
1464
}
1465
};
1466
1467
using WrImageKey = ImageKey;
1468
1469
struct WrBorderImage {
1470
LayoutSideOffsets widths;
1471
WrImageKey image;
1472
int32_t width;
1473
int32_t height;
1474
bool fill;
1475
DeviceIntSideOffsets slice;
1476
LayoutSideOffsets outset;
1477
RepeatMode repeat_horizontal;
1478
RepeatMode repeat_vertical;
1479
1480
bool operator==(const WrBorderImage& aOther) const {
1481
return widths == aOther.widths &&
1482
image == aOther.image &&
1483
width == aOther.width &&
1484
height == aOther.height &&
1485
fill == aOther.fill &&
1486
slice == aOther.slice &&
1487
outset == aOther.outset &&
1488
repeat_horizontal == aOther.repeat_horizontal &&
1489
repeat_vertical == aOther.repeat_vertical;
1490
}
1491
};
1492
1493
struct WrStackingContextClip {
1494
enum class Tag {
1495
None,
1496
ClipId,
1497
ClipChain,
1498
1499
Sentinel /* this must be last for serialization purposes. */
1500
};
1501
1502
struct ClipId_Body {
1503
WrClipId _0;
1504
1505
bool operator==(const ClipId_Body& aOther) const {
1506
return _0 == aOther._0;
1507
}
1508
};
1509
1510
struct ClipChain_Body {
1511
uint64_t _0;
1512
1513
bool operator==(const ClipChain_Body& aOther) const {
1514
return _0 == aOther._0;
1515
}
1516
};
1517
1518
Tag tag;
1519
union {
1520
ClipId_Body clip_id;
1521
ClipChain_Body clip_chain;
1522
};
1523
1524
static WrStackingContextClip None() {
1525
WrStackingContextClip result;
1526
result.tag = Tag::None;
1527
return result;
1528
}
1529
1530
static WrStackingContextClip ClipId(const WrClipId &a0) {
1531
WrStackingContextClip result;
1532
::new (&result.clip_id._0) (WrClipId)(a0);
1533
result.tag = Tag::ClipId;
1534
return result;
1535
}
1536
1537
static WrStackingContextClip ClipChain(const uint64_t &a0) {
1538
WrStackingContextClip result;
1539
::new (&result.clip_chain._0) (uint64_t)(a0);
1540
result.tag = Tag::ClipChain;
1541
return result;
1542
}
1543
1544
bool IsNone() const {
1545
return tag == Tag::None;
1546
}
1547
1548
bool IsClipId() const {
1549
return tag == Tag::ClipId;
1550
}
1551
1552
bool IsClipChain() const {
1553
return tag == Tag::ClipChain;
1554
}
1555
1556
bool operator==(const WrStackingContextClip& aOther) const {
1557
if (tag != aOther.tag) {
1558
return false;
1559
}
1560
switch (tag) {
1561
case Tag::ClipId: return clip_id == aOther.clip_id;
1562
case Tag::ClipChain: return clip_chain == aOther.clip_chain;
1563
default: return true;
1564
}
1565
}
1566
};
1567
1568
struct WrAnimationProperty {
1569
WrAnimationType effect_type;
1570
uint64_t id;
1571
1572
bool operator==(const WrAnimationProperty& aOther) const {
1573
return effect_type == aOther.effect_type &&
1574
id == aOther.id;
1575
}
1576
};
1577
1578
struct PrimitiveFlags {
1579
uint8_t bits;
1580
1581
explicit operator bool() const {
1582
return !!bits;
1583
}
1584
PrimitiveFlags operator|(const PrimitiveFlags& aOther) const {
1585
return {static_cast<decltype(bits)>(this->bits | aOther.bits)};
1586
}
1587
PrimitiveFlags& operator|=(const PrimitiveFlags& aOther) {
1588
*this = (*this | aOther);
1589
return *this;
1590
}
1591
PrimitiveFlags operator&(const PrimitiveFlags& aOther) const {
1592
return {static_cast<decltype(bits)>(this->bits & aOther.bits)};
1593
}
1594
PrimitiveFlags& operator&=(const PrimitiveFlags& aOther) {
1595
*this = (*this & aOther);
1596
return *this;
1597
}
1598
bool operator==(const PrimitiveFlags& aOther) const {
1599
return bits == aOther.bits;
1600
}
1601
};
1602
static const PrimitiveFlags PrimitiveFlags_IS_BACKFACE_VISIBLE = (PrimitiveFlags){ .bits = 1 << 0 };
1603
static const PrimitiveFlags PrimitiveFlags_IS_SCROLLBAR_CONTAINER = (PrimitiveFlags){ .bits = 1 << 1 };
1604
static const PrimitiveFlags PrimitiveFlags_IS_SCROLLBAR_THUMB = (PrimitiveFlags){ .bits = 1 << 2 };
1605
1606
/// IMPORTANT: If you add fields to this struct, you need to also add initializers
1607
/// for those fields in WebRenderAPI.h.
1608
struct WrStackingContextParams {
1609
WrStackingContextClip clip;
1610
const WrAnimationProperty *animation;
1611
const float *opacity;
1612
TransformStyle transform_style;
1613
WrReferenceFrameKind reference_frame_kind;
1614
const uint64_t *scrolling_relative_to;
1615
PrimitiveFlags prim_flags;
1616
/// True if picture caching should be enabled for this stacking context.
1617
bool cache_tiles;
1618
MixBlendMode mix_blend_mode;
1619
/// True if this stacking context is a backdrop root.
1621
bool is_backdrop_root;
1622
1623
bool operator==(const WrStackingContextParams& aOther) const {
1624
return clip == aOther.clip &&
1625
animation == aOther.animation &&
1626
opacity == aOther.opacity &&
1627
transform_style == aOther.transform_style &&
1628
reference_frame_kind == aOther.reference_frame_kind &&
1629
scrolling_relative_to == aOther.scrolling_relative_to &&
1630
prim_flags == aOther.prim_flags &&
1631
cache_tiles == aOther.cache_tiles &&
1632
mix_blend_mode == aOther.mix_blend_mode &&
1633
is_backdrop_root == aOther.is_backdrop_root;
1634
}
1635
};
1636
1637
/// A 3d transform stored as a 4 by 4 matrix in row-major order in memory.
1638
///
1639
/// Transforms can be parametrized over the source and destination units, to describe a
1640
/// transformation from a space to another.
1641
/// For example, `Transform3D<f32, WorldSpace, ScreenSpace>::transform_point3d`
1642
/// takes a `Point3D<f32, WorldSpace>` and returns a `Point3D<f32, ScreenSpace>`.
1643
///
1644
/// Transforms expose a set of convenience methods for pre- and post-transformations.
1645
/// A pre-transformation corresponds to adding an operation that is applied before
1646
/// the rest of the transformation, while a post-transformation adds an operation
1647
/// that is applied after.
1648
///
1649
/// These transforms are for working with _row vectors_, so the matrix math for transforming
1650
/// a vector is `v * T`. If your library is using column vectors, use `row_major` functions when you
1651
/// are asked for `column_major` representations and vice versa.
1652
template<typename T, typename Src, typename Dst>
1653
struct Transform3D {
1654
T m11;
1655
T m12;
1656
T m13;
1657
T m14;
1658
T m21;
1659
T m22;
1660
T m23;
1661
T m24;
1662
T m31;
1663
T m32;
1664
T m33;
1665
T m34;
1666
T m41;
1667
T m42;
1668
T m43;
1669
T m44;
1670
1671
bool operator==(const Transform3D& aOther) const {
1672
return m11 == aOther.m11 &&
1673
m12 == aOther.m12 &&
1674
m13 == aOther.m13 &&
1675
m14 == aOther.m14 &&
1676
m21 == aOther.m21 &&
1677
m22 == aOther.m22 &&
1678
m23 == aOther.m23 &&
1679
m24 == aOther.m24 &&
1680
m31 == aOther.m31 &&
1681
m32 == aOther.m32 &&
1682
m33 == aOther.m33 &&
1683
m34 == aOther.m34 &&
1684
m41 == aOther.m41 &&
1685
m42 == aOther.m42 &&
1686
m43 == aOther.m43 &&
1687
m44 == aOther.m44;
1688
}
1689
};
1690
1691
using LayoutTransform = Transform3D<float, LayoutPixel, LayoutPixel>;
1692
1693
/// Configure whether the contents of a stacking context
1694
/// should be rasterized in local space or screen space.
1695
/// Local space rasterized pictures are typically used
1696
/// when we want to cache the output, and performance is
1697
/// important. Note that this is a performance hint only,
1698
/// which WR may choose to ignore.
1699
union RasterSpace {
1700
enum class Tag : uint8_t {
1701
Local,
1702
Screen,
1703
1704
Sentinel /* this must be last for serialization purposes. */
1705
};
1706
1707
struct Local_Body {
1708
Tag tag;
1709
float _0;
1710
1711
bool operator==(const Local_Body& aOther) const {
1712
return _0 == aOther._0;
1713
}
1714
};
1715
1716
struct {
1717
Tag tag;
1718
};
1719
Local_Body local;
1720
1721
static RasterSpace Local(const float &a0) {
1722
RasterSpace result;
1723
::new (&result.local._0) (float)(a0);
1724
result.tag = Tag::Local;
1725
return result;
1726
}
1727
1728
static RasterSpace Screen() {
1729
RasterSpace result;
1730
result.tag = Tag::Screen;
1731
return result;
1732
}
1733
1734
bool IsLocal() const {
1735
return tag == Tag::Local;
1736
}
1737
1738
bool IsScreen() const {
1739
return tag == Tag::Screen;
1740
}
1741
1742
bool operator==(const RasterSpace& aOther) const {
1743
if (tag != aOther.tag) {
1744
return false;
1745
}
1746
switch (tag) {
1747
case Tag::Local: return local == aOther.local;
1748
default: return true;
1749
}
1750
}
1751
};
1752
1753
using GlyphIndex = uint32_t;
1754
1755
struct GlyphInstance {
1756
GlyphIndex index;
1757
LayoutPoint point;
1758
1759
bool operator==(const GlyphInstance& aOther) const {
1760
return index == aOther.index &&
1761
point == aOther.point;
1762
}
1763
};
1764
1765
struct GlyphOptions {
1766
FontRenderMode render_mode;
1767
FontInstanceFlags flags;
1768
1769
bool operator==(const GlyphOptions& aOther) const {
1770
return render_mode == aOther.render_mode &&
1771
flags == aOther.flags;
1772
}
1773
};
1774
1775
using WrColorDepth = ColorDepth;
1776
1777
using WrYuvColorSpace = YuvColorSpace;
1778
1779
using WrColorRange = ColorRange;
1780
1781
struct ByteSlice {
1782
const uint8_t *buffer;
1783
uintptr_t len;
1784
1785
bool operator==(const ByteSlice& aOther) const {
1786
return buffer == aOther.buffer &&
1787
len == aOther.len;
1788
}
1789
};
1790
1791
using LayoutIntRect = Rect<int32_t, LayoutPixel>;
1792
1793
using DeviceIntRect = Rect<int32_t, DevicePixel>;
1794
1795
using TileOffset = Point2D<int32_t, TileCoordinate>;
1796
1797
struct MutByteSlice {
1798
uint8_t *buffer;
1799
uintptr_t len;
1800
1801
bool operator==(const MutByteSlice& aOther) const {
1802
return buffer == aOther.buffer &&
1803
len == aOther.len;
1804
}
1805
};
1806
1807
/// A C function that takes a pointer to a heap allocation and returns its size.
1808
///
1809
/// This is borrowed from the malloc_size_of crate, upon which we want to avoid
1810
/// a dependency from WebRender.
1811
using VoidPtrToSizeFn = uintptr_t(*)(const void *ptr);
1812
1813
/// A handle to a screenshot that is being asynchronously captured and scaled.
1814
struct AsyncScreenshotHandle {
1815
uintptr_t _0;
1816
1817
bool operator==(const AsyncScreenshotHandle& aOther) const {
1818
return _0 == aOther._0;
1819
}
1820
};
1821
1822
struct WrExternalImage {
1823
WrExternalImageType image_type;
1824
uint32_t handle;
1825
float u0;
1826
float v0;
1827
float u1;
1828
float v1;
1829
const uint8_t *buff;
1830
uintptr_t size;
1831
1832
bool operator==(const WrExternalImage& aOther) const {
1833
return image_type == aOther.image_type &&
1834
handle == aOther.handle &&
1835
u0 == aOther.u0 &&
1836
v0 == aOther.v0 &&
1837
u1 == aOther.u1 &&
1838
v1 == aOther.v1 &&
1839
buff == aOther.buff &&
1840
size == aOther.size;
1841
}
1842
};
1843
1844
/// An arbitrary identifier for an external image provided by the
1845
/// application. It must be a unique identifier for each external
1846
/// image.
1847
struct ExternalImageId {
1848
uint64_t _0;
1849
1850
bool operator==(const ExternalImageId& aOther) const {
1851
return _0 == aOther._0;
1852
}
1853
};
1854
1855
/// A handle to a recorded frame that was captured.
1856
struct RecordedFrameHandle {
1857
uintptr_t _0;
1858
1859
bool operator==(const RecordedFrameHandle& aOther) const {
1860
return _0 == aOther._0;
1861
}
1862
};
1863
1864
/// Some basic statistics about the rendered scene, used in Gecko, as
1865
/// well as in wrench reftests to ensure that tests are batching and/or
1866
/// allocating on render targets as we expect them to.
1867
struct RendererStats {
1868
uintptr_t total_draw_calls;
1869
uintptr_t alpha_target_count;
1870
uintptr_t color_target_count;
1871
uintptr_t texture_upload_kb;
1872
uint64_t resource_upload_time;
1873
uint64_t gpu_cache_upload_time;
1874
1875
bool operator==(const RendererStats& aOther) const {
1876
return total_draw_calls == aOther.total_draw_calls &&
1877
alpha_target_count == aOther.alpha_target_count &&
1878
color_target_count == aOther.color_target_count &&
1879
texture_upload_kb == aOther.texture_upload_kb &&
1880
resource_upload_time == aOther.resource_upload_time &&
1881
gpu_cache_upload_time == aOther.gpu_cache_upload_time;
1882
}
1883
};
1884
1885
struct WrExternalImageHandler {
1886
void *external_image_obj;
1887
1888
bool operator==(const WrExternalImageHandler& aOther) const {
1889
return external_image_obj == aOther.external_image_obj;
1890
}
1891
};
1892
1893
/// An opaque identifier describing a blob image registered with WebRender.
1894
/// This is used as a handle to reference blob images, and can be used as an
1895
/// image in display items.
1896
struct BlobImageKey {
1897
ImageKey _0;
1898
1899
bool operator==(const BlobImageKey& aOther) const {
1900
return _0 == aOther._0;
1901
}
1902
};
1903
1904
struct WrImageDescriptor {
1905
ImageFormat format;
1906
int32_t width;
1907
int32_t height;
1908
int32_t stride;
1909
OpacityType opacity;
1910
1911
bool operator==(const WrImageDescriptor& aOther) const {
1912
return format == aOther.format &&
1913
width == aOther.width &&
1914
height == aOther.height &&
1915
stride == aOther.stride &&
1916
opacity == aOther.opacity;
1917
}
1918
};
1919
1920
/// Storage format identifier for externally-managed images.
1921
union ExternalImageType {
1922
enum class Tag : uint8_t {
1923
/// The image is texture-backed.
1924
TextureHandle,
1925
/// The image is heap-allocated by the embedding.
1926
Buffer,
1927
1928
Sentinel /* this must be last for serialization purposes. */
1929
};
1930
1931
struct TextureHandle_Body {
1932
Tag tag;
1933
TextureTarget _0;
1934
1935
bool operator==(const TextureHandle_Body& aOther) const {
1936
return _0 == aOther._0;
1937
}
1938
};
1939
1940
struct {
1941
Tag tag;
1942
};
1943
TextureHandle_Body texture_handle;
1944
1945
static ExternalImageType TextureHandle(const TextureTarget &a0) {
1946
ExternalImageType result;
1947
::new (&result.texture_handle._0) (TextureTarget)(a0);
1948
result.tag = Tag::TextureHandle;
1949
return result;
1950
}
1951
1952
static ExternalImageType Buffer() {
1953
ExternalImageType result;
1954
result.tag = Tag::Buffer;
1955
return result;
1956
}
1957
1958
bool IsTextureHandle() const {
1959
return tag == Tag::TextureHandle;
1960
}
1961
1962
bool IsBuffer() const {
1963
return tag == Tag::Buffer;
1964
}
1965
1966
bool operator==(const ExternalImageType& aOther) const {
1967
if (tag != aOther.tag) {
1968
return false;
1969
}
1970
switch (tag) {
1971
case Tag::TextureHandle: return texture_handle == aOther.texture_handle;
1972
default: return true;
1973
}
1974
}
1975
};
1976
1977
struct WrTransformProperty {
1978
uint64_t id;
1979
LayoutTransform transform;
1980
};
1981
1982
struct WrOpacityProperty {
1983
uint64_t id;
1984
float opacity;
1985
1986
bool operator==(const WrOpacityProperty& aOther) const {
1987
return id == aOther.id &&
1988
opacity == aOther.opacity;
1989
}
1990
};
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
extern "C" {
2081
2082
extern void AddBlobFont(WrFontInstanceKey aInstanceKey,
2083
WrFontKey aFontKey,
2084
float aSize,
2085
const FontInstanceOptions *aOptions,
2086
const FontInstancePlatformOptions *aPlatformOptions,
2087
const FontVariation *aVariations,
2088
uintptr_t aNumVariations);
2089
2090
extern void AddFontData(WrFontKey aKey,
2091
const uint8_t *aData,
2092
uintptr_t aSize,
2093
uint32_t aIndex,
2094
const ArcVecU8 *aVec);
2095
2096
extern void AddNativeFontHandle(WrFontKey aKey,
2097
void *aHandle,
2098
uint32_t aIndex);
2099
2100
extern void ClearBlobImageResources(WrIdNamespace aNamespace);
2101
2102
extern void DeleteBlobFont(WrFontInstanceKey aKey);
2103
2104
extern void DeleteFontData(WrFontKey aKey);
2105
2106
#if defined(ANDROID)
2107
extern int __android_log_write(int aPrio,
2108
const char *aTag,
2109
const char *aText);
2110
#endif
2111
2112
extern void apz_deregister_sampler(WrWindowId aWindowId);
2113
2114
extern void apz_deregister_updater(WrWindowId aWindowId);
2115
2116
extern void apz_post_scene_swap(WrWindowId aWindowId,
2117
WrPipelineInfo aPipelineInfo);
2118
2119
extern void apz_pre_scene_swap(WrWindowId aWindowId);
2120
2121
extern void apz_register_sampler(WrWindowId aWindowId);
2122
2123
extern void apz_register_updater(WrWindowId aWindowId);
2124
2125
extern void apz_run_updater(WrWindowId aWindowId);
2126
2127
extern void apz_sample_transforms(WrWindowId aWindowId,
2128
Transaction *aTransaction,
2129
WrDocumentId aDocumentId);
2130
2131
extern void gecko_profiler_add_text_marker(const char *aName,
2132
const char *aTextBytes,
2133
uintptr_t aTextLen,
2134
uint64_t aMicroseconds);
2135
2136
extern void gecko_profiler_end_marker(const char *aName);
2137
2138
extern void gecko_profiler_register_thread(const char *aName);
2139
2140
extern void gecko_profiler_start_marker(const char *aName);
2141
2142
extern bool gecko_profiler_thread_is_being_profiled();
2143
2144
extern void gecko_profiler_unregister_thread();
2145
2146
extern void gfx_critical_error(const char *aMsg);
2147
2148
extern void gfx_critical_note(const char *aMsg);
2149
2150
extern bool gfx_use_wrench();
2151
2152
extern const char *gfx_wr_resource_path_override();
2153
2154
extern bool is_glcontext_angle(void *aGlcontextPtr);
2155
2156
extern bool is_glcontext_gles(void *aGlcontextPtr);
2157
2158
extern bool is_in_compositor_thread();
2159
2160
extern bool is_in_main_thread();
2161
2162
extern bool is_in_render_thread();
2163
2164
extern void record_telemetry_time(TelemetryProbe aProbe,
2165
uint64_t aTimeNs);
2166
2167
bool remove_program_binary_disk_cache(const nsAString *aProfPath);
2168
2169
const VecU8 *wr_add_ref_arc(const ArcVecU8 *aArc);
2170
2171
void wr_api_accumulate_memory_report(DocumentHandle *aDh,
2172
MemoryReport *aReport);
2173
2174
void wr_api_capture(DocumentHandle *aDh,
2175
const char *aPath,
2176
uint32_t aBitsRaw);
2177
2178
void wr_api_clear_all_caches(DocumentHandle *aDh);
2179
2180
void wr_api_clone(DocumentHandle *aDh,
2181
DocumentHandle **aOutHandle);
2182
2183
void wr_api_create_document(DocumentHandle *aRootDh,
2184
DocumentHandle **aOutHandle,
2185
DeviceIntSize aDocSize,
2186
int8_t aLayer,
2187
uint32_t aDocumentId);
2188
2189
void wr_api_delete(DocumentHandle *aDh);
2190
2191
void wr_api_delete_document(DocumentHandle *aDh);
2192
2193
void wr_api_finalize_builder(WrState *aState,
2194
LayoutSize *aContentSize,
2195
BuiltDisplayListDescriptor *aDlDescriptor,
2196
WrVecU8 *aDlData);
2197
2198
void wr_api_flush_scene_builder(DocumentHandle *aDh);
2199
2200
WrIdNamespace wr_api_get_namespace(DocumentHandle *aDh);
2201
2202
bool wr_api_hit_test(DocumentHandle *aDh,
2203
WorldPoint aPoint,
2204
WrPipelineId *aOutPipelineId,
2205
uint64_t *aOutScrollId,
2206
uint16_t *aOutHitInfo);
2207
2208
void wr_api_notify_memory_pressure(DocumentHandle *aDh);
2209
2210
void wr_api_send_external_event(DocumentHandle *aDh,
2211
uintptr_t aEvt);
2212
2213
void wr_api_send_transaction(DocumentHandle *aDh,
2214
Transaction *aTransaction,
2215
bool aIsAsync);
2216
2217
void wr_api_send_transactions(const DocumentHandle *const *aDocumentHandles,
2218
Transaction *const *aTransactions,
2219
uintptr_t aTransactionCount,
2220
bool aIsAsync);
2221
2222
void wr_api_set_debug_flags(DocumentHandle *aDh,
2223
DebugFlags aFlags);
2224
2225
void wr_api_set_transaction_logging(DocumentHandle *aDh,
2226
bool aAValue);
2227
2228
void wr_api_shut_down(DocumentHandle *aDh);
2229
2230
void wr_api_wake_scene_builder(DocumentHandle *aDh);
2231
2232
void wr_clear_item_tag(WrState *aState);
2233
2234
void wr_dec_ref_arc(const VecU8 *aArc);
2235
2236
void wr_device_delete(Device *aDevice);
2237
2238
void wr_dp_clear_save(WrState *aState);
2239
2240
WrClipId wr_dp_define_clip_with_parent_clip(WrState *aState,
2241
const WrSpaceAndClip *aParent,
2242
LayoutRect aClipRect,
2243
const ComplexClipRegion *aComplex,
2244
uintptr_t aComplexCount,
2245
const ImageMask *aMask);
2246
2247
WrClipId wr_dp_define_clip_with_parent_clip_chain(WrState *aState,
2248
const WrSpaceAndClipChain *aParent,
2249
LayoutRect aClipRect,
2250
const ComplexClipRegion *aComplex,
2251
uintptr_t aComplexCount,
2252
const ImageMask *aMask);
2253
2254
uint64_t wr_dp_define_clipchain(WrState *aState,
2255
const uint64_t *aParentClipchainId,
2256
const WrClipId *aClips,
2257
uintptr_t aClipsCount);
2258
2259
WrSpaceAndClip wr_dp_define_scroll_layer(WrState *aState,
2260
uint64_t aExternalScrollId,
2261
const WrSpaceAndClip *aParent,
2262
LayoutRect aContentRect,
2263
LayoutRect aClipRect,
2264
LayoutPoint aScrollOffset);
2265
2266
WrSpatialId wr_dp_define_sticky_frame(WrState *aState,
2267
WrSpatialId aParentSpatialId,
2268
LayoutRect aContentRect,
2269
const float *aTopMargin,
2270
const float *aRightMargin,
2271
const float *aBottomMargin,
2272
const float *aLeftMargin,
2273
StickyOffsetBounds aVerticalBounds,
2274
StickyOffsetBounds aHorizontalBounds,
2275
LayoutVector2D aAppliedOffset);
2276
2277
void wr_dp_pop_all_shadows(WrState *aState);
2278
2279
void wr_dp_pop_stacking_context(WrState *aState,
2280
bool aIsReferenceFrame);
2281
2282
void wr_dp_push_backdrop_filter_with_parent_clip(WrState *aState,
2283
LayoutRect aRect,
2284
LayoutRect aClip,
2285
bool aIsBackfaceVisible,
2286
const WrSpaceAndClip *aParent,
2287
const FilterOp *aFilters,
2288
uintptr_t aFilterCount,
2289
const WrFilterData *aFilterDatas,
2290
uintptr_t aFilterDatasCount);
2291
2292
void wr_dp_push_border(WrState *aState,
2293
LayoutRect aRect,
2294
LayoutRect aClip,
2295
bool aIsBackfaceVisible,
2296
const WrSpaceAndClipChain *aParent,
2297
AntialiasBorder aDoAa,
2298
LayoutSideOffsets aWidths,
2299
BorderSide aTop,
2300
BorderSide aRight,
2301
BorderSide aBottom,
2302
BorderSide aLeft,
2303
BorderRadius aRadius);
2304
2305
void wr_dp_push_border_gradient(WrState *aState,
2306
LayoutRect aRect,
2307
LayoutRect aClip,
2308
bool aIsBackfaceVisible,
2309
const WrSpaceAndClipChain *aParent,
2310
LayoutSideOffsets aWidths,
2311
int32_t aWidth,
2312
int32_t