diff options
| -rw-r--r-- | FL/Fl_Bitmap.H | 1 | ||||
| -rw-r--r-- | FL/Fl_Image.H | 2 | ||||
| -rw-r--r-- | FL/Fl_Pixmap.H | 1 | ||||
| -rw-r--r-- | src/Fl_Bitmap.cxx | 5 | ||||
| -rw-r--r-- | src/Fl_Graphics_Driver.cxx | 6 | ||||
| -rw-r--r-- | src/Fl_Image.cxx | 11 | ||||
| -rw-r--r-- | src/Fl_Pixmap.cxx | 4 |
7 files changed, 25 insertions, 5 deletions
diff --git a/FL/Fl_Bitmap.H b/FL/Fl_Bitmap.H index fe457999b..dd3fe392d 100644 --- a/FL/Fl_Bitmap.H +++ b/FL/Fl_Bitmap.H @@ -46,6 +46,7 @@ private: /** for internal use */ fl_uintptr_t id_; float cache_scale_; // graphics scaling value when id_ was computed + virtual int draw_scaled_(int X, int Y, int W, int H); public: diff --git a/FL/Fl_Image.H b/FL/Fl_Image.H index 3f0ab6fa7..ae626772c 100644 --- a/FL/Fl_Image.H +++ b/FL/Fl_Image.H @@ -69,6 +69,7 @@ private: // Forbid use of copy constructor and assign operator Fl_Image & operator=(const Fl_Image &); Fl_Image(const Fl_Image &); + virtual int draw_scaled_(int X, int Y, int W, int H); protected: @@ -224,6 +225,7 @@ private: fl_uintptr_t id_; fl_uintptr_t mask_; float cache_scale_; // graphics scaling value when id_ was computed + virtual int draw_scaled_(int X, int Y, int W, int H); public: diff --git a/FL/Fl_Pixmap.H b/FL/Fl_Pixmap.H index df6eddb4c..a80b4d27a 100644 --- a/FL/Fl_Pixmap.H +++ b/FL/Fl_Pixmap.H @@ -42,6 +42,7 @@ class FL_EXPORT Fl_Pixmap : public Fl_Image { void set_data(const char * const *p); int prepare(int XP, int YP, int WP, int HP, int &cx, int &cy, int &X, int &Y, int &W, int &H); + virtual int draw_scaled_(int X, int Y, int W, int H); protected: diff --git a/src/Fl_Bitmap.cxx b/src/Fl_Bitmap.cxx index 450886d38..9baacf321 100644 --- a/src/Fl_Bitmap.cxx +++ b/src/Fl_Bitmap.cxx @@ -232,6 +232,11 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) { } +int Fl_Bitmap::draw_scaled_(int X, int Y, int W, int H) { + return (W <= w() && H <= h()) ? fl_graphics_driver->draw_scaled(this, X, Y, W, H) : 0; +} + + // // End of "$Id$". // diff --git a/src/Fl_Graphics_Driver.cxx b/src/Fl_Graphics_Driver.cxx index 737bffc09..e802952c9 100644 --- a/src/Fl_Graphics_Driver.cxx +++ b/src/Fl_Graphics_Driver.cxx @@ -196,11 +196,7 @@ void Fl_Graphics_Driver::draw(Fl_Shared_Image *shared, int X, int Y) { shared->image_->draw(X, Y, shared->w(), shared->h(), 0, 0); return; } - // don't call Fl_Graphics_Driver::draw_scaled(Fl_Image*,...) for an enlarged Fl_Bitmap or Fl_Pixmap - if (shared->image_->as_rgb_image() || (shared->w() <= shared->image_->w() && shared->h() <= shared->image_->h())) { - int done = draw_scaled(shared->image_, X, Y, shared->w(), shared->h()); - if (done) return; - } + if ( shared->image_->draw_scaled_(X, Y, shared->w(), shared->h()) ) return; if (shared->scaled_image_ && (shared->scaled_image_->w() != shared->w() || shared->scaled_image_->h() != shared->h())) { delete shared->scaled_image_; shared->scaled_image_ = NULL; diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx index 4b074be4a..a622f7d9e 100644 --- a/src/Fl_Image.cxx +++ b/src/Fl_Image.cxx @@ -578,6 +578,17 @@ void Fl_RGB_Image::label(Fl_Menu_Item* m) { m->label(_FL_IMAGE_LABEL, (const char*)this); } +int Fl_RGB_Image::draw_scaled_(int X, int Y, int W, int H) { + return fl_graphics_driver->draw_scaled(this, X, Y, W, H); +} + +// Draws the image scaled to W and H, and returns 1, +// or returns 0 if scaled drawing is not implemented for this image. +// Image classes can re-implement this function for specific image types. +int Fl_Image::draw_scaled_(int X, int Y, int W, int H) { + return 0; +} + // // End of "$Id$". // diff --git a/src/Fl_Pixmap.cxx b/src/Fl_Pixmap.cxx index 67b7e67e4..55658249a 100644 --- a/src/Fl_Pixmap.cxx +++ b/src/Fl_Pixmap.cxx @@ -394,6 +394,10 @@ void Fl_Pixmap::desaturate() { } } +int Fl_Pixmap::draw_scaled_(int X, int Y, int W, int H) { + return (W <= w() && H <= h()) ? fl_graphics_driver->draw_scaled(this, X, Y, W, H) : 0; +} + // // End of "$Id$". // |
