From 14ee093a5b57953073432ead358cbbc80b1b1837 Mon Sep 17 00:00:00 2001 From: Bastien Orivel Date: Thu, 8 Aug 2019 17:10:59 +0200 Subject: [PATCH] Implement size_from_pattern I tried to mimic the azure implementation but raqote doesn't have a concept of horizontal or vertical repeat so this might be wrong/incomplete but this is the last function needed to finally have some tests pass --- components/canvas/raqote_backend.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/components/canvas/raqote_backend.rs b/components/canvas/raqote_backend.rs index 573ee2bb8ff..1c31346661a 100644 --- a/components/canvas/raqote_backend.rs +++ b/components/canvas/raqote_backend.rs @@ -24,8 +24,18 @@ impl Backend for RaqoteBackend { color.as_raqote().a != 0 } - fn size_from_pattern(&self, _rect: &Rect, _pattern: &Pattern) -> Option> { - unimplemented!() + fn size_from_pattern(&self, rect: &Rect, pattern: &Pattern) -> Option> { + match pattern { + Pattern::Raqote(raqote::Source::Image(image, extend, ..)) => { + match extend { + raqote::ExtendMode::Repeat => { + Some(rect.size) + }, + _ => Some(Size2D::new(image.width as f32, image.height as f32)) + } + }, + _ => None + } } fn set_shadow_color<'a>(&mut self, _color: RGBA, _state: &mut CanvasPaintState<'a>) {