From b42f9eec48f9be80666c48eeaf3d707b47a0d032 Mon Sep 17 00:00:00 2001 From: Jaemin Moon Date: Wed, 20 Nov 2013 13:54:07 +0900 Subject: [PATCH] push/pop clip --- src/components/gfx/render_context.rs | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) mode change 100644 => 100755 src/components/gfx/render_context.rs diff --git a/src/components/gfx/render_context.rs b/src/components/gfx/render_context.rs old mode 100644 new mode 100755 index 8fe801cd3f4..314410222aa --- a/src/components/gfx/render_context.rs +++ b/src/components/gfx/render_context.rs @@ -43,6 +43,8 @@ impl<'self> RenderContext<'self> { self.draw_target.fill_rect(&bounds.to_azure_rect(), &ColorPattern(color)); } + + pub fn draw_border(&self, bounds: &Rect, border: SideOffsets2D, @@ -52,6 +54,7 @@ impl<'self> RenderContext<'self> { let rect = bounds.to_azure_rect(); let border = border.to_float_px(); + self.draw_target.make_current(); let mut dash: [AzFloat, ..2] = [0 as AzFloat, 0 as AzFloat]; let mut stroke_opts = StrokeOptions(0 as AzFloat, 10 as AzFloat); @@ -101,6 +104,32 @@ impl<'self> RenderContext<'self> { &draw_opts); } + pub fn draw_push_clip(&self, + bounds: &Rect, + border: SideOffsets2D + ){ + + let rect = bounds.to_azure_rect(); + let path_builder = self.draw_target.create_path_builder(); + + let left_top = Point2D(rect.origin.x, rect.origin.y); + let right_top = Point2D(rect.origin.x + rect.size.width, rect.origin.y); + let left_bottom = Point2D(rect.origin.x, rect.origin.y + rect.size.height); + let right_bottom = Point2D(rect.origin.x + rect.size.width, rect.origin.y + rect.size.height); + + path_builder.move_to(left_top); + path_builder.line_to(right_top); + path_builder.line_to(right_bottom); + path_builder.line_to(left_bottom); + + let path = path_builder.finish(); + self.draw_target.push_clip(&path); + } + + pub fn draw_pop_clip(&self){ + self.draw_target.pop_clip(); + } + pub fn draw_image(&self, bounds: Rect, image: Arc<~Image>) { let image = image.get(); let size = Size2D(image.width as i32, image.height as i32);