X11 and WIN32: slightly change Fl_XXX_Graphics_Driver::cache(Fl_Pixmap*) to use the Fl_Image_Surface object.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12399 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
9eeac9c737
commit
86e60e9068
@ -289,9 +289,7 @@ void Fl_Scalable_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, i
|
||||
int w2=pxm->w(), h2=pxm->h();
|
||||
cache_size(pxm, w2, h2);
|
||||
Fl_Pixmap *pxm2 = (Fl_Pixmap*)pxm->copy(w2, h2);
|
||||
float s = scale_; scale_ = 1;
|
||||
*id(pxm) = cache(pxm2, pxm2->w(), pxm2->h(), pxm2->data());
|
||||
scale_ = s;
|
||||
*cache_scale(pxm) = scale_;
|
||||
*mask(pxm) = *mask(pxm2);
|
||||
*mask(pxm2) = 0;
|
||||
|
||||
@ -72,6 +72,7 @@ public:
|
||||
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);
|
||||
fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array);
|
||||
virtual void uncache_pixmap(fl_uintptr_t p);
|
||||
fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array);
|
||||
void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_);
|
||||
virtual double width_unscaled(const char *str, int n);
|
||||
|
||||
@ -644,9 +644,8 @@ void Fl_GDI_Printer_Graphics_Driver::draw_unscaled(Fl_Pixmap *pxm, float s, int
|
||||
|
||||
|
||||
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);
|
||||
Fl_Image_Surface *surf = new Fl_Image_Surface(w, h);
|
||||
Fl_Surface_Device::push_current(surf);
|
||||
uchar *bitmap = 0;
|
||||
Fl_Surface_Device::surface()->driver()->mask_bitmap(&bitmap);
|
||||
fl_draw_pixmap(data, 0, 0, FL_BLACK);
|
||||
@ -656,11 +655,17 @@ fl_uintptr_t Fl_GDI_Graphics_Driver::cache(Fl_Pixmap *img, int w, int h, const c
|
||||
*Fl_Graphics_Driver::mask(img) = (fl_uintptr_t)fl_create_bitmask(w, h, bitmap);
|
||||
delete[] bitmap;
|
||||
}
|
||||
fl_end_offscreen();
|
||||
*cache_scale(img) = Fl_Scalable_Graphics_Driver::scale();
|
||||
Fl_Surface_Device::pop_current();
|
||||
Fl_Offscreen id = surf->get_offscreen_before_delete();
|
||||
delete surf;
|
||||
*cache_scale(img) = 1;
|
||||
return (fl_uintptr_t)id;
|
||||
}
|
||||
|
||||
void Fl_GDI_Graphics_Driver::uncache_pixmap(fl_uintptr_t offscreen) {
|
||||
DeleteObject((Fl_Offscreen)offscreen);
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
||||
@ -122,6 +122,7 @@ public:
|
||||
virtual void rtl_draw_unscaled(const char* str, int n, int x, int y);
|
||||
virtual void font_unscaled(Fl_Font face, Fl_Fontsize size);
|
||||
fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array);
|
||||
virtual void uncache_pixmap(fl_uintptr_t p);
|
||||
fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array);
|
||||
void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_);
|
||||
virtual double width_unscaled(const char *str, int n);
|
||||
|
||||
@ -813,22 +813,27 @@ void Fl_Xlib_Graphics_Driver::draw_unscaled(Fl_Pixmap *pxm, float s, int X, int
|
||||
|
||||
|
||||
fl_uintptr_t Fl_Xlib_Graphics_Driver::cache(Fl_Pixmap *pxm, int w, int h, const char *const*data) {
|
||||
Fl_Offscreen id;
|
||||
id = fl_create_offscreen(w, h);
|
||||
fl_begin_offscreen(id);
|
||||
Fl_Image_Surface *surf = new Fl_Image_Surface(w, h);
|
||||
Fl_Surface_Device::push_current(surf);
|
||||
uchar *bitmap = 0;
|
||||
Fl_Surface_Device::surface()->driver()->mask_bitmap(&bitmap);
|
||||
fl_draw_pixmap(data, 0, 0, FL_BLACK);
|
||||
Fl_Surface_Device::surface()->driver()->mask_bitmap(0);
|
||||
if (bitmap) {
|
||||
*Fl_Graphics_Driver::mask(pxm) = (fl_uintptr_t)create_bitmask(w * scale_, h * scale_, bitmap);
|
||||
*Fl_Graphics_Driver::mask(pxm) = (fl_uintptr_t)create_bitmask(w, h, bitmap);
|
||||
delete[] bitmap;
|
||||
}
|
||||
fl_end_offscreen();
|
||||
*cache_scale(pxm) = Fl_Scalable_Graphics_Driver::scale();
|
||||
Fl_Surface_Device::pop_current();
|
||||
Fl_Offscreen id = surf->get_offscreen_before_delete();
|
||||
delete surf;
|
||||
*cache_scale(pxm) = 1;
|
||||
return (fl_uintptr_t)id;
|
||||
}
|
||||
|
||||
void Fl_Xlib_Graphics_Driver::uncache_pixmap(fl_uintptr_t offscreen) {
|
||||
XFreePixmap(fl_display, (Fl_Offscreen)offscreen);
|
||||
}
|
||||
|
||||
|
||||
#if HAVE_XRENDER
|
||||
/* Draws with Xrender an Fl_Offscreen with optional scaling and accounting for transparency if necessary.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user