Homogenise and simplify the API of Fl_Graphics_Driver::cache(image-type *) virtual member functions.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12833 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2018-04-13 13:22:15 +00:00
parent e440b8859f
commit 2abe8bd413
15 changed files with 64 additions and 67 deletions

View File

@ -169,11 +169,11 @@ protected:
matrix *fl_matrix; /**< Points to the current coordinate transformation matrix */ matrix *fl_matrix; /**< Points to the current coordinate transformation matrix */
virtual void global_gc(); virtual void global_gc();
/** Support function for Fl_Pixmap drawing */ /** Support function for Fl_Pixmap drawing */
virtual fl_uintptr_t cache(Fl_Pixmap *img) { return 0; } virtual void cache(Fl_Pixmap *img) { }
/** Support function for Fl_Bitmap drawing */ /** Support function for Fl_Bitmap drawing */
virtual fl_uintptr_t cache(Fl_Bitmap *img) { return 0; } virtual void cache(Fl_Bitmap *img) { }
/** Support function for Fl_RGB_Image drawing */ /** Support function for Fl_RGB_Image drawing */
virtual fl_uintptr_t cache(Fl_RGB_Image *img) { return 0; } virtual void cache(Fl_RGB_Image *img) { }
/** Support function for Fl_RGB_Image drawing */ /** Support function for Fl_RGB_Image drawing */
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_) { }
// --- implementation is in src/drivers/xxx/Fl_xxx_Graphics_Driver_image.cxx // --- implementation is in src/drivers/xxx/Fl_xxx_Graphics_Driver_image.cxx

View File

@ -125,7 +125,7 @@ int Fl_Bitmap::prepare(int XP, int YP, int WP, int HP, int &cx, int &cy,
} }
if (fl_graphics_driver->start_image(this, XP,YP,WP,HP,cx,cy,X,Y,W,H)) return 1; if (fl_graphics_driver->start_image(this, XP,YP,WP,HP,cx,cy,X,Y,W,H)) return 1;
if (!id_) if (!id_)
id_ = fl_graphics_driver->cache(this); fl_graphics_driver->cache(this);
return 0; return 0;
} }

View File

@ -328,12 +328,14 @@ void Fl_Graphics_Driver::draw_pixmap(Fl_Pixmap *pxm, int XP, int YP, int WP, int
if (!*id(pxm)) { if (!*id(pxm)) {
if (pxm->data_w() != w2 || pxm->data_h() != h2) { // build a scaled id_ & mask_ for pxm if (pxm->data_w() != w2 || pxm->data_h() != h2) { // build a scaled id_ & mask_ for pxm
Fl_Pixmap *pxm2 = (Fl_Pixmap*)pxm->copy(w2, h2); Fl_Pixmap *pxm2 = (Fl_Pixmap*)pxm->copy(w2, h2);
*id(pxm) = cache(pxm2); cache(pxm2);
*id(pxm) = *id(pxm2);
*id(pxm2) = 0;
*pw = w2; *ph = h2; // memorize size of cached form of pixmap *pw = w2; *ph = h2; // memorize size of cached form of pixmap
*mask(pxm) = *mask(pxm2); *mask(pxm) = *mask(pxm2);
*mask(pxm2) = 0; *mask(pxm2) = 0;
delete pxm2; delete pxm2;
} else *id(pxm) = cache(pxm); } else cache(pxm);
} }
// draw pxm using its scaled id_ & pixmap_ // draw pxm using its scaled id_ & pixmap_
draw_fixed(pxm, X, Y, W, H, cx, cy); draw_fixed(pxm, X, Y, W, H, cx, cy);
@ -355,10 +357,12 @@ void Fl_Graphics_Driver::draw_bitmap(Fl_Bitmap *bm, int XP, int YP, int WP, int
if (!*id(bm)) { if (!*id(bm)) {
if (bm->data_w() != w2 || bm->data_h() != h2) { // build a scaled id_ for bm if (bm->data_w() != w2 || bm->data_h() != h2) { // build a scaled id_ for bm
Fl_Bitmap *bm2 = (Fl_Bitmap*)bm->copy(w2, h2); Fl_Bitmap *bm2 = (Fl_Bitmap*)bm->copy(w2, h2);
*id(bm) = cache(bm2); cache(bm2);
*id(bm) = *id(bm2);
*id(bm2) = 0;
*pw = w2; *ph = h2; // memorize size of cached form of bitmap *pw = w2; *ph = h2; // memorize size of cached form of bitmap
delete bm2; delete bm2;
} else *id(bm) = cache(bm); } else cache(bm);
} }
// draw bm using its scaled id_ // draw bm using its scaled id_
draw_fixed(bm, X, Y, W, H, cx, cy); draw_fixed(bm, X, Y, W, H, cx, cy);

