mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
push/pop clip
This commit is contained in:
parent
9d0958f91c
commit
b42f9eec48
1 changed files with 29 additions and 0 deletions
29
src/components/gfx/render_context.rs
Normal file → Executable file
29
src/components/gfx/render_context.rs
Normal file → Executable file
|
@ -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<Au>,
|
||||
border: SideOffsets2D<Au>,
|
||||
|
@ -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<Au>,
|
||||
border: SideOffsets2D<f32>
|
||||
){
|
||||
|
||||
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<Au>, image: Arc<~Image>) {
|
||||
let image = image.get();
|
||||
let size = Size2D(image.width as i32, image.height as i32);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue