Try to use WebRender types more

The newer versions of WebRender move types around between `webrender` and
`webrender_api` and this will reduce the churn during the upgrade.
This commit is contained in:
Martin Robinson 2023-07-10 15:54:39 +02:00
parent 1543912589
commit 3230162fd0
No known key found for this signature in database
GPG key ID: D56AA4FA55EFE6F8
39 changed files with 330 additions and 327 deletions

View file

@ -8,7 +8,7 @@ use style::computed_values::text_decoration_style::T as ComputedTextDecorationSt
use style::computed_values::transform_style::T as ComputedTransformStyle;
use style::values::computed::Filter as ComputedFilter;
use style::values::computed::Length;
use webrender_api as wr;
use webrender_api::{units, FilterOp, LineStyle, MixBlendMode, TransformStyle};
pub trait ToWebRender {
type Type;
@ -16,18 +16,18 @@ pub trait ToWebRender {
}
impl ToWebRender for ComputedFilter {
type Type = wr::FilterOp;
type Type = FilterOp;
fn to_webrender(&self) -> Self::Type {
match *self {
ComputedFilter::Blur(radius) => wr::FilterOp::Blur(radius.px()),
ComputedFilter::Brightness(amount) => wr::FilterOp::Brightness(amount.0),
ComputedFilter::Contrast(amount) => wr::FilterOp::Contrast(amount.0),
ComputedFilter::Grayscale(amount) => wr::FilterOp::Grayscale(amount.0),
ComputedFilter::HueRotate(angle) => wr::FilterOp::HueRotate(angle.radians()),
ComputedFilter::Invert(amount) => wr::FilterOp::Invert(amount.0),
ComputedFilter::Opacity(amount) => wr::FilterOp::Opacity(amount.0.into(), amount.0),
ComputedFilter::Saturate(amount) => wr::FilterOp::Saturate(amount.0),
ComputedFilter::Sepia(amount) => wr::FilterOp::Sepia(amount.0),
ComputedFilter::Blur(radius) => FilterOp::Blur(radius.px()),
ComputedFilter::Brightness(amount) => FilterOp::Brightness(amount.0),
ComputedFilter::Contrast(amount) => FilterOp::Contrast(amount.0),
ComputedFilter::Grayscale(amount) => FilterOp::Grayscale(amount.0),
ComputedFilter::HueRotate(angle) => FilterOp::HueRotate(angle.radians()),
ComputedFilter::Invert(amount) => FilterOp::Invert(amount.0),
ComputedFilter::Opacity(amount) => FilterOp::Opacity(amount.0.into(), amount.0),
ComputedFilter::Saturate(amount) => FilterOp::Saturate(amount.0),
ComputedFilter::Sepia(amount) => FilterOp::Sepia(amount.0),
// Statically check that DropShadow is impossible.
ComputedFilter::DropShadow(ref shadow) => match *shadow {},
// Statically check that Url is impossible.
@ -36,64 +36,64 @@ impl ToWebRender for ComputedFilter {
}
}
impl ToWebRender for ComputedMixBlendMode {
type Type = wr::MixBlendMode;
type Type = MixBlendMode;
fn to_webrender(&self) -> Self::Type {
match *self {
ComputedMixBlendMode::Normal => wr::MixBlendMode::Normal,
ComputedMixBlendMode::Multiply => wr::MixBlendMode::Multiply,
ComputedMixBlendMode::Screen => wr::MixBlendMode::Screen,
ComputedMixBlendMode::Overlay => wr::MixBlendMode::Overlay,
ComputedMixBlendMode::Darken => wr::MixBlendMode::Darken,
ComputedMixBlendMode::Lighten => wr::MixBlendMode::Lighten,
ComputedMixBlendMode::ColorDodge => wr::MixBlendMode::ColorDodge,
ComputedMixBlendMode::ColorBurn => wr::MixBlendMode::ColorBurn,
ComputedMixBlendMode::HardLight => wr::MixBlendMode::HardLight,
ComputedMixBlendMode::SoftLight => wr::MixBlendMode::SoftLight,
ComputedMixBlendMode::Difference => wr::MixBlendMode::Difference,
ComputedMixBlendMode::Exclusion => wr::MixBlendMode::Exclusion,
ComputedMixBlendMode::Hue => wr::MixBlendMode::Hue,
ComputedMixBlendMode::Saturation => wr::MixBlendMode::Saturation,
ComputedMixBlendMode::Color => wr::MixBlendMode::Color,
ComputedMixBlendMode::Luminosity => wr::MixBlendMode::Luminosity,
ComputedMixBlendMode::Normal => MixBlendMode::Normal,
ComputedMixBlendMode::Multiply => MixBlendMode::Multiply,
ComputedMixBlendMode::Screen => MixBlendMode::Screen,
ComputedMixBlendMode::Overlay => MixBlendMode::Overlay,
ComputedMixBlendMode::Darken => MixBlendMode::Darken,
ComputedMixBlendMode::Lighten => MixBlendMode::Lighten,
ComputedMixBlendMode::ColorDodge => MixBlendMode::ColorDodge,
ComputedMixBlendMode::ColorBurn => MixBlendMode::ColorBurn,
ComputedMixBlendMode::HardLight => MixBlendMode::HardLight,
ComputedMixBlendMode::SoftLight => MixBlendMode::SoftLight,
ComputedMixBlendMode::Difference => MixBlendMode::Difference,
ComputedMixBlendMode::Exclusion => MixBlendMode::Exclusion,
ComputedMixBlendMode::Hue => MixBlendMode::Hue,
ComputedMixBlendMode::Saturation => MixBlendMode::Saturation,
ComputedMixBlendMode::Color => MixBlendMode::Color,
ComputedMixBlendMode::Luminosity => MixBlendMode::Luminosity,
}
}
}
impl ToWebRender for ComputedTransformStyle {
type Type = wr::TransformStyle;
type Type = TransformStyle;
fn to_webrender(&self) -> Self::Type {
match *self {
ComputedTransformStyle::Flat => wr::TransformStyle::Flat,
ComputedTransformStyle::Preserve3d => wr::TransformStyle::Preserve3D,
ComputedTransformStyle::Flat => TransformStyle::Flat,
ComputedTransformStyle::Preserve3d => TransformStyle::Preserve3D,
}
}
}
impl ToWebRender for PhysicalPoint<Length> {
type Type = webrender_api::units::LayoutPoint;
type Type = units::LayoutPoint;
fn to_webrender(&self) -> Self::Type {
webrender_api::units::LayoutPoint::new(self.x.px(), self.y.px())
units::LayoutPoint::new(self.x.px(), self.y.px())
}
}
impl ToWebRender for PhysicalSize<Length> {
type Type = webrender_api::units::LayoutSize;
type Type = units::LayoutSize;
fn to_webrender(&self) -> Self::Type {
webrender_api::units::LayoutSize::new(self.width.px(), self.height.px())
units::LayoutSize::new(self.width.px(), self.height.px())
}
}
impl ToWebRender for PhysicalRect<Length> {
type Type = webrender_api::units::LayoutRect;
type Type = units::LayoutRect;
fn to_webrender(&self) -> Self::Type {
webrender_api::units::LayoutRect::new(self.origin.to_webrender(), self.size.to_webrender())
units::LayoutRect::new(self.origin.to_webrender(), self.size.to_webrender())
}
}
impl ToWebRender for PhysicalSides<Length> {
type Type = webrender_api::units::LayoutSideOffsets;
type Type = units::LayoutSideOffsets;
fn to_webrender(&self) -> Self::Type {
webrender_api::units::LayoutSideOffsets::new(
units::LayoutSideOffsets::new(
self.top.px(),
self.right.px(),
self.bottom.px(),
@ -103,14 +103,14 @@ impl ToWebRender for PhysicalSides<Length> {
}
impl ToWebRender for ComputedTextDecorationStyle {
type Type = webrender_api::LineStyle;
type Type = LineStyle;
fn to_webrender(&self) -> Self::Type {
match *self {
ComputedTextDecorationStyle::Solid => wr::LineStyle::Solid,
ComputedTextDecorationStyle::Dotted => wr::LineStyle::Dotted,
ComputedTextDecorationStyle::Dashed => wr::LineStyle::Dashed,
ComputedTextDecorationStyle::Wavy => wr::LineStyle::Wavy,
_ => wr::LineStyle::Solid,
ComputedTextDecorationStyle::Solid => LineStyle::Solid,
ComputedTextDecorationStyle::Dotted => LineStyle::Dotted,
ComputedTextDecorationStyle::Dashed => LineStyle::Dashed,
ComputedTextDecorationStyle::Wavy => LineStyle::Wavy,
_ => LineStyle::Solid,
}
}
}

View file

@ -66,7 +66,7 @@ pub(super) fn build_linear(
) {
use style::values::specified::position::HorizontalPositionKeyword::*;
use style::values::specified::position::VerticalPositionKeyword::*;
use webrender_api::units::LayoutVector2D as Vec2;
use units::LayoutVector2D as Vec2;
let gradient_box = layer.tile_size;
// A vector of length 1.0 in the direction of the gradient line

View file

@ -42,7 +42,7 @@ pub struct WebRenderImageInfo {
pub key: Option<wr::ImageKey>,
}
// `webrender_api::display_item::ItemTag` is private
// webrender's `ItemTag` is private.
type ItemTag = (u64, u16);
type HitInfo = Option<ItemTag>;

View file

@ -14,6 +14,7 @@ use gfx_traits::print_tree::PrintTree;
use style::animation::AnimationSetKey;
use style::dom::OpaqueNode;
use style::values::computed::Length;
use webrender_api::units;
#[derive(Serialize)]
pub struct FragmentTree {
@ -61,8 +62,8 @@ impl FragmentTree {
}
}
pub fn scrollable_overflow(&self) -> webrender_api::units::LayoutSize {
webrender_api::units::LayoutSize::from_untyped(Size2D::new(
pub fn scrollable_overflow(&self) -> units::LayoutSize {
units::LayoutSize::from_untyped(Size2D::new(
self.scrollable_overflow.size.width.px(),
self.scrollable_overflow.size.height.px(),
))

View file

@ -34,14 +34,14 @@ use style::values::generics::text::LineHeight;
use style_traits::CSSPixel;
use style_traits::ToCss;
use webrender_api::units::LayoutPixel;
use webrender_api::ExternalScrollId;
use webrender_api::{DisplayListBuilder, ExternalScrollId};
/// Mutable data belonging to the LayoutThread.
///
/// This needs to be protected by a mutex so we can do fast RPCs.
pub struct LayoutThreadData {
/// The root stacking context.
pub display_list: Option<webrender_api::DisplayListBuilder>,
pub display_list: Option<DisplayListBuilder>,
/// A queued response for the union of the content boxes of a node.
pub content_box_response: Option<Rect<Au>>,