From 4de491d02e5c45d9a43cb7f93b729aaae1bbe8b6 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Fri, 25 Nov 2022 15:53:04 +0100 Subject: Make Fl_XXX_Graphics_Driver::create_bitmask() a static member function --- src/drivers/GDI/Fl_GDI_Graphics_Driver.H | 2 +- src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx | 12 +++++------- src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H | 2 +- src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H index 521584fa4..39af1e68e 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H @@ -69,7 +69,7 @@ public: virtual void *gc() {return gc_;} // --- bitmap stuff - HBITMAP create_bitmask(int w, int h, const uchar *array); // NOT virtual + static HBITMAP create_bitmask(int w, int h, const uchar *array); // NOT virtual virtual void delete_bitmask(fl_uintptr_t bm); HBITMAP create_alphamask(int w, int h, int d, int ld, const uchar *array); virtual void draw_unscaled(const char* str, int n, int x, int y); diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx index d3e23be9f..62598f2ce 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx @@ -337,7 +337,7 @@ void Fl_GDI_Graphics_Driver::colored_rectf(int x, int y, int w, int h, uchar r, // Create an N-bit bitmap for masking... HBITMAP Fl_GDI_Graphics_Driver::create_bitmask(int w, int h, const uchar *data) { // this won't work when the user changes display mode during run or - // has two screens with differnet depths + // has two screens with different depths HBITMAP bm; static uchar hiNibble[16] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, @@ -345,8 +345,9 @@ HBITMAP Fl_GDI_Graphics_Driver::create_bitmask(int w, int h, const uchar *data) static uchar loNibble[16] = { 0x00, 0x08, 0x04, 0x0c, 0x02, 0x0a, 0x06, 0x0e, 0x01, 0x09, 0x05, 0x0d, 0x03, 0x0b, 0x07, 0x0f }; - int np = GetDeviceCaps(gc_, PLANES); //: was always one on sample machines - int bpp = GetDeviceCaps(gc_, BITSPIXEL);//: 1,4,8,16,24,32 and more odd stuff? + HDC current_gc = (HDC)Fl_Surface_Device::surface()->driver()->gc(); + int np = GetDeviceCaps(current_gc, PLANES); //: was always one on sample machines + int bpp = GetDeviceCaps(current_gc, BITSPIXEL);//: 1,4,8,16,24,32 and more odd stuff? int Bpr = (bpp*w+7)/8; //: bytes per row int pad = Bpr&1, w1 = (w+7)/8, shr = ((w-1)&7)+1; if (bpp==4) shr = (shr+1)/2; @@ -803,11 +804,8 @@ void Fl_GDI_Graphics_Driver::cache(Fl_Pixmap *img) { fl_draw_pixmap(img->data(), 0, 0, FL_BLACK); uchar *bitmap = *pbitmap; if (bitmap) { - // Note: activating the surface device changes graphics drivers. - // Don't use 'this', but the new driver instead. *Fl_Graphics_Driver::mask(img) = - (fl_uintptr_t)((Fl_GDI_Graphics_Driver *)fl_graphics_driver)-> - create_bitmask(img->data_w(), img->data_h(), bitmap); + (fl_uintptr_t)create_bitmask(img->data_w(), img->data_h(), bitmap); delete[] bitmap; } *pbitmap = 0; diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H index 945ba4a78..f5c9bd3a2 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H @@ -65,7 +65,7 @@ public: char can_do_alpha_blending(); // --- bitmap stuff - CGImageRef create_bitmask(int w, int h, const uchar *array); // NOT virtual + static CGImageRef create_bitmask(int w, int h, const uchar *array); // NOT virtual virtual void delete_bitmask(fl_uintptr_t bm); void draw_pixmap(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); void draw_bitmap(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H index cf2fcac58..899d39819 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H @@ -119,7 +119,7 @@ public: static int fl_overlay; // --- bitmap stuff - unsigned long create_bitmask(int w, int h, const uchar *array); // NOT virtual + static unsigned long create_bitmask(int w, int h, const uchar *array); // NOT virtual virtual void delete_bitmask(fl_uintptr_t bm); virtual void draw_unscaled(const char* str, int n, int x, int y); virtual void draw_unscaled(int angle, const char *str, int n, int x, int y); -- cgit v1.2.3