View File

@ -64,7 +64,7 @@ int Fl_Pixmap::prepare(int XP, int YP, int WP, int HP, int &cx, int &cy,
} }
if ( fl_graphics_driver->start_image(this, XP,YP,WP,HP,cx,cy,X,Y,W,H) ) return 1; if ( fl_graphics_driver->start_image(this, XP,YP,WP,HP,cx,cy,X,Y,W,H) ) return 1;
if (!id_) { if (!id_) {
id_ = fl_graphics_driver->cache(this); fl_graphics_driver->cache(this);
} }
return 0; return 0;
} }

View File

@ -67,10 +67,10 @@ protected:
// set fl_gc, which we do not use in the Android port at this point // set fl_gc, which we do not use in the Android port at this point
// super: virtual void global_gc(); // super: virtual void global_gc();
/** Support function for Fl_Pixmap drawing */ /** Support function for Fl_Pixmap drawing */
virtual fl_uintptr_t cache(Fl_Pixmap *img) override; virtual void cache(Fl_Pixmap *img) override;
/** Support function for Fl_Bitmap drawing */ /** Support function for Fl_Bitmap drawing */
virtual fl_uintptr_t cache(Fl_Bitmap *img) override; virtual void cache(Fl_Bitmap *img) override;
virtual fl_uintptr_t cache(Fl_RGB_Image *img) override; virtual void cache(Fl_RGB_Image *img) override;
/** Support function for Fl_RGB_Image drawing */ /** Support function for Fl_RGB_Image drawing */
virtual void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_) override; virtual void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_) override;
// --- implementation is in src/drivers/xxx/Fl_xxx_Graphics_Driver_image.cxx // --- implementation is in src/drivers/xxx/Fl_xxx_Graphics_Driver_image.cxx

View File

@ -984,7 +984,7 @@ void Fl_Android_Graphics_Driver::draw_fixed(Fl_Bitmap *bm, int X, int Y, int W,
} }
fl_uintptr_t Fl_Android_Graphics_Driver::cache(Fl_Bitmap *bm) void Fl_Android_Graphics_Driver::cache(Fl_Bitmap *bm)
{ {
int w = bm->w(), h = bm->h(); int w = bm->w(), h = bm->h();
int rowBytes = (w+7)>>3; int rowBytes = (w+7)>>3;
@ -1002,12 +1002,12 @@ fl_uintptr_t Fl_Android_Graphics_Driver::cache(Fl_Bitmap *bm)
} }
} }
return (fl_uintptr_t)cache; *Fl_Graphics_Driver::id(bm) = (fl_uintptr_t)cache;
} }
fl_uintptr_t Fl_Android_Graphics_Driver::cache(Fl_Pixmap *img) void Fl_Android_Graphics_Driver::cache(Fl_Pixmap *img)
{ {
int w = img->w(), h = img->h(); int w = img->w(), h = img->h();
int rowBytes = 4*w; int rowBytes = 4*w;
@ -1015,7 +1015,8 @@ fl_uintptr_t Fl_Android_Graphics_Driver::cache(Fl_Pixmap *img)
int ret = fl_convert_pixmap(img->data(), rgba, 0); int ret = fl_convert_pixmap(img->data(), rgba, 0);
if (ret==0) { if (ret==0) {
::free(rgba); ::free(rgba);
return 0; *Fl_Graphics_Driver::id(img) = 0;
return;
} }
Fl_Android_565A_Map *cache = new Fl_Android_565A_Map(w, h); Fl_Android_565A_Map *cache = new Fl_Android_565A_Map(w, h);
@ -1032,7 +1033,7 @@ fl_uintptr_t Fl_Android_Graphics_Driver::cache(Fl_Pixmap *img)
} }
::free(rgba); ::free(rgba);
return (fl_uintptr_t)cache; *Fl_Graphics_Driver::id(img) = (fl_uintptr_t)cache;
} }
@ -1042,7 +1043,7 @@ void Fl_Android_Graphics_Driver::uncache_pixmap(fl_uintptr_t p)
delete img; delete img;
} }
fl_uintptr_t Fl_Android_Graphics_Driver::cache(Fl_RGB_Image *img) void Fl_Android_Graphics_Driver::cache(Fl_RGB_Image *img)
{ {
int w = img->data_w(), h = img->data_h(), d = img->d(), stride = w*d + img->ld(); int w = img->data_w(), h = img->data_h(), d = img->d(), stride = w*d + img->ld();
Fl_Android_565A_Map *cgimg = new Fl_Android_565A_Map(w, h); Fl_Android_565A_Map *cgimg = new Fl_Android_565A_Map(w, h);
@ -1092,7 +1093,6 @@ fl_uintptr_t Fl_Android_Graphics_Driver::cache(Fl_RGB_Image *img)
} }
} }
} }
return (fl_uintptr_t)cgimg;
} }
void Fl_Android_Graphics_Driver::draw_fixed(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, int cy) void Fl_Android_Graphics_Driver::draw_fixed(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, int cy)

View File

@ -44,7 +44,7 @@ private:
void draw_fixed(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); void draw_fixed(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
protected: protected:
void draw_fixed(Fl_RGB_Image *rgb, int XP, int YP, int WP, int HP, int cx, int cy); void draw_fixed(Fl_RGB_Image *rgb, int XP, int YP, int WP, int HP, int cx, int cy);
fl_uintptr_t cache(Fl_RGB_Image *rgb); void cache(Fl_RGB_Image *rgb);
HDC gc_; HDC gc_;
int numcount; int numcount;
int counts[20]; int counts[20];
@ -73,9 +73,9 @@ public:
virtual void draw_image_unscaled(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); virtual void draw_image_unscaled(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3);
virtual void draw_image_mono_unscaled(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); virtual void draw_image_mono_unscaled(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0);
virtual void draw_image_mono_unscaled(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); virtual void draw_image_mono_unscaled(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); void cache(Fl_Pixmap *img);
virtual void uncache_pixmap(fl_uintptr_t p); virtual void uncache_pixmap(fl_uintptr_t p);
fl_uintptr_t cache(Fl_Bitmap *img); void cache(Fl_Bitmap *img);
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_);
virtual double width_unscaled(const char *str, int n); virtual double width_unscaled(const char *str, int n);
virtual double width_unscaled(unsigned int c); virtual double width_unscaled(unsigned int c);

View File

