mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Implement HTMLCanvasElement.toDataURL for WebGL canvas (fixes #19147)
This commit is contained in:
parent
4a6453ac9a
commit
a77d35b60c
186 changed files with 63 additions and 1543 deletions
|
@ -345,11 +345,22 @@ impl HTMLCanvasElementMethods for HTMLCanvasElement {
|
|||
Finite::wrap(self.Height() as f64))?;
|
||||
image_data.get_data_array()
|
||||
}
|
||||
Some(CanvasContext::WebGL(ref context)) => {
|
||||
match context.get_image_data(self.Width(), self.Height()) {
|
||||
Some(data) => data,
|
||||
None => return Ok("data:,".into()),
|
||||
}
|
||||
}
|
||||
Some(CanvasContext::WebGL2(ref context)) => {
|
||||
match context.base_context().get_image_data(self.Width(), self.Height()) {
|
||||
Some(data) => data,
|
||||
None => return Ok("data:,".into()),
|
||||
}
|
||||
}
|
||||
None => {
|
||||
// Each pixel is fully-transparent black.
|
||||
vec![0; (self.Width() * self.Height() * 4) as usize]
|
||||
}
|
||||
_ => return Err(Error::NotSupported) // WebGL
|
||||
};
|
||||
|
||||
// Only handle image/png for now.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue