diff options
| -rw-r--r-- | FL/Fl_Tiled_Image.H | 9 | ||||
| -rw-r--r-- | src/Fl_Tiled_Image.cxx | 4 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx | 15 |
3 files changed, 16 insertions, 12 deletions
diff --git a/FL/Fl_Tiled_Image.H b/FL/Fl_Tiled_Image.H index 599de4b4e..ebccd3be4 100644 --- a/FL/Fl_Tiled_Image.H +++ b/FL/Fl_Tiled_Image.H @@ -30,13 +30,16 @@ color_average(), desaturate(), or inactive() methods. */ class FL_EXPORT Fl_Tiled_Image : public Fl_Image { - protected: +private: + static bool drawing_tiled_image_; +protected: Fl_Image *image_; // The image that is tiled int alloc_image_; // Did we allocate this image? - public: - +public: + /** Returns true when the FLTK library is currently drawing an Fl_Tiled_Image object. */ + static inline bool drawing_tiled_image() { return drawing_tiled_image_;}; Fl_Tiled_Image(Fl_Image *i, int W = 0, int H = 0); virtual ~Fl_Tiled_Image(); diff --git a/src/Fl_Tiled_Image.cxx b/src/Fl_Tiled_Image.cxx index 2ec62e79a..cfc89bfb4 100644 --- a/src/Fl_Tiled_Image.cxx +++ b/src/Fl_Tiled_Image.cxx @@ -20,6 +20,8 @@ #include <FL/Fl_Window.H> #include <FL/fl_draw.H> +bool Fl_Tiled_Image::drawing_tiled_image_ = false; + /** The constructors create a new tiled image containing the specified image. Use a width and height of 0 to tile the whole window/widget. @@ -181,6 +183,7 @@ Fl_Tiled_Image::draw(int X, // I - Starting X position if (W == 0 || H == 0) return; fl_push_clip(X, Y, W, H); + drawing_tiled_image_ = true; if (cx > 0) iw -= cx; // crop image if (cy > 0) ih -= cy; @@ -194,5 +197,6 @@ Fl_Tiled_Image::draw(int X, // I - Starting X position } } } + drawing_tiled_image_ = false; fl_pop_clip(); } diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx index 73bea246e..d57e5b031 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx @@ -51,6 +51,7 @@ # include <FL/fl_draw.H> # include <FL/platform.H> # include <FL/Fl_Image_Surface.H> +# include <FL/Fl_Tiled_Image.H> # include "../../Fl_Screen_Driver.H" # include "../../Fl_XColor.H" # include "../../flstring.h" @@ -780,16 +781,9 @@ void Fl_Xlib_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP if (Wfull == 0 || Hfull == 0) return; bool need_clip = (cx || cy || WP < rgb->w() || HP < rgb->h()); if (need_clip) push_clip(XP, YP, WP, HP); - int offset = 0; - if (Wfull > rgb->data_w() || Hfull > rgb->data_h()) { - // When enlarging while drawing with XRender, 1 pixel around target area seems unpainted, - // so we increase a bit the target area and move it 1 pixel to left and top. - Wfull = (rgb->w()+2)*scale(), Hfull = (rgb->h()+2)*scale(); - offset = 1; - } scale_and_render_pixmap( *Fl_Graphics_Driver::id(rgb), rgb->d(), rgb->data_w() / double(Wfull), rgb->data_h() / double(Hfull), - Xs + this->floor(offset_x_) - offset, Ys + this->floor(offset_y_) - offset, + Xs + this->floor(offset_x_), Ys + this->floor(offset_y_), Wfull, Hfull); if (need_clip) pop_clip(); } @@ -830,7 +824,10 @@ int Fl_Xlib_Graphics_Driver::scale_and_render_pixmap(Fl_Offscreen pixmap, int de { XDoubleToFixed( 0 ), XDoubleToFixed( 0 ), XDoubleToFixed( 1 ) } }}; XRenderSetPictureTransform(fl_display, src, &mat); - if (Fl_Image::scaling_algorithm() == FL_RGB_SCALING_BILINEAR) { + if (Fl_Image::scaling_algorithm() == FL_RGB_SCALING_BILINEAR && + !Fl_Tiled_Image::drawing_tiled_image()) { + // The filter is not used when drawing tiled images because drawn image edges + // become somewhat blurry. XRenderSetPictureFilter(fl_display, src, FilterBilinear, 0, 0); // A note at https://www.talisman.org/~erlkonig/misc/x11-composite-tutorial/ : // "When you use a filter you'll probably want to use PictOpOver as the render op, |