@ -442,7 +442,7 @@ void Fl_GDI_Printer_Graphics_Driver::draw_bitmap(Fl_Bitmap *bm, int XP, int YP,
} }
if (recache || !*id(bm)) { if (recache || !*id(bm)) {
bm->uncache(); bm->uncache();
*Fl_Graphics_Driver::id(bm) = cache(bm); cache(bm);
} }
HDC tempdc; HDC tempdc;
int save; int save;
@ -478,7 +478,7 @@ void Fl_GDI_Printer_Graphics_Driver::draw_bitmap(Fl_Bitmap *bm, int XP, int YP,
} }
fl_uintptr_t Fl_GDI_Graphics_Driver::cache(Fl_RGB_Image *img) void Fl_GDI_Graphics_Driver::cache(Fl_RGB_Image *img)
{ {
Fl_Image_Surface *surface = new Fl_Image_Surface(img->data_w(), img->data_h()); Fl_Image_Surface *surface = new Fl_Image_Surface(img->data_w(), img->data_h());
Fl_Surface_Device::push_current(surface); Fl_Surface_Device::push_current(surface);
@ -498,7 +498,6 @@ fl_uintptr_t Fl_GDI_Graphics_Driver::cache(Fl_RGB_Image *img)
*pw = img->data_w(); *pw = img->data_w();
*ph = img->data_h(); *ph = img->data_h();
*Fl_Graphics_Driver::id(img) = (fl_uintptr_t)offs; *Fl_Graphics_Driver::id(img) = (fl_uintptr_t)offs;
return (fl_uintptr_t)offs;
} }
@ -510,11 +509,7 @@ void Fl_GDI_Graphics_Driver::draw_fixed(Fl_RGB_Image *img, int X, int Y, int W,
if (W + cx > img->data_w()) W = img->data_w() - cx; if (W + cx > img->data_w()) W = img->data_w() - cx;
if (H + cy > img->data_h()) H = img->data_h() - cy; if (H + cy > img->data_h()) H = img->data_h() - cy;
if (!*Fl_Graphics_Driver::id(img)) { if (!*Fl_Graphics_Driver::id(img)) {
*Fl_Graphics_Driver::id(img) = (fl_uintptr_t)cache(img); cache(img);
int *pw, *ph;
cache_w_h(img, pw, ph);
*pw = img->data_w();
*ph = img->data_h();
} }
if (*Fl_Graphics_Driver::mask(img)) { if (*Fl_Graphics_Driver::mask(img)) {
HDC new_gc = CreateCompatibleDC(gc_); HDC new_gc = CreateCompatibleDC(gc_);
@ -542,11 +537,7 @@ void Fl_GDI_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP,
return; return;
} }
if (!*Fl_Graphics_Driver::id(rgb)) { if (!*Fl_Graphics_Driver::id(rgb)) {
*Fl_Graphics_Driver::id(rgb) = (fl_uintptr_t)cache(rgb); cache(rgb);
int *pw, *ph;
cache_w_h(rgb, pw, ph);
*pw = rgb->data_w();
*ph = rgb->data_h();
} }
float scaleW = float(rgb->data_w())/rgb->w(); float scaleW = float(rgb->data_w())/rgb->w();
float scaleH = float(rgb->data_h())/rgb->h(); float scaleH = float(rgb->data_h())/rgb->h();
@ -630,12 +621,12 @@ static Fl_Bitmask fl_create_bitmap(int w, int h, const uchar *data) {
return bm; return bm;
} }
fl_uintptr_t Fl_GDI_Graphics_Driver::cache(Fl_Bitmap *bm) { void Fl_GDI_Graphics_Driver::cache(Fl_Bitmap *bm) {
int *pw, *ph; int *pw, *ph;
cache_w_h(bm, pw, ph); cache_w_h(bm, pw, ph);
*pw = bm->data_w(); *pw = bm->data_w();
*ph = bm->data_h(); *ph = bm->data_h();
return (fl_uintptr_t)fl_create_bitmap(bm->data_w(), bm->data_h(), bm->array); *Fl_Graphics_Driver::id(bm) = (fl_uintptr_t)fl_create_bitmap(bm->data_w(), bm->data_h(), bm->array);
} }
void Fl_GDI_Graphics_Driver::draw_fixed(Fl_Pixmap *pxm, int X, int Y, int W, int H, int cx, int cy) { void Fl_GDI_Graphics_Driver::draw_fixed(Fl_Pixmap *pxm, int X, int Y, int W, int H, int cx, int cy) {
@ -673,7 +664,7 @@ void Fl_GDI_Printer_Graphics_Driver::draw_pixmap(Fl_Pixmap *pxm, int XP, int YP,
} }
if (recache || !*id(pxm)) { if (recache || !*id(pxm)) {
pxm->uncache(); pxm->uncache();
*Fl_Graphics_Driver::id(pxm) = cache(pxm); cache(pxm);
} }
HDC new_gc = CreateCompatibleDC(gc_); HDC new_gc = CreateCompatibleDC(gc_);
int save = SaveDC(new_gc); int save = SaveDC(new_gc);
@ -693,7 +684,7 @@ void Fl_GDI_Printer_Graphics_Driver::draw_pixmap(Fl_Pixmap *pxm, int XP, int YP,
} }
fl_uintptr_t Fl_GDI_Graphics_Driver::cache(Fl_Pixmap *img) { void Fl_GDI_Graphics_Driver::cache(Fl_Pixmap *img) {
Fl_Image_Surface *surf = new Fl_Image_Surface(img->data_w(), img->data_h()); Fl_Image_Surface *surf = new Fl_Image_Surface(img->data_w(), img->data_h());
Fl_Surface_Device::push_current(surf); Fl_Surface_Device::push_current(surf);
uchar *bitmap = 0; uchar *bitmap = 0;
@ -712,7 +703,7 @@ fl_uintptr_t Fl_GDI_Graphics_Driver::cache(Fl_Pixmap *img) {
cache_w_h(img, pw, ph); cache_w_h(img, pw, ph);
*pw = img->data_w(); *pw = img->data_w();
*ph = img->data_h(); *ph = img->data_h();
return (fl_uintptr_t)id; *Fl_Graphics_Driver::id(img) = (fl_uintptr_t)id;
} }
void Fl_GDI_Graphics_Driver::uncache_pixmap(fl_uintptr_t offscreen) { void Fl_GDI_Graphics_Driver::uncache_pixmap(fl_uintptr_t offscreen) {

View File

@ -169,8 +169,8 @@ class Fl_Pico_Graphics_Driver : public Fl_Graphics_Driver {
// virtual void font_descriptor(Fl_Font_Descriptor *d) { font_descriptor_ = d;} // virtual void font_descriptor(Fl_Font_Descriptor *d) { font_descriptor_ = d;}
// // --- implementation is in src/fl_image.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_font.cxx // // --- 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) ; virtual Fl_Bitmask create_bitmask(int w, int h, const uchar *array) ;
// virtual fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array) { return 0; } // virtual void cache(Fl_Pixmap *img) { return 0; }
// virtual fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array) { return 0; } // virtual void cache(Fl_Bitmap *img) { return 0; }
// 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) ; virtual void delete_bitmask(Fl_Bitmask bm) ;
// 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

@ -53,8 +53,9 @@ public:
// void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); // void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3);
// void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); // void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0);
// 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); // void cache(Fl_Pixmap *img);
// fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array); // void cache(Fl_Bitmap *img);
// void cache(Fl_RGB_Image *img);
// 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_);
// void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); // void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
// void draw_CGImage(CGImageRef cgimg, int x, int y, int w, int h, int srcx, int srcy, int sw, int sh); // void draw_CGImage(CGImageRef cgimg, int x, int y, int w, int h, int srcx, int srcy, int sw, int sh);

View File

@ -52,8 +52,9 @@ public:
// void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); // void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3);
// void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); // void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0);
// 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); // void cache(Fl_Pixmap *img);
// fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array); // void cache(Fl_Bitmap *img);
// void cache(Fl_RGB_Image *img);
// 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_);
// void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); // void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
// void draw_CGImage(CGImageRef cgimg, int x, int y, int w, int h, int srcx, int srcy, int sw, int sh); // void draw_CGImage(CGImageRef cgimg, int x, int y, int w, int h, int srcx, int srcy, int sw, int sh);

View File

@ -74,9 +74,9 @@ public:
void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3);
void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0);
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); void cache(Fl_Pixmap *img);
fl_uintptr_t cache(Fl_Bitmap *img); void cache(Fl_Bitmap *img);
fl_uintptr_t cache(Fl_RGB_Image *img); void cache(Fl_RGB_Image *img);
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_);
void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
void draw_CGImage(CGImageRef cgimg, int x, int y, int w, int h, int srcx, int srcy, int sw, int sh); void draw_CGImage(CGImageRef cgimg, int x, int y, int w, int h, int srcx, int srcy, int sw, int sh);

