mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Canvas: added support for the globalAlpha attribute.
This commit is contained in:
parent
83d9ab3ba5
commit
5c560397eb
12 changed files with 29 additions and 56 deletions
|
@ -49,6 +49,7 @@ pub struct CanvasRenderingContext2D {
|
|||
global: GlobalField,
|
||||
renderer: Sender<CanvasMsg>,
|
||||
canvas: JS<HTMLCanvasElement>,
|
||||
global_alpha: Cell<f64>,
|
||||
image_smoothing_enabled: Cell<bool>,
|
||||
stroke_color: Cell<RGBA>,
|
||||
line_width: Cell<f64>,
|
||||
|
@ -70,6 +71,7 @@ impl CanvasRenderingContext2D {
|
|||
global: GlobalField::from_rooted(&global),
|
||||
renderer: CanvasPaintTask::start(size),
|
||||
canvas: JS::from_rooted(canvas),
|
||||
global_alpha: Cell::new(1.0),
|
||||
image_smoothing_enabled: Cell::new(true),
|
||||
stroke_color: Cell::new(black),
|
||||
line_width: Cell::new(1.0),
|
||||
|
@ -342,6 +344,19 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
|
|||
self.update_transform()
|
||||
}
|
||||
|
||||
fn GlobalAlpha(self) -> f64 {
|
||||
self.global_alpha.get()
|
||||
}
|
||||
|
||||
fn SetGlobalAlpha(self, alpha: f64) {
|
||||
if !alpha.is_finite() || alpha > 1.0 || alpha < 0.0 {
|
||||
return;
|
||||
}
|
||||
|
||||
self.global_alpha.set(alpha);
|
||||
self.renderer.send(CanvasMsg::SetGlobalAlpha(alpha as f32)).unwrap()
|
||||
}
|
||||
|
||||
fn FillRect(self, x: f64, y: f64, width: f64, height: f64) {
|
||||
if !(x.is_finite() && y.is_finite() &&
|
||||
width.is_finite() && height.is_finite()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue