FLTK logo

[master] 4de491d - Make Fl_XXX_Graphics_Driver::create_bitmask() a static member function

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 4de491d - Make Fl_XXX_Graphics_Driver::create_bitmask() a static member function "ManoloFLTK" Nov 25, 2022  
 
commit 4de491d02e5c45d9a43cb7f93b729aaae1bbe8b6
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Fri Nov 25 15:53:04 2022 +0100
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Fri Nov 25 15:53:28 2022 +0100

    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 src/drivers/GDI/Fl_GDI_Graphics_Driver.H src/drivers/GDI/Fl_GDI_Graphics_Driver.H
index 521584f..39af1e6 100644
--- src/drivers/GDI/Fl_GDI_Graphics_Driver.H
+++ 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 src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
index d3e23be..62598f2 100644
--- src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
+++ 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 src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H
index 945ba4a..f5c9bd3 100644
--- src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H
+++ 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 src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
index cf2fcac..899d398 100644
--- src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
+++ 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);
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.