From 32d4bc4099ac62a32166c9d39ddd47d6a193be2a Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sun, 18 Mar 2012 18:48:29 +0000 Subject: Fix STR#2810: removed all uses of function Fl_Device::class_name(). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9293 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Bitmap.cxx | 2 +- src/Fl_Device.cxx | 7 ++- src/Fl_Double_Window.cxx | 48 ++++++++++++---- src/Fl_GDI_Printer.cxx | 2 +- src/Fl_Image.cxx | 4 +- src/Fl_Pixmap.cxx | 136 ++++++++++++++++++++------------------------ src/Fl_Text_Display.cxx | 2 +- src/Fl_cocoa.mm | 2 - src/Fl_win32.cxx | 6 +- src/Fl_x.cxx | 4 +- src/fl_draw_image_mac.cxx | 4 +- src/fl_draw_image_win32.cxx | 6 +- src/fl_draw_pixmap.cxx | 21 ++----- src/fl_font_win32.cxx | 4 +- src/fl_line_style.cxx | 4 +- src/fl_rect.cxx | 8 +-- 16 files changed, 130 insertions(+), 130 deletions(-) (limited to 'src') diff --git a/src/Fl_Bitmap.cxx b/src/Fl_Bitmap.cxx index 080471e54..4a03fffa9 100644 --- a/src/Fl_Bitmap.cxx +++ b/src/Fl_Bitmap.cxx @@ -295,7 +295,7 @@ void Fl_GDI_Graphics_Driver::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, HDC tempdc; int save; BOOL use_print_algo = false; - if (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { + if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) { static HMODULE hMod = NULL; if (!hMod) { hMod = LoadLibrary("MSIMG32.DLL"); diff --git a/src/Fl_Device.cxx b/src/Fl_Device.cxx index db8243cdc..cde8156ed 100644 --- a/src/Fl_Device.cxx +++ b/src/Fl_Device.cxx @@ -3,7 +3,7 @@ // // implementation of Fl_Device class for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2011 by Bill Spitzak and others. +// Copyright 2010-2012 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -29,6 +29,7 @@ const char *Fl_Quartz_Graphics_Driver::class_id = "Fl_Quartz_Graphics_Driver"; #endif #if defined(WIN32) || defined(FL_DOXYGEN) const char *Fl_GDI_Graphics_Driver::class_id = "Fl_GDI_Graphics_Driver"; +const char *Fl_GDI_Printer_Graphics_Driver::class_id = "Fl_GDI_Printer_Graphics_Driver"; #endif #if !(defined(__APPLE__) || defined(WIN32)) const char *Fl_Xlib_Graphics_Driver::class_id = "Fl_Xlib_Graphics_Driver"; @@ -42,6 +43,9 @@ void Fl_Surface_Device::set_current(void) _surface = this; } +FL_EXPORT Fl_Graphics_Driver *fl_graphics_driver; // the current target device of graphics operations +Fl_Surface_Device* Fl_Surface_Device::_surface; // the current target surface of graphics operations + const Fl_Graphics_Driver::matrix Fl_Graphics_Driver::m0 = {1, 0, 0, 1, 0, 0}; Fl_Graphics_Driver::Fl_Graphics_Driver() { @@ -88,6 +92,7 @@ Fl_Display_Device::Fl_Display_Device(Fl_Graphics_Driver *graphics_driver) : Fl_S #endif fl_mac_os_version = versionMajor * 10000 + versionMinor * 100 + versionBugFix; #endif +this->set_current(); }; diff --git a/src/Fl_Double_Window.cxx b/src/Fl_Double_Window.cxx index bec91f1c1..3c20f8be0 100644 --- a/src/Fl_Double_Window.cxx +++ b/src/Fl_Double_Window.cxx @@ -59,7 +59,6 @@ void Fl_Double_Window::show() { Fl_Window::show(); } -static void fl_copy_offscreen_to_display(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); /** \addtogroup fl_drawings @{ @@ -70,23 +69,46 @@ static void fl_copy_offscreen_to_display(int x, int y, int w, int h, Fl_Offscree \param pixmap offscreen buffer containing the rectangle to copy \param srcx,srcy origin in offscreen buffer of rectangle to copy */ +#if FLTK_ABI_VERSION >= 10302 +inline void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) { + fl_graphics_driver->copy_offscreen(x, y, w, h, pixmap, srcx, srcy); +} +#else void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) { +#ifdef WIN32 + if (fl_graphics_driver->class_name() == Fl_GDI_Graphics_Driver::class_id || + fl_graphics_driver->class_name() == Fl_GDI_Printer_Graphics_Driver::class_id) { +#else if (fl_graphics_driver->class_name() == Fl_Display_Device::display_device()->driver()->class_name()) { - fl_copy_offscreen_to_display(x, y, w, h, pixmap, srcx, srcy); +#endif +#ifdef USE_X11 + ((Fl_Xlib_Graphics_Driver*)fl_graphics_driver)->copy_offscreen(x, y, w, h, pixmap, srcx, srcy); +#elif defined(WIN32) + ((Fl_GDI_Graphics_Driver*)fl_graphics_driver)->copy_offscreen(x, y, w, h, pixmap, srcx, srcy); +#elif defined(__APPLE__) + ((Fl_Quartz_Graphics_Driver*)fl_graphics_driver)->copy_offscreen(x, y, w, h, pixmap, srcx, srcy); +#endif } else { // when copy is not to the display - fl_begin_offscreen(pixmap); - uchar *img = fl_read_image(NULL, srcx, srcy, w, h, 0); - fl_end_offscreen(); - fl_draw_image(img, x, y, w, h, 3, 0); - delete[] img; + fl_graphics_driver->copy_offscreen(x, y, w, h, pixmap, srcx, srcy); } } +#endif // FLTK_ABI_VERSION /** @} */ +/** see fl_copy_offscreen() */ +void Fl_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) +{ + fl_begin_offscreen(pixmap); + uchar *img = fl_read_image(NULL, srcx, srcy, w, h, 0); + fl_end_offscreen(); + fl_draw_image(img, x, y, w, h, 3, 0); + delete[] img; +} + #if defined(USE_X11) -static void fl_copy_offscreen_to_display(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) { +void Fl_Xlib_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) { XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y); } @@ -158,7 +180,7 @@ HDC fl_makeDC(HBITMAP bitmap) { return new_gc; } -static void fl_copy_offscreen_to_display(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy) { +void Fl_GDI_Graphics_Driver::copy_offscreen(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy) { HDC new_gc = CreateCompatibleDC(fl_gc); int save = SaveDC(new_gc); SelectObject(new_gc, bitmap); @@ -171,11 +193,11 @@ void Fl_GDI_Graphics_Driver::copy_offscreen_with_alpha(int x,int y,int w,int h,H HDC new_gc = CreateCompatibleDC(fl_gc); int save = SaveDC(new_gc); SelectObject(new_gc, bitmap); + fl_can_do_alpha_blending(); // make sure this is called BOOL alpha_ok = 0; // first try to alpha blend // if to printer, always try alpha_blend - int to_display = Fl_Surface_Device::surface()->class_name() == Fl_Display_Device::class_id; // true iff display output - if ( (to_display && fl_can_do_alpha_blending()) || Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { + if ( Fl_Surface_Device::surface() != Fl_Display_Device::display_device() || fl_can_do_alpha_blending() ) { if (fl_alpha_blend) alpha_ok = fl_alpha_blend(fl_gc, x, y, w, h, new_gc, srcx, srcy, w, h, blendfunc); } // if that failed (it shouldn't), still copy the bitmap over, but now alpha is 1 @@ -194,6 +216,7 @@ char fl_can_do_alpha_blending() { return 1; } +#if ! defined(FL_DOXYGEN) Fl_Offscreen Fl_Quartz_Graphics_Driver::create_offscreen_with_alpha(int w, int h) { void *data = calloc(w*h,4); CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB(); @@ -202,6 +225,7 @@ Fl_Offscreen Fl_Quartz_Graphics_Driver::create_offscreen_with_alpha(int w, int h CGColorSpaceRelease(lut); return (Fl_Offscreen)ctx; } +#endif /** \addtogroup fl_drawings @{ @@ -227,7 +251,7 @@ static void bmProviderRelease (void *src, const void *data, size_t size) { if(count == 1) free((void*)data); } -static void fl_copy_offscreen_to_display(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int srcy) { +void Fl_Quartz_Graphics_Driver::copy_offscreen(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int srcy) { CGContextRef src = (CGContextRef)osrc; void *data = CGBitmapContextGetData(src); int sw = CGBitmapContextGetWidth(src); diff --git a/src/Fl_GDI_Printer.cxx b/src/Fl_GDI_Printer.cxx index d1bc98772..be740e30f 100644 --- a/src/Fl_GDI_Printer.cxx +++ b/src/Fl_GDI_Printer.cxx @@ -27,7 +27,7 @@ extern HWND fl_window; Fl_System_Printer::Fl_System_Printer(void) : Fl_Paged_Device() { hPr = NULL; - driver(new Fl_GDI_Graphics_Driver); + driver(new Fl_GDI_Printer_Graphics_Driver); } Fl_System_Printer::~Fl_System_Printer(void) { diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx index 267ee4167..4bf41f888 100644 --- a/src/Fl_Image.cxx +++ b/src/Fl_Image.cxx @@ -532,7 +532,7 @@ void Fl_GDI_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, int } else if (img->d()==2 || img->d()==4) { copy_offscreen_with_alpha(X, Y, W, H, (Fl_Offscreen)img->id_, cx, cy); } else { - fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)img->id_, cx, cy); + copy_offscreen(X, Y, W, H, (Fl_Offscreen)img->id_, cx, cy); } } @@ -569,7 +569,7 @@ void Fl_Xlib_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, in XSetClipOrigin(fl_display, fl_gc, X-cx, Y-cy); } - fl_copy_offscreen(X, Y, W, H, img->id_, cx, cy); + copy_offscreen(X, Y, W, H, img->id_, cx, cy); if (img->mask_) { // put the old clip region back diff --git a/src/Fl_Pixmap.cxx b/src/Fl_Pixmap.cxx index 2c780d326..d5e3c29d1 100644 --- a/src/Fl_Pixmap.cxx +++ b/src/Fl_Pixmap.cxx @@ -92,69 +92,50 @@ static int start(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int w, int h, i return 0; } -#ifdef __APPLE__ -void Fl_Quartz_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) { - int X, Y, W, H; - if (pxm->w() < 0) pxm->measure(); - int code = start(pxm, XP, YP, WP, HP, pxm->w(), pxm->h(), cx, cy, X, Y, W, H); +int Fl_Pixmap::prepare(int XP, int YP, int WP, int HP, int cx, int cy, + int &X, int &Y, int &W, int &H) { + if (w() < 0) measure(); + int code = start(this, XP, YP, WP, HP, w(), h(), cx, cy, X, Y, W, H); if (code) { - if (code == 2) pxm->draw_empty(XP, YP); - return; - } - if (!pxm->id_) { - pxm->id_ = create_offscreen_with_alpha(pxm->w(), pxm->h()); - fl_begin_offscreen((Fl_Offscreen)pxm->id_); - fl_draw_pixmap(pxm->data(), 0, 0, FL_GREEN); - fl_end_offscreen(); - } - fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy); -} - -#elif defined(WIN32) -void Fl_GDI_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) { - int X, Y, W, H; - if (pxm->w() < 0) pxm->measure(); - int code = start(pxm, XP, YP, WP, HP, pxm->w(), pxm->h(), cx, cy, X, Y, W, H); - if (code) { - if (code == 2) pxm->draw_empty(XP, YP); - return; + if (code == 2) draw_empty(XP, YP); + return 1; } - if (!pxm->id_) { - pxm->id_ = fl_create_offscreen(pxm->w(), pxm->h()); - fl_begin_offscreen((Fl_Offscreen)pxm->id_); + if (!id_) { +#ifdef __APPLE__ + id_ = Fl_Quartz_Graphics_Driver::create_offscreen_with_alpha(w(), h()); +#else + id_ = fl_create_offscreen(w(), h()); +#endif + fl_begin_offscreen((Fl_Offscreen)id_); +#ifndef __APPLE__ uchar *bitmap = 0; fl_mask_bitmap = &bitmap; - fl_draw_pixmap(pxm->data(), 0, 0, FL_BLACK); +#endif + fl_draw_pixmap(data(), 0, 0, FL_BLACK); +#ifndef __APPLE__ fl_mask_bitmap = 0; if (bitmap) { - pxm->mask_ = fl_create_bitmask(pxm->w(), pxm->h(), bitmap); + mask_ = fl_create_bitmask(w(), h(), bitmap); delete[] bitmap; } +#endif fl_end_offscreen(); } - if (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { - typedef BOOL (WINAPI* fl_transp_func) (HDC,int,int,int,int,HDC,int,int,int,int,UINT); - static HMODULE hMod = NULL; - static fl_transp_func fl_TransparentBlt = NULL; - if (!hMod) { - hMod = LoadLibrary("MSIMG32.DLL"); - if(hMod) fl_TransparentBlt = (fl_transp_func)GetProcAddress(hMod, "TransparentBlt"); - } - if (fl_TransparentBlt) { - HDC new_gc = CreateCompatibleDC(fl_gc); - int save = SaveDC(new_gc); - SelectObject(new_gc, (void*)pxm->id_); - // print all of offscreen but its parts in background color - extern UINT win_pixmap_bg_color; // computed by fl_draw_pixmap() - fl_TransparentBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, pxm->w(), pxm->h(), win_pixmap_bg_color ); - RestoreDC(new_gc,save); - DeleteDC(new_gc); - } - else { - fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy); - } - } - else if (pxm->mask_) { + return 0; +} + +#ifdef __APPLE__ +void Fl_Quartz_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) { + int X, Y, W, H; + if (pxm->prepare(XP, YP, WP, HP, cx, cy, X, Y, W, H)) return; + copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy); +} + +#elif defined(WIN32) +void Fl_GDI_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) { + int X, Y, W, H; + if (pxm->prepare(XP, YP, WP, HP, cx, cy, X, Y, W, H)) return; + if (pxm->mask_) { HDC new_gc = CreateCompatibleDC(fl_gc); int save = SaveDC(new_gc); SelectObject(new_gc, (void*)pxm->mask_); @@ -164,32 +145,39 @@ void Fl_GDI_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP RestoreDC(new_gc,save); DeleteDC(new_gc); } else { - fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy); + copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy); } } -#else // Xlib -void Fl_Xlib_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) { +void Fl_GDI_Printer_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) { int X, Y, W, H; - if (pxm->w() < 0) pxm->measure(); - int code = start(pxm, XP, YP, WP, HP, pxm->w(), pxm->h(), cx, cy, X, Y, W, H); - if (code) { - if (code == 2) pxm->draw_empty(XP, YP); - return; + if (pxm->prepare(XP, YP, WP, HP, cx, cy, X, Y, W, H)) return; + typedef BOOL (WINAPI* fl_transp_func) (HDC,int,int,int,int,HDC,int,int,int,int,UINT); + static HMODULE hMod = NULL; + static fl_transp_func fl_TransparentBlt = NULL; + if (!hMod) { + hMod = LoadLibrary("MSIMG32.DLL"); + if(hMod) fl_TransparentBlt = (fl_transp_func)GetProcAddress(hMod, "TransparentBlt"); } - if (!pxm->id_) { - pxm->id_ = fl_create_offscreen(pxm->w(), pxm->h()); - fl_begin_offscreen((Fl_Offscreen)pxm->id_); - uchar *bitmap = 0; - fl_mask_bitmap = &bitmap; - fl_draw_pixmap(pxm->data(), 0, 0, FL_BLACK); - fl_mask_bitmap = 0; - if (bitmap) { - pxm->mask_ = fl_create_bitmask(pxm->w(), pxm->h(), bitmap); - delete[] bitmap; - } - fl_end_offscreen(); + if (fl_TransparentBlt) { + HDC new_gc = CreateCompatibleDC(fl_gc); + int save = SaveDC(new_gc); + SelectObject(new_gc, (void*)pxm->id_); + // print all of offscreen but its parts in background color + extern UINT win_pixmap_bg_color; // computed by fl_draw_pixmap() + fl_TransparentBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, pxm->w(), pxm->h(), win_pixmap_bg_color ); + RestoreDC(new_gc,save); + DeleteDC(new_gc); } + else { + copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy); + } +} + +#else // Xlib +void Fl_Xlib_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) { + int X, Y, W, H; + if (pxm->prepare(XP, YP, WP, HP, cx, cy, X, Y, W, H)) return; if (pxm->mask_) { // I can't figure out how to combine a mask with existing region, // so cut the image down to a clipped rectangle: @@ -202,7 +190,7 @@ void Fl_Xlib_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int H int oy = Y-cy; if (oy < 0) oy += pxm->h(); XSetClipOrigin(fl_display, fl_gc, X-cx, Y-cy); } - fl_copy_offscreen(X, Y, W, H, pxm->id_, cx, cy); + copy_offscreen(X, Y, W, H, pxm->id_, cx, cy); if (pxm->mask_) { // put the old clip region back XSetClipOrigin(fl_display, fl_gc, 0, 0); diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index 2d060fa49..eba2557e3 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -3369,7 +3369,7 @@ void Fl_Text_Display::draw(void) { // draw the non-text, non-scrollbar areas. if (damage() & FL_DAMAGE_ALL) { // printf("drawing all (box = %d)\n", box()); - if (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { + if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) { // if to printer, draw the background fl_rectf(text_area.x, text_area.y, text_area.w, text_area.h, color() ); } diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index d1dd3ade0..c89934764 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -89,8 +89,6 @@ static void cocoaMouseHandler(NSEvent *theEvent); static Fl_Quartz_Graphics_Driver fl_quartz_driver; static Fl_Display_Device fl_quartz_display(&fl_quartz_driver); -FL_EXPORT Fl_Graphics_Driver *fl_graphics_driver = (Fl_Graphics_Driver*)&fl_quartz_driver; // the current target device of graphics operations -Fl_Surface_Device* Fl_Surface_Device::_surface = (Fl_Surface_Device*)&fl_quartz_display; // the current target surface of graphics operations Fl_Display_Device *Fl_Display_Device::_display = &fl_quartz_display; // the platform display // public variables diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 44613a666..531a7ab76 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -3,7 +3,7 @@ // // WIN32-specific code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2012 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -85,8 +85,6 @@ static Fl_GDI_Graphics_Driver fl_gdi_driver; static Fl_Display_Device fl_gdi_display(&fl_gdi_driver); -FL_EXPORT Fl_Graphics_Driver *fl_graphics_driver = (Fl_Graphics_Driver*)&fl_gdi_driver; // the current target driver of graphics operations -Fl_Surface_Device* Fl_Surface_Device::_surface = (Fl_Surface_Device*)&fl_gdi_display; // the current target surface of graphics operations Fl_Display_Device *Fl_Display_Device::_display = &fl_gdi_display; // the platform display // dynamic wsock dll handling api: @@ -1949,7 +1947,7 @@ void fl_cleanup_dc_list(void) { // clean up the list } Fl_Region XRectangleRegion(int x, int y, int w, int h) { - if (Fl_Surface_Device::surface()->class_name() == Fl_Display_Device::class_id) return CreateRectRgn(x,y,x+w,y+h); + if (Fl_Surface_Device::surface() == Fl_Display_Device::display_device()) return CreateRectRgn(x,y,x+w,y+h); // because rotation may apply, the rectangle becomes a polygon in device coords POINT pt[4] = { {x, y}, {x + w, y}, {x + w, y + h}, {x, y + h} }; LPtoDP(fl_gc, pt, 4); diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 46eed2b61..3ee226173 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -3,7 +3,7 @@ // // X specific code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2011 by Bill Spitzak and others. +// Copyright 1998-2012 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -54,8 +54,6 @@ static int randrEventBase; // base of RandR-defined events static Fl_Xlib_Graphics_Driver fl_xlib_driver; static Fl_Display_Device fl_xlib_display(&fl_xlib_driver); -FL_EXPORT Fl_Graphics_Driver *fl_graphics_driver = (Fl_Graphics_Driver*)&fl_xlib_driver; // the current target device of graphics operations -Fl_Surface_Device* Fl_Surface_Device::_surface = (Fl_Surface_Device*)&fl_xlib_display; // the current target surface of graphics operations Fl_Display_Device *Fl_Display_Device::_display = &fl_xlib_display;// the platform display //////////////////////////////////////////////////////////////// diff --git a/src/fl_draw_image_mac.cxx b/src/fl_draw_image_mac.cxx index 9a97eb6a5..3a177ff1e 100644 --- a/src/fl_draw_image_mac.cxx +++ b/src/fl_draw_image_mac.cxx @@ -3,7 +3,7 @@ // // MacOS image drawing code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2012 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -55,7 +55,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, const void *array = buf; uchar *tmpBuf = 0; - if (cb || Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { + if (cb || Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) { tmpBuf = new uchar[ H*W*delta ]; if (cb) { for (int i=0; i MAXBUFFER && Fl_Surface_Device::surface()->class_name() != Fl_Printer::class_id) { + if (size > MAXBUFFER && Fl_Surface_Device::surface() == Fl_Display_Device::display_device()) { size = MAXBUFFER; blocking = MAXBUFFER/linesize; } @@ -247,7 +247,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, } } } - if(Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { + if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) { // if print context, device and logical units are not equal, so SetDIBitsToDevice // does not do the expected job, whereas StretchDIBits does it. StretchDIBits(fl_gc, x, y+j-k, w, k, 0, 0, w, k, diff --git a/src/fl_draw_pixmap.cxx b/src/fl_draw_pixmap.cxx index 0bbc9057f..3c55559df 100644 --- a/src/fl_draw_pixmap.cxx +++ b/src/fl_draw_pixmap.cxx @@ -3,7 +3,7 @@ // // Pixmap drawing code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2012 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -332,9 +332,7 @@ int fl_draw_pixmap(const char*const* cdata, int x, int y, Fl_Color bg) { #endif #ifdef __APPLE_QUARTZ__ - if (fl_graphics_driver->class_name() == Fl_Quartz_Graphics_Driver::class_id ) { - bool transparent = (transparent_index>=0); - transparent = true; + if (Fl_Surface_Device::surface() == Fl_Display_Device::display_device()) { U32 *array = new U32[d.w * d.h], *q = array; for (int Y = 0; Y < d.h; Y++) { const uchar* p = data[Y]; @@ -349,18 +347,9 @@ int fl_draw_pixmap(const char*const* cdata, int x, int y, Fl_Color bg) { } } } - CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB(); - CGDataProviderRef src = CGDataProviderCreateWithData( 0L, array, d.w * d.h * 4, 0L); - CGImageRef img = CGImageCreate(d.w, d.h, 8, 4*8, 4*d.w, - lut, transparent?kCGImageAlphaLast:kCGImageAlphaNoneSkipLast, - src, 0L, false, kCGRenderingIntentDefault); - CGColorSpaceRelease(lut); - CGDataProviderRelease(src); - CGRect rect = { { x, y} , { d.w, d.h } }; - Fl_X::q_begin_image(rect, 0, 0, d.w, d.h); - CGContextDrawImage(fl_gc, rect, img); - Fl_X::q_end_image(); - CGImageRelease(img); + Fl_RGB_Image* rgb = new Fl_RGB_Image((uchar*)array, d.w, d.h, 4); + rgb->draw(x, y); + delete rgb; delete[] array; } else { diff --git a/src/fl_font_win32.cxx b/src/fl_font_win32.cxx index 151e5e523..99358d606 100644 --- a/src/fl_font_win32.cxx +++ b/src/fl_font_win32.cxx @@ -3,7 +3,7 @@ // // WIN32 font selection routines for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2011 by Bill Spitzak and others. +// Copyright 1998-2012 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -263,7 +263,7 @@ static void on_printer_extents_update(int &dx, int &dy, int &w, int &h) // if printer context, extents shd be converted to logical coords #define EXTENTS_UPDATE(x,y,w,h) \ - if (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { on_printer_extents_update(x,y,w,h); } + if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) { on_printer_extents_update(x,y,w,h); } // Function to determine the extent of the "inked" area of the glyphs in a string void Fl_GDI_Graphics_Driver::text_extents(const char *c, int n, int &dx, int &dy, int &w, int &h) { diff --git a/src/fl_line_style.cxx b/src/fl_line_style.cxx index 194ee22bc..947f01afe 100644 --- a/src/fl_line_style.cxx +++ b/src/fl_line_style.cxx @@ -3,7 +3,7 @@ // // Line style code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2012 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -118,7 +118,7 @@ void Fl_Graphics_Driver::line_style(int style, int width, char* dashes) { fl_quartz_line_width_ = (float)width; fl_quartz_line_cap_ = Cap[(style>>8)&3]; // when printing kCGLineCapSquare seems better for solid lines - if ( Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id && style == FL_SOLID && dashes == NULL ) { + if ( Fl_Surface_Device::surface() != Fl_Display_Device::display_device() && style == FL_SOLID && dashes == NULL ) { fl_quartz_line_cap_ = kCGLineCapSquare; } fl_quartz_line_join_ = Join[(style>>12)&3]; diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx index 33a874856..ee4430497 100644 --- a/src/fl_rect.cxx +++ b/src/fl_rect.cxx @@ -3,7 +3,7 @@ // // Rectangle drawing routines for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2012 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -40,7 +40,7 @@ extern int fl_line_width_; #ifdef __APPLE_QUARTZ__ extern float fl_quartz_line_width_; -#define USINGQUARTZPRINTER (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) +#define USINGQUARTZPRINTER (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) #endif #ifdef USE_X11 @@ -612,7 +612,7 @@ int Fl_Graphics_Driver::not_clipped(int x, int y, int w, int h) { return XRectInRegion(r, x, y, w, h); #elif defined(WIN32) RECT rect; - if (Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { // in case of print context, convert coords from logical to device + if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) { // in case of print context, convert coords from logical to device POINT pt[2] = { {x, y}, {x + w, y + h} }; LPtoDP(fl_gc, pt, 2); rect.left = pt[0].x; rect.top = pt[0].y; rect.right = pt[1].x; rect.bottom = pt[1].y; @@ -672,7 +672,7 @@ int Fl_Graphics_Driver::clip_box(int x, int y, int w, int h, int& X, int& Y, int } else { // partial intersection RECT rect; GetRgnBox(temp, &rect); - if(Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) { // if print context, convert coords from device to logical + if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) { // if print context, convert coords from device to logical POINT pt[2] = { {rect.left, rect.top}, {rect.right, rect.bottom} }; DPtoLP(fl_gc, pt, 2); X = pt[0].x; Y = pt[0].y; W = pt[1].x - X; H = pt[1].y - Y; -- cgit v1.2.3