Skip to content

Commit

Permalink
Remove the global variable fl_mask_bitmap - put it in the graphics dr…
Browse files Browse the repository at this point in the history
…iver's virtual API.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11216 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Feb 25, 2016
1 parent e24f3f7 commit 31793cb
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 13 deletions.
5 changes: 5 additions & 0 deletions FL/Fl_Graphics_Driver.H
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions FL/Fl_PostScript.H
Expand Up @@ -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;};
Expand Down
4 changes: 4 additions & 0 deletions src/drivers/GDI/Fl_GDI_Graphics_Driver.h
Expand Up @@ -38,7 +38,11 @@ class FL_EXPORT Fl_GDI_Graphics_Driver : public Fl_Graphics_Driver {
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; }
Expand Down
5 changes: 2 additions & 3 deletions src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
Expand Up @@ -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() {
Expand Down
3 changes: 3 additions & 0 deletions src/drivers/Xlib/Fl_Xlib_Graphics_Driver.h
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/fl_draw_pixmap.cxx
Expand Up @@ -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.
Expand Down Expand Up @@ -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++) {
Expand Down
6 changes: 2 additions & 4 deletions src/ps_image.cxx
Expand Up @@ -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;
Expand Down Expand Up @@ -577,15 +575,15 @@ 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);
fl_draw_pixmap(di,XP -cx, YP -cy, FL_BLACK );
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){
Expand Down

0 comments on commit 31793cb

Please sign in to comment.