diff options
| author | Manolo Gouy <Manolo> | 2018-03-28 13:00:12 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2018-03-28 13:00:12 +0000 |
| commit | 458d0636436b5f25e444dc285007dceac296c2ee (patch) | |
| tree | 88510e081d4f4199db92879b4a1960ea22204769 /src/drivers/Xlib | |
| parent | 29bda776bb78352b331771bd1169de31e4edc1be (diff) | |
Image classes: memorise the width and the height of the cached form of the image to support GUI scaling
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12811 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Xlib')
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx | 18 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H index 7d74b70e1..785c76369 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H @@ -101,6 +101,7 @@ protected: static Window draw_window; static struct _XftDraw* draw_; #endif + Fl_Offscreen cache_rgb(Fl_RGB_Image *img); public: Fl_Xlib_Graphics_Driver(void); virtual ~Fl_Xlib_Graphics_Driver(); diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx index 902cb5e45..c271dae53 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx @@ -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; } -static Fl_Offscreen cache_rgb(Fl_RGB_Image *img) { +Fl_Offscreen Fl_Xlib_Graphics_Driver::cache_rgb(Fl_RGB_Image *img) { Fl_Image_Surface *surface; int depth = img->d(); if (depth == 1 || depth == 3) { @@ -713,6 +713,10 @@ static Fl_Offscreen cache_rgb(Fl_RGB_Image *img) { Fl_Surface_Device::pop_current(); Fl_Offscreen off = surface->get_offscreen_before_delete(); delete surface; + int *pw, *ph; + cache_w_h(img, pw, ph); + *pw = img->data_w(); + *ph = img->data_h(); return off; } @@ -728,7 +732,6 @@ void Fl_Xlib_Graphics_Driver::draw_unscaled(Fl_RGB_Image *img, float s, int X, i if (H + cy > img->data_h()) H = img->data_h() - cy; if (!*Fl_Graphics_Driver::id(img)) { *Fl_Graphics_Driver::id(img) = cache_rgb(img); - *cache_scale(img) = 1; } Fl_Region r2 = scale_clip(s); if (*Fl_Graphics_Driver::id(img)) { @@ -767,7 +770,10 @@ 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) { - *cache_scale(bm) = Fl_Scalable_Graphics_Driver::scale(); + int *pw, *ph; + cache_w_h(bm, pw, ph); + *pw = bm->data_w(); + *ph = bm->data_h(); return (fl_uintptr_t)create_bitmask(bm->data_w(), bm->data_h(), bm->array); } @@ -830,7 +836,10 @@ fl_uintptr_t Fl_Xlib_Graphics_Driver::cache(Fl_Pixmap *pxm) { Fl_Surface_Device::pop_current(); Fl_Offscreen id = surf->get_offscreen_before_delete(); delete surf; - *cache_scale(pxm) = 1; + int *pw, *ph; + cache_w_h(pxm, pw, ph); + *pw = pxm->data_w(); + *ph = pxm->data_h(); return (fl_uintptr_t)id; } @@ -881,7 +890,6 @@ int Fl_Xlib_Graphics_Driver::draw_scaled(Fl_Image *img, int XP, int YP, int WP, if (!rgb || !can_do_alpha_blending()) return 0; if (!*Fl_Graphics_Driver::id(rgb)) { *Fl_Graphics_Driver::id(rgb) = cache_rgb(rgb); - *cache_scale(rgb) = 1; } cache_size(img, WP, HP); return scale_and_render_pixmap( *Fl_Graphics_Driver::id(rgb), rgb->d(), |
