diff options
| author | Manolo Gouy <Manolo> | 2016-02-25 10:14:28 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-02-25 10:14:28 +0000 |
| commit | 31793cbdba8e318350c5ed11b06d5a678eb15608 (patch) | |
| tree | 6663410ff80abfa841ebf30a9a7f75bffeb730ac | |
| parent | e24f3f79a334a501c9a239b32fe465981a8c3aab (diff) | |
Remove the global variable fl_mask_bitmap - put it in the graphics driver's virtual API.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11216 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | FL/Fl_Graphics_Driver.H | 5 | ||||
| -rw-r--r-- | FL/Fl_PostScript.H | 3 | ||||
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver.h | 4 | ||||
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx | 5 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx | 1 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h | 3 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx | 5 | ||||
| -rw-r--r-- | src/fl_draw_pixmap.cxx | 6 | ||||
| -rw-r--r-- | src/ps_image.cxx | 6 |
9 files changed, 25 insertions, 13 deletions
diff --git a/FL/Fl_Graphics_Driver.H b/FL/Fl_Graphics_Driver.H index 4129f7147..da12bf8a4 100644 --- a/FL/Fl_Graphics_Driver.H +++ b/FL/Fl_Graphics_Driver.H @@ -88,6 +88,7 @@ class FL_EXPORT Fl_Graphics_Driver : public Fl_Device { friend class Fl_Pixmap; friend class Fl_Bitmap; friend class Fl_RGB_Image; + friend int fl_draw_pixmap(const char*const* cdata, int x, int y, Fl_Color bg); public: // The following functions create the various graphics drivers that are required // for core operations. They must be implemented as members of Fl_Graphics_Driver, @@ -255,6 +256,10 @@ public: /** Returns the driver-specific graphics context, of NULL if there's none. */ virtual void *gc(void) {return NULL;} protected: + /** Support for pixmap drawing */ + virtual uchar **mask_bitmap() { return 0; } + /** Support for pixmap drawing */ + virtual void mask_bitmap(uchar **) {} // --- implementation is in src/fl_vertex.cxx which includes src/cfg_gfx/xxx_rect.cxx virtual void transformed_vertex0(COORD_T x, COORD_T y); virtual void fixloop(); diff --git a/FL/Fl_PostScript.H b/FL/Fl_PostScript.H index 69114ce2c..0c52be73b 100644 --- a/FL/Fl_PostScript.H +++ b/FL/Fl_PostScript.H @@ -67,6 +67,9 @@ private: void *prepare85(); void write85(void *data, const uchar *p, int len); void close85(void *data); +protected: + uchar **mask_bitmap() {return &mask;} + void mask_bitmap(uchar **value) { } public: static const char *class_id; const char *class_name() {return class_id;}; diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.h b/src/drivers/GDI/Fl_GDI_Graphics_Driver.h index d49df4e90..32c17d1b9 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.h +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.h @@ -38,7 +38,11 @@ protected: HDC gc_; int numcount; int counts[20]; + uchar **mask_bitmap_; + uchar **mask_bitmap() {return mask_bitmap_;} + void mask_bitmap(uchar **value) { mask_bitmap_ = value; } public: + Fl_GDI_Graphics_Driver() {mask_bitmap_ = NULL;} static const char *class_id; const char *class_name() {return class_id;}; virtual int has_feature(driver_feature mask) { return mask & NATIVE; } diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx index 5ce2c5822..dca25ef8d 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx @@ -627,18 +627,17 @@ void Fl_GDI_Printer_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP } } -extern uchar **fl_mask_bitmap; fl_uintptr_t Fl_GDI_Graphics_Driver::cache(Fl_Pixmap *img, int w, int h, const char *const*data) { Fl_Offscreen id; id = fl_create_offscreen(w, h); fl_begin_offscreen(id); uchar *bitmap = 0; - fl_mask_bitmap = &bitmap; + mask_bitmap(&bitmap); fl_draw_pixmap(data, 0, 0, FL_BLACK); extern UINT win_pixmap_bg_color; // computed by fl_draw_pixmap() img->pixmap_bg_color = win_pixmap_bg_color; - fl_mask_bitmap = 0; + mask_bitmap(0); if (bitmap) { img->mask_ = (fl_uintptr_t)fl_create_bitmask(w, h, bitmap); delete[] bitmap; diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx index 9eb716ace..ebaf0792b 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx @@ -59,6 +59,7 @@ Fl_Xlib_Graphics_Driver::Fl_Xlib_Graphics_Driver(void) { gc_ = XCreateGC(fl_display, RootWindow(fl_display, fl_screen), 0, 0); fl_gc = gc_; } + mask_bitmap_ = NULL; } char Fl_Xlib_Graphics_Driver::can_do_alpha_blending() { diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h index 276316213..7c1f4799a 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h @@ -35,6 +35,9 @@ class FL_EXPORT Fl_Xlib_Graphics_Driver : public Fl_Graphics_Driver { protected: static GC gc_; + uchar **mask_bitmap_; + uchar **mask_bitmap() {return mask_bitmap_;} + void mask_bitmap(uchar **value) { mask_bitmap_ = value; } public: static const char *class_id; Fl_Xlib_Graphics_Driver(void); diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx index 591203174..53aa48a13 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx @@ -806,16 +806,15 @@ void Fl_Xlib_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int H else copy_offscreen(X, Y, W, H, pxm->id_, cx, cy); } -extern uchar **fl_mask_bitmap; // if non-zero, create bitmap and store pointer here fl_uintptr_t Fl_Xlib_Graphics_Driver::cache(Fl_Pixmap *img, int w, int h, const char *const*data) { Fl_Offscreen id; id = fl_create_offscreen(w, h); fl_begin_offscreen(id); uchar *bitmap = 0; - fl_mask_bitmap = &bitmap; + mask_bitmap(&bitmap); fl_draw_pixmap(data, 0, 0, FL_BLACK); - fl_mask_bitmap = 0; + mask_bitmap(0); if (bitmap) { img->mask_ = (fl_uintptr_t)fl_create_bitmask(w, h, bitmap); delete[] bitmap; diff --git a/src/fl_draw_pixmap.cxx b/src/fl_draw_pixmap.cxx index 544965185..cf7bd5a72 100644 --- a/src/fl_draw_pixmap.cxx +++ b/src/fl_draw_pixmap.cxx @@ -70,7 +70,6 @@ int fl_measure_pixmap(const char * const *cdata, int &w, int &h) { return 1; } -uchar **fl_mask_bitmap; // if non-zero, create bitmap and store pointer here /** Draw XPM image data, with the top-left corner at the given position. @@ -256,10 +255,11 @@ int fl_draw_pixmap(const char*const* cdata, int x, int y, Fl_Color bg) { } // build the mask bitmap used by Fl_Pixmap: - if (fl_mask_bitmap) { + uchar **p = fl_graphics_driver->mask_bitmap(); + if (p) { int W = (w+7)/8; uchar* bitmap = new uchar[W * h]; - *fl_mask_bitmap = bitmap; + *p = bitmap; const uchar *p = &buffer[3]; uchar b = 0; for (int Y = 0; Y < h; Y++) { diff --git a/src/ps_image.cxx b/src/ps_image.cxx index 0cee215e3..f6a118485 100644 --- a/src/ps_image.cxx +++ b/src/ps_image.cxx @@ -347,8 +347,6 @@ static inline uchar swap_byte(const uchar b) { } -extern uchar **fl_mask_bitmap; - struct callback_data { const uchar *data; int D, LD; @@ -577,7 +575,7 @@ void Fl_PostScript_Graphics_Driver::draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int w,h; if (!fl_measure_pixmap(di, w, h)) return; mask=0; - fl_mask_bitmap=&mask; + mask_bitmap(&mask); mx = WP; my = HP; push_clip(XP, YP, WP, HP); @@ -585,7 +583,7 @@ void Fl_PostScript_Graphics_Driver::draw(Fl_Pixmap * pxm,int XP, int YP, int WP, pop_clip(); delete[] mask; mask=0; - fl_mask_bitmap=0; + mask_bitmap(0); } void Fl_PostScript_Graphics_Driver::draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy){ |
