Fix Fl_RGB_Image::uncache() and Fl_Bitmap::uncache().

It is not possible to use fl_graphics_driver in these functions
because when they are called *fl_graphics_driver may have been
deleted. A solution is to use  Fl_Display_Device::display_device()->driver()
instead which is always valid.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11212 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2016-02-23 20:37:22 +00:00
parent 0f7e3ac086
commit 941c301ceb
9 changed files with 3 additions and 20 deletions

View File

@ -223,7 +223,6 @@ public:
virtual Fl_Bitmask create_bitmask(int w, int h, const uchar *array) = 0; virtual Fl_Bitmask create_bitmask(int w, int h, const uchar *array) = 0;
virtual fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array) { return 0; } virtual fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array) { return 0; }
virtual fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array) { return 0; } virtual fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array) { return 0; }
virtual void uncache(Fl_Bitmap *img, fl_uintptr_t &id_) { }
virtual void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_) { } virtual void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_) { }
virtual void delete_bitmask(Fl_Bitmask bm) = 0; virtual void delete_bitmask(Fl_Bitmask bm) = 0;
virtual void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0) {} virtual void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0) {}

View File

@ -34,7 +34,7 @@ Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) {
} }
void fl_delete_bitmask(Fl_Bitmask bm) { void fl_delete_bitmask(Fl_Bitmask bm) {
return fl_graphics_driver->delete_bitmask(bm); return Fl_Display_Device::display_device()->driver()->delete_bitmask(bm);
} }
// Create a 1-bit mask used for alpha blending // Create a 1-bit mask used for alpha blending
@ -147,7 +147,7 @@ Fl_Bitmap::~Fl_Bitmap() {
void Fl_Bitmap::uncache() { void Fl_Bitmap::uncache() {
if (id_) { if (id_) {
fl_graphics_driver->uncache(this, id_); fl_delete_bitmask((Fl_Bitmask)id_);
id_ = 0; id_ = 0;
} }
} }

View File

@ -289,7 +289,7 @@ Fl_RGB_Image::~Fl_RGB_Image() {
} }
void Fl_RGB_Image::uncache() { void Fl_RGB_Image::uncache() {
fl_graphics_driver->uncache(this, id_, mask_); Fl_Display_Device::display_device()->driver()->uncache(this, id_, mask_);
} }
Fl_Image *Fl_RGB_Image::copy(int W, int H) { Fl_Image *Fl_RGB_Image::copy(int W, int H) {

View File

@ -62,7 +62,6 @@ public:
void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1);
fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array); fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array);
fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array); fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array);
void uncache(Fl_Bitmap *img, fl_uintptr_t &id_);
void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_); void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_);
double width(const char *str, int n); double width(const char *str, int n);
double width(unsigned int c); double width(unsigned int c);

View File

@ -585,10 +585,6 @@ fl_uintptr_t Fl_GDI_Graphics_Driver::cache(Fl_Bitmap*, int w, int h, const uchar
return (fl_uintptr_t)fl_create_bitmap(w, h, array); return (fl_uintptr_t)fl_create_bitmap(w, h, array);
} }
void Fl_GDI_Graphics_Driver::uncache(Fl_Bitmap *img, fl_uintptr_t &id_) {
delete_bitmask((Fl_Offscreen)id_);
}
void Fl_GDI_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) { 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; int X, Y, W, H;
if (pxm->prepare(XP, YP, WP, HP, cx, cy, X, Y, W, H)) return; if (pxm->prepare(XP, YP, WP, HP, cx, cy, X, Y, W, H)) return;

View File

@ -62,7 +62,6 @@ public:
void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1);
fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array); fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array);
fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array); fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array);
void uncache(Fl_Bitmap *img, fl_uintptr_t &id_);
void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_); void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_);
#if ! defined(FL_DOXYGEN) #if ! defined(FL_DOXYGEN)
static Fl_Offscreen create_offscreen_with_alpha(int w, int h); static Fl_Offscreen create_offscreen_with_alpha(int w, int h);

View File

@ -301,10 +301,6 @@ fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Bitmap*, int w, int h, const uc
return (fl_uintptr_t)create_bitmask(w, h, array); return (fl_uintptr_t)create_bitmask(w, h, array);
} }
void Fl_Quartz_Graphics_Driver::uncache(Fl_Bitmap*, fl_uintptr_t &id_) {
delete_bitmask((Fl_Bitmask)id_);
}
fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Pixmap *img, int w, int h, const char *const*data) { fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Pixmap *img, int w, int h, const char *const*data) {
Fl_Offscreen id; Fl_Offscreen id;
id = create_offscreen_with_alpha(w, h); id = create_offscreen_with_alpha(w, h);

View File

@ -59,7 +59,6 @@ public:
void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1);
fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array); fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array);
fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array); fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array);
void uncache(Fl_Bitmap *img, fl_uintptr_t &id_);
void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_); void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_);
double width(const char *str, int n); double width(const char *str, int n);
double width(unsigned int c); double width(unsigned int c);

View File

@ -768,11 +768,6 @@ fl_uintptr_t Fl_Xlib_Graphics_Driver::cache(Fl_Bitmap*, int w, int h, const ucha
return (fl_uintptr_t)create_bitmask(w, h, array); return (fl_uintptr_t)create_bitmask(w, h, array);
} }
void Fl_Xlib_Graphics_Driver::uncache(Fl_Bitmap*, fl_uintptr_t &id_) {
delete_bitmask((Fl_Offscreen)id_);
}
void Fl_Xlib_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) { 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; int X, Y, W, H;
if (pxm->prepare(XP, YP, WP, HP, cx, cy, X, Y, W, H)) return; if (pxm->prepare(XP, YP, WP, HP, cx, cy, X, Y, W, H)) return;