diff --git a/FL/Fl_Bitmap.H b/FL/Fl_Bitmap.H index 84ce3281b90dae5438984955728b81d7c8e56285..d47a82acf865e056231f9defd2fa0b243783ab85 100644 --- a/FL/Fl_Bitmap.H +++ b/FL/Fl_Bitmap.H @@ -40,6 +40,7 @@ struct Fl_Menu_Item; (bitmap) images. Images are drawn using the current color. */ class FL_EXPORT Fl_Bitmap : public Fl_Image { + friend class Fl_Device; public: /** pointer to raw bitmap data */ @@ -57,6 +58,7 @@ class FL_EXPORT Fl_Bitmap : public Fl_Image { unsigned id_; #endif // __APPLE__ || WIN32 + void generic_device_draw(int XP, int YP, int WP, int HP, int cx, int cy); public: /** The constructors create a new bitmap from the specified bitmap data */ diff --git a/FL/Fl_Image.H b/FL/Fl_Image.H index 72ee4477c898212c4ab95b9c0dac07f8bbc79aa9..ff10b1ef6d3141a96870ecb868bca2622e19d81f 100644 --- a/FL/Fl_Image.H +++ b/FL/Fl_Image.H @@ -188,6 +188,8 @@ class FL_EXPORT Fl_Image { <FL/Fl_RGB_Image.H> should be included. */ class FL_EXPORT Fl_RGB_Image : public Fl_Image { + friend class Fl_Device; + void generic_device_draw(int X, int Y, int W, int H, int cx=0, int cy=0); public: const uchar *array; diff --git a/FL/Fl_Pixmap.H b/FL/Fl_Pixmap.H index 616add0f47e13bda48dc8c4b97443652ad25b844..8cab445a5eb452f98e0dd4baa54b3182f1bfb675 100644 --- a/FL/Fl_Pixmap.H +++ b/FL/Fl_Pixmap.H @@ -45,6 +45,7 @@ struct Fl_Menu_Item; (pixmap) images, including transparency. */ class FL_EXPORT Fl_Pixmap : public Fl_Image { + friend class Fl_Device; void copy_data(); void delete_data(); void set_data(const char * const *p); @@ -66,6 +67,7 @@ class FL_EXPORT Fl_Pixmap : public Fl_Image { unsigned id_; // for internal use unsigned mask_; // for internal use (mask bitmap) #endif // __APPLE__ || WIN32 + void generic_device_draw(int XP, int YP, int WP, int HP, int cx, int cy); public: diff --git a/src/Fl_Bitmap.cxx b/src/Fl_Bitmap.cxx index 3995c0773115f8036bcef810e0fbb73f8fd3fc2b..13d5bcaee35162df137071427dfe9a3745507507 100644 --- a/src/Fl_Bitmap.cxx +++ b/src/Fl_Bitmap.cxx @@ -248,10 +248,10 @@ Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *array) } void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) { - if(fl_device->type() == Fl_Device::postscript_device) { - fl_device->draw(this, XP, YP, WP, HP, cx, cy); - return; - } + fl_device->draw(this, XP, YP, WP, HP, cx, cy); +} + +void Fl_Bitmap::generic_device_draw(int XP, int YP, int WP, int HP, int cx, int cy) { if (!array) { draw_empty(XP, YP); return; diff --git a/src/Fl_Device.cxx b/src/Fl_Device.cxx index 98a5ad8fa517fbd55793397b655981de51aee340..9c76d3f6f20efcdb60b9ababa77a3c89a5fa0916 100644 --- a/src/Fl_Device.cxx +++ b/src/Fl_Device.cxx @@ -27,7 +27,6 @@ #include <FL/Fl.H> #include <FL/Fl_Device.H> -//#include <FL/fl_draw.H> #include <FL/Fl_Image.H> /** \brief Draws an Fl_Pixmap object to the device. @@ -35,9 +34,8 @@ Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by the cx and cy arguments. */ -void Fl_Device::draw(Fl_Pixmap *pxm,int XP, int YP, int WP, int HP, int cx, int cy) -{ - pxm->draw(XP, YP, WP, HP, cx, cy); +void Fl_Device::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) { + pxm->generic_device_draw(XP, YP, WP, HP, cx, cy); } /** \brief Draws an Fl_Bitmap object to the device. @@ -45,9 +43,8 @@ void Fl_Device::draw(Fl_Pixmap *pxm,int XP, int YP, int WP, int HP, int cx, int Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by the cx and cy arguments. */ -void Fl_Device::draw(Fl_Bitmap *bm,int XP, int YP, int WP, int HP, int cx, int cy) -{ - bm->draw(XP, YP, WP, HP, cx, cy); +void Fl_Device::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) { + bm->generic_device_draw(XP, YP, WP, HP, cx, cy); } /** \brief Draws an Fl_RGB_Image object to the device. @@ -55,9 +52,8 @@ void Fl_Device::draw(Fl_Bitmap *bm,int XP, int YP, int WP, int HP, int cx, int c Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by the cx and cy arguments. */ -void Fl_Device::draw(Fl_RGB_Image *rgb,int XP, int YP, int WP, int HP, int cx, int cy) -{ - rgb->draw(XP, YP, WP, HP, cx, cy); +void Fl_Device::draw(Fl_RGB_Image *rgb, int XP, int YP, int WP, int HP, int cx, int cy) { + rgb->generic_device_draw(XP, YP, WP, HP, cx, cy); } /** diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx index c7a79bfd103a1104239110a9349aa677bdfae65e..bf39f6b09e2c4ab15e51a9e5a1b074d3178df11d 100644 --- a/src/Fl_Image.cxx +++ b/src/Fl_Image.cxx @@ -434,10 +434,10 @@ static void alpha_blend(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, i #endif // !WIN32 && !__APPLE_QUARTZ__ void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) { - if(fl_device->type() == Fl_Device::postscript_device) { - fl_device->draw(this, XP, YP, WP, HP, cx, cy); - return; - } + fl_device->draw(this, XP, YP, WP, HP, cx, cy); +} + +void Fl_RGB_Image::generic_device_draw(int XP, int YP, int WP, int HP, int cx, int cy) { // Don't draw an empty image... if (!d() || !array) { draw_empty(XP, YP); diff --git a/src/Fl_Pixmap.cxx b/src/Fl_Pixmap.cxx index eb030c615f426b87d359226899fb660e97214222..0bb602e8e36cc46a161c255eb34e2b07f9602f91 100644 --- a/src/Fl_Pixmap.cxx +++ b/src/Fl_Pixmap.cxx @@ -74,10 +74,10 @@ void Fl_Pixmap::measure() { } void Fl_Pixmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) { - if(fl_device->type() == Fl_Device::postscript_device) { - fl_device->draw(this, XP, YP, WP, HP, cx, cy); - return; - } + fl_device->draw(this, XP, YP, WP, HP, cx, cy); +} + +void Fl_Pixmap::generic_device_draw(int XP, int YP, int WP, int HP, int cx, int cy) { // ignore empty or bad pixmap data: if (!data()) { draw_empty(XP, YP);