summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2018-03-28 13:00:12 +0000
committerManolo Gouy <Manolo>2018-03-28 13:00:12 +0000
commit458d0636436b5f25e444dc285007dceac296c2ee (patch)
tree88510e081d4f4199db92879b4a1960ea22204769 /src/drivers
parent29bda776bb78352b331771bd1169de31e4edc1be (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')
-rw-r--r--src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx20
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H1
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx18
3 files changed, 30 insertions, 9 deletions
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
index 5c00198f0..6b9cb6d87 100644
--- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
+++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
@@ -498,7 +498,10 @@ void Fl_GDI_Graphics_Driver::draw_unscaled(Fl_RGB_Image *img, float s, int X, in
if (H + cy > img->data_h()) H = img->data_h() - cy;
if (!*Fl_Graphics_Driver::id(img)) {
*Fl_Graphics_Driver::id(img) = (fl_uintptr_t)build_id(img, (void**)(Fl_Graphics_Driver::mask(img)));
- *cache_scale(img) = 1;
+ int *pw, *ph;
+ cache_w_h(img, pw, ph);
+ *pw = img->data_w();
+ *ph = img->data_h();
}
Fl_Region r2 = scale_clip(s);
if (*Fl_Graphics_Driver::mask(img)) {
@@ -541,7 +544,10 @@ int Fl_GDI_Graphics_Driver::draw_scaled(Fl_Image *img, int XP, int YP, int WP, i
if (!*Fl_Graphics_Driver::id(rgb)) {
*Fl_Graphics_Driver::id(rgb) = (fl_uintptr_t)build_id(rgb,
(void**)(Fl_Graphics_Driver::mask(rgb)));
- *cache_scale(rgb) = 1;
+ int *pw, *ph;
+ cache_w_h(rgb, pw, ph);
+ *pw = rgb->data_w();
+ *ph = rgb->data_h();
}
cache_size(img, WP, HP);
HDC new_gc = CreateCompatibleDC(gc_);
@@ -600,7 +606,10 @@ static Fl_Bitmask fl_create_bitmap(int w, int h, const uchar *data) {
}
fl_uintptr_t Fl_GDI_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)fl_create_bitmap(bm->data_w(), bm->data_h(), bm->array);
}
@@ -660,7 +669,10 @@ fl_uintptr_t Fl_GDI_Graphics_Driver::cache(Fl_Pixmap *img) {
Fl_Surface_Device::pop_current();
Fl_Offscreen id = surf->get_offscreen_before_delete();
delete surf;
- *cache_scale(img) = 1;
+ int *pw, *ph;
+ cache_w_h(img, pw, ph);
+ *pw = img->data_w();
+ *ph = img->data_h();
return (fl_uintptr_t)id;
}
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(),