mirror of
https://github.com/servo/servo.git
synced 2025-09-27 23:30:08 +01:00
canvas: Use Transform2D<f64>
instead of Transform2D<f32>
(#38316)
I mostly did dumb replacement so please check that this is correct. In addition, `canvas_data::draw_with_shadow` needs some a bit of a closer look. Testing: This is covered by existing tests, and it is likely that WPT tests are unaffected by the precision of the transform, even though it is technically more correct. Fixes: #38256 Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
parent
4ff1e8dbd9
commit
3f7f9ba6cd
8 changed files with 91 additions and 97 deletions
|
@ -126,8 +126,8 @@ impl VelloCPUDrawTarget {
|
|||
Size2D::new(self.ctx.width(), self.ctx.height()).cast()
|
||||
}
|
||||
|
||||
fn is_viewport_cleared(&mut self, rect: &Rect<f32>, transform: Transform2D<f32>) -> bool {
|
||||
let transformed_rect = transform.outer_transformed_rect(rect);
|
||||
fn is_viewport_cleared(&mut self, rect: &Rect<f32>, transform: Transform2D<f64>) -> bool {
|
||||
let transformed_rect = transform.outer_transformed_rect(&rect.cast());
|
||||
if transformed_rect.is_empty() {
|
||||
return false;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ impl GenericDrawTarget for VelloCPUDrawTarget {
|
|||
}
|
||||
}
|
||||
|
||||
fn clear_rect(&mut self, rect: &Rect<f32>, transform: Transform2D<f32>) {
|
||||
fn clear_rect(&mut self, rect: &Rect<f32>, transform: Transform2D<f64>) {
|
||||
// vello_cpu RenderingContext only ever grows,
|
||||
// so we need to use every opportunity to shrink it
|
||||
if self.is_viewport_cleared(rect, transform) {
|
||||
|
@ -217,7 +217,7 @@ impl GenericDrawTarget for VelloCPUDrawTarget {
|
|||
source: Rect<f64>,
|
||||
filter: Filter,
|
||||
composition_options: CompositionOptions,
|
||||
transform: Transform2D<f32>,
|
||||
transform: Transform2D<f64>,
|
||||
) {
|
||||
self.ensure_drawing();
|
||||
let scale_up = dest.size.width > source.size.width || dest.size.height > source.size.height;
|
||||
|
@ -272,7 +272,7 @@ impl GenericDrawTarget for VelloCPUDrawTarget {
|
|||
fill_rule: FillRule,
|
||||
style: FillOrStrokeStyle,
|
||||
composition_options: CompositionOptions,
|
||||
transform: Transform2D<f32>,
|
||||
transform: Transform2D<f64>,
|
||||
) {
|
||||
self.ensure_drawing();
|
||||
self.with_composition(composition_options.composition_operation, |self_| {
|
||||
|
@ -290,7 +290,7 @@ impl GenericDrawTarget for VelloCPUDrawTarget {
|
|||
start: Point2D<f32>,
|
||||
style: FillOrStrokeStyle,
|
||||
composition_options: CompositionOptions,
|
||||
transform: Transform2D<f32>,
|
||||
transform: Transform2D<f64>,
|
||||
) {
|
||||
self.ensure_drawing();
|
||||
self.ctx.set_paint(paint(style, composition_options.alpha));
|
||||
|
@ -348,7 +348,7 @@ impl GenericDrawTarget for VelloCPUDrawTarget {
|
|||
rect: &Rect<f32>,
|
||||
style: FillOrStrokeStyle,
|
||||
composition_options: CompositionOptions,
|
||||
transform: Transform2D<f32>,
|
||||
transform: Transform2D<f64>,
|
||||
) {
|
||||
self.ensure_drawing();
|
||||
self.with_composition(composition_options.composition_operation, |self_| {
|
||||
|
@ -368,7 +368,7 @@ impl GenericDrawTarget for VelloCPUDrawTarget {
|
|||
}
|
||||
}
|
||||
|
||||
fn push_clip(&mut self, path: &Path, fill_rule: FillRule, transform: Transform2D<f32>) {
|
||||
fn push_clip(&mut self, path: &Path, fill_rule: FillRule, transform: Transform2D<f64>) {
|
||||
self.ctx.set_transform(transform.cast().into());
|
||||
let mut path = path.clone();
|
||||
path.transform(transform.cast());
|
||||
|
@ -396,7 +396,7 @@ impl GenericDrawTarget for VelloCPUDrawTarget {
|
|||
style: FillOrStrokeStyle,
|
||||
line_options: LineOptions,
|
||||
composition_options: CompositionOptions,
|
||||
transform: Transform2D<f32>,
|
||||
transform: Transform2D<f64>,
|
||||
) {
|
||||
self.ensure_drawing();
|
||||
self.with_composition(composition_options.composition_operation, |self_| {
|
||||
|
@ -413,7 +413,7 @@ impl GenericDrawTarget for VelloCPUDrawTarget {
|
|||
style: FillOrStrokeStyle,
|
||||
line_options: LineOptions,
|
||||
composition_options: CompositionOptions,
|
||||
transform: Transform2D<f32>,
|
||||
transform: Transform2D<f64>,
|
||||
) {
|
||||
self.ensure_drawing();
|
||||
self.with_composition(composition_options.composition_operation, |self_| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue