diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2019-06-12 10:02:11 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2019-06-12 10:02:11 +0200 |
| commit | aa9f0a6962012991aa8a1fac005442efdc970757 (patch) | |
| tree | b0f161da3cae3bccb163e70a8564d4d007b4df03 /src/Fl_cocoa.mm | |
| parent | b238ec26e54d0f062629044c1842191200cdda3c (diff) | |
Move Fl_Cocoa_Window_Driver::capture_titlebar_and_borders() to Fl_Cocoa_Window_Driver.cxx from Fl_cocoa.mm
Diffstat (limited to 'src/Fl_cocoa.mm')
| -rw-r--r-- | src/Fl_cocoa.mm | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index cb549001e..94cd35489 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -4386,56 +4386,6 @@ void Fl_Cocoa_Window_Driver::draw_layer_to_context(CALayer *layer, CGContextRef #endif } - -/* Returns images of the capture of the window title-bar. - On the Mac OS platform, left, bottom and right are returned NULL; top is returned with depth 4. - */ -void Fl_Cocoa_Window_Driver::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right) -{ - left = bottom = right = NULL; - int htop = pWindow->decorated_h() - h(); - CALayer *layer = get_titlebar_layer(); - CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB(); - float s = Fl::screen_driver()->scale(screen_num()); - int scaled_w = int(w() * s); - uchar *rgba = new uchar[4 * scaled_w * htop * 4]; - CGContextRef auxgc = CGBitmapContextCreate(rgba, 2 * scaled_w, 2 * htop, 8, 8 * scaled_w, cspace, kCGImageAlphaPremultipliedLast); - CGColorSpaceRelease(cspace); - CGContextClearRect(auxgc, CGRectMake(0,0,2*scaled_w,2*htop)); - CGContextScaleCTM(auxgc, 2, 2); - if (layer) { - Fl_Cocoa_Window_Driver::draw_layer_to_context(layer, auxgc, scaled_w, htop); - if (fl_mac_os_version >= 101300) { - // drawn layer is left transparent and alpha-premultiplied: demultiply it and set it opaque. - uchar *p = rgba; - uchar *last = rgba + 4 * scaled_w * htop * 4; - while (p < last) { - uchar q = *(p+3); - if (q) { - float m = 255./q; - *p++ *= m; - *p++ *= m; - *p++ *= m; - *p++ = 0xff; - } else p += 4; - } - } - } else { - Fl_Graphics_Driver::default_driver().scale(1); - CGImageRef img = CGImage_from_window_rect(0, -htop, scaled_w, htop, false); - Fl_Graphics_Driver::default_driver().scale(s); - CGContextSaveGState(auxgc); - clip_to_rounded_corners(auxgc, scaled_w, htop); - CGContextDrawImage(auxgc, CGRectMake(0, 0, scaled_w, htop), img); - CGContextRestoreGState(auxgc); - CFRelease(img); - } - top = new Fl_RGB_Image(rgba, 2 * scaled_w, 2 * htop, 4); - top->alloc_array = 1; - top->scale(w(),htop, s <1 ? 0 : 1, 1); - CGContextRelease(auxgc); -} - void Fl_Cocoa_Window_Driver::gl_start(NSOpenGLContext *ctxt) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8 if (views_use_CA) { |
