Copy as Markdown
Other Tools
/* 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
/* Generated with cbindgen:0.26.0 */
/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.
* To generate this file:
* 1. Get the latest cbindgen using `cargo install --force cbindgen`
* 2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate webrender_bindings -o gfx/webrender_bindings/webrender_ffi_generated.h`
*/
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
namespace mozilla {
namespace wr {
/// Special value handled in this wrapper layer to signify a redundant clip chain.
constexpr static const uint64_t ROOT_CLIP_CHAIN = ~0;
constexpr static const uintptr_t BudgetType_COUNT = 7;
/// Defined here for cbindgen
constexpr static const int32_t MAX_RENDER_TASK_SIZE = 16384;
/// Maximum number of SVGFE filters in one graph, this is constant size to avoid
/// allocating anything, and the SVG spec allows us to drop all filters on an
/// item if the graph is excessively complex - a graph this large will never be
/// a good user experience, performance-wise.
constexpr static const uintptr_t SVGFE_GRAPH_MAX = 256;
constexpr static const uintptr_t POLYGON_CLIP_VERTEX_MAX = 32;
constexpr static const uintptr_t MAX_TEXT_RUN_LENGTH = 2040;
/// Whether a border should be antialiased.
enum class AntialiasBorder {
No = 0,
Yes,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const AntialiasBorder& aInstance) {
switch (aInstance) {
case AntialiasBorder::No: aStream << "No"; break;
case AntialiasBorder::Yes: aStream << "Yes"; break;
case AntialiasBorder::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
/// Boolean configuration option.
enum class BoolParameter : uint32_t {
PboUploads = 0,
Multithreading = 1,
BatchedUploads = 2,
DrawCallsForTextureCopy = 3,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const BoolParameter& aInstance) {
switch (aInstance) {
case BoolParameter::PboUploads: aStream << "PboUploads"; break;
case BoolParameter::Multithreading: aStream << "Multithreading"; break;
case BoolParameter::BatchedUploads: aStream << "BatchedUploads"; break;
case BoolParameter::DrawCallsForTextureCopy: aStream << "DrawCallsForTextureCopy"; break;
case BoolParameter::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class BorderStyle : uint32_t {
None = 0,
Solid = 1,
Double = 2,
Dotted = 3,
Dashed = 4,
Hidden = 5,
Groove = 6,
Ridge = 7,
Inset = 8,
Outset = 9,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const BorderStyle& aInstance) {
switch (aInstance) {
case BorderStyle::None: aStream << "None"; break;
case BorderStyle::Solid: aStream << "Solid"; break;
case BorderStyle::Double: aStream << "Double"; break;
case BorderStyle::Dotted: aStream << "Dotted"; break;
case BorderStyle::Dashed: aStream << "Dashed"; break;
case BorderStyle::Hidden: aStream << "Hidden"; break;
case BorderStyle::Groove: aStream << "Groove"; break;
case BorderStyle::Ridge: aStream << "Ridge"; break;
case BorderStyle::Inset: aStream << "Inset"; break;
case BorderStyle::Outset: aStream << "Outset"; break;
case BorderStyle::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class BoxShadowClipMode : uint8_t {
Outset = 0,
Inset = 1,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const BoxShadowClipMode& aInstance) {
switch (aInstance) {
case BoxShadowClipMode::Outset: aStream << "Outset"; break;
case BoxShadowClipMode::Inset: aStream << "Inset"; break;
case BoxShadowClipMode::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
/// A stage of the rendering pipeline.
enum class Checkpoint : uint32_t {
///
SceneBuilt,
///
FrameBuilt,
///
FrameTexturesUpdated,
///
FrameRendered,
/// NotificationRequests get notified with this if they get dropped without having been
/// notified. This provides the guarantee that if a request is created it will get notified.
TransactionDropped,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const Checkpoint& aInstance) {
switch (aInstance) {
case Checkpoint::SceneBuilt: aStream << "SceneBuilt"; break;
case Checkpoint::FrameBuilt: aStream << "FrameBuilt"; break;
case Checkpoint::FrameTexturesUpdated: aStream << "FrameTexturesUpdated"; break;
case Checkpoint::FrameRendered: aStream << "FrameRendered"; break;
case Checkpoint::TransactionDropped: aStream << "TransactionDropped"; break;
case Checkpoint::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class ClipMode {
Clip,
ClipOut,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const ClipMode& aInstance) {
switch (aInstance) {
case ClipMode::Clip: aStream << "Clip"; break;
case ClipMode::ClipOut: aStream << "ClipOut"; break;
case ClipMode::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
/// Specifies the color depth of an image. Currently only used for YUV images.
enum class ColorDepth : uint8_t {
/// 8 bits image (most common)
Color8,
/// 10 bits image
Color10,
/// 12 bits image
Color12,
/// 16 bits image
Color16,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const ColorDepth& aInstance) {
switch (aInstance) {
case ColorDepth::Color8: aStream << "Color8"; break;
case ColorDepth::Color10: aStream << "Color10"; break;
case ColorDepth::Color12: aStream << "Color12"; break;
case ColorDepth::Color16: aStream << "Color16"; break;
case ColorDepth::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class ColorRange : uint8_t {
Limited = 0,
Full = 1,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const ColorRange& aInstance) {
switch (aInstance) {
case ColorRange::Limited: aStream << "Limited"; break;
case ColorRange::Full: aStream << "Full"; break;
case ColorRange::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class ComponentTransferFuncType : uint8_t {
Identity = 0,
Table = 1,
Discrete = 2,
Linear = 3,
Gamma = 4,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const ComponentTransferFuncType& aInstance) {
switch (aInstance) {
case ComponentTransferFuncType::Identity: aStream << "Identity"; break;
case ComponentTransferFuncType::Table: aStream << "Table"; break;
case ComponentTransferFuncType::Discrete: aStream << "Discrete"; break;
case ComponentTransferFuncType::Linear: aStream << "Linear"; break;
case ComponentTransferFuncType::Gamma: aStream << "Gamma"; break;
case ComponentTransferFuncType::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
/// Crash annotations included in crash reports.
enum class CrashAnnotation {
CompileShader = 0,
DrawShader = 1,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const CrashAnnotation& aInstance) {
switch (aInstance) {
case CrashAnnotation::CompileShader: aStream << "CompileShader"; break;
case CrashAnnotation::DrawShader: aStream << "DrawShader"; break;
case CrashAnnotation::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class ExtendMode : uint8_t {
Clamp,
Repeat,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const ExtendMode& aInstance) {
switch (aInstance) {
case ExtendMode::Clamp: aStream << "Clamp"; break;
case ExtendMode::Repeat: aStream << "Repeat"; break;
case ExtendMode::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class FillRule : uint8_t {
Nonzero = 1,
Evenodd = 2,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const FillRule& aInstance) {
switch (aInstance) {
case FillRule::Nonzero: aStream << "Nonzero"; break;
case FillRule::Evenodd: aStream << "Evenodd"; break;
case FillRule::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
/// Floating point configuration option.
enum class FloatParameter : uint32_t {
/// The minimum time for the CPU portion of a frame to be considered slow
SlowCpuFrameThreshold = 0,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const FloatParameter& aInstance) {
switch (aInstance) {
case FloatParameter::SlowCpuFrameThreshold: aStream << "SlowCpuFrameThreshold"; break;
case FloatParameter::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
#if !(defined(XP_MACOSX) || defined(XP_WIN))
enum class FontHinting : uint8_t {
None,
Mono,
Light,
Normal,
LCD,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const FontHinting& aInstance) {
switch (aInstance) {
case FontHinting::None: aStream << "None"; break;
case FontHinting::Mono: aStream << "Mono"; break;
case FontHinting::Light: aStream << "Light"; break;
case FontHinting::Normal: aStream << "Normal"; break;
case FontHinting::LCD: aStream << "LCD"; break;
case FontHinting::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
#endif
#if !(defined(XP_MACOSX) || defined(XP_WIN))
enum class FontLCDFilter : uint8_t {
None,
Default,
Light,
Legacy,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const FontLCDFilter& aInstance) {
switch (aInstance) {
case FontLCDFilter::None: aStream << "None"; break;
case FontLCDFilter::Default: aStream << "Default"; break;
case FontLCDFilter::Light: aStream << "Light"; break;
case FontLCDFilter::Legacy: aStream << "Legacy"; break;
case FontLCDFilter::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
#endif
enum class FontRenderMode : uint8_t {
Mono = 0,
Alpha,
Subpixel,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const FontRenderMode& aInstance) {
switch (aInstance) {
case FontRenderMode::Mono: aStream << "Mono"; break;
case FontRenderMode::Alpha: aStream << "Alpha"; break;
case FontRenderMode::Subpixel: aStream << "Subpixel"; break;
case FontRenderMode::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
/// A flag in each scrollable frame to represent whether the owner of the frame document
/// has any scroll-linked effect.
/// for a definition of scroll-linked effect.
enum class HasScrollLinkedEffect : uint8_t {
Yes,
No,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const HasScrollLinkedEffect& aInstance) {
switch (aInstance) {
case HasScrollLinkedEffect::Yes: aStream << "Yes"; break;
case HasScrollLinkedEffect::No: aStream << "No"; break;
case HasScrollLinkedEffect::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
/// Specifies the type of texture target in driver terms.
enum class ImageBufferKind : uint8_t {
/// Standard texture. This maps to GL_TEXTURE_2D in OpenGL.
Texture2D = 0,
/// Rectangle texture. This maps to GL_TEXTURE_RECTANGLE in OpenGL. This
/// is similar to a standard texture, with a few subtle differences
/// (no mipmaps, non-power-of-two dimensions, different coordinate space)
/// that make it useful for representing the kinds of textures we use
/// for background on Rectangle textures.
TextureRect = 1,
/// External texture. This maps to GL_TEXTURE_EXTERNAL_OES in OpenGL, which
/// is an extension. This is used for image formats that OpenGL doesn't
/// understand, particularly YUV. See
TextureExternal = 2,
/// External texture which is forced to be converted from YUV to RGB using BT709 colorspace.
/// This maps to GL_TEXTURE_EXTERNAL_OES in OpenGL, using the EXT_YUV_TARGET extension.
TextureExternalBT709 = 3,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const ImageBufferKind& aInstance) {
switch (aInstance) {
case ImageBufferKind::Texture2D: aStream << "Texture2D"; break;
case ImageBufferKind::TextureRect: aStream << "TextureRect"; break;
case ImageBufferKind::TextureExternal: aStream << "TextureExternal"; break;
case ImageBufferKind::TextureExternalBT709: aStream << "TextureExternalBT709"; break;
case ImageBufferKind::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
/// Specifies the format of a series of pixels, in driver terms.
enum class ImageFormat : uint8_t {
/// One-channel, byte storage. The "red" doesn't map to the color
/// red per se, and is just the way that OpenGL has historically referred
/// to single-channel buffers.
R8 = 1,
/// One-channel, short storage
R16 = 2,
/// Four channels, byte storage.
BGRA8 = 3,
/// Four channels, float storage.
RGBAF32 = 4,
/// Two-channels, byte storage. Similar to `R8`, this just means
/// "two channels" rather than "red and green".
RG8 = 5,
/// Two-channels, short storage. Similar to `R16`, this just means
/// "two channels" rather than "red and green".
RG16 = 6,
/// Four channels, signed integer storage.
RGBAI32 = 7,
/// Four channels, byte storage.
RGBA8 = 8,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const ImageFormat& aInstance) {
switch (aInstance) {
case ImageFormat::R8: aStream << "R8"; break;
case ImageFormat::R16: aStream << "R16"; break;
case ImageFormat::BGRA8: aStream << "BGRA8"; break;
case ImageFormat::RGBAF32: aStream << "RGBAF32"; break;
case ImageFormat::RG8: aStream << "RG8"; break;
case ImageFormat::RG16: aStream << "RG16"; break;
case ImageFormat::RGBAI32: aStream << "RGBAI32"; break;
case ImageFormat::RGBA8: aStream << "RGBA8"; break;
case ImageFormat::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class ImageRendering : uint8_t {
Auto = 0,
CrispEdges = 1,
Pixelated = 2,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const ImageRendering& aInstance) {
switch (aInstance) {
case ImageRendering::Auto: aStream << "Auto"; break;
case ImageRendering::CrispEdges: aStream << "CrispEdges"; break;
case ImageRendering::Pixelated: aStream << "Pixelated"; break;
case ImageRendering::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
/// Integer configuration option.
enum class IntParameter : uint32_t {
BatchedUploadThreshold = 0,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const IntParameter& aInstance) {
switch (aInstance) {
case IntParameter::BatchedUploadThreshold: aStream << "BatchedUploadThreshold"; break;
case IntParameter::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class LineOrientation : uint8_t {
Vertical,
Horizontal,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const LineOrientation& aInstance) {
switch (aInstance) {
case LineOrientation::Vertical: aStream << "Vertical"; break;
case LineOrientation::Horizontal: aStream << "Horizontal"; break;
case LineOrientation::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class LineStyle : uint8_t {
Solid,
Dotted,
Dashed,
Wavy,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const LineStyle& aInstance) {
switch (aInstance) {
case LineStyle::Solid: aStream << "Solid"; break;
case LineStyle::Dotted: aStream << "Dotted"; break;
case LineStyle::Dashed: aStream << "Dashed"; break;
case LineStyle::Wavy: aStream << "Wavy"; break;
case LineStyle::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class MixBlendMode : uint8_t {
Normal = 0,
Multiply = 1,
Screen = 2,
Overlay = 3,
Darken = 4,
Lighten = 5,
ColorDodge = 6,
ColorBurn = 7,
HardLight = 8,
SoftLight = 9,
Difference = 10,
Exclusion = 11,
Hue = 12,
Saturation = 13,
Color = 14,
Luminosity = 15,
PlusLighter = 16,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const MixBlendMode& aInstance) {
switch (aInstance) {
case MixBlendMode::Normal: aStream << "Normal"; break;
case MixBlendMode::Multiply: aStream << "Multiply"; break;
case MixBlendMode::Screen: aStream << "Screen"; break;
case MixBlendMode::Overlay: aStream << "Overlay"; break;
case MixBlendMode::Darken: aStream << "Darken"; break;
case MixBlendMode::Lighten: aStream << "Lighten"; break;
case MixBlendMode::ColorDodge: aStream << "ColorDodge"; break;
case MixBlendMode::ColorBurn: aStream << "ColorBurn"; break;
case MixBlendMode::HardLight: aStream << "HardLight"; break;
case MixBlendMode::SoftLight: aStream << "SoftLight"; break;
case MixBlendMode::Difference: aStream << "Difference"; break;
case MixBlendMode::Exclusion: aStream << "Exclusion"; break;
case MixBlendMode::Hue: aStream << "Hue"; break;
case MixBlendMode::Saturation: aStream << "Saturation"; break;
case MixBlendMode::Color: aStream << "Color"; break;
case MixBlendMode::Luminosity: aStream << "Luminosity"; break;
case MixBlendMode::PlusLighter: aStream << "PlusLighter"; break;
case MixBlendMode::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
/// Used to indicate if an image is opaque, or has an alpha channel.
enum class OpacityType : uint8_t {
Opaque = 0,
HasAlphaChannel = 1,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const OpacityType& aInstance) {
switch (aInstance) {
case OpacityType::Opaque: aStream << "Opaque"; break;
case OpacityType::HasAlphaChannel: aStream << "HasAlphaChannel"; break;
case OpacityType::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class RepeatMode : uint8_t {
Stretch,
Repeat,
Round,
Space,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const RepeatMode& aInstance) {
switch (aInstance) {
case RepeatMode::Stretch: aStream << "Stretch"; break;
case RepeatMode::Repeat: aStream << "Repeat"; break;
case RepeatMode::Round: aStream << "Round"; break;
case RepeatMode::Space: aStream << "Space"; break;
case RepeatMode::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class TransformStyle : uint8_t {
Flat = 0,
Preserve3D = 1,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const TransformStyle& aInstance) {
switch (aInstance) {
case TransformStyle::Flat: aStream << "Flat"; break;
case TransformStyle::Preserve3D: aStream << "Preserve3D"; break;
case TransformStyle::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class WrAnimationType : uint32_t {
Transform = 0,
Opacity = 1,
BackgroundColor = 2,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const WrAnimationType& aInstance) {
switch (aInstance) {
case WrAnimationType::Transform: aStream << "Transform"; break;
case WrAnimationType::Opacity: aStream << "Opacity"; break;
case WrAnimationType::BackgroundColor: aStream << "BackgroundColor"; break;
case WrAnimationType::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class WrExternalImageType : uint32_t {
RawData,
NativeTexture,
Invalid,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const WrExternalImageType& aInstance) {
switch (aInstance) {
case WrExternalImageType::RawData: aStream << "RawData"; break;
case WrExternalImageType::NativeTexture: aStream << "NativeTexture"; break;
case WrExternalImageType::Invalid: aStream << "Invalid"; break;
case WrExternalImageType::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class WrReferenceFrameKind : uint8_t {
Transform,
Perspective,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const WrReferenceFrameKind& aInstance) {
switch (aInstance) {
case WrReferenceFrameKind::Transform: aStream << "Transform"; break;
case WrReferenceFrameKind::Perspective: aStream << "Perspective"; break;
case WrReferenceFrameKind::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class WrRotation : uint8_t {
Degree0,
Degree90,
Degree180,
Degree270,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const WrRotation& aInstance) {
switch (aInstance) {
case WrRotation::Degree0: aStream << "Degree0"; break;
case WrRotation::Degree90: aStream << "Degree90"; break;
case WrRotation::Degree180: aStream << "Degree180"; break;
case WrRotation::Degree270: aStream << "Degree270"; break;
case WrRotation::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class YuvColorSpace : uint8_t {
Rec601 = 0,
Rec709 = 1,
Rec2020 = 2,
Identity = 3,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const YuvColorSpace& aInstance) {
switch (aInstance) {
case YuvColorSpace::Rec601: aStream << "Rec601"; break;
case YuvColorSpace::Rec709: aStream << "Rec709"; break;
case YuvColorSpace::Rec2020: aStream << "Rec2020"; break;
case YuvColorSpace::Identity: aStream << "Identity"; break;
case YuvColorSpace::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
enum class YuvRangedColorSpace : uint8_t {
Rec601Narrow = 0,
Rec601Full = 1,
Rec709Narrow = 2,
Rec709Full = 3,
Rec2020Narrow = 4,
Rec2020Full = 5,
GbrIdentity = 6,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const YuvRangedColorSpace& aInstance) {
switch (aInstance) {
case YuvRangedColorSpace::Rec601Narrow: aStream << "Rec601Narrow"; break;
case YuvRangedColorSpace::Rec601Full: aStream << "Rec601Full"; break;
case YuvRangedColorSpace::Rec709Narrow: aStream << "Rec709Narrow"; break;
case YuvRangedColorSpace::Rec709Full: aStream << "Rec709Full"; break;
case YuvRangedColorSpace::Rec2020Narrow: aStream << "Rec2020Narrow"; break;
case YuvRangedColorSpace::Rec2020Full: aStream << "Rec2020Full"; break;
case YuvRangedColorSpace::GbrIdentity: aStream << "GbrIdentity"; break;
case YuvRangedColorSpace::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
template<typename T = void>
struct Arc;
/// Features of the batch that, if not requested, may allow a fast-path.
///
/// Rather than breaking batches when primitives request different features,
/// we always request the minimum amount of features to satisfy all items in
/// the batch.
/// The goal is to let the renderer be optionally select more specialized
/// versions of a shader if the batch doesn't require code certain code paths.
/// Not all shaders necessarily implement all of these features.
struct BatchFeatures;
/// A set of flags describing why a picture may need a backing surface.
struct BlitReason;
/// Flags that define how the common brush shader
/// code should process this instance.
struct BrushFlags;
/// Bit flags for WR stages to store in a capture.
struct CaptureBits;
/// Mask for clearing caches in debug commands.
struct ClearCache;
struct ClipNodeFlags;
/// ID for a ClipTreeNode
struct ClipNodeId;
/// A set of flags describing why a picture may need a backing surface.
struct ClusterFlags;
/// Optional features that can be opted-out of when compositing,
/// possibly allowing a fast path to be selected.
struct CompositeFeatures;
struct Device;
/// Geometry in the coordinate system of the render target (screen or intermediate
/// surface) in physical pixels.
struct DevicePixel;
struct DocumentHandle;
/// Each bit of the edge AA mask is:
/// 0, when the edge of the primitive needs to be considered for AA
/// 1, when the edge of the segment needs to be considered for AA
///
/// *Note*: the bit values have to match the shader logic in
/// `write_transform_vertex()` function.
struct EdgeAaSegmentMask;
/// Various flags that are part of an image descriptor.
struct ImageDescriptorFlags;
template<typename T = void>
struct Index;
struct ItemFlags;
/// Geometry in a stacking context's local coordinate space (logical pixels).
struct LayoutPixel;
struct PassId;
/// Flags describing properties for a given PicturePrimitive
struct PictureFlags;
/// A set of bitflags that can be set in the visibility information
/// for a primitive instance. This can be used to control how primitives
/// are treated during batching.
struct PrimitiveVisibilityFlags;
/// The renderer is responsible for submitting to the GPU the work prepared by the
/// RenderBackend.
///
/// We have a separate `Renderer` instance for each instance of WebRender (generally
/// one per OS window), and all instances share the same thread.
struct Renderer;
/// Flags that control how shaders are pre-cached, if at all.
struct ShaderPrecacheFlags;
/// Slice flags
struct SliceFlags;
struct SpatialNodeIndex;
/// Defines which sub-slice (effectively a z-index) a primitive exists on within
/// a picture cache instance.
struct SubSliceIndex;
struct TextureFlags;
/// Unit for tile coordinates.
struct TileCoordinate;
/// A Transaction is a group of commands to apply atomically to a document.
///
/// This mechanism ensures that:
/// - no other message can be interleaved between two commands that need to be applied together.
/// - no redundant work is performed if two commands in the same transaction cause the scene or
/// the frame to be rebuilt.
struct Transaction;
/// The default unit.
struct UnknownUnit;
template<typename T = void>
struct Vec;
/// Geometry in the document's coordinate space (logical pixels).
struct WorldPixel;
struct WrChunkPool;
struct WrGlyphRasterThread;
struct WrProgramCache;
/// A wrapper around a strong reference to a Shaders object.
struct WrShaders;
struct WrState;
struct WrThreadPool;
struct WrVecU8 {
/// `data` must always be valid for passing to Vec::from_raw_parts.
/// In particular, it must be non-null even if capacity is zero.
uint8_t *data;
uintptr_t length;
uintptr_t capacity;
friend std::ostream& operator<<(std::ostream& aStream, const WrVecU8& aInstance) {
return aStream << "{ " << "data=" << aInstance.data << ", "
<< "length=" << aInstance.length << ", "
<< "capacity=" << aInstance.capacity << " }";
}
bool operator==(const WrVecU8& aOther) const {
return data == aOther.data &&
length == aOther.length &&
capacity == aOther.capacity;
}
};
struct ByteSlice {
const uint8_t *buffer;
uintptr_t len;
friend std::ostream& operator<<(std::ostream& aStream, const ByteSlice& aInstance) {
return aStream << "{ " << "buffer=" << aInstance.buffer << ", "
<< "len=" << aInstance.len << " }";
}
bool operator==(const ByteSlice& aOther) const {
return buffer == aOther.buffer &&
len == aOther.len;
}
};
struct WrExternalImage {
WrExternalImageType image_type;
uint32_t handle;
float u0;
float v0;
float u1;
float v1;
const uint8_t *buff;
uintptr_t size;
friend std::ostream& operator<<(std::ostream& aStream, const WrExternalImage& aInstance) {
return aStream << "{ " << "image_type=" << aInstance.image_type << ", "
<< "handle=" << aInstance.handle << ", "
<< "u0=" << aInstance.u0 << ", "
<< "v0=" << aInstance.v0 << ", "
<< "u1=" << aInstance.u1 << ", "
<< "v1=" << aInstance.v1 << ", "
<< "buff=" << aInstance.buff << ", "
<< "size=" << aInstance.size << " }";
}
bool operator==(const WrExternalImage& aOther) const {
return image_type == aOther.image_type &&
handle == aOther.handle &&
u0 == aOther.u0 &&
v0 == aOther.v0 &&
u1 == aOther.u1 &&
v1 == aOther.v1 &&
buff == aOther.buff &&
size == aOther.size;
}
};
/// An arbitrary identifier for an external image provided by the
/// application. It must be a unique identifier for each external
/// image.
struct ExternalImageId {
uint64_t _0;
friend std::ostream& operator<<(std::ostream& aStream, const ExternalImageId& aInstance) {
return aStream << "{ " << "_0=" << aInstance._0 << " }";
}
bool operator==(const ExternalImageId& aOther) const {
return _0 == aOther._0;
}
};
struct WrWindowId {
uint64_t mHandle;
friend std::ostream& operator<<(std::ostream& aStream, const WrWindowId& aInstance) {
return aStream << "{ " << "mHandle=" << aInstance.mHandle << " }";
}
bool operator==(const WrWindowId& aOther) const {
return mHandle == aOther.mHandle;
}
bool operator<(const WrWindowId& aOther) const {
return mHandle < aOther.mHandle;
}
bool operator<=(const WrWindowId& aOther) const {
return mHandle <= aOther.mHandle;
}
};
struct FramePublishId {
uint64_t _0;
friend std::ostream& operator<<(std::ostream& aStream, const FramePublishId& aInstance) {
return aStream << "{ " << "_0=" << aInstance._0 << " }";
}
bool operator==(const FramePublishId& aOther) const {
return _0 == aOther._0;
}
static const FramePublishId INVALID;
};
/// An invalid sentinel FramePublishId, which will always compare less than
/// any valid FrameId.
constexpr inline const FramePublishId FramePublishId::INVALID = FramePublishId{ /* ._0 = */ 0 };
/// Flags to track why we are rendering.
struct RenderReasons {
uint32_t _0;
constexpr explicit operator bool() const {
return !!_0;
}
constexpr RenderReasons operator~() const {
return RenderReasons { static_cast<decltype(_0)>(~_0) };
}
constexpr RenderReasons operator|(const RenderReasons& aOther) const {
return RenderReasons { static_cast<decltype(_0)>(this->_0 | aOther._0) };
}
RenderReasons& operator|=(const RenderReasons& aOther) {
*this = (*this | aOther);
return *this;
}
constexpr RenderReasons operator&(const RenderReasons& aOther) const {
return RenderReasons { static_cast<decltype(_0)>(this->_0 & aOther._0) };
}
RenderReasons& operator&=(const RenderReasons& aOther) {
*this = (*this & aOther);
return *this;
}
constexpr RenderReasons operator^(const RenderReasons& aOther) const {
return RenderReasons { static_cast<decltype(_0)>(this->_0 ^ aOther._0) };
}
RenderReasons& operator^=(const RenderReasons& aOther) {
*this = (*this ^ aOther);
return *this;
}
friend std::ostream& operator<<(std::ostream& aStream, const RenderReasons& aInstance) {
return aStream << "{ " << "_0=" << aInstance._0 << " }";
}
bool operator==(const RenderReasons& aOther) const {
return _0 == aOther._0;
}
static const RenderReasons NONE;
static const RenderReasons SCENE;
static const RenderReasons ANIMATED_PROPERTY;
static const RenderReasons RESOURCE_UPDATE;
static const RenderReasons ASYNC_IMAGE;
static const RenderReasons CLEAR_RESOURCES;
static const RenderReasons APZ;
static const RenderReasons RESIZE;
static const RenderReasons WIDGET;
static const RenderReasons TEXTURE_CACHE_FLUSH;
static const RenderReasons SNAPSHOT;
static const RenderReasons POST_RESOURCE_UPDATES_HOOK;
static const RenderReasons CONFIG_CHANGE;
static const RenderReasons CONTENT_SYNC;
static const RenderReasons FLUSH;
static const RenderReasons TESTING;
static const RenderReasons OTHER;
static const RenderReasons VSYNC;
static const RenderReasons SKIPPED_COMPOSITE;
static const RenderReasons START_OBSERVING_VSYNC;
static const RenderReasons ASYNC_IMAGE_COMPOSITE_UNTIL;
static const uint32_t NUM_BITS;
};
/// Equivalent of empty() for the C++ side.
constexpr inline const RenderReasons RenderReasons::NONE = RenderReasons{ /* ._0 = */ (uint32_t)0 };
constexpr inline const RenderReasons RenderReasons::SCENE = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 0) };
constexpr inline const RenderReasons RenderReasons::ANIMATED_PROPERTY = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 1) };
constexpr inline const RenderReasons RenderReasons::RESOURCE_UPDATE = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 2) };
constexpr inline const RenderReasons RenderReasons::ASYNC_IMAGE = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 3) };
constexpr inline const RenderReasons RenderReasons::CLEAR_RESOURCES = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 4) };
constexpr inline const RenderReasons RenderReasons::APZ = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 5) };
/// Window resize
constexpr inline const RenderReasons RenderReasons::RESIZE = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 6) };
/// Various widget-related reasons
constexpr inline const RenderReasons RenderReasons::WIDGET = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 7) };
/// See Frame::must_be_drawn
constexpr inline const RenderReasons RenderReasons::TEXTURE_CACHE_FLUSH = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 8) };
constexpr inline const RenderReasons RenderReasons::SNAPSHOT = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 9) };
constexpr inline const RenderReasons RenderReasons::POST_RESOURCE_UPDATES_HOOK = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 10) };
constexpr inline const RenderReasons RenderReasons::CONFIG_CHANGE = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 11) };
constexpr inline const RenderReasons RenderReasons::CONTENT_SYNC = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 12) };
constexpr inline const RenderReasons RenderReasons::FLUSH = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 13) };
constexpr inline const RenderReasons RenderReasons::TESTING = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 14) };
constexpr inline const RenderReasons RenderReasons::OTHER = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 15) };
/// Vsync isn't actually "why" we render but it can be useful
/// to see which frames were driven by the vsync scheduler so
/// we store a bit for it.
constexpr inline const RenderReasons RenderReasons::VSYNC = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 16) };
constexpr inline const RenderReasons RenderReasons::SKIPPED_COMPOSITE = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 17) };
/// Gecko does some special things when it starts observing vsync
/// so it can be useful to know what frames are associated with it.
constexpr inline const RenderReasons RenderReasons::START_OBSERVING_VSYNC = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 18) };
constexpr inline const RenderReasons RenderReasons::ASYNC_IMAGE_COMPOSITE_UNTIL = RenderReasons{ /* ._0 = */ (uint32_t)(1 << 19) };
constexpr inline const uint32_t RenderReasons::NUM_BITS = 17;
/// This type carries no valuable semantics for WR. However, it reflects the fact that
/// clients (Servo) may generate pipelines by different semi-independent sources.
/// These pipelines still belong to the same `IdNamespace` and the same `DocumentId`.
/// Having this extra Id field enables them to generate `PipelineId` without collision.
using PipelineSourceId = uint32_t;
/// From the point of view of WR, `PipelineId` is completely opaque and generic as long as
/// it's clonable, serializable, comparable, and hashable.
struct PipelineId {
PipelineSourceId mNamespace;
uint32_t mHandle;
friend std::ostream& operator<<(std::ostream& aStream, const PipelineId& aInstance) {
return aStream << "{ " << "mNamespace=" << aInstance.mNamespace << ", "
<< "mHandle=" << aInstance.mHandle << " }";
}
bool operator==(const PipelineId& aOther) const {
return mNamespace == aOther.mNamespace &&
mHandle == aOther.mHandle;
}
static const PipelineId INVALID;
};
constexpr inline const PipelineId PipelineId::INVALID = PipelineId{ };
using WrPipelineId = PipelineId;
/// ID namespaces uniquely identify different users of WebRender's API.
///
/// For example in Gecko each content process uses a separate id namespace.
struct IdNamespace {
uint32_t mHandle;
friend std::ostream& operator<<(std::ostream& aStream, const IdNamespace& aInstance) {
return aStream << "{ " << "mHandle=" << aInstance.mHandle << " }";
}
bool operator==(const IdNamespace& aOther) const {
return mHandle == aOther.mHandle;
}
bool operator!=(const IdNamespace& aOther) const {
return mHandle != aOther.mHandle;
}
bool operator<(const IdNamespace& aOther) const {
return mHandle < aOther.mHandle;
}
bool operator<=(const IdNamespace& aOther) const {
return mHandle <= aOther.mHandle;
}
};
/// A key uniquely identifying a WebRender document.
///
/// Instances can manage one or several documents (using the same render backend thread).
/// Each document will internally correspond to a single scene, and scenes are made of
/// one or several pipelines.
struct DocumentId {
///
IdNamespace mNamespace;
///
uint32_t mHandle;
friend std::ostream& operator<<(std::ostream& aStream, const DocumentId& aInstance) {
return aStream << "{ " << "mNamespace=" << aInstance.mNamespace << ", "
<< "mHandle=" << aInstance.mHandle << " }";
}
bool operator==(const DocumentId& aOther) const {
return mNamespace == aOther.mNamespace &&
mHandle == aOther.mHandle;
}
static const DocumentId INVALID;
};
///
constexpr inline const DocumentId DocumentId::INVALID = DocumentId{ };
using WrDocumentId = DocumentId;
/// An epoch identifies the state of a pipeline in time.
///
/// This is mostly used as a synchronization mechanism to observe how/when particular pipeline
/// updates propagate through WebRender and are applied at various stages.
struct Epoch {
uint32_t mHandle;
friend std::ostream& operator<<(std::ostream& aStream, const Epoch& aInstance) {
return aStream << "{ " << "mHandle=" << aInstance.mHandle << " }";
}
bool operator==(const Epoch& aOther) const {
return mHandle == aOther.mHandle;
}
bool operator!=(const Epoch& aOther) const {
return mHandle != aOther.mHandle;
}
bool operator<(const Epoch& aOther) const {
return mHandle < aOther.mHandle;
}
bool operator<=(const Epoch& aOther) const {
return mHandle <= aOther.mHandle;
}
};
using WrEpoch = Epoch;
struct WrPipelineEpoch {
WrPipelineId pipeline_id;
WrDocumentId document_id;
WrEpoch epoch;
friend std::ostream& operator<<(std::ostream& aStream, const WrPipelineEpoch& aInstance) {
return aStream << "{ " << "pipeline_id=" << aInstance.pipeline_id << ", "
<< "document_id=" << aInstance.document_id << ", "
<< "epoch=" << aInstance.epoch << " }";
}
bool operator==(const WrPipelineEpoch& aOther) const {
return pipeline_id == aOther.pipeline_id &&
document_id == aOther.document_id &&
epoch == aOther.epoch;
}
};
struct WrRemovedPipeline {
WrPipelineId pipeline_id;
WrDocumentId document_id;
friend std::ostream& operator<<(std::ostream& aStream, const WrRemovedPipeline& aInstance) {
return aStream << "{ " << "pipeline_id=" << aInstance.pipeline_id << ", "
<< "document_id=" << aInstance.document_id << " }";
}
bool operator==(const WrRemovedPipeline& aOther) const {
return pipeline_id == aOther.pipeline_id &&
document_id == aOther.document_id;
}
};
struct WrPipelineInfo {
/// This contains an entry for each pipeline that was rendered, along with
/// the epoch at which it was rendered. Rendered pipelines include the root
/// pipeline and any other pipelines that were reachable via IFrame display
/// items from the root pipeline.
nsTArray<WrPipelineEpoch> epochs;
/// This contains an entry for each pipeline that was removed during the
/// last transaction. These pipelines would have been explicitly removed by
/// calling remove_pipeline on the transaction object; the pipeline showing
/// up in this array means that the data structures have been torn down on
/// the webrender side, and so any remaining data structures on the caller
/// side can now be torn down also.
nsTArray<WrRemovedPipeline> removed_pipelines;
friend std::ostream& operator<<(std::ostream& aStream, const WrPipelineInfo& aInstance) {
return aStream << "{ " << "epochs=" << aInstance.epochs << ", "
<< "removed_pipelines=" << aInstance.removed_pipelines << " }";
}
bool operator==(const WrPipelineInfo& aOther) const {
return epochs == aOther.epochs &&
removed_pipelines == aOther.removed_pipelines;
}
};
/// Represents RGBA screen colors with floating point numbers.
///
/// All components must be between 0.0 and 1.0.
/// An alpha value of 1.0 is opaque while 0.0 is fully transparent.
struct ColorF {
float r;
float g;
float b;
float a;
friend std::ostream& operator<<(std::ostream& aStream, const ColorF& aInstance) {
return aStream << "{ " << "r=" << aInstance.r << ", "
<< "g=" << aInstance.g << ", "
<< "b=" << aInstance.b << ", "
<< "a=" << aInstance.a << " }";
}
bool operator==(const ColorF& aOther) const {
return r == aOther.r &&
g == aOther.g &&
b == aOther.b &&
a == aOther.a;
}
static const ColorF BLACK;
static const ColorF TRANSPARENT;
static const ColorF WHITE;
};
constexpr inline const ColorF ColorF::BLACK = ColorF{ /* .r = */ 0.0, /* .g = */ 0.0, /* .b = */ 0.0, /* .a = */ 1.0 };
constexpr inline const ColorF ColorF::TRANSPARENT = ColorF{ /* .r = */ 0.0, /* .g = */ 0.0, /* .b = */ 0.0, /* .a = */ 0.0 };
constexpr inline const ColorF ColorF::WHITE = ColorF{ /* .r = */ 1.0, /* .g = */ 1.0, /* .b = */ 1.0, /* .a = */ 1.0 };
struct WrExternalImageHandler {
void *external_image_obj;
friend std::ostream& operator<<(std::ostream& aStream, const WrExternalImageHandler& aInstance) {
return aStream << "{ " << "external_image_obj=" << aInstance.external_image_obj << " }";
}
bool operator==(const WrExternalImageHandler& aOther) const {
return external_image_obj == aOther.external_image_obj;
}
};
/// Some basic statistics about the rendered scene, used in Gecko, as
/// well as in wrench reftests to ensure that tests are batching and/or
/// allocating on render targets as we expect them to.
struct RendererStats {
uintptr_t total_draw_calls;
uintptr_t alpha_target_count;
uintptr_t color_target_count;
double texture_upload_mb;
double resource_upload_time;
double gpu_cache_upload_time;
double gecko_display_list_time;
double wr_display_list_time;
double scene_build_time;
double frame_build_time;
bool full_display_list;
bool full_paint;
friend std::ostream& operator<<(std::ostream& aStream, const RendererStats& aInstance) {
return aStream << "{ " << "total_draw_calls=" << aInstance.total_draw_calls << ", "
<< "alpha_target_count=" << aInstance.alpha_target_count << ", "
<< "color_target_count=" << aInstance.color_target_count << ", "
<< "texture_upload_mb=" << aInstance.texture_upload_mb << ", "
<< "resource_upload_time=" << aInstance.resource_upload_time << ", "
<< "gpu_cache_upload_time=" << aInstance.gpu_cache_upload_time << ", "
<< "gecko_display_list_time=" << aInstance.gecko_display_list_time << ", "
<< "wr_display_list_time=" << aInstance.wr_display_list_time << ", "
<< "scene_build_time=" << aInstance.scene_build_time << ", "
<< "frame_build_time=" << aInstance.frame_build_time << ", "
<< "full_display_list=" << aInstance.full_display_list << ", "
<< "full_paint=" << aInstance.full_paint << " }";
}
bool operator==(const RendererStats& aOther) const {
return total_draw_calls == aOther.total_draw_calls &&
alpha_target_count == aOther.alpha_target_count &&
color_target_count == aOther.color_target_count &&
texture_upload_mb == aOther.texture_upload_mb &&
resource_upload_time == aOther.resource_upload_time &&
gpu_cache_upload_time == aOther.gpu_cache_upload_time &&
gecko_display_list_time == aOther.gecko_display_list_time &&
wr_display_list_time == aOther.wr_display_list_time &&
scene_build_time == aOther.scene_build_time &&
frame_build_time == aOther.frame_build_time &&
full_display_list == aOther.full_display_list &&
full_paint == aOther.full_paint;
}
};
/// A 2d Point tagged with a unit.
template<typename T, typename U>
struct Point2D {
T x;
T y;
friend std::ostream& operator<<(std::ostream& aStream, const Point2D& aInstance) {
return aStream << "{ " << "x=" << aInstance.x << ", "
<< "y=" << aInstance.y << " }";
}
bool operator==(const Point2D& aOther) const {
return x == aOther.x &&
y == aOther.y;
}
};
/// A 2d axis aligned rectangle represented by its minimum and maximum coordinates.
///
/// # Representation
///
/// This struct is similar to [`Rect`], but stores rectangle as two endpoints
/// instead of origin point and size. Such representation has several advantages over
/// [`Rect`] representation:
/// - Several operations are more efficient with `Box2D`, including [`intersection`],
/// [`union`], and point-in-rect.
/// - The representation is less susceptible to overflow. With [`Rect`], computation
/// of second point can overflow for a large range of values of origin and size.
/// However, with `Box2D`, computation of [`size`] cannot overflow if the coordinates
/// are signed and the resulting size is unsigned.
///
/// A known disadvantage of `Box2D` is that translating the rectangle requires translating
/// both points, whereas translating [`Rect`] only requires translating one point.
///
/// # Empty box
///
/// A box is considered empty (see [`is_empty`]) if any of the following is true:
/// - it's area is empty,
/// - it's area is negative (`min.x > max.x` or `min.y > max.y`),
/// - it contains NaNs.
///
/// [`Rect`]: struct.Rect.html
/// [`intersection`]: #method.intersection
/// [`is_empty`]: #method.is_empty
/// [`union`]: #method.union
/// [`size`]: #method.size
template<typename T, typename U>
struct Box2D {
Point2D<T, U> min;
Point2D<T, U> max;
friend std::ostream& operator<<(std::ostream& aStream, const Box2D& aInstance) {
return aStream << "{ " << "min=" << aInstance.min << ", "
<< "max=" << aInstance.max << " }";
}
bool operator==(const Box2D& aOther) const {
return min == aOther.min &&
max == aOther.max;
}
inline T width() const { return max.x - min.x; }
inline T height() const { return max.y - min.y; }
};
using DeviceIntRect = Box2D<int32_t, DevicePixel>;
/// A handle to a recorded frame that was captured.
struct RecordedFrameHandle {
uintptr_t _0;
friend std::ostream& operator<<(std::ostream& aStream, const RecordedFrameHandle& aInstance) {
return aStream << "{ " << "_0=" << aInstance._0 << " }";
}
bool operator==(const RecordedFrameHandle& aOther) const {
return _0 == aOther._0;
}
};
/// A handle to a screenshot that is being asynchronously captured and scaled.
struct AsyncScreenshotHandle {
uintptr_t _0;
friend std::ostream& operator<<(std::ostream& aStream, const AsyncScreenshotHandle& aInstance) {
return aStream << "{ " << "_0=" << aInstance._0 << " }";
}
bool operator==(const AsyncScreenshotHandle& aOther) const {
return _0 == aOther._0;
}
};
/// Memory report for interning-related data structures.
struct InterningMemoryReport {
///
InternerSubReport interners;
///
InternerSubReport data_stores;
};
/// Collection of heap sizes, in bytes.
struct MemoryReport {
uintptr_t clip_stores;
uintptr_t gpu_cache_metadata;
uintptr_t gpu_cache_cpu_mirror;
uintptr_t hit_testers;
uintptr_t fonts;
uintptr_t weak_fonts;
uintptr_t images;
uintptr_t rasterized_blobs;
uintptr_t shader_cache;
InterningMemoryReport interning;
uintptr_t display_list;
uintptr_t upload_staging_memory;
uintptr_t swgl;
uintptr_t frame_allocator;
uintptr_t render_tasks;
uintptr_t gpu_cache_textures;
uintptr_t vertex_data_textures;
uintptr_t render_target_textures;
uintptr_t picture_tile_textures;
uintptr_t atlas_textures;
uintptr_t standalone_textures;
uintptr_t texture_cache_structures;
uintptr_t depth_target_textures;
uintptr_t texture_upload_pbos;
uintptr_t swap_chain;
uintptr_t render_texture_hosts;
uintptr_t upload_staging_textures;
};
/// An arbitrary identifier for a native (OS compositor) surface
struct NativeSurfaceId {
uint64_t _0;
friend std::ostream& operator<<(std::ostream& aStream, const NativeSurfaceId& aInstance) {
return aStream << "{ " << "_0=" << aInstance._0 << " }";
}
bool operator==(const NativeSurfaceId& aOther) const {
return _0 == aOther._0;
}
static const NativeSurfaceId DEBUG_OVERLAY;
};
/// A special id for the native surface that is used for debug / profiler overlays.
constexpr inline const NativeSurfaceId NativeSurfaceId::DEBUG_OVERLAY = NativeSurfaceId{ /* ._0 = */ UINT64_MAX };
using DeviceIntPoint = Point2D<int32_t, DevicePixel>;
/// A 2d size tagged with a unit.
template<typename T, typename U>
struct Size2D {
/// The extent of the element in the `U` units along the `x` axis (usually horizontal).
T width;
/// The extent of the element in the `U` units along the `y` axis (usually vertical).
T height;
friend std::ostream& operator<<(std::ostream& aStream, const Size2D& aInstance) {
return aStream << "{ " << "width=" << aInstance.width << ", "
<< "height=" << aInstance.height << " }";
}
bool operator==(const Size2D& aOther) const {
return width == aOther.width &&
height == aOther.height;
}
};
using DeviceIntSize = Size2D<int32_t, DevicePixel>;
struct NativeTileId {
NativeSurfaceId surface_id;
int32_t x;
int32_t y;
friend std::ostream& operator<<(std::ostream& aStream, const NativeTileId& aInstance) {
return aStream << "{ " << "surface_id=" << aInstance.surface_id << ", "
<< "x=" << aInstance.x << ", "
<< "y=" << aInstance.y << " }";
}
bool operator==(const NativeTileId& aOther) const {
return surface_id == aOther.surface_id &&
x == aOther.x &&
y == aOther.y;
}
static const NativeTileId DEBUG_OVERLAY;
};
/// A special id for the native surface that is used for debug / profiler overlays.
constexpr inline const NativeTileId NativeTileId::DEBUG_OVERLAY = NativeTileId{ /* .surface_id = */ NativeSurfaceId::DEBUG_OVERLAY, /* .x = */ 0, /* .y = */ 0 };
/// A 2d Vector tagged with a unit.
template<typename T, typename U>
struct Vector2D {
/// The `x` (traditionally, horizontal) coordinate.
T x;
/// The `y` (traditionally, vertical) coordinate.
T y;
friend std::ostream& operator<<(std::ostream& aStream, const Vector2D& aInstance) {
return aStream << "{ " << "x=" << aInstance.x << ", "
<< "y=" << aInstance.y << " }";
}
bool operator==(const Vector2D& aOther) const {
return x == aOther.x &&
y == aOther.y;
}
};
struct ScaleOffset {
Vector2D<float, UnknownUnit> scale;
Vector2D<float, UnknownUnit> offset;
friend std::ostream& operator<<(std::ostream& aStream, const ScaleOffset& aInstance) {
return aStream << "{ " << "scale=" << aInstance.scale << ", "
<< "offset=" << aInstance.offset << " }";
}
bool operator==(const ScaleOffset& aOther) const {
return scale == aOther.scale &&
offset == aOther.offset;
}
};
/// The transform type to apply to Compositor surfaces.
using CompositorSurfaceTransform = ScaleOffset;
struct CompositorCapabilities {
/// The virtual surface size used by the underlying platform.
int32_t virtual_surface_size;
/// Whether the compositor requires redrawing on invalidation.
bool redraw_on_invalidation;
/// The maximum number of dirty rects that can be provided per compositor
/// surface update. If this is zero, the entire compositor surface for
/// a given tile will be drawn if it's dirty.
uintptr_t max_update_rects;
/// Whether or not this compositor will create surfaces for backdrops.
bool supports_surface_for_backdrop;
/// Whether external compositor surface supports negative scaling.
bool supports_external_compositor_surface_negative_scaling;
friend std::ostream& operator<<(std::ostream& aStream, const CompositorCapabilities& aInstance) {
return aStream << "{ " << "virtual_surface_size=" << aInstance.virtual_surface_size << ", "
<< "redraw_on_invalidation=" << aInstance.redraw_on_invalidation << ", "
<< "max_update_rects=" << aInstance.max_update_rects << ", "
<< "supports_surface_for_backdrop=" << aInstance.supports_surface_for_backdrop << ", "
<< "supports_external_compositor_surface_negative_scaling=" << aInstance.supports_external_compositor_surface_negative_scaling << " }";
}
bool operator==(const CompositorCapabilities& aOther) const {
return virtual_surface_size == aOther.virtual_surface_size &&
redraw_on_invalidation == aOther.redraw_on_invalidation &&
max_update_rects == aOther.max_update_rects &&
supports_surface_for_backdrop == aOther.supports_surface_for_backdrop &&
supports_external_compositor_surface_negative_scaling == aOther.supports_external_compositor_surface_negative_scaling;
}
};
struct WindowVisibility {
bool is_fully_occluded;
friend std::ostream& operator<<(std::ostream& aStream, const WindowVisibility& aInstance) {
return aStream << "{ " << "is_fully_occluded=" << aInstance.is_fully_occluded << " }";
}
bool operator==(const WindowVisibility& aOther) const {
return is_fully_occluded == aOther.is_fully_occluded;
}
};
/// Descriptor for a locked surface that will be directly composited by SWGL.
struct SWGLCompositeSurfaceInfo {
/// The number of YUV planes in the surface. 0 indicates non-YUV BGRA.
/// 1 is interleaved YUV. 2 is NV12. 3 is planar YUV.
uint32_t yuv_planes;
/// Textures for planes of the surface, or 0 if not applicable.
uint32_t textures[3];
/// Color space of surface if using a YUV format.
YuvRangedColorSpace color_space;
/// Color depth of surface if using a YUV format.
ColorDepth color_depth;
/// The actual source surface size before transformation.
DeviceIntSize size;
friend std::ostream& operator<<(std::ostream& aStream, const SWGLCompositeSurfaceInfo& aInstance) {
return aStream << "{ " << "yuv_planes=" << aInstance.yuv_planes << ", "
<< "textures=" << aInstance.textures << ", "
<< "color_space=" << aInstance.color_space << ", "
<< "color_depth=" << aInstance.color_depth << ", "
<< "size=" << aInstance.size << " }";
}
};
/// A C function that takes a pointer to a heap allocation and returns its size.
///
/// This is borrowed from the malloc_size_of crate, upon which we want to avoid
/// a dependency from WebRender.
using VoidPtrToSizeFn = uintptr_t(*)(const void *ptr);
/// Flags to enable/disable various builtin debugging tools.
struct DebugFlags {
uint32_t _0;
constexpr explicit operator bool() const {
return !!_0;
}
constexpr DebugFlags operator~() const {
return DebugFlags { static_cast<decltype(_0)>(~_0) };
}
constexpr DebugFlags operator|(const DebugFlags& aOther) const {
return DebugFlags { static_cast<decltype(_0)>(this->_0 | aOther._0) };
}
DebugFlags& operator|=(const DebugFlags& aOther) {
*this = (*this | aOther);
return *this;
}
constexpr