View File

@ -142,7 +142,7 @@ void Fl_Quartz_Graphics_Driver::draw_bitmap(Fl_Bitmap *bm, int XP, int YP, int W
} }
} }
fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_RGB_Image *rgb) { void Fl_Quartz_Graphics_Driver::cache(Fl_RGB_Image *rgb) {
CGColorSpaceRef lut = rgb->d()<=2 ? CGColorSpaceCreateDeviceGray() : CGColorSpaceCreateDeviceRGB(); CGColorSpaceRef lut = rgb->d()<=2 ? CGColorSpaceCreateDeviceGray() : CGColorSpaceCreateDeviceRGB();
int ld = rgb->ld(); int ld = rgb->ld();
if (!ld) ld = rgb->data_w() * rgb->d(); if (!ld) ld = rgb->data_w() * rgb->d();
@ -170,7 +170,6 @@ fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_RGB_Image *rgb) {
*Fl_Graphics_Driver::id(rgb) = (fl_uintptr_t)cgimg; *Fl_Graphics_Driver::id(rgb) = (fl_uintptr_t)cgimg;
CGColorSpaceRelease(lut); CGColorSpaceRelease(lut);
CGDataProviderRelease(src); CGDataProviderRelease(src);
return (fl_uintptr_t)cgimg;
} }
void Fl_Quartz_Graphics_Driver::draw_rgb(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy) { void Fl_Quartz_Graphics_Driver::draw_rgb(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy) {
@ -190,7 +189,8 @@ void Fl_Quartz_Graphics_Driver::draw_rgb(Fl_RGB_Image *img, int XP, int YP, int
cgimg = NULL; cgimg = NULL;
} }
if (!cgimg) { if (!cgimg) {
cgimg = (CGImageRef)cache(img); cache(img);
cgimg = (CGImageRef)*Fl_Graphics_Driver::id(img);
} }
if (cgimg && gc_) { if (cgimg && gc_) {
draw_CGImage(cgimg, X,Y,W,H, cx,cy, img->w(), img->h()); draw_CGImage(cgimg, X,Y,W,H, cx,cy, img->w(), img->h());
@ -233,8 +233,8 @@ void Fl_Quartz_Graphics_Driver::uncache(Fl_RGB_Image*, fl_uintptr_t &id_, fl_uin
} }
} }
fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Bitmap *bm) { void Fl_Quartz_Graphics_Driver::cache(Fl_Bitmap *bm) {
return (fl_uintptr_t)create_bitmask(bm->data_w(), bm->data_h(), bm->array); *Fl_Graphics_Driver::id(bm) = (fl_uintptr_t)create_bitmask(bm->data_w(), bm->data_h(), bm->array);
} }
@ -242,7 +242,7 @@ static void pmProviderRelease (void *ctxt, const void *data, size_t size) {
CFRelease(ctxt); CFRelease(ctxt);
} }
fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Pixmap *img) { void Fl_Quartz_Graphics_Driver::cache(Fl_Pixmap *img) {
Fl_Image_Surface *surf = new Fl_Image_Surface(img->data_w(), img->data_h()); Fl_Image_Surface *surf = new Fl_Image_Surface(img->data_w(), img->data_h());
Fl_Surface_Device::push_current(surf); Fl_Surface_Device::push_current(surf);
fl_draw_pixmap(img->data(), 0, 0, FL_BLACK); fl_draw_pixmap(img->data(), 0, 0, FL_BLACK);
@ -259,7 +259,7 @@ fl_uintptr_t Fl_Quartz_Graphics_Driver::cache(Fl_Pixmap *img) {
src_bytes, 0L, false, kCGRenderingIntentDefault); src_bytes, 0L, false, kCGRenderingIntentDefault);
CGColorSpaceRelease(lut); CGColorSpaceRelease(lut);
CGDataProviderRelease(src_bytes); CGDataProviderRelease(src_bytes);
return (fl_uintptr_t)cgimg; *Fl_Graphics_Driver::id(img) = (fl_uintptr_t)cgimg;
} }
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) 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)

