Skip to content

Commit

Permalink
WIP: Make GenericPathBuilder's methods take &mut self
Browse files Browse the repository at this point in the history
  • Loading branch information
pylbrecht authored and Eijebong committed Aug 21, 2019
1 parent 9f90139 commit b43c5c3
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 82 deletions.
26 changes: 16 additions & 10 deletions components/canvas/canvas_data.rs
Expand Up @@ -215,7 +215,12 @@ impl<'a> PathBuilderRef<'a> {
// The prototypes are derived from azure's methods.
pub trait GenericDrawTarget {
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(
&self,
gradient_stops: Vec<GradientStop>,
Expand Down Expand Up @@ -250,32 +255,32 @@ pub trait GenericDrawTarget {
sigma: f32,
operator: CompositionOp,
);
fn fill(&self, path: &Path, pattern: Pattern, draw_options: &DrawOptions);
fn fill_rect(&self, rect: &Rect<f32>, pattern: Pattern, draw_options: Option<&DrawOptions>);
fn fill(&mut self, path: &Path, pattern: Pattern, draw_options: &DrawOptions);
fn fill_rect(&mut self, rect: &Rect<f32>, pattern: Pattern, draw_options: Option<&DrawOptions>);
fn get_format(&self) -> SurfaceFormat;
fn get_size(&self) -> Size2D<i32>;
fn get_transform(&self) -> Transform2D<f32>;
fn pop_clip(&self);
fn push_clip(&self, path: &Path);
fn set_transform(&self, matrix: &Transform2D<f32>);
fn pop_clip(&mut self);
fn push_clip(&mut self, path: &Path);
fn set_transform(&mut self, matrix: &Transform2D<f32>);
fn snapshot(&self) -> SourceSurface;
fn stroke(
&self,
&mut self,
path: &Path,
pattern: Pattern,
stroke_options: &StrokeOptions,
draw_options: &DrawOptions,
);
fn stroke_line(
&self,
&mut self,
start: Point2D<f32>,
end: Point2D<f32>,
pattern: Pattern,
stroke_options: &StrokeOptions,
draw_options: &DrawOptions,
);
fn stroke_rect(
&self,
&mut self,
rect: &Rect<f32>,
pattern: Pattern,
stroke_options: &StrokeOptions,
Expand Down Expand Up @@ -659,7 +664,8 @@ impl<'a> CanvasData<'a> {

pub fn clip(&mut self) {
self.ensure_path();
self.drawtarget.push_clip(&self.path());
let path = self.path();
self.drawtarget.push_clip(&path);
}

pub fn is_point_in_path(
Expand Down
144 changes: 72 additions & 72 deletions components/canvas/raqote_backend.rs
Expand Up @@ -143,129 +143,129 @@ impl Path {
}

impl GenericDrawTarget for raqote::DrawTarget {
fn clear_rect(&self, _rect: &Rect<f32>) {
unimplemented!()
fn clear_rect(&self, rect: &Rect<f32>) {
unimplemented!();
}

fn copy_surface(
&self,
_surface: SourceSurface,
_source: Rect<i32>,
_destination: Point2D<i32>,
&mut self,
surface: SourceSurface,
source: Rect<i32>,
destination: Point2D<i32>,
) {
unimplemented!()
unimplemented!();
}

fn create_gradient_stops(
&self,
_gradient_stops: Vec<GradientStop>,
_extend_mode: ExtendMode,
gradient_stops: Vec<GradientStop>,
extend_mode: ExtendMode,
) -> GradientStops {
unimplemented!()
unimplemented!();
}

fn create_path_builder(&self) -> Box<dyn GenericPathBuilder> {
unimplemented!()
unimplemented!();
}

fn create_similar_draw_target(
&self,
_size: &Size2D<i32>,
_format: SurfaceFormat,
size: &Size2D<i32>,
format: SurfaceFormat,
) -> Box<dyn GenericDrawTarget> {
unimplemented!()
unimplemented!();
}
fn create_source_surface_from_data(
&self,
_data: &[u8],
_size: Size2D<i32>,
_stride: i32,
data: &[u8],
size: Size2D<i32>,
stride: i32,
) -> Option<SourceSurface> {
unimplemented!()
unimplemented!();
}
fn draw_surface(
&self,
_surface: SourceSurface,
_dest: Rect<f64>,
_source: Rect<f64>,
_filter: Filter,
_draw_options: &DrawOptions,
surface: SourceSurface,
dest: Rect<f64>,
source: Rect<f64>,
filter: Filter,
draw_options: &DrawOptions,
) {
unimplemented!()
unimplemented!();
}
fn draw_surface_with_shadow(
&self,
_surface: SourceSurface,
_dest: &Point2D<f32>,
_color: &Color,
_offset: &Vector2D<f32>,
_sigma: f32,
_operator: CompositionOp,
surface: SourceSurface,
dest: &Point2D<f32>,
color: &Color,
offset: &Vector2D<f32>,
sigma: f32,
operator: CompositionOp,
) {
unimplemented!()
unimplemented!();
}
fn fill(&self, _path: &Path, _pattern: Pattern, _draw_options: &DrawOptions) {
unimplemented!()
fn fill(&mut self, path: &Path, pattern: Pattern, draw_options: &DrawOptions) {
unimplemented!();
}
fn fill_rect(&self, _rect: &Rect<f32>, _pattern: Pattern, _draw_options: Option<&DrawOptions>) {
unimplemented!()
fn fill_rect(
&mut self,
rect: &Rect<f32>,
pattern: Pattern,
draw_options: Option<&DrawOptions>,
) {
unimplemented!();
}
fn get_format(&self) -> SurfaceFormat {
unimplemented!()
unimplemented!();
}
fn get_size(&self) -> Size2D<i32> {
unimplemented!()
unimplemented!();
}
fn get_transform(&self) -> Transform2D<f32> {
unimplemented!()
unimplemented!();
}
fn pop_clip(&self) {
unimplemented!()
fn pop_clip(&mut self) {
unimplemented!();
}
fn push_clip(&self, _path: &Path) {
unimplemented!()
fn push_clip(&mut self, path: &Path) {
unimplemented!();
}
fn set_transform(&self, _matrix: &Transform2D<f32>) {
unimplemented!()
fn set_transform(&mut self, matrix: &Transform2D<f32>) {
unimplemented!();
}
fn snapshot(&self) -> SourceSurface {
unimplemented!()
unimplemented!();
}
fn stroke(
&self,
_path: &Path,
_pattern: Pattern,
_stroke_options: &StrokeOptions,
_draw_options: &DrawOptions,
&mut self,
path: &Path,
pattern: Pattern,
stroke_options: &StrokeOptions,
draw_options: &DrawOptions,
) {
unimplemented!()
unimplemented!();
}
fn stroke_line(
&self,
_start: Point2D<f32>,
_end: Point2D<f32>,
_pattern: Pattern,
_stroke_options: &StrokeOptions,
_draw_options: &DrawOptions,
&mut self,
start: Point2D<f32>,
end: Point2D<f32>,
pattern: Pattern,
stroke_options: &StrokeOptions,
draw_options: &DrawOptions,
) {
unimplemented!()
unimplemented!();
}
fn stroke_rect(
&self,
_rect: &Rect<f32>,
_pattern: Pattern,
_stroke_options: &StrokeOptions<'_>,
_draw_options: &DrawOptions,
&mut self,
rect: &Rect<f32>,
pattern: Pattern,
stroke_options: &StrokeOptions,
draw_options: &DrawOptions,
) {
unimplemented!()
unimplemented!();
}

fn snapshot_data(&self, _f: &dyn Fn(&[u8]) -> Vec<u8>) -> Vec<u8> {
unimplemented!()
fn snapshot_data(&self, f: &Fn(&[u8]) -> Vec<u8>) -> Vec<u8> {
unimplemented!();
}

fn snapshot_data_owned(&self) -> Vec<u8> {
unimplemented!()
unimplemented!();
}
}

Expand Down

0 comments on commit b43c5c3

Please sign in to comment.