WIP: Make GenericPathBuilder's methods take &mut self

This commit is contained in:
pylbrecht 2019-07-02 19:14:15 +02:00 committed by Bastien Orivel
parent 9f9013946a
commit b43c5c30e3
2 changed files with 88 additions and 82 deletions

View file

@ -215,7 +215,12 @@ impl<'a> PathBuilderRef<'a> {
// 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(&self, rect: &Rect<f32>);
fn copy_surface(&self, surface: SourceSurface, source: Rect<i32>, destination: Point2D<i32>); fn copy_surface(
&mut self,
surface: SourceSurface,
source: Rect<i32>,
destination: Point2D<i32>,
);
fn create_gradient_stops( fn create_gradient_stops(
&self, &self,
gradient_stops: Vec<GradientStop>, gradient_stops: Vec<GradientStop>,
@ -250,24 +255,24 @@ pub trait GenericDrawTarget {
sigma: f32, sigma: f32,
operator: CompositionOp, operator: CompositionOp,
); );
fn fill(&self, path: &Path, pattern: Pattern, draw_options: &DrawOptions); fn fill(&mut self, path: &Path, pattern: Pattern, draw_options: &DrawOptions);
fn fill_rect(&self, rect: &Rect<f32>, pattern: Pattern, draw_options: Option<&DrawOptions>); fn fill_rect(&mut self, rect: &Rect<f32>, pattern: Pattern, draw_options: Option<&DrawOptions>);
fn get_format(&self) -> SurfaceFormat; fn get_format(&self) -> SurfaceFormat;
fn get_size(&self) -> Size2D<i32>; fn get_size(&self) -> Size2D<i32>;
fn get_transform(&self) -> Transform2D<f32>; fn get_transform(&self) -> Transform2D<f32>;
fn pop_clip(&self); fn pop_clip(&mut self);
fn push_clip(&self, path: &Path); fn push_clip(&mut self, path: &Path);
fn set_transform(&self, matrix: &Transform2D<f32>); fn set_transform(&mut self, matrix: &Transform2D<f32>);
fn snapshot(&self) -> SourceSurface; fn snapshot(&self) -> SourceSurface;
fn stroke( fn stroke(
&self, &mut self,
path: &Path, path: &Path,
pattern: Pattern, pattern: Pattern,
stroke_options: &StrokeOptions, stroke_options: &StrokeOptions,
draw_options: &DrawOptions, draw_options: &DrawOptions,
); );
fn stroke_line( fn stroke_line(
&self, &mut self,
start: Point2D<f32>, start: Point2D<f32>,
end: Point2D<f32>, end: Point2D<f32>,
pattern: Pattern, pattern: Pattern,
@ -275,7 +280,7 @@ pub trait GenericDrawTarget {
draw_options: &DrawOptions, draw_options: &DrawOptions,
); );
fn stroke_rect( fn stroke_rect(
&self, &mut self,
rect: &Rect<f32>, rect: &Rect<f32>,
pattern: Pattern, pattern: Pattern,
stroke_options: &StrokeOptions, stroke_options: &StrokeOptions,
@ -659,7 +664,8 @@ impl<'a> CanvasData<'a> {
pub fn clip(&mut self) { pub fn clip(&mut self) {
self.ensure_path(); self.ensure_path();
self.drawtarget.push_clip(&self.path()); let path = self.path();
self.drawtarget.push_clip(&path);
} }
pub fn is_point_in_path( pub fn is_point_in_path(

View file

@ -143,129 +143,129 @@ impl Path {
} }
impl GenericDrawTarget for raqote::DrawTarget { impl GenericDrawTarget for raqote::DrawTarget {
fn clear_rect(&self, _rect: &Rect<f32>) { fn clear_rect(&self, rect: &Rect<f32>) {
unimplemented!() unimplemented!();
} }
fn copy_surface( fn copy_surface(
&self, &mut self,
_surface: SourceSurface, surface: SourceSurface,
_source: Rect<i32>, source: Rect<i32>,
_destination: Point2D<i32>, destination: Point2D<i32>,
) { ) {
unimplemented!() unimplemented!();
} }
fn create_gradient_stops( fn create_gradient_stops(
&self, &self,
_gradient_stops: Vec<GradientStop>, gradient_stops: Vec<GradientStop>,
_extend_mode: ExtendMode, extend_mode: ExtendMode,
) -> GradientStops { ) -> GradientStops {
unimplemented!() unimplemented!();
} }
fn create_path_builder(&self) -> Box<dyn GenericPathBuilder> { fn create_path_builder(&self) -> Box<dyn GenericPathBuilder> {
unimplemented!() unimplemented!();
} }
fn create_similar_draw_target( fn create_similar_draw_target(
&self, &self,
_size: &Size2D<i32>, size: &Size2D<i32>,
_format: SurfaceFormat, format: SurfaceFormat,
) -> Box<dyn GenericDrawTarget> { ) -> Box<dyn GenericDrawTarget> {
unimplemented!() unimplemented!();
} }
fn create_source_surface_from_data( fn create_source_surface_from_data(
&self, &self,
_data: &[u8], data: &[u8],
_size: Size2D<i32>, size: Size2D<i32>,
_stride: i32, stride: i32,
) -> Option<SourceSurface> { ) -> Option<SourceSurface> {
unimplemented!() unimplemented!();
} }
fn draw_surface( fn draw_surface(
&self, &self,
_surface: SourceSurface, surface: SourceSurface,
_dest: Rect<f64>, dest: Rect<f64>,
_source: Rect<f64>, source: Rect<f64>,
_filter: Filter, filter: Filter,
_draw_options: &DrawOptions, draw_options: &DrawOptions,
) { ) {
unimplemented!() unimplemented!();
} }
fn draw_surface_with_shadow( fn draw_surface_with_shadow(
&self, &self,
_surface: SourceSurface, surface: SourceSurface,
_dest: &Point2D<f32>, dest: &Point2D<f32>,
_color: &Color, color: &Color,
_offset: &Vector2D<f32>, offset: &Vector2D<f32>,
_sigma: f32, sigma: f32,
_operator: CompositionOp, operator: CompositionOp,
) { ) {
unimplemented!() unimplemented!();
} }
fn fill(&self, _path: &Path, _pattern: Pattern, _draw_options: &DrawOptions) { fn fill(&mut self, path: &Path, pattern: Pattern, draw_options: &DrawOptions) {
unimplemented!() unimplemented!();
} }
fn fill_rect(&self, _rect: &Rect<f32>, _pattern: Pattern, _draw_options: Option<&DrawOptions>) { fn fill_rect(
unimplemented!() &mut self,
rect: &Rect<f32>,
pattern: Pattern,
draw_options: Option<&DrawOptions>,
) {
unimplemented!();
} }
fn get_format(&self) -> SurfaceFormat { fn get_format(&self) -> SurfaceFormat {
unimplemented!() unimplemented!();
} }
fn get_size(&self) -> Size2D<i32> { fn get_size(&self) -> Size2D<i32> {
unimplemented!() unimplemented!();
} }
fn get_transform(&self) -> Transform2D<f32> { fn get_transform(&self) -> Transform2D<f32> {
unimplemented!() unimplemented!();
} }
fn pop_clip(&self) { fn pop_clip(&mut self) {
unimplemented!() unimplemented!();
} }
fn push_clip(&self, _path: &Path) { fn push_clip(&mut self, path: &Path) {
unimplemented!() unimplemented!();
} }
fn set_transform(&self, _matrix: &Transform2D<f32>) { fn set_transform(&mut self, matrix: &Transform2D<f32>) {
unimplemented!() unimplemented!();
} }
fn snapshot(&self) -> SourceSurface { fn snapshot(&self) -> SourceSurface {
unimplemented!() unimplemented!();
} }
fn stroke( fn stroke(
&self, &mut self,
_path: &Path, path: &Path,
_pattern: Pattern, pattern: Pattern,
_stroke_options: &StrokeOptions, stroke_options: &StrokeOptions,
_draw_options: &DrawOptions, draw_options: &DrawOptions,
) { ) {
unimplemented!() unimplemented!();
} }
fn stroke_line( fn stroke_line(
&self, &mut self,
_start: Point2D<f32>, start: Point2D<f32>,
_end: Point2D<f32>, end: Point2D<f32>,
_pattern: Pattern, pattern: Pattern,
_stroke_options: &StrokeOptions, stroke_options: &StrokeOptions,
_draw_options: &DrawOptions, draw_options: &DrawOptions,
) { ) {
unimplemented!() unimplemented!();
} }
fn stroke_rect( fn stroke_rect(
&self, &mut self,
_rect: &Rect<f32>, rect: &Rect<f32>,
_pattern: Pattern, pattern: Pattern,
_stroke_options: &StrokeOptions<'_>, stroke_options: &StrokeOptions,
_draw_options: &DrawOptions, draw_options: &DrawOptions,
) { ) {
unimplemented!() unimplemented!();
} }
fn snapshot_data(&self, f: &Fn(&[u8]) -> Vec<u8>) -> Vec<u8> {
fn snapshot_data(&self, _f: &dyn Fn(&[u8]) -> Vec<u8>) -> Vec<u8> { unimplemented!();
unimplemented!()
} }
fn snapshot_data_owned(&self) -> Vec<u8> { fn snapshot_data_owned(&self) -> Vec<u8> {
unimplemented!() unimplemented!();
} }
} }