From d67f395031b0e9cfb266bf31a4a5e08a2d109e3b Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Wed, 30 Mar 2016 20:16:40 +0000 Subject: Rewrite functions XRectangleRegion(), XDestroyRegion() under the driver model. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11479 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx') diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx index a829534d3..c288a5666 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx @@ -71,8 +71,13 @@ void Fl_Quartz_Graphics_Driver::copy_offscreen(int x,int y,int w,int h,Fl_Offscr CGDataProviderRelease(src_bytes); } +// so a CGRect matches exactly what is denoted x,y,w,h for clipping purposes +CGRect Fl_Quartz_Graphics_Driver::fl_cgrectmake_cocoa(int x, int y, int w, int h) { + return CGRectMake(x - 0.5, y - 0.5, w, h); +} + void Fl_Graphics_Driver::add_rectangle_to_region(Fl_Region r, int X, int Y, int W, int H) { - CGRect arg = fl_cgrectmake_cocoa(X, Y, W, H); + CGRect arg = Fl_Quartz_Graphics_Driver::fl_cgrectmake_cocoa(X, Y, W, H); int j; // don't add a rectangle totally inside the Fl_Region for(j = 0; j < r->count; j++) { if(CGRectContainsRect(r->rects[j], arg)) break; @@ -83,6 +88,21 @@ void Fl_Graphics_Driver::add_rectangle_to_region(Fl_Region r, int X, int Y, int } } +Fl_Region Fl_Graphics_Driver::XRectangleRegion(int x, int y, int w, int h) { + Fl_Region R = (Fl_Region)malloc(sizeof(*R)); + R->count = 1; + R->rects = (CGRect *)malloc(sizeof(CGRect)); + *(R->rects) = Fl_Quartz_Graphics_Driver::fl_cgrectmake_cocoa(x, y, w, h); + return R; +} + +void Fl_Graphics_Driver::XDestroyRegion(Fl_Region r) { + if(r) { + free(r->rects); + free(r); + } +} + // // End of "$Id$". // -- cgit v1.2.3