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
NCSU Canvas Rendering Project Initial Steps #20447
Conversation
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @pcwalton (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.
Great work!
@@ -99,7 +100,8 @@ impl<'a> CanvasPaintState<'a> { | |||
impl<'a> CanvasPaintThread<'a> { | |||
fn new(size: Size2D<i32>, | |||
webrender_api_sender: webrender_api::RenderApiSender, | |||
antialias: AntialiasMode) -> CanvasPaintThread<'a> { | |||
antialias: AntialiasMode, | |||
canvas_id: CanvasId) -> CanvasPaintThread<'a> { |
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.
nit: indentation
} | ||
} | ||
|
||
/// Creates a new `CanvasPaintThread` and returns an `IpcSender` to | ||
/// communicate with it. | ||
pub fn start(size: Size2D<i32>, | ||
webrender_api_sender: webrender_api::RenderApiSender, | ||
antialias: bool) | ||
antialias: bool, | ||
canvas_id: CanvasId) |
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.
nit: indentation
opts::get().enable_canvas_antialiasing); | ||
if let Err(e) = response_sender.send(sender) { | ||
opts::get().enable_canvas_antialiasing,self.canvas_id.clone()); | ||
if let Err(e) = response_sender.send((sender,self.canvas_id.clone())) { |
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.
nit: add a space after ,
in both these lines.
@@ -1800,7 +1800,7 @@ impl FragmentDisplayListBuilding for Fragment { | |||
let ipc_renderer = ipc_renderer.lock().unwrap(); | |||
let (sender, receiver) = ipc::channel().unwrap(); | |||
ipc_renderer | |||
.send(CanvasMsg::FromLayout(FromLayoutMsg::SendData(sender))) | |||
.send(CanvasMsg::FromLayout(FromLayoutMsg::SendData(sender), canvas_fragment_info.canvas_id.clone())) |
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.
nit: move this argument onto the next line so it's easier to read.
@@ -133,7 +134,8 @@ impl CanvasRenderingContext2D { | |||
let script_to_constellation_chan = global.script_to_constellation_chan(); | |||
debug!("Asking constellation to create new canvas thread."); | |||
script_to_constellation_chan.send(ScriptMsg::CreateCanvasPaintThread(size, sender)).unwrap(); | |||
let ipc_renderer = receiver.recv().unwrap(); | |||
let response = receiver.recv().unwrap(); | |||
let (ipc_renderer, canvas_id) = response; |
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.
These lines can be combined:
let (ipc_render, canvas_id) = receiver.recv().unwrap();
@@ -11,7 +11,7 @@ use LayoutControlMsg; | |||
use LoadData; | |||
use WorkerGlobalScopeInit; | |||
use WorkerScriptLoadOrigin; | |||
use canvas_traits::canvas::CanvasMsg; | |||
use canvas_traits::canvas::{CanvasMsg,CanvasId}; |
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.
nit: space after ,
@@ -79,7 +79,7 @@ pub enum ScriptMsg { | |||
ChangeRunningAnimationsState(AnimationState), | |||
/// Requests that a new 2D canvas thread be created. (This is done in the constellation because | |||
/// 2D canvases may use the GPU and we don't want to give untrusted content access to the GPU.) | |||
CreateCanvasPaintThread(Size2D<i32>, IpcSender<IpcSender<CanvasMsg>>), | |||
CreateCanvasPaintThread(Size2D<i32>, IpcSender<(IpcSender<CanvasMsg>,CanvasId)>), |
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.
nit: space after ,
try { | ||
ctx2.drawImage.apply(ctx2, args); | ||
try { | ||
ctx2.drawImage.apply(ctx2, args); |
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.
nit: revert the formatting changes in this file.
}; | ||
|
||
var t0 = performance.now(); //save starting time | ||
drawImage(25, 25); // The source canvas will copied to the 0,0 position of the destination canvas |
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.
nit: odd indentation on this line.
|
||
args.unshift(canvas1); | ||
try { | ||
ctx2.drawImage.apply(ctx2, args); |
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.
nit: odd indentation on these lines.
Please squash all the commits into one as well. |
Hi! This is my first time squashing all of the commits into one. I probably did something that I wasn't supposed to. |
Yeah, if the pull request still shows >1 commit after refreshing, it didn't achieve the desired effect. Be sure to run |
I see. I'll do that now. |
Error syncing changes upstream. Logs saved in error-snapshot-1522386139768. |
Error syncing changes upstream. Logs saved in error-snapshot-1522386382447. |
Error syncing changes upstream. Logs saved in error-snapshot-1522386512547. |
It seems as though I've messed something up. |
Indeed. I recommend running |
Ok, all of the automated tests that use a canvas are panicking with stacks like this:
This means that LayoutHTMLCanvasElementHelpers::data is invoking HTMLCanvasElement::get_canvas_id, which calls DomRefCell::borrow on |
cc @SimonSapin so you're aware of what's happening in this PR. |
@bors-servo r+ |
📌 Commit 3b5cdec has been approved by |
NCSU Canvas Rendering Project Initial Steps <!-- Please describe your changes on the following line: --> Implements the initial steps from: https://github.com/servo/servo/wiki/Canvas-rendering-project --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20447) <!-- Reviewable:end -->
💔 Test failed - linux-rel-css |
Note: to run these 2d and 3d canvas tests locally, use |
unsafe { | ||
let canvas = &*self.unsafe_get(); | ||
if let &Some(CanvasContext::Context2d(ref context)) = canvas.context.borrow_for_layout() { | ||
context.get_canvas_id() |
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.
Sorry, one more change is required. There needs to be a get_canvas_id_for_layout
method added to LayoutCanvasRenderingContext2DHelpers
in canvasrenderingcontext2d.rs
. This line should then read context.to_layout().get_canvas_id()
.
Those tests succeeded locally! I'm really hoping we'll see success fully this time! |
@bors-servo r+ |
📌 Commit 8a1590e has been approved by |
NCSU Canvas Rendering Project Initial Steps <!-- Please describe your changes on the following line: --> Implements the initial steps from: https://github.com/servo/servo/wiki/Canvas-rendering-project --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20447) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
Implements the initial steps from:
https://github.com/servo/servo/wiki/Canvas-rendering-project
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is