Fix a problem seen in fluid on the Mac OS platform.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11285 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2016-03-04 22:30:18 +00:00
parent 7c5c803ca9
commit a46e324405
3 changed files with 21 additions and 3 deletions

View File

@ -221,6 +221,7 @@ public:
// --- implementation is in src/fl_image.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_font.cxx
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 void uncache(Fl_Pixmap *img) { }
virtual fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array) { return 0; }
virtual void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_) { }
virtual void delete_bitmask(Fl_Bitmask bm) = 0;

View File

@ -101,7 +101,11 @@ Fl_Pixmap::~Fl_Pixmap() {
void Fl_Pixmap::uncache() {
if (id_) {
#ifdef __APPLE__
fl_graphics_driver->uncache(this);
#else
fl_delete_offscreen((Fl_Offscreen)id_);
#endif
id_ = 0;
}

View File

@ -25,6 +25,7 @@
#include <FL/fl_draw.H>
#include <FL/Fl_Printer.H>
#include <FL/x.H>
#include <FL/Fl_Image_Surface.H>
#define MAXBUFFER 0x40000 // 256k
@ -272,13 +273,25 @@ fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Bitmap*, int w, int h, const uc
}
fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Pixmap *img, int w, int h, const char *const*data) {
Fl_Offscreen id = fl_create_offscreen(w, h);
fl_begin_offscreen(id);
Fl_Image_Surface *surface = new Fl_Image_Surface(w,h);
surface->set_current();
fl_draw_pixmap(data, 0, 0, FL_BLACK);
fl_end_offscreen();
surface->end_current();
Fl_Offscreen id = surface->get_offscreen_before_delete();
delete surface;
return (fl_uintptr_t)id;
}
void Fl_Quartz_Graphics_Driver::uncache(Fl_Pixmap *img)
{
if (img->id_) {
void *data = CGBitmapContextGetData((CGContextRef)img->id_);
free(data);
CGContextRelease((CGContextRef)img->id_);
img->id_ = NULL;
}
}
void Fl_Quartz_Graphics_Driver::draw_CGImage(CGImageRef cgimg, int x, int y, int w, int h, int srcx, int srcy, int sw, int sh)
{
CGRect rect = CGRectMake(x, y, w, h);