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
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Generated with cbindgen:0.16.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`
* a. Alternatively, you can clone `https://github.com/eqrion/cbindgen` and use a tagged release
* 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 {
static const uintptr_t BudgetType_COUNT = 7;
/// 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;
}
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,
/// 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::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;
}
#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;
}
/// 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,
/// Array texture. This maps to GL_TEXTURE_2D_ARRAY in OpenGL. See
/// on Array textures.
Texture2DArray = 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::Texture2DArray: aStream << "Texture2DArray"; 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, byte 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;
}
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,
/// 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::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 TelemetryProbe {
SceneBuildTime = 0,
SceneSwapTime = 1,
FrameBuildTime = 2,
/// Must be last for serialization purposes
Sentinel,
};
inline std::ostream& operator<<(std::ostream& aStream, const TelemetryProbe& aInstance) {
switch (aInstance) {
case TelemetryProbe::SceneBuildTime: aStream << "SceneBuildTime"; break;
case TelemetryProbe::SceneSwapTime: aStream << "SceneSwapTime"; break;
case TelemetryProbe::FrameBuildTime: aStream << "FrameBuildTime"; break;
case TelemetryProbe::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,
Zoom,
/// 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::Zoom: aStream << "Zoom"; 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;
}
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;
/// A set of flags describing why a picture may need a backing surface.
struct ClusterFlags;
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;
struct ItemFlags;
/// Geometry in a stacking context's local coordinate space (logical pixels).
struct LayoutPixel;
/// 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;
/// Startup parameters for the texture cache.
///
/// Texture sizes must be at least 512.
struct TextureCacheConfig;
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;
template<typename T = void>
struct Vec;
/// Geometry in the document's coordinate space (logical pixels).
struct WorldPixel;
struct WrProgramCache;
/// A wrapper around a strong reference to a Shaders object.
struct WrShaders;
struct WrState;
struct WrThreadPool;
struct WrVecU8 {
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;
}
};
/// 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;
}
};
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;
}
};
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;
};
inline const ColorF ColorF::BLACK = ColorF{ /* .r = */ 0.0, /* .g = */ 0.0, /* .b = */ 0.0, /* .a = */ 1.0 };
inline const ColorF ColorF::TRANSPARENT = ColorF{ /* .r = */ 0.0, /* .g = */ 0.0, /* .b = */ 0.0, /* .a = */ 0.0 };
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;
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 << " }";
}
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;
}
};
/// 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 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;
}
};
/// A 2d Rectangle optionally tagged with a unit.
///
/// # Representation
///
/// `Rect` is represented by an origin point and a size.
///
/// See [`Rect`] for a rectangle represented by two endpoints.
///
/// # Empty rectangle
///
/// A rectangle is considered empty (see [`is_empty`]) if any of the following is true:
/// - it's area is empty,
/// - it's area is negative (`size.x < 0` or `size.y < 0`),
/// - it contains NaNs.
///
/// [`is_empty`]: #method.is_empty
/// [`Box2D`]: struct.Box2D.html
template<typename T, typename U>
struct Rect {
Point2D<T, U> origin;
Size2D<T, U> size;
friend std::ostream& operator<<(std::ostream& aStream, const Rect& aInstance) {
return aStream << "{ " << "origin=" << aInstance.origin << ", "
<< "size=" << aInstance.size << " }";
}
bool operator==(const Rect& aOther) const {
return origin == aOther.origin &&
size == aOther.size;
}
};
using DeviceIntRect = Rect<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 render_tasks;
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 gpu_cache_textures;
uintptr_t vertex_data_textures;
uintptr_t render_target_textures;
uintptr_t texture_cache_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;
}
};
using DeviceIntPoint = Point2D<int32_t, DevicePixel>;
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;
}
};
/// A 3d transform stored as a column-major 4 by 4 matrix.
///
/// Transforms can be parametrized over the source and destination units, to describe a
/// transformation from a space to another.
/// For example, `Transform3D<f32, WorldSpace, ScreenSpace>::transform_point3d`
/// takes a `Point3D<f32, WorldSpace>` and returns a `Point3D<f32, ScreenSpace>`.
///
/// Transforms expose a set of convenience methods for pre- and post-transformations.
/// Pre-transformations (`pre_*` methods) correspond to adding an operation that is
/// applied before the rest of the transformation, while post-transformations (`then_*`
/// methods) add an operation that is applied after.
///
/// When translating Transform3D into general matrix representations, consider that the
/// representation follows the column major notation with column vectors.
///
/// ```text
/// |x'| | m11 m12 m13 m14 | |x|
/// |y'| | m21 m22 m23 m24 | |y|
/// |z'| = | m31 m32 m33 m34 | x |y|
/// |w | | m41 m42 m43 m44 | |1|
/// ```
///
/// The translation terms are m41, m42 and m43.
template<typename T, typename Src, typename Dst>
struct Transform3D {
T m11;
T m12;
T m13;
T m14;
T m21;
T m22;
T m23;
T m24;
T m31;
T m32;
T m33;
T m34;
T m41;
T m42;
T m43;
T m44;
friend std::ostream& operator<<(std::ostream& aStream, const Transform3D& aInstance) {
return aStream << "{ " << "m11=" << aInstance.m11 << ", "
<< "m12=" << aInstance.m12 << ", "
<< "m13=" << aInstance.m13 << ", "
<< "m14=" << aInstance.m14 << ", "
<< "m21=" << aInstance.m21 << ", "
<< "m22=" << aInstance.m22 << ", "
<< "m23=" << aInstance.m23 << ", "
<< "m24=" << aInstance.m24 << ", "
<< "m31=" << aInstance.m31 << ", "
<< "m32=" << aInstance.m32 << ", "
<< "m33=" << aInstance.m33 << ", "
<< "m34=" << aInstance.m34 << ", "
<< "m41=" << aInstance.m41 << ", "
<< "m42=" << aInstance.m42 << ", "
<< "m43=" << aInstance.m43 << ", "
<< "m44=" << aInstance.m44 << " }";
}
bool operator==(const Transform3D& aOther) const {
return m11 == aOther.m11 &&
m12 == aOther.m12 &&
m13 == aOther.m13 &&
m14 == aOther.m14 &&
m21 == aOther.m21 &&
m22 == aOther.m22 &&
m23 == aOther.m23 &&
m24 == aOther.m24 &&
m31 == aOther.m31 &&
m32 == aOther.m32 &&
m33 == aOther.m33 &&
m34 == aOther.m34 &&
m41 == aOther.m41 &&
m42 == aOther.m42 &&
m43 == aOther.m43 &&
m44 == aOther.m44;
}
};
/// The transform type to apply to Compositor surfaces.
using CompositorSurfaceTransform = Transform3D<float, DevicePixel, DevicePixel>;
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;
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 << " }";
}
bool operator==(const CompositorCapabilities& aOther) const {
return virtual_surface_size == aOther.virtual_surface_size &&
redraw_on_invalidation == aOther.redraw_on_invalidation;
}
};
/// 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.
YuvColorSpace 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 bits;
explicit operator bool() const {
return !!bits;
}
DebugFlags operator~() const {
return {static_cast<decltype(bits)>(~bits)};
}
DebugFlags operator|(const DebugFlags& aOther) const {
return {static_cast<decltype(bits)>(this->bits | aOther.bits)};
}
DebugFlags& operator|=(const DebugFlags& aOther) {
*this = (*this | aOther);
return *this;
}
DebugFlags operator&(const DebugFlags& aOther) const {
return {static_cast<decltype(bits)>(this->bits & aOther.bits)};
}
DebugFlags& operator&=(const DebugFlags& aOther) {
*this = (*this & aOther);
return *this;
}
DebugFlags operator^(const DebugFlags& aOther) const {
return {static_cast<decltype(bits)>(this->bits ^ aOther.bits)};
}
DebugFlags& operator^=(const DebugFlags& aOther) {
*this = (*this ^ aOther);
return *this;
}
friend std::ostream& operator<<(std::ostream& aStream, const DebugFlags& aInstance) {
return aStream << "{ " << "bits=" << aInstance.bits << " }";
}
bool operator==(const DebugFlags& aOther) const {
return bits == aOther.bits;
}
static const DebugFlags PROFILER_DBG;
static const DebugFlags RENDER_TARGET_DBG;
static const DebugFlags TEXTURE_CACHE_DBG;
static const DebugFlags GPU_TIME_QUERIES;
static const DebugFlags GPU_SAMPLE_QUERIES;
static const DebugFlags DISABLE_BATCHING;
static const DebugFlags EPOCHS;
static const DebugFlags ECHO_DRIVER_MESSAGES;
static const DebugFlags SHOW_OVERDRAW;
static const DebugFlags GPU_CACHE_DBG;
static const DebugFlags TEXTURE_CACHE_DBG_CLEAR_EVICTED;
static const DebugFlags PICTURE_CACHING_DBG;
static const DebugFlags PRIMITIVE_DBG;
static const DebugFlags ZOOM_DBG;
static const DebugFlags SMALL_SCREEN;
static const DebugFlags DISABLE_OPAQUE_PASS;
static const DebugFlags DISABLE_ALPHA_PASS;
static const DebugFlags DISABLE_CLIP_MASKS;
static const DebugFlags DISABLE_TEXT_PRIMS;
static const DebugFlags DISABLE_GRADIENT_PRIMS;
static const DebugFlags OBSCURE_IMAGES;
static const DebugFlags GLYPH_FLASHING;
static const DebugFlags SMART_PROFILER;
static const DebugFlags INVALIDATION_DBG;
static const DebugFlags TILE_CACHE_LOGGING_DBG;
static const DebugFlags PROFILER_CAPTURE;
static const DebugFlags FORCE_PICTURE_INVALIDATION;
static const DebugFlags USE_BATCHED_TEXTURE_UPLOADS;
static const DebugFlags USE_DRAW_CALLS_FOR_TEXTURE_COPY;
};
/// Display the frame profiler on screen.
inline const DebugFlags DebugFlags::PROFILER_DBG = DebugFlags{ /* .bits = */ (uint32_t)(1 << 0) };
/// Display intermediate render targets on screen.
inline const DebugFlags DebugFlags::RENDER_TARGET_DBG = DebugFlags{ /* .bits = */ (uint32_t)(1 << 1) };
/// Display all texture cache pages on screen.
inline const DebugFlags DebugFlags::TEXTURE_CACHE_DBG = DebugFlags{ /* .bits = */ (uint32_t)(1 << 2) };
/// Display GPU timing results.
inline const DebugFlags DebugFlags::GPU_TIME_QUERIES = DebugFlags{ /* .bits = */ (uint32_t)(1 << 3) };
/// Query the number of pixels that pass the depth test divided and show it
/// in the profiler as a percentage of the number of pixels in the screen
/// (window width times height).
inline const DebugFlags DebugFlags::GPU_SAMPLE_QUERIES = DebugFlags{ /* .bits = */ (uint32_t)(1 << 4) };
/// Render each quad with their own draw call.
///
/// Terrible for performance but can help with understanding the drawing
/// order when inspecting renderdoc or apitrace recordings.
inline const DebugFlags DebugFlags::DISABLE_BATCHING = DebugFlags{ /* .bits = */ (uint32_t)(1 << 5) };
/// Display the pipeline epochs.
inline const DebugFlags DebugFlags::EPOCHS = DebugFlags{ /* .bits = */ (uint32_t)(1 << 6) };
/// Print driver messages to stdout.
inline const DebugFlags DebugFlags::ECHO_DRIVER_MESSAGES = DebugFlags{ /* .bits = */ (uint32_t)(1 << 7) };
/// Show an overlay displaying overdraw amount.
inline const DebugFlags DebugFlags::SHOW_OVERDRAW = DebugFlags{ /* .bits = */ (uint32_t)(1 << 8) };
/// Display the contents of GPU cache.
inline const DebugFlags DebugFlags::GPU_CACHE_DBG = DebugFlags{ /* .bits = */ (uint32_t)(1 << 9) };
/// Clear evicted parts of the texture cache for debugging purposes.
inline const DebugFlags DebugFlags::TEXTURE_CACHE_DBG_CLEAR_EVICTED = DebugFlags{ /* .bits = */ (uint32_t)(1 << 10) };
/// Show picture caching debug overlay
inline const DebugFlags DebugFlags::PICTURE_CACHING_DBG = DebugFlags{ /* .bits = */ (uint32_t)(1 << 11) };
/// Highlight all primitives with colors based on kind.
inline const DebugFlags DebugFlags::PRIMITIVE_DBG = DebugFlags{ /* .bits = */ (uint32_t)(1 << 12) };
/// Draw a zoom widget showing part of the framebuffer zoomed in.
inline const DebugFlags DebugFlags::ZOOM_DBG = DebugFlags{ /* .bits = */ (uint32_t)(1 << 13) };
/// Scale the debug renderer down for a smaller screen. This will disrupt
/// any mapping between debug display items and page content, so shouldn't
/// be used with overlays like the picture caching or primitive display.
inline const DebugFlags DebugFlags::SMALL_SCREEN = DebugFlags{ /* .bits = */ (uint32_t)(1 << 14) };
/// Disable various bits of the WebRender pipeline, to help narrow
/// down where slowness might be coming from.
inline const DebugFlags DebugFlags::DISABLE_OPAQUE_PASS = DebugFlags{ /* .bits = */ (uint32_t)(1 << 15) };
///
inline const DebugFlags DebugFlags::DISABLE_ALPHA_PASS = DebugFlags{ /* .bits = */ (uint32_t)(1 << 16) };
///
inline const DebugFlags DebugFlags::DISABLE_CLIP_MASKS = DebugFlags{ /* .bits = */ (uint32_t)(1 << 17) };
///
inline const DebugFlags DebugFlags::DISABLE_TEXT_PRIMS = DebugFlags{ /* .bits = */ (uint32_t)(1 << 18) };
///
inline const DebugFlags DebugFlags::DISABLE_GRADIENT_PRIMS = DebugFlags{ /* .bits = */ (uint32_t)(1 << 19) };
///
inline const DebugFlags DebugFlags::OBSCURE_IMAGES = DebugFlags{ /* .bits = */ (uint32_t)(1 << 20) };
/// Taint the transparent area of the glyphs with a random opacity to easily
/// see when glyphs are re-rasterized.
inline const DebugFlags DebugFlags::GLYPH_FLASHING = DebugFlags{ /* .bits = */ (uint32_t)(1 << 21) };
/// The profiler only displays information that is out of the ordinary.
inline const DebugFlags DebugFlags::SMART_PROFILER = DebugFlags{ /* .bits = */ (uint32_t)(1 << 22) };
/// If set, dump picture cache invalidation debug to console.
inline const DebugFlags DebugFlags::INVALIDATION_DBG = DebugFlags{ /* .bits = */ (uint32_t)(1 << 23) };
/// Log tile cache to memory for later saving as part of wr-capture
inline const DebugFlags DebugFlags::TILE_CACHE_LOGGING_DBG = DebugFlags{ /* .bits = */ (uint32_t)(1 << 24) };
/// Collect and dump profiler statistics to captures.
inline const DebugFlags DebugFlags::PROFILER_CAPTURE = DebugFlags{ /* .bits = */ (uint32_t)((uint32_t)1 << 25) };
/// Invalidate picture tiles every frames (useful when inspecting GPU work in external tools).
inline const DebugFlags DebugFlags::FORCE_PICTURE_INVALIDATION = DebugFlags{ /* .bits = */ (uint32_t)((uint32_t)1 << 26) };
inline const DebugFlags DebugFlags::USE_BATCHED_TEXTURE_UPLOADS = DebugFlags{ /* .bits = */ (uint32_t)((uint32_t)1 << 27) };
inline const DebugFlags DebugFlags::USE_DRAW_CALLS_FOR_TEXTURE_COPY = DebugFlags{ /* .bits = */ (uint32_t)((uint32_t)1 << 28) };
using LayoutSize = Size2D<float, LayoutPixel>;
/// Describes the memory layout of a display list.
///
/// A display list consists of some number of display list items, followed by a number of display
/// items.
struct BuiltDisplayListDescriptor {
/// The first IPC time stamp: before any work has been done
uint64_t builder_start_time;
/// The second IPC time stamp: after serialization
uint64_t builder_finish_time;
/// The third IPC time stamp: just before sending
uint64_t send_start_time;
/// The amount of clipping nodes created while building this display list.
uintptr_t total_clip_nodes;
/// The amount of spatial nodes created while building this display list.
uintptr_t total_spatial_nodes;
/// The size of the cache for this display list.
uintptr_t cache_size;
/// The offset for additional display list data.
uintptr_t extra_data_offset;
friend std::ostream& operator<<(std::ostream& aStream, const BuiltDisplayListDescriptor& aInstance) {
return aStream << "{ " << "builder_start_time=" << aInstance.builder_start_time << ", "
<< "builder_finish_time=" << aInstance.builder_finish_time << ", "
<< "send_start_time=" << aInstance.send_start_time << ", "
<< "total_clip_nodes=" << aInstance.total_clip_nodes << ", "
<< "total_spatial_nodes=" << aInstance.total_spatial_nodes << ", "
<< "cache_size=" << aInstance.cache_size << ", "
<< "extra_data_offset=" << aInstance.extra_data_offset << " }";
}
bool operator==(const BuiltDisplayListDescriptor& aOther) const {
return builder_start_time == aOther.builder_start_time &&
builder_finish_time == aOther.builder_finish_time &&
send_start_time == aOther.send_start_time &&
total_clip_nodes == aOther.total_clip_nodes &&
total_spatial_nodes == aOther.total_spatial_nodes &&
cache_size == aOther.cache_size &&
extra_data_offset == aOther.extra_data_offset;
}
};
template<typename T>
struct WrAnimationPropertyValue {
uint64_t id;
T value;
friend std::ostream& operator<<(std::ostream& aStream, const WrAnimationPropertyValue& aInstance) {
return aStream << "{ " << "id=" << aInstance.id << ", "
<< "value=" << aInstance.value << " }";
}
};
using WrOpacityProperty = WrAnimationPropertyValue<float>;
using LayoutTransform = Transform3D<float, LayoutPixel, LayoutPixel>;
using WrTransformProperty = WrAnimationPropertyValue<LayoutTransform>;
using WrColorProperty = WrAnimationPropertyValue<ColorF>;
using LayoutPoint = Point2D<float, LayoutPixel>;
/// An opaque identifier describing an image registered with WebRender.
/// This is used as a handle to reference images, and is used as the
/// hash map key for the actual image storage in the `ResourceCache`.
struct ImageKey {
IdNamespace mNamespace;
uint32_t mHandle;
friend std::ostream& operator<<(std::ostream& aStream, const ImageKey& aInstance) {
return aStream << "{ " << "mNamespace=" << aInstance.mNamespace << ", "
<< "mHandle=" << aInstance.mHandle << " }";
}
bool operator==(const ImageKey& aOther) const {
return mNamespace == aOther.mNamespace &&
mHandle == aOther.mHandle;
}
bool operator!=(const ImageKey& aOther) const {
return mNamespace != aOther.mNamespace ||
mHandle != aOther.mHandle;
}
};
using WrImageKey = ImageKey;
struct WrImageDescriptor {
ImageFormat format;
int32_t width;
int32_t height;
int32_t stride;
OpacityType opacity;
bool prefer_compositor_surface;
friend std::ostream& operator<<(std::ostream& aStream, const WrImageDescriptor& aInstance) {
return aStream << "{ " << "format=" << aInstance.format << ", "
<< "width=" << aInstance.width << ", "
<< "height=" << aInstance.height << ", "
<< "stride=" << aInstance.stride << ", "
<< "opacity=" << aInstance.opacity << ", "
<< "prefer_compositor_surface=" << aInstance.prefer_compositor_surface << " }";
}
bool operator==(const WrImageDescriptor& aOther) const {
return format == aOther.format &&
width == aOther.width &&
height == aOther.height &&
stride == aOther.stride &&
opacity == aOther.opacity &&
prefer_compositor_surface == aOther.prefer_compositor_surface;
}
};
/// An opaque identifier describing a blob image registered with WebRender.
/// This is used as a handle to reference blob images, and can be used as an
/// image in display items.
struct BlobImageKey {
ImageKey _0;
friend std::ostream& operator<<(std::ostream& aStream, const BlobImageKey& aInstance) {
return aStream << "{ " << "_0=" << aInstance._0 << " }";
}
bool operator==(const BlobImageKey& aOther) const {
return _0 == aOther._0;
}
};
/// Storage format identifier for externally-managed images.
union ExternalImageType {
enum class Tag : uint8_t {
/// The image is texture-backed.
TextureHandle,
/// The image is heap-allocated by the embedding.
Buffer,
/// Must be last for serialization purposes
Sentinel,
};
friend std::ostream& operator<<(std::ostream& aStream, const Tag& aInstance) {
using Tag = ExternalImageType::Tag;
switch (aInstance) {
case Tag::TextureHandle: aStream << "TextureHandle"; break;
case Tag::Buffer: aStream << "Buffer"; break;
case Tag::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
friend std::ostream& operator<<(std::ostream& aStream, const ExternalImageType& aInstance) {
using Tag = ExternalImageType::Tag;
switch (aInstance.tag) {
case Tag::TextureHandle: aStream << aInstance.texture_handle; break;
case Tag::Buffer: aStream << "Buffer"; break;
case Tag::Sentinel: aStream << "Sentinel"; break;
}
return aStream;
}
struct TextureHandle_Body {
Tag tag;
ImageBufferKind _0;
friend std::ostream& operator<<(std::ostream& aStream, const TextureHandle_Body& aInstance) {
return aStream << "{ " << "tag=" << aInstance.tag << ", "
<< "_0=" << aInstance._0 << " }";
}
bool operator==(const TextureHandle_Body& aOther) const {
return _0 == aOther._0;
}
};
struct {
Tag tag;
};
TextureHandle_Body texture_handle;
static ExternalImageType TextureHandle(const ImageBufferKind &a0) {
ExternalImageType result;
::new (&result.texture_handle._0) (ImageBufferKind)(a0);
result.tag = Tag::TextureHandle;
return result;
}
bool IsTextureHandle() const {
return tag == Tag::TextureHandle;
}
static ExternalImageType Buffer() {
ExternalImageType result;
result.tag = Tag::Buffer;
return result;
}
bool IsBuffer() const {
return tag == Tag::Buffer;
}
static ExternalImageType Sentinel() {
ExternalImageType result;
result.tag = Tag::Sentinel;
return result;
}
bool IsSentinel() const {
return tag == Tag::Sentinel;
}
bool operator==(const ExternalImageType& aOther) const {
if (tag != aOther.tag) {
return false;
}
switch (tag) {
case Tag::TextureHandle: return texture_handle == aOther.texture_handle;
default: break;
}
return true;
}
};
using LayoutIntRect = Rect<int32_t, LayoutPixel>;
struct FontKey {
IdNamespace mNamespace;
uint32_t mHandle;
friend std::ostream& operator<<(std::ostream& aStream, const FontKey& aInstance) {
return aStream << "{ " << "mNamespace=" << aInstance.mNamespace << ", "
<< "mHandle=" << aInstance.mHandle << " }";
}
bool operator==(const FontKey& aOther) const {
return mNamespace == aOther.mNamespace &&
mHandle == aOther.mHandle;
}
};
using WrFontKey = FontKey;
struct FontInstanceKey {
IdNamespace mNamespace;
uint32_t mHandle;
friend std::ostream& operator<<(std::ostream& aStream, const FontInstanceKey& aInstance) {
return aStream << "{ " << "mNamespace=" << aInstance.mNamespace << ", "
<< "mHandle=" << aInstance.mHandle << " }";
}
bool operator==(const FontInstanceKey& aOther) const {
return mNamespace == aOther.mNamespace &&
mHandle == aOther.mHandle;
}
};
using WrFontInstanceKey = FontInstanceKey;
struct FontInstanceFlags {
uint32_t bits;
explicit operator bool() const {
return !!bits;
}
FontInstanceFlags operator~() const {
return {static_cast<decltype(bits)>(~bits)};
}
FontInstanceFlags operator|(const FontInstanceFlags& aOther) const {
return {static_cast<decltype(bits)>(this->bits | aOther.bits)};
}
FontInstanceFlags& operator|=(const FontInstanceFlags& aOther) {
*this = (*this | aOther);
return *this;
}
FontInstanceFlags operator&(const FontInstanceFlags& aOther) const {
return {static_cast<decltype(bits)>(this->bits & aOther.bits)};
}
FontInstanceFlags& operator&=(const FontInstanceFlags& aOther) {
*this = (*this & aOther);
return *this;
}
FontInstanceFlags operator^(const FontInstanceFlags& aOther) const {
return {static_cast<decltype(bits)>(this->bits ^ aOther.bits)};
}
FontInstanceFlags& operator^=(const FontInstanceFlags& aOther) {
*this = (*this ^ aOther);
return *this;
}
friend std::ostream& operator<<(std::ostream& aStream, const FontInstanceFlags& aInstance) {
return aStream << "{ " << "bits=" << aInstance.bits << " }";
}
bool operator==(const FontInstanceFlags& aOther) const {
return bits == aOther.bits;
}
static const FontInstanceFlags SYNTHETIC_BOLD;
static const FontInstanceFlags EMBEDDED_BITMAPS;
static const FontInstanceFlags SUBPIXEL_BGR;
static const FontInstanceFlags TRANSPOSE;
static const FontInstanceFlags FLIP_X;
static const FontInstanceFlags FLIP_Y;
static const FontInstanceFlags SUBPIXEL_POSITION;
static const FontInstanceFlags VERTICAL;
static const FontInstanceFlags TRANSFORM_GLYPHS;
static const FontInstanceFlags TEXTURE_PADDING;
static const FontInstanceFlags FORCE_GDI;
static const FontInstanceFlags FORCE_SYMMETRIC;
static const FontInstanceFlags NO_SYMMETRIC;
static const FontInstanceFlags FONT_SMOOTHING;
static const FontInstanceFlags FORCE_AUTOHINT;
static const FontInstanceFlags NO_AUTOHINT;
static const FontInstanceFlags VERTICAL_LAYOUT;
static const FontInstanceFlags LCD_VERTICAL;
};
inline const FontInstanceFlags FontInstanceFlags::SYNTHETIC_BOLD = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 1) };
inline const FontInstanceFlags FontInstanceFlags::EMBEDDED_BITMAPS = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 2) };
inline const FontInstanceFlags FontInstanceFlags::SUBPIXEL_BGR = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 3) };
inline const FontInstanceFlags FontInstanceFlags::TRANSPOSE = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 4) };
inline const FontInstanceFlags FontInstanceFlags::FLIP_X = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 5) };
inline const FontInstanceFlags FontInstanceFlags::FLIP_Y = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 6) };
inline const FontInstanceFlags FontInstanceFlags::SUBPIXEL_POSITION = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 7) };
inline const FontInstanceFlags FontInstanceFlags::VERTICAL = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 8) };
inline const FontInstanceFlags FontInstanceFlags::TRANSFORM_GLYPHS = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 12) };
inline const FontInstanceFlags FontInstanceFlags::TEXTURE_PADDING = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 13) };
inline const FontInstanceFlags FontInstanceFlags::FORCE_GDI = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 16) };
inline const FontInstanceFlags FontInstanceFlags::FORCE_SYMMETRIC = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 17) };
inline const FontInstanceFlags FontInstanceFlags::NO_SYMMETRIC = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 18) };
inline const FontInstanceFlags FontInstanceFlags::FONT_SMOOTHING = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 16) };
inline const FontInstanceFlags FontInstanceFlags::FORCE_AUTOHINT = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 16) };
inline const FontInstanceFlags FontInstanceFlags::NO_AUTOHINT = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 17) };
inline const FontInstanceFlags FontInstanceFlags::VERTICAL_LAYOUT = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 18) };
inline const FontInstanceFlags FontInstanceFlags::LCD_VERTICAL = FontInstanceFlags{ /* .bits = */ (uint32_t)(1 << 19) };
/// Represents RGBA screen colors with one byte per channel.
///
/// If the alpha value `a` is 255 the color is opaque.
struct ColorU {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
friend std::ostream& operator<<(std::ostream& aStream, const ColorU& aInstance) {
return aStream << "{ " << "r=" << aInstance.r << ", "
<< "g=" << aInstance.g << ", "
<< "b=" << aInstance.b << ", "
<< "a=" << aInstance.a << " }";
}
bool operator==(const ColorU& aOther) const {
return r == aOther.r &&
g == aOther.g &&
b == aOther.b &&
a == aOther.a;
}
};
struct SyntheticItalics {
int16_t angle;
friend std::ostream& operator<<(std::ostream& aStream, const SyntheticItalics& aInstance) {
return aStream << "{ " << "angle=" << aInstance.angle << " }";
}
bool operator==(const SyntheticItalics& aOther) const {
return angle == aOther.angle;
}
static const float ANGLE_SCALE;
};
inline const float SyntheticItalics::ANGLE_SCALE = 256.0;
struct FontInstanceOptions {
FontRenderMode render_mode;
FontInstanceFlags flags;
/// When bg_color.a is != 0 and render_mode is FontRenderMode::Subpixel,
/// the text will be rendered with bg_color.r/g/b as an opaque estimated
/// background color.
ColorU bg_color;
SyntheticItalics synthetic_italics;
friend std::ostream& operator<<(std::ostream& aStream, const FontInstanceOptions& aInstance) {
return aStream << "{ " << "render_mode=" << aInstance.render_mode << ", "
<< "flags=" << aInstance.flags << ", "
<< "bg_color=" << aInstance.bg_color << ", "
<< "synthetic_italics=" << aInstance.synthetic_italics << " }";
}
bool operator==(const FontInstanceOptions& aOther) const {
return render_mode == aOther.render_mode &&
flags == aOther.flags &&
bg_color == aOther.bg_color &&
synthetic_italics == aOther.synthetic_italics;
}
};
#if defined(XP_WIN)
struct FontInstancePlatformOptions {
uint16_t gamma;
uint8_t contrast;
uint8_t cleartype_level;
friend std::ostream& operator<<(std::ostream& aStream, const FontInstancePlatformOptions& aInstance) {
return aStream << "{ " << "gamma=" << aInstance.gamma << ", "
<< "contrast=" << aInstance.contrast << ", "
<< "cleartype_level=" << aInstance.cleartype_level << " }";
}
bool operator==(const FontInstancePlatformOptions& aOther) const {
return gamma == aOther.gamma &&
contrast == aOther.contrast &&
cleartype_level == aOther.cleartype_level;
}
};
#endif
#if defined(XP_MACOSX)
struct FontInstancePlatformOptions {
uint32_t unused;
friend std::ostream& operator<<(std::ostream& aStream, const FontInstancePlatformOptions& aInstance) {
return aStream << "{ " << "unused=" << aInstance.unused << " }";
}
bool operator==(const