From 3f9f4debbba0527658ce09044fbff90e332235cc Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Mon, 18 Dec 2017 08:52:55 +0000 Subject: STR#3444: Add MacOS support for application rescaling (not quite complete) With this, most MacOS FLTK app can be scaled with command/+/-/0/ keystrokes. A scaling problem remains, visible in test/cube, where the "Test" string is not positioned correctly. GLUT apps can also be scaled (across platforms). SVG images are re-rasterized after app scaling for optimal drawing. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12594 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_SVG_Image.cxx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/Fl_SVG_Image.cxx') diff --git a/src/Fl_SVG_Image.cxx b/src/Fl_SVG_Image.cxx index d7eb8c83c..fd941d49a 100644 --- a/src/Fl_SVG_Image.cxx +++ b/src/Fl_SVG_Image.cxx @@ -193,6 +193,7 @@ void Fl_SVG_Image::rasterize_(int W, int H) { rasterized_ = true; raster_w_ = W; raster_h_ = H; +//printf("rasterize to %dx%d\n",W, H); } @@ -234,10 +235,14 @@ void Fl_SVG_Image::resize(int width, int height) { void Fl_SVG_Image::draw(int X, int Y, int W, int H, int cx, int cy) { - static float f = Fl::screen_driver()->retina_factor(); + float f = 1; + if (Fl_Surface_Device::surface() == Fl_Display_Device::display_device()) { + f = Fl::screen_driver()->retina_factor() * fl_graphics_driver->scale(); + } int w1 = w(), h1 = h(); /* When f > 1, there may be several pixels per drawing unit in an area - of size w() x h() of the display. This occurs, e.g., with Apple retina displays. + of size w() x h() of the display. This occurs, e.g., with Apple retina displays + and when the display is rescaled. The SVG is rasterized to the area dimension in pixels. The image is then drawn scaled to its size expressed in drawing units. With this procedure, the SVG image is drawn using the full resolution of the display. @@ -269,9 +274,6 @@ void Fl_SVG_Image::color_average(Fl_Color c, float i) { int Fl_SVG_Image::draw_scaled(int X, int Y, int W, int H) { - if (rasterized_ && raster_w_ >= W && raster_h_ >= H) { - return fl_graphics_driver->draw_scaled(this, X, Y, W, H); - } w(W); h(H); draw(X, Y, W, H, 0, 0); -- cgit v1.2.3