View File

@ -101,7 +101,7 @@ protected:
static Window draw_window; static Window draw_window;
static struct _XftDraw* draw_; static struct _XftDraw* draw_;
#endif #endif
fl_uintptr_t cache(Fl_RGB_Image *img); void cache(Fl_RGB_Image *img);
public: public:
Fl_Xlib_Graphics_Driver(void); Fl_Xlib_Graphics_Driver(void);
virtual ~Fl_Xlib_Graphics_Driver(); virtual ~Fl_Xlib_Graphics_Driver();
@ -123,9 +123,9 @@ public:
virtual void draw_unscaled(int angle, const char *str, int n, int x, int y); virtual void draw_unscaled(int angle, const char *str, int n, int x, int y);
virtual void rtl_draw_unscaled(const char* str, int n, int x, int y); virtual void rtl_draw_unscaled(const char* str, int n, int x, int y);
virtual void font_unscaled(Fl_Font face, Fl_Fontsize size); virtual void font_unscaled(Fl_Font face, Fl_Fontsize size);
fl_uintptr_t cache(Fl_Pixmap *img); void cache(Fl_Pixmap *img);
virtual void uncache_pixmap(fl_uintptr_t p); virtual void uncache_pixmap(fl_uintptr_t p);
fl_uintptr_t cache(Fl_Bitmap *img); void cache(Fl_Bitmap *img);
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_);
virtual double width_unscaled(const char *str, int n); virtual double width_unscaled(const char *str, int n);
virtual double width_unscaled(unsigned int c); virtual double width_unscaled(unsigned int c);

