Implement clear_rect

This commit is contained in:
Bastien Orivel 2019-08-08 17:34:00 +02:00
parent 24313a82a1
commit 9229dc4d85
2 changed files with 21 additions and 4 deletions

View file

@ -214,7 +214,7 @@ impl<'a> PathBuilderRef<'a> {
// This defines required methods for DrawTarget of azure and raqote // This defines required methods for DrawTarget of azure and raqote
// The prototypes are derived from azure's methods. // The prototypes are derived from azure's methods.
pub trait GenericDrawTarget { pub trait GenericDrawTarget {
fn clear_rect(&self, rect: &Rect<f32>); fn clear_rect(&mut self, rect: &Rect<f32>);
fn copy_surface( fn copy_surface(
&mut self, &mut self,
surface: SourceSurface, surface: SourceSurface,
@ -527,7 +527,7 @@ impl<'a> CanvasData<'a> {
} }
} }
pub fn clear_rect(&self, rect: &Rect<f32>) { pub fn clear_rect(&mut self, rect: &Rect<f32>) {
self.drawtarget.clear_rect(rect); self.drawtarget.clear_rect(rect);
} }

View file

@ -192,8 +192,25 @@ impl Path {
} }
impl GenericDrawTarget for raqote::DrawTarget { impl GenericDrawTarget for raqote::DrawTarget {
fn clear_rect(&self, _rect: &Rect<f32>) { fn clear_rect(&mut self, rect: &Rect<f32>) {
unimplemented!(); let mut pb = raqote::PathBuilder::new();
pb.rect(
rect.origin.x,
rect.origin.y,
rect.size.width,
rect.size.height,
);
raqote::DrawTarget::fill(
self,
&pb.finish(),
&raqote::Source::Solid(raqote::SolidSource {
r: 0,
g: 0,
b: 0,
a: 0,
}),
&raqote::DrawOptions::new(),
);
} }
fn copy_surface( fn copy_surface(
&mut self, &mut self,