summaryrefslogtreecommitdiff
path: root/src/Fl_SVG_Image.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Fl_SVG_Image.cxx')
-rw-r--r--src/Fl_SVG_Image.cxx21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Fl_SVG_Image.cxx b/src/Fl_SVG_Image.cxx
index 91be0c70d..4e4645d3f 100644
--- a/src/Fl_SVG_Image.cxx
+++ b/src/Fl_SVG_Image.cxx
@@ -22,6 +22,8 @@
#include <FL/Fl_SVG_Image.H>
#include <FL/fl_utf8.h>
+#include <FL/fl_draw.H>
+#include <FL/Fl_Screen_Driver.H>
#include <stdio.h>
#include <stdlib.h>
@@ -182,8 +184,23 @@ 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) {
- resize(w(), h());
- Fl_RGB_Image::draw(X, Y, W, H, cx, cy);
+ static float f = Fl::screen_driver()->retina_factor();
+ 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.
+ 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.
+ */
+ resize(f*w(), f*h());
+ if (f == 1) {
+ Fl_RGB_Image::draw(X, Y, W, H, cx, cy);
+ } else {
+ bool need_clip = (cx || cy || W != w1 || H != h1);
+ if (need_clip) fl_push_clip(X, Y, W, H);
+ fl_graphics_driver->draw_scaled(this, X-cx, Y-cy, w1, h1);
+ if (need_clip) fl_pop_clip();
+ }
}