diff options
| author | Manolo Gouy <Manolo> | 2010-02-02 17:13:55 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2010-02-02 17:13:55 +0000 |
| commit | 5ec87ac84845728cc004ef2920502a8e4eb4d9a0 (patch) | |
| tree | 2c562c77c544dce0d595e0aa1385612a87cc04a7 /src/Fl_cocoa.mm | |
| parent | c7b67bc25275b587d357939a21df6c534d56b5e9 (diff) | |
simplifying clipping algorithm: done once in make_current() instead of repeated at each fl_restore_clip() call
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7037 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_cocoa.mm')
| -rw-r--r-- | src/Fl_cocoa.mm | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 27ba2c086..2aa221eac 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -114,7 +114,6 @@ char fl_key_vector[32]; // used by Fl::get_key() bool fl_show_iconic; // true if called from iconize() - shows the next created window in collapsed state int fl_disable_transient_for; // secret method of removing TRANSIENT_FOR //const Fl_Window* fl_modal_for; // parent of modal() window -Fl_Region fl_window_region = 0; Window fl_window; Fl_Window *Fl_Window::current_; //EventRef fl_os_event; // last (mouse) event @@ -2246,11 +2245,8 @@ void Fl_Window::make_current() [[(NSWindow*)i->xid contentView] lockFocus]; i->gc = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; fl_gc = i->gc; - if ( fl_window_region ) XDestroyRegion(fl_window_region); - if (this->window()) { - fl_window_region = XRectangleRegion(0,0,w(),h()); - } else { - fl_window_region = XRectangleRegion(0, 0, w(), h()); + Fl_Region fl_window_region = XRectangleRegion(0,0,w(),h()); + if ( ! this->window() ) { for ( Fl_X *cx = i->xidChildren; cx; cx = cx->xidNext ) { // clip-out all sub-windows Fl_Window *cw = cx->w; Fl_Region from = fl_window_region; @@ -2262,8 +2258,19 @@ void Fl_Window::make_current() // antialiasing must be deactivated because it applies to rectangles too // and escapes even clipping!!! // it gets activated when needed (e.g., draw text) - CGContextSetShouldAntialias(fl_gc, false); - // this is the native view context with origin at bottom left + CGContextSetShouldAntialias(fl_gc, false); + CGFloat hgt = [[(NSWindow*)fl_window contentView] frame].size.height; + 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 + win = this; + while(win && win->window()) { // translate to subwindow origin if this is a subwindow context + CGContextTranslateCTM(fl_gc, win->x(), win->y()); + win = win->window(); + } + //apply window's clip + CGContextClipToRects(fl_gc, fl_window_region->rects, fl_window_region->count ); + XDestroyRegion(fl_window_region); +// this is the context with origin at top left of (sub)window clipped out of its subwindows if any CGContextSaveGState(fl_gc); #if defined(USE_CAIRO) if (Fl::cairo_autolink_context()) Fl::cairo_make_current(this); // capture gc changes automatically to update the cairo context adequately @@ -2286,24 +2293,14 @@ extern void fl_quartz_restore_line_style_(); // current Quartz context void Fl_X::q_fill_context() { if (!fl_gc) return; - int hgt = 0; - if (fl_window) { - hgt = [[(NSWindow*)Fl_X::i(Fl_Window::current_)->xid contentView] frame].size.height; - } else { - hgt = CGBitmapContextGetHeight(fl_gc); - } - CGContextTranslateCTM(fl_gc, 0.5, hgt-0.5f); - CGContextScaleCTM(fl_gc, 1.0f, -1.0f); // now 0,0 is top-left point of the context + if ( ! fl_window) { // a bitmap context + size_t hgt = CGBitmapContextGetHeight(fl_gc); + CGContextTranslateCTM(fl_gc, 0.5, hgt-0.5f); + CGContextScaleCTM(fl_gc, 1.0f, -1.0f); // now 0,0 is top-left point of the context + } fl_font(fl_fontsize); fl_color(fl_color_); fl_quartz_restore_line_style_(); - if (fl_window) { // translate to subwindow origin if this is a subwindow context - Fl_Window *w = Fl_Window::current_; - while(w && w->window()) { - CGContextTranslateCTM(fl_gc, w->x(), w->y()); - w = w->window(); - } - } } // The only way to reset clipping to its original state is to pop the current graphics |
