From ed547c6c63ee7e36ccf2a688cbc7ab83eb7d7f19 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sat, 24 Jan 2015 12:54:21 +0000 Subject: Simpler coding of the half-pixel offset necessary when clipping to a rectangle. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10533 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_cocoa.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 3d8e5d206..0cd9d1620 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -2979,7 +2979,6 @@ void Fl_X::make(Fl_Window* w) if (!CGRectContainsRect(prect, srect)) { // if subwindow extends outside its parent window CGRect clip = CGRectIntersection(prect, srect); clip = CGRectOffset(clip, -w->x(), -w->y()); - clip = fl_cgrectmake_cocoa(clip.origin.x, clip.origin.y, clip.size.width, clip.size.height); x->subRect(new CGRect(clip)); } set_subwindow_frame(w); @@ -3175,7 +3174,7 @@ void Fl_Window::resize(int X,int Y,int W,int H) { [[i->xid contentView] setNeedsDisplay:YES]; // subwindow needs redrawn if (CGRectEqualToRect(srect, full)) r = NULL; else { - r = new CGRect(fl_cgrectmake_cocoa(srect.origin.x, srect.origin.y, srect.size.width, srect.size.height)); + r = new CGRect(srect); } i->subRect(r); } @@ -3233,7 +3232,8 @@ void Fl_Window::make_current() CGContextTranslateCTM(fl_gc, 0.5, hgt-0.5f); CGContextScaleCTM(fl_gc, 1.0f, -1.0f); // now 0,0 is top-left point of the window // for subwindows, limit drawing to inside of parent window - if (i->subRect()) CGContextClipToRect(fl_gc, *(i->subRect())); + // half pixel offset is necessary for clipping as done by fl_cgrectmake_cocoa() + if (i->subRect()) CGContextClipToRect(fl_gc, CGRectOffset(*(i->subRect()), -0.5, -0.5)); // this is the context with origin at top left of (sub)window CGContextSaveGState(fl_gc); -- cgit v1.2.3