New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make offscreen canvas rendering context use offscreen canvas' size #24518
Conversation
…o using canvas size where needed; made canvas definite instead of optional. still need to change sizing in associated classes to use u64 instead of u32 removed size from offscreencanvasrenderingcontext2d.rs; now getting canvas size through referenced canvas Updated pixels::clip to use u64 data types and added trait to canvasrenderingcontext2d.rs to convert u32 sizes to u64 added Size2D<u32> to Size2D<u64> conversion to webglrenderingcontext and converted u32 sizes to u64 where relevant updated get_rect to use u64. beginning to make type changes to canvas.rs Updated canvas, canvas_data, and canvas_paint_thread to use u64 when relevant Added ability to Recreate canvas when OffscreenCanvas::SetWidth() or OffscreenCanvas::SetHeight() are called Fixed formatting; passes ./mach test-tidy 🎉
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @paulrouget (or someone else) soon. |
Heads up! This PR modifies the following files:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I just have a couple pieces of cleanup to suggest.
let image_data = self | ||
.canvas(canvas_id) | ||
.read_pixels(source_rect.to_u32(), image_size.to_u32()); | ||
.read_pixels(source_rect_u64, image_size.to_u64()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be source_rect.to_u64()
, right?
@@ -1189,3 +1189,26 @@ impl RectToi32 for Rect<f64> { | |||
) | |||
} | |||
} | |||
|
|||
pub trait Size2DExt { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use pub(crate)
here and for RectExt_.
@@ -207,3 +211,13 @@ impl<'a> CanvasPaintThread<'a> { | |||
self.canvases.get_mut(&canvas_id).expect("Bogus canvas id") | |||
} | |||
} | |||
|
|||
pub trait Size2DExt { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can have use crate::canvas_data::Size2DExt;
instead of duplicating this.
@@ -2123,3 +2136,13 @@ fn adjust_size_sign( | |||
} | |||
(origin, size.to_u32()) | |||
} | |||
|
|||
pub trait Size2DExt { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's define these in one file in components/script/ and import them from there in the other files in this crate.
} | ||
} | ||
|
||
pub trait RectExt_ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I filed servo/euclid#374 if you felt like submitting these methods upstream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I submitted PR #375!
@bors-servo try=wpt |
Make offscreen canvas rendering context use offscreen canvas' size Updated the offscreen canvas rendering context to use the offscreen canvas' size. This involved upgrading several methods to accept u64 sizes. Additionally, the code in OffscreenCanvas::SetWidth() and OffscreenCanvas::SetHeight() was updated to send CanvasMsg::Recreate to the canvas paint thread. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #24465 - [X] These changes do not require tests because the purpose of this was to tidy up code
💔 Test failed - linux-rel-css |
|
Looks like we'll want to be a bit more careful about our implementation of to_u64. Let's base it off of the same conversion methods from upstream: https://github.com/servo/euclid/blob/6dcc86f0e5370b5be45a955239131293bd336c66/src/rect.rs#L539-L546 |
Make offscreen canvas rendering context use offscreen canvas' size; Consolidate size helpers <!-- Please describe your changes on the following line: --> Addresses issues raised in the review of PR #24518 and includes changes to 17 tests' metadata for those that now PASS. Contains fixes in PR #24518: Updated the offscreen canvas rendering context to use the offscreen canvas' size. This involved upgrading several methods to accept u64 sizes. Additionally, the code in OffscreenCanvas::SetWidth() and OffscreenCanvas::SetHeight() was updated to send CanvasMsg::Recreate to the canvas paint thread. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #24465 <!-- Either: --> - [X] There are tests for these changes – 17 were updated to PASS
Make offscreen canvas rendering context use offscreen canvas' size; Consolidate size helpers <!-- Please describe your changes on the following line: --> Addresses issues raised in the review of PR #24518 and includes changes to 17 tests' metadata for those that now PASS. Contains fixes in PR #24518: Updated the offscreen canvas rendering context to use the offscreen canvas' size. This involved upgrading several methods to accept u64 sizes. Additionally, the code in OffscreenCanvas::SetWidth() and OffscreenCanvas::SetHeight() was updated to send CanvasMsg::Recreate to the canvas paint thread. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #24465 and fix #24536 <!-- Either: --> - [X] There are tests for these changes – 17 were updated to PASS
Make offscreen canvas rendering context use offscreen canvas' size; Consolidate size helpers <!-- Please describe your changes on the following line: --> Addresses issues raised in the review of PR #24518 and includes changes to 17 tests' metadata for those that now PASS. Contains fixes in PR #24518: Updated the offscreen canvas rendering context to use the offscreen canvas' size. This involved upgrading several methods to accept u64 sizes. Additionally, the code in OffscreenCanvas::SetWidth() and OffscreenCanvas::SetHeight() was updated to send CanvasMsg::Recreate to the canvas paint thread. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #24465 and fix #24536 <!-- Either: --> - [X] There are tests for these changes – 17 were updated to PASS
Make offscreen canvas rendering context use offscreen canvas' size; Consolidate size helpers <!-- Please describe your changes on the following line: --> Addresses issues raised in the review of PR #24518 and includes changes to 17 tests' metadata for those that now PASS. Contains fixes in PR #24518: Updated the offscreen canvas rendering context to use the offscreen canvas' size. This involved upgrading several methods to accept u64 sizes. Additionally, the code in OffscreenCanvas::SetWidth() and OffscreenCanvas::SetHeight() was updated to send CanvasMsg::Recreate to the canvas paint thread. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #24465 and fix #24536 <!-- Either: --> - [X] There are tests for these changes – 17 were updated to PASS
Updated the offscreen canvas rendering context to use the offscreen canvas' size. This involved upgrading several methods to accept u64 sizes.
Additionally, the code in OffscreenCanvas::SetWidth() and OffscreenCanvas::SetHeight() was updated to send CanvasMsg::Recreate to the canvas paint thread.
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThese changes fix Make offscreen canvas rendering context use offscreen canvas' size #24465
These changes do not require tests because the purpose of this was to tidy up code