View File

@ -696,7 +696,7 @@ static void alpha_blend(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, i
delete[] dst; delete[] dst;
} }
fl_uintptr_t Fl_Xlib_Graphics_Driver::cache(Fl_RGB_Image *img) { void Fl_Xlib_Graphics_Driver::cache(Fl_RGB_Image *img) {
Fl_Image_Surface *surface; Fl_Image_Surface *surface;
int depth = img->d(); int depth = img->d();
if (depth == 1 || depth == 3) { if (depth == 1 || depth == 3) {
@ -706,7 +706,8 @@ fl_uintptr_t Fl_Xlib_Graphics_Driver::cache(Fl_RGB_Image *img) {
surface = new Fl_Image_Surface(img->data_w(), img->data_h(), 0, pixmap); surface = new Fl_Image_Surface(img->data_w(), img->data_h(), 0, pixmap);
depth |= FL_IMAGE_WITH_ALPHA; depth |= FL_IMAGE_WITH_ALPHA;
} else { } else {
return 0; *Fl_Graphics_Driver::id(img) = 0;
return;
} }
Fl_Surface_Device::push_current(surface); Fl_Surface_Device::push_current(surface);
fl_draw_image(img->array, 0, 0, img->data_w(), img->data_h(), depth, img->ld()); fl_draw_image(img->array, 0, 0, img->data_w(), img->data_h(), depth, img->ld());
@ -718,7 +719,6 @@ fl_uintptr_t Fl_Xlib_Graphics_Driver::cache(Fl_RGB_Image *img) {
*pw = img->data_w(); *pw = img->data_w();
*ph = img->data_h(); *ph = img->data_h();
*Fl_Graphics_Driver::id(img) = (fl_uintptr_t)off; *Fl_Graphics_Driver::id(img) = (fl_uintptr_t)off;
return (fl_uintptr_t)off;
} }
@ -758,7 +758,7 @@ void Fl_Xlib_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP
return; return;
} }
if (!*Fl_Graphics_Driver::id(rgb)) { if (!*Fl_Graphics_Driver::id(rgb)) {
*Fl_Graphics_Driver::id(rgb) = cache(rgb); cache(rgb);
} }
cache_size(rgb, W, H); cache_size(rgb, W, H);
scale_and_render_pixmap( *Fl_Graphics_Driver::id(rgb), rgb->d(), scale_and_render_pixmap( *Fl_Graphics_Driver::id(rgb), rgb->d(),
@ -774,12 +774,12 @@ void Fl_Xlib_Graphics_Driver::uncache(Fl_RGB_Image*, fl_uintptr_t &id_, fl_uintp
} }
} }
fl_uintptr_t Fl_Xlib_Graphics_Driver::cache(Fl_Bitmap *bm) { void Fl_Xlib_Graphics_Driver::cache(Fl_Bitmap *bm) {
int *pw, *ph; int *pw, *ph;
cache_w_h(bm, pw, ph); cache_w_h(bm, pw, ph);
*pw = bm->data_w(); *pw = bm->data_w();
*ph = bm->data_h(); *ph = bm->data_h();
return (fl_uintptr_t)create_bitmask(bm->data_w(), bm->data_h(), bm->array); *Fl_Graphics_Driver::id(bm) = (fl_uintptr_t)create_bitmask(bm->data_w(), bm->data_h(), bm->array);
} }
void Fl_Xlib_Graphics_Driver::draw_fixed(Fl_Pixmap *pxm, int X, int Y, int W, int H, int cx, int cy) { void Fl_Xlib_Graphics_Driver::draw_fixed(Fl_Pixmap *pxm, int X, int Y, int W, int H, int cx, int cy) {
@ -827,7 +827,7 @@ void Fl_Xlib_Graphics_Driver::draw_fixed(Fl_Pixmap *pxm, int X, int Y, int W, in
} }
fl_uintptr_t Fl_Xlib_Graphics_Driver::cache(Fl_Pixmap *pxm) { void Fl_Xlib_Graphics_Driver::cache(Fl_Pixmap *pxm) {
Fl_Image_Surface *surf = new Fl_Image_Surface(pxm->data_w(), pxm->data_h()); Fl_Image_Surface *surf = new Fl_Image_Surface(pxm->data_w(), pxm->data_h());
Fl_Surface_Device::push_current(surf); Fl_Surface_Device::push_current(surf);
uchar *bitmap = 0; uchar *bitmap = 0;
@ -845,7 +845,7 @@ fl_uintptr_t Fl_Xlib_Graphics_Driver::cache(Fl_Pixmap *pxm) {
cache_w_h(pxm, pw, ph); cache_w_h(pxm, pw, ph);
*pw = pxm->data_w(); *pw = pxm->data_w();
*ph = pxm->data_h(); *ph = pxm->data_h();
return (fl_uintptr_t)id; *Fl_Graphics_Driver::id(pxm) = (fl_uintptr_t)id;
} }
void Fl_Xlib_Graphics_Driver::uncache_pixmap(fl_uintptr_t offscreen) { void Fl_Xlib_Graphics_Driver::uncache_pixmap(fl_uintptr_t offscreen) {