Use more WebRender types in gfx/display_list

This uses floating-point (Layout) coordinates in where possible.
Replace NormalBorder struct with WebRender equivalent.
Remove ToPointF and ToRectF traits.
Convert border RepeatKeyword with ToLayout.
Add some definitions to malloc_size_of for WebRender types.
This commit is contained in:
Pyfisch 2018-01-12 21:24:23 +01:00
parent 8612a87ed2
commit 8c7c5f6e79
10 changed files with 181 additions and 240 deletions

View file

@ -23,7 +23,7 @@ use style::values::generics::image::EndingShape as GenericEndingShape;
use style::values::generics::image::GradientItem as GenericGradientItem;
use style::values::specified::background::RepeatKeyword;
use style::values::specified::position::{X, Y};
use webrender_api::GradientStop;
use webrender_api::{ExtendMode, GradientStop};
/// A helper data structure for gradients.
#[derive(Clone, Copy)]
@ -370,6 +370,14 @@ fn convert_gradient_stops(gradient_items: &[GradientItem], total_length: Au) ->
stops
}
fn as_gradient_extend_mode(repeating: bool) -> ExtendMode {
if repeating {
ExtendMode::Repeat
} else {
ExtendMode::Clamp
}
}
pub fn convert_linear_gradient(
size: Size2D<Au>,
stops: &[GradientItem],
@ -431,10 +439,10 @@ pub fn convert_linear_gradient(
let center = Point2D::new(size.width / 2, size.height / 2);
display_list::Gradient {
start_point: center - delta,
end_point: center + delta,
start_point: (center - delta).to_layout(),
end_point: (center + delta).to_layout(),
stops: stops,
repeating: repeating,
extend_mode: as_gradient_extend_mode(repeating),
}
}
@ -473,10 +481,10 @@ pub fn convert_radial_gradient(
}
display_list::RadialGradient {
center: center,
radius: radius,
center: center.to_layout(),
radius: radius.to_layout(),
stops: stops,
repeating: repeating,
extend_mode: as_gradient_extend_mode(repeating),
}
}