From f553129f78cde7b5841871bdbae619c709089a0a Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 29 Sep 2023 08:20:59 +0000 Subject: [PATCH] Bug 1855870 - Upgrade webrender to bitflags 2. r=gfx-reviewers,gw Differential Revision: https://phabricator.services.mozilla.com/D189605 --- Cargo.lock | 6 +-- gfx/thebes/gfxPlatform.cpp | 2 +- gfx/wr/Cargo.lock | 51 +++++++++++-------- gfx/wr/servo-tidy.toml | 2 + gfx/wr/webrender/Cargo.toml | 2 +- gfx/wr/webrender/src/batch.rs | 1 + gfx/wr/webrender/src/clip.rs | 10 ++-- gfx/wr/webrender/src/command_buffer.rs | 2 + gfx/wr/webrender/src/composite.rs | 1 + gfx/wr/webrender/src/device/gl.rs | 2 +- gfx/wr/webrender/src/gpu_types.rs | 20 ++++---- gfx/wr/webrender/src/picture.rs | 3 ++ gfx/wr/webrender/src/render_api.rs | 2 + gfx/wr/webrender/src/renderer/mod.rs | 2 +- gfx/wr/webrender/src/scene_building.rs | 1 + gfx/wr/webrender/src/segment.rs | 29 ++++++----- gfx/wr/webrender/src/visibility.rs | 1 + gfx/wr/webrender_api/Cargo.toml | 2 +- gfx/wr/webrender_api/src/display_item.rs | 16 +++--- gfx/wr/webrender_api/src/font.rs | 8 +-- gfx/wr/webrender_api/src/image.rs | 2 +- gfx/wr/webrender_api/src/lib.rs | 20 +++++--- gfx/wr/webrender_build/Cargo.toml | 2 +- gfx/wr/webrender_build/src/shader_features.rs | 2 +- widget/windows/nsWindow.cpp | 2 +- widget/windows/nsWindowGfx.cpp | 6 +-- 26 files changed, 118 insertions(+), 79 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f7498ff2b4be..78a67a7cca8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6223,7 +6223,7 @@ name = "webrender" version = "0.62.0" dependencies = [ "bincode", - "bitflags 1.999.999", + "bitflags 2.4.0", "build-parallel", "byteorder", "derive_more 0.99.999", @@ -6260,7 +6260,7 @@ name = "webrender_api" version = "0.62.0" dependencies = [ "app_units", - "bitflags 1.999.999", + "bitflags 2.4.0", "byteorder", "crossbeam-channel", "euclid", @@ -6307,7 +6307,7 @@ dependencies = [ name = "webrender_build" version = "0.0.2" dependencies = [ - "bitflags 1.999.999", + "bitflags 2.4.0", "lazy_static", "serde", ] diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 1b19f6ebb54d..d7c03b967f89 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -574,7 +574,7 @@ static void WebRenderDebugPrefChangeCallback(const char* aPrefName, void*) { wr::DebugFlags::WINDOW_VISIBILITY_DBG) GFX_WEBRENDER_DEBUG(".restrict-blob-size", wr::DebugFlags::RESTRICT_BLOB_SIZE) #undef GFX_WEBRENDER_DEBUG - gfx::gfxVars::SetWebRenderDebugFlags(flags.bits); + gfx::gfxVars::SetWebRenderDebugFlags(flags._0); } static void WebRenderQualityPrefChangeCallback(const char* aPref, void*) { diff --git a/gfx/wr/Cargo.lock b/gfx/wr/Cargo.lock index b7a18a97846a..6709627f51a5 100644 --- a/gfx/wr/Cargo.lock +++ b/gfx/wr/Cargo.lock @@ -178,6 +178,15 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +dependencies = [ + "serde", +] + [[package]] name = "bitvec" version = "0.19.6" @@ -333,7 +342,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b" dependencies = [ "atty", - "bitflags", + "bitflags 1.3.2", "clap_lex", "indexmap", "strsim", @@ -366,7 +375,7 @@ version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f63902e9223530efb4e26ccd0cf55ec30d592d3b42e21a28defc42a9586e832" dependencies = [ - "bitflags", + "bitflags 1.3.2", "block", "cocoa-foundation", "core-foundation 0.9.2", @@ -382,7 +391,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318" dependencies = [ - "bitflags", + "bitflags 1.3.2", "block", "core-foundation 0.9.2", "core-graphics-types", @@ -460,7 +469,7 @@ version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation 0.7.0", "foreign-types 0.3.2", "libc", @@ -472,7 +481,7 @@ version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation 0.9.2", "core-graphics-types", "foreign-types 0.3.2", @@ -485,7 +494,7 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "970a29baf4110c26fedbc7f82107d42c23f7e88e404c4577ed73fe99ff85a212" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation 0.9.2", "core-graphics-types", "foreign-types 0.5.0", @@ -498,7 +507,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bb142d41022986c1d8ff29103a1411c8a3dfad3552f87a4f8dc50d61d4f4e33" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation 0.9.2", "libc", ] @@ -1518,7 +1527,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447a296f7aca299cfbb50f4e4f3d49451549af655fb7215d7f8c0c3d64bad42b" dependencies = [ - "bitflags", + "bitflags 1.3.2", "byteorder", "libc", "lmdb-rkv-sys", @@ -1688,7 +1697,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d868f654c72e75f8687572699cdabe755f03effbb62542768e995d5b8d699d" dependencies = [ - "bitflags", + "bitflags 1.3.2", "jni-sys", "ndk-sys", "num_enum", @@ -1747,7 +1756,7 @@ version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cc", "cfg-if 1.0.0", "libc", @@ -2055,7 +2064,7 @@ version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "910f09135b1ed14bb16be445a8c23ddf0777eca485fbfc7cee00d81fecab158a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crc32fast", "deflate", "inflate", @@ -2214,7 +2223,7 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -2253,7 +2262,7 @@ checksum = "9f0ea3af1393b22f8fe25615b6fa5d13072b7b622e66acffc8b12b2baa0342b1" dependencies = [ "arrayref", "bincode", - "bitflags", + "bitflags 1.3.2", "byteorder", "id-arena", "lazy_static", @@ -2275,7 +2284,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "300a51053b1cb55c80b7a9fde4120726ddf25ca241a1cbb926626f62fb136bff" dependencies = [ "base64", - "bitflags", + "bitflags 1.3.2", "serde", ] @@ -2452,7 +2461,7 @@ version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a28f16a97fa0e8ce563b2774d1e732dd5d4025d2772c5dba0a41a0f90a29da3" dependencies = [ - "bitflags", + "bitflags 1.3.2", "calloop", "dlib", "lazy_static", @@ -2958,7 +2967,7 @@ version = "0.29.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91223460e73257f697d9e23d401279123d36039a3f7a449e983f123292d4458f" dependencies = [ - "bitflags", + "bitflags 1.3.2", "downcast-rs", "libc", "nix", @@ -3007,7 +3016,7 @@ version = "0.29.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60147ae23303402e41fe034f74fb2c35ad0780ee88a1c40ac09a3be1e7465741" dependencies = [ - "bitflags", + "bitflags 1.3.2", "wayland-client", "wayland-commons", "wayland-scanner", @@ -3050,7 +3059,7 @@ name = "webrender" version = "0.62.0" dependencies = [ "bincode", - "bitflags", + "bitflags 2.4.0", "build-parallel", "byteorder", "derive_more", @@ -3105,7 +3114,7 @@ name = "webrender_api" version = "0.62.0" dependencies = [ "app_units", - "bitflags", + "bitflags 2.4.0", "byteorder", "crossbeam-channel", "euclid", @@ -3122,7 +3131,7 @@ dependencies = [ name = "webrender_build" version = "0.0.2" dependencies = [ - "bitflags", + "bitflags 2.4.0", "lazy_static", "serde", ] @@ -3250,7 +3259,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b43cc931d58b99461188607efd7acb2a093e65fc621f54cad78517a6063e73a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cocoa", "core-foundation 0.9.2", "core-graphics 0.22.3", diff --git a/gfx/wr/servo-tidy.toml b/gfx/wr/servo-tidy.toml index 65023b8b7722..442c407fcaa7 100644 --- a/gfx/wr/servo-tidy.toml +++ b/gfx/wr/servo-tidy.toml @@ -6,6 +6,8 @@ check-alphabetical-order = false [ignore] # Ignored packages with duplicated versions packages = [ + # transition to bitflags 2 is underway. + "bitflags", "cfg-if", "core-foundation", "core-foundation-sys", diff --git a/gfx/wr/webrender/Cargo.toml b/gfx/wr/webrender/Cargo.toml index bb7cea661f8e..4c906e7d9069 100644 --- a/gfx/wr/webrender/Cargo.toml +++ b/gfx/wr/webrender/Cargo.toml @@ -28,7 +28,7 @@ webrender_build = { version = "0.0.2", path = "../webrender_build" } [dependencies] bincode = "1.0" -bitflags = "1.2" +bitflags = { version = "2", features = ["serde"] } byteorder = "1.0" euclid = { version = "0.22.0", features = ["serde"] } fxhash = "0.2.1" diff --git a/gfx/wr/webrender/src/batch.rs b/gfx/wr/webrender/src/batch.rs index 89893c595c0f..fbd617d8b347 100644 --- a/gfx/wr/webrender/src/batch.rs +++ b/gfx/wr/webrender/src/batch.rs @@ -523,6 +523,7 @@ bitflags! { /// Not all shaders necessarily implement all of these features. #[cfg_attr(feature = "capture", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] + #[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct BatchFeatures: u8 { const ALPHA_PASS = 1 << 0; const ANTIALIASING = 1 << 1; diff --git a/gfx/wr/webrender/src/clip.rs b/gfx/wr/webrender/src/clip.rs index 7b107deb98ec..83ed9255b6d4 100644 --- a/gfx/wr/webrender/src/clip.rs +++ b/gfx/wr/webrender/src/clip.rs @@ -892,11 +892,13 @@ impl From for ClipNode { } // Flags that are attached to instances of clip nodes. +#[cfg_attr(feature = "capture", derive(Serialize))] +#[cfg_attr(feature = "replay", derive(Deserialize))] +#[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, MallocSizeOf)] +pub struct ClipNodeFlags(u8); + bitflags! { - #[cfg_attr(feature = "capture", derive(Serialize))] - #[cfg_attr(feature = "replay", derive(Deserialize))] - #[derive(MallocSizeOf)] - pub struct ClipNodeFlags: u8 { + impl ClipNodeFlags : u8 { const SAME_SPATIAL_NODE = 0x1; const SAME_COORD_SYSTEM = 0x2; const USE_FAST_PATH = 0x4; diff --git a/gfx/wr/webrender/src/command_buffer.rs b/gfx/wr/webrender/src/command_buffer.rs index 3961e329fdb1..c0630db0543f 100644 --- a/gfx/wr/webrender/src/command_buffer.rs +++ b/gfx/wr/webrender/src/command_buffer.rs @@ -71,6 +71,7 @@ bitflags! { #[repr(transparent)] #[cfg_attr(feature = "capture", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] + #[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct QuadFlags : u8 { const IS_OPAQUE = 1 << 0; @@ -93,6 +94,7 @@ bitflags! { #[repr(transparent)] #[cfg_attr(feature = "capture", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] + #[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct MaskFlags : i32 { const PRIM_SPACE = 1 << 0; } diff --git a/gfx/wr/webrender/src/composite.rs b/gfx/wr/webrender/src/composite.rs index 7959e8d5df79..5d0260157330 100644 --- a/gfx/wr/webrender/src/composite.rs +++ b/gfx/wr/webrender/src/composite.rs @@ -108,6 +108,7 @@ pub enum CompositeSurfaceFormat { bitflags! { /// Optional features that can be opted-out of when compositing, /// possibly allowing a fast path to be selected. + #[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct CompositeFeatures: u8 { // UV coordinates do not require clamping, for example because the // entire texture is being composited. diff --git a/gfx/wr/webrender/src/device/gl.rs b/gfx/wr/webrender/src/device/gl.rs index 9a9d30b521a8..3ce8a3b9f799 100644 --- a/gfx/wr/webrender/src/device/gl.rs +++ b/gfx/wr/webrender/src/device/gl.rs @@ -416,7 +416,7 @@ impl ExternalTexture { } bitflags! { - #[derive(Default)] + #[derive(Default, Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct TextureFlags: u32 { /// This texture corresponds to one of the shared texture caches. const IS_SHARED_TEXTURE_CACHE = 1 << 0; diff --git a/gfx/wr/webrender/src/gpu_types.rs b/gfx/wr/webrender/src/gpu_types.rs index 7f74c89f9ce5..8ff7fc66f767 100644 --- a/gfx/wr/webrender/src/gpu_types.rs +++ b/gfx/wr/webrender/src/gpu_types.rs @@ -605,16 +605,18 @@ pub struct MaskInstance { } -bitflags! { - // Note: This can use up to 12 bits due to how it will - // be packed in the instance data. +// Note: This can use up to 12 bits due to how it will +// be packed in the instance data. - /// Flags that define how the common brush shader - /// code should process this instance. - #[cfg_attr(feature = "capture", derive(Serialize))] - #[cfg_attr(feature = "replay", derive(Deserialize))] - #[derive(MallocSizeOf)] - pub struct BrushFlags: u16 { +/// Flags that define how the common brush shader +/// code should process this instance. +#[cfg_attr(feature = "capture", derive(Serialize))] +#[cfg_attr(feature = "replay", derive(Deserialize))] +#[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, MallocSizeOf)] +pub struct BrushFlags(u16); + +bitflags! { + impl BrushFlags: u16 { /// Apply perspective interpolation to UVs const PERSPECTIVE_INTERPOLATION = 1; /// Do interpolation relative to segment rect, diff --git a/gfx/wr/webrender/src/picture.rs b/gfx/wr/webrender/src/picture.rs index 55a4ef19bb4b..10d7dbffa47d 100644 --- a/gfx/wr/webrender/src/picture.rs +++ b/gfx/wr/webrender/src/picture.rs @@ -3962,6 +3962,7 @@ pub struct RasterConfig { bitflags! { /// A set of flags describing why a picture may need a backing surface. #[cfg_attr(feature = "capture", derive(Serialize))] + #[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct BlitReason: u32 { /// Mix-blend-mode on a child that requires isolation. const ISOLATE = 1; @@ -4219,6 +4220,7 @@ pub struct OrderedPictureChild { bitflags! { /// A set of flags describing why a picture may need a backing surface. #[cfg_attr(feature = "capture", derive(Serialize))] + #[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct ClusterFlags: u32 { /// Whether this cluster is visible when the position node is a backface. const IS_BACKFACE_VISIBLE = 1; @@ -4424,6 +4426,7 @@ impl PrimitiveList { bitflags! { #[cfg_attr(feature = "capture", derive(Serialize))] /// Flags describing properties for a given PicturePrimitive + #[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct PictureFlags : u8 { /// This picture is a resolve target (doesn't actually render content itself, /// will have content copied in to it) diff --git a/gfx/wr/webrender/src/render_api.rs b/gfx/wr/webrender/src/render_api.rs index 6180e45ac119..f99033ed664c 100644 --- a/gfx/wr/webrender/src/render_api.rs +++ b/gfx/wr/webrender/src/render_api.rs @@ -832,6 +832,7 @@ impl fmt::Debug for FrameMsg { bitflags!{ /// Bit flags for WR stages to store in a capture. // Note: capturing `FRAME` without `SCENE` is not currently supported. + #[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct CaptureBits: u8 { /// const SCENE = 0x1; @@ -846,6 +847,7 @@ bitflags!{ bitflags!{ /// Mask for clearing caches in debug commands. + #[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct ClearCache: u8 { /// const IMAGES = 0b1; diff --git a/gfx/wr/webrender/src/renderer/mod.rs b/gfx/wr/webrender/src/renderer/mod.rs index 085b37ea5ff3..ac15eae8870c 100644 --- a/gfx/wr/webrender/src/renderer/mod.rs +++ b/gfx/wr/webrender/src/renderer/mod.rs @@ -5484,7 +5484,7 @@ impl Renderer { bitflags! { /// Flags that control how shaders are pre-cached, if at all. - #[derive(Default)] + #[derive(Default, Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct ShaderPrecacheFlags: u32 { /// Needed for const initialization const EMPTY = 0; diff --git a/gfx/wr/webrender/src/scene_building.rs b/gfx/wr/webrender/src/scene_building.rs index 8d926c135c91..3616310afd1a 100644 --- a/gfx/wr/webrender/src/scene_building.rs +++ b/gfx/wr/webrender/src/scene_building.rs @@ -417,6 +417,7 @@ impl PictureChainBuilder { bitflags! { /// Slice flags + #[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct SliceFlags : u8 { /// Slice created by a prim that has PrimitiveFlags::IS_SCROLLBAR_CONTAINER const IS_SCROLLBAR = 1; diff --git a/gfx/wr/webrender/src/segment.rs b/gfx/wr/webrender/src/segment.rs index 55e76f33f27a..31385d0cabec 100644 --- a/gfx/wr/webrender/src/segment.rs +++ b/gfx/wr/webrender/src/segment.rs @@ -59,20 +59,22 @@ use smallvec::SmallVec; // clip mask overhead, and possibly exceeding the maximum row size of the GPU cache. const MAX_SEGMENTS: usize = 64; -bitflags! { - // Note: This can use up to 4 bits due to how it will be packed in - // the instance data. +// Note: This can use up to 4 bits due to how it will be packed in +// the instance data. - /// 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. - #[cfg_attr(feature = "capture", derive(Serialize))] - #[cfg_attr(feature = "replay", derive(Deserialize))] - #[derive(MallocSizeOf)] - pub struct EdgeAaSegmentMask: u8 { +/// 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. +#[cfg_attr(feature = "capture", derive(Serialize))] +#[cfg_attr(feature = "replay", derive(Deserialize))] +#[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, MallocSizeOf)] +pub struct EdgeAaSegmentMask(u8); + +bitflags! { + impl EdgeAaSegmentMask: u8 { /// const LEFT = 0x1; /// @@ -85,6 +87,7 @@ bitflags! { } bitflags! { + #[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct ItemFlags: u8 { const X_ACTIVE = 0x1; const Y_ACTIVE = 0x2; diff --git a/gfx/wr/webrender/src/visibility.rs b/gfx/wr/webrender/src/visibility.rs index 06e9076a1050..39922d850bf2 100644 --- a/gfx/wr/webrender/src/visibility.rs +++ b/gfx/wr/webrender/src/visibility.rs @@ -72,6 +72,7 @@ bitflags! { // TODO(gw): We should also move `is_compositor_surface` to be part of // this flags struct. #[cfg_attr(feature = "capture", derive(Serialize))] + #[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct PrimitiveVisibilityFlags: u8 { /// Implies that this primitive covers the entire picture cache slice, /// and can thus be dropped during batching and drawn with clear color. diff --git a/gfx/wr/webrender_api/Cargo.toml b/gfx/wr/webrender_api/Cargo.toml index 758a67b08272..a679fe1e5b5a 100644 --- a/gfx/wr/webrender_api/Cargo.toml +++ b/gfx/wr/webrender_api/Cargo.toml @@ -15,7 +15,7 @@ display_list_stats = [] [dependencies] app_units = "0.7.3" -bitflags = "1.2" +bitflags = { version = "2", features = ["serde"] } byteorder = "1.2.1" euclid = { version = "0.22.6", features = ["serde"] } malloc_size_of_derive = "0.1" diff --git a/gfx/wr/webrender_api/src/display_item.rs b/gfx/wr/webrender_api/src/display_item.rs index 675386cfaece..4b7d4c5a8da4 100644 --- a/gfx/wr/webrender_api/src/display_item.rs +++ b/gfx/wr/webrender_api/src/display_item.rs @@ -34,10 +34,12 @@ pub type ItemTag = (u64, u16); /// refers to individual display items, but this may change later. pub type ItemKey = u16; +#[repr(C)] +#[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, Deserialize, MallocSizeOf, Serialize, PeekPoke)] +pub struct PrimitiveFlags(u8); + bitflags! { - #[repr(C)] - #[derive(Deserialize, MallocSizeOf, Serialize, PeekPoke)] - pub struct PrimitiveFlags: u8 { + impl PrimitiveFlags: u8 { /// The CSS backface-visibility property (yes, it can be really granular) const IS_BACKFACE_VISIBLE = 1 << 0; /// If set, this primitive represents a scroll bar container @@ -930,10 +932,12 @@ impl Hash for RasterSpace { } } +#[repr(C)] +#[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, Deserialize, MallocSizeOf, Serialize, PeekPoke)] +pub struct StackingContextFlags(u8); + bitflags! { - #[repr(C)] - #[derive(Deserialize, MallocSizeOf, Serialize, PeekPoke)] - pub struct StackingContextFlags: u8 { + impl StackingContextFlags: u8 { /// If true, this stacking context is a blend container than contains /// mix-blend-mode children (and should thus be isolated). const IS_BLEND_CONTAINER = 1 << 0; diff --git a/gfx/wr/webrender_api/src/font.rs b/gfx/wr/webrender_api/src/font.rs index 286742bff6c8..7d4de4f3422d 100644 --- a/gfx/wr/webrender_api/src/font.rs +++ b/gfx/wr/webrender_api/src/font.rs @@ -181,10 +181,12 @@ impl Default for GlyphOptions { } } +#[repr(C)] +#[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, Deserialize, MallocSizeOf, Serialize, PeekPoke)] +pub struct FontInstanceFlags(u32); + bitflags! { - #[repr(C)] - #[derive(Deserialize, MallocSizeOf, Serialize, PeekPoke)] - pub struct FontInstanceFlags: u32 { + impl FontInstanceFlags: u32 { // Common flags // Use native synthetic bold, if supported. const SYNTHETIC_BOLD = 1 << 1; diff --git a/gfx/wr/webrender_api/src/image.rs b/gfx/wr/webrender_api/src/image.rs index 4ce73f9e4660..abdce9b0763b 100644 --- a/gfx/wr/webrender_api/src/image.rs +++ b/gfx/wr/webrender_api/src/image.rs @@ -229,7 +229,7 @@ impl ColorDepth { bitflags! { /// Various flags that are part of an image descriptor. - #[derive(Deserialize, Serialize)] + #[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, Deserialize, Serialize)] pub struct ImageDescriptorFlags: u32 { /// Whether this image is opaque, or has an alpha channel. Avoiding blending /// for opaque surfaces is an important optimization. diff --git a/gfx/wr/webrender_api/src/lib.rs b/gfx/wr/webrender_api/src/lib.rs index 77e7a9535886..cd2c44c0a9a1 100644 --- a/gfx/wr/webrender_api/src/lib.rs +++ b/gfx/wr/webrender_api/src/lib.rs @@ -576,11 +576,13 @@ pub enum IntParameter { BatchedUploadThreshold = 0, } +/// Flags to track why we are rendering. +#[repr(C)] +#[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, Default, Deserialize, MallocSizeOf, Serialize)] +pub struct RenderReasons(u32); + bitflags! { - /// Flags to track why we are rendering. - #[repr(C)] - #[derive(Default, Deserialize, MallocSizeOf, Serialize)] - pub struct RenderReasons: u32 { + impl RenderReasons: u32 { /// Equivalent of empty() for the C++ side. const NONE = 0; const SCENE = 1 << 0; @@ -618,11 +620,13 @@ impl RenderReasons { pub const NUM_BITS: u32 = 17; } +/// Flags to enable/disable various builtin debugging tools. +#[repr(C)] +#[derive(Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, Default, Deserialize, MallocSizeOf, Serialize)] +pub struct DebugFlags(u32); + bitflags! { - /// Flags to enable/disable various builtin debugging tools. - #[repr(C)] - #[derive(Default, Deserialize, MallocSizeOf, Serialize)] - pub struct DebugFlags: u32 { + impl DebugFlags: u32 { /// Display the frame profiler on screen. const PROFILER_DBG = 1 << 0; /// Display intermediate render targets on screen. diff --git a/gfx/wr/webrender_build/Cargo.toml b/gfx/wr/webrender_build/Cargo.toml index acd50834fdab..c2c3a2db288e 100644 --- a/gfx/wr/webrender_build/Cargo.toml +++ b/gfx/wr/webrender_build/Cargo.toml @@ -11,6 +11,6 @@ edition = "2018" serialize_program = ["serde"] [dependencies] -bitflags = "1.2" +bitflags = "2" lazy_static = "1" serde = { optional = true, version = "1.0", features = ["serde_derive"] } diff --git a/gfx/wr/webrender_build/src/shader_features.rs b/gfx/wr/webrender_build/src/shader_features.rs index db16cdf703ce..d3002721aef3 100644 --- a/gfx/wr/webrender_build/src/shader_features.rs +++ b/gfx/wr/webrender_build/src/shader_features.rs @@ -5,7 +5,7 @@ use std::collections::HashMap; bitflags! { - #[derive(Default)] + #[derive(Default, Debug, Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] pub struct ShaderFeatureFlags: u32 { const GL = 1 << 0; const GLES = 1 << 1; diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index d0b80060501f..a1722c08e96e 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -7101,7 +7101,7 @@ void nsWindow::OnSizeModeChange() { this, mode != nsSizeMode_Minimized); wr::DebugFlags flags{0}; - flags.bits = gfx::gfxVars::WebRenderDebugFlags(); + flags._0 = gfx::gfxVars::WebRenderDebugFlags(); bool debugEnabled = bool(flags & wr::DebugFlags::WINDOW_VISIBILITY_DBG); if (debugEnabled && mCompositorWidgetDelegate) { mCompositorWidgetDelegate->NotifyVisibilityUpdated(mode, diff --git a/widget/windows/nsWindowGfx.cpp b/widget/windows/nsWindowGfx.cpp index 9b91eca1954d..c2a91dcf6bfb 100644 --- a/widget/windows/nsWindowGfx.cpp +++ b/widget/windows/nsWindowGfx.cpp @@ -407,7 +407,7 @@ void nsWindow::NotifyOcclusionState(mozilla::widget::OcclusionState aState) { mIsFullyOccluded, mFrameState->GetSizeMode())); wr::DebugFlags flags{0}; - flags.bits = gfx::gfxVars::WebRenderDebugFlags(); + flags._0 = gfx::gfxVars::WebRenderDebugFlags(); bool debugEnabled = bool(flags & wr::DebugFlags::WINDOW_VISIBILITY_DBG); if (debugEnabled && mCompositorWidgetDelegate) { mCompositorWidgetDelegate->NotifyVisibilityUpdated( @@ -434,7 +434,7 @@ void nsWindow::MaybeEnableWindowOcclusion(bool aEnable) { WinWindowOcclusionTracker::Get()->Enable(this, mWnd); wr::DebugFlags flags{0}; - flags.bits = gfx::gfxVars::WebRenderDebugFlags(); + flags._0 = gfx::gfxVars::WebRenderDebugFlags(); bool debugEnabled = bool(flags & wr::DebugFlags::WINDOW_VISIBILITY_DBG); if (debugEnabled && mCompositorWidgetDelegate) { mCompositorWidgetDelegate->NotifyVisibilityUpdated( @@ -455,7 +455,7 @@ void nsWindow::MaybeEnableWindowOcclusion(bool aEnable) { NotifyOcclusionState(OcclusionState::VISIBLE); wr::DebugFlags flags{0}; - flags.bits = gfx::gfxVars::WebRenderDebugFlags(); + flags._0 = gfx::gfxVars::WebRenderDebugFlags(); bool debugEnabled = bool(flags & wr::DebugFlags::WINDOW_VISIBILITY_DBG); if (debugEnabled && mCompositorWidgetDelegate) { mCompositorWidgetDelegate->NotifyVisibilityUpdated(