From bbd551469150593d05ae7c671b2e3366bcd303d2 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Fri, 25 May 2018 04:36:49 +0000 Subject: Rewrite static function Fl_Image_Surface::rescale(Fl_Image_Surface*&) as member function Fl_Image_Surface::rescale(). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12936 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- FL/Fl_Image_Surface.H | 2 +- src/Fl_Image_Surface.cxx | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/FL/Fl_Image_Surface.H b/FL/Fl_Image_Surface.H index 1daf4bc63..e411822c9 100644 --- a/FL/Fl_Image_Surface.H +++ b/FL/Fl_Image_Surface.H @@ -86,7 +86,7 @@ public: void origin(int x, int y); int printable_rect(int *w, int *h); Fl_Offscreen offscreen(); - static void rescale(Fl_Image_Surface*& surf); + void rescale(); }; diff --git a/src/Fl_Image_Surface.cxx b/src/Fl_Image_Surface.cxx index 07afef0d6..7fa4da631 100644 --- a/src/Fl_Image_Surface.cxx +++ b/src/Fl_Image_Surface.cxx @@ -118,16 +118,18 @@ Fl_Offscreen Fl_Image_Surface::get_offscreen_before_delete_() { return keep; } -/** Adapts an Fl_Image_Surface object to the new value of the GUI scale factor. +/** Adapts the Fl_Image_Surface object to the new value of the GUI scale factor. + The Fl_Image_Surface object must not be the current drawing surface. + This function is useful only for an object constructed with non-zero \p high_res parameter. \version 1.4 */ -void Fl_Image_Surface::rescale(Fl_Image_Surface*& surface) { - Fl_RGB_Image *rgb = surface->image(); +void Fl_Image_Surface::rescale() { + Fl_RGB_Image *rgb = image(); int w, h; - surface->printable_rect(&w, &h); - delete surface; - surface = new Fl_Image_Surface(w, h, 1); - Fl_Surface_Device::push_current(surface); + printable_rect(&w, &h); + delete platform_surface; + platform_surface = Fl_Image_Surface_Driver::newImageSurfaceDriver(w, h, 1, 0); + Fl_Surface_Device::push_current(this); rgb->draw(0,0); Fl_Surface_Device::pop_current(); delete rgb; @@ -170,7 +172,7 @@ static int find_slot(void) { // return an available slot to memorize an Fl_Image fl_begin_offscreen(off)Fl_Surface_Device::push_current(surface) fl_end_offscreen()Fl_Surface_Device::pop_current() fl_copy_offscreen(x,y,w,h, off, sx,sy)fl_copy_offscreen(x,y,w,h, surface->offscreen(), sx,sy) - fl_rescale_offscreen(off)Fl_Image_Surface::rescale(surface) + fl_rescale_offscreen(off)surface->rescale() fl_delete_offscreen(off)delete surface */ @@ -229,7 +231,7 @@ void fl_rescale_offscreen(Fl_Offscreen &ctx) { } } if (i >= count_offscreens) return; - Fl_Image_Surface::rescale(offscreen_api_surface[i]); + offscreen_api_surface[i]->rescale(); ctx = offscreen_api_surface[i]->offscreen(); } -- cgit v1.2.3