summaryrefslogtreecommitdiff
path: root/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2017-12-26 16:07:51 +0000
committerManolo Gouy <Manolo>2017-12-26 16:07:51 +0000
commit7758d472c2356f6908bce9fec6aa3e6d7e6a63e1 (patch)
tree0bac011dc51e12d811f249855e91ba60addce2e8 /src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx
parent8ee87d15e3c369d74752736a9c3e6614e2950cb0 (diff)
Continue support for GUI rescaling under MacOS: fix fl_XXX_offscreen() functions and Fl_Image_Surface class
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12605 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx')
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx
index c8d751aa1..573a5df8e 100644
--- a/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx
@@ -23,6 +23,7 @@
#include <FL/fl_draw.H>
#include <FL/Fl_Image_Surface.H>
#include "Fl_Quartz_Graphics_Driver.H"
+#include "../Cocoa/Fl_Cocoa_Window_Driver.H"
#include <ApplicationServices/ApplicationServices.h>
class Fl_Quartz_Image_Surface_Driver : public Fl_Image_Surface_Driver {
@@ -46,15 +47,21 @@ Fl_Image_Surface_Driver *Fl_Image_Surface_Driver::newImageSurfaceDriver(int w, i
Fl_Quartz_Image_Surface_Driver::Fl_Quartz_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off) : Fl_Image_Surface_Driver(w, h, high_res, 0) {
- int W = high_res ? 2*w : w;
- int H = high_res ? 2*h : h;
+ int W = w, H = h;
+ float s = 1;
+ if (high_res) {
+ s = Fl_Graphics_Driver::default_driver().scale();
+ Fl_Window *cw = Fl_Window::current();
+ if (cw && ((Fl_Cocoa_Window_Driver*)cw->driver())->mapped_to_retina()) s *= 2;
+ W *= s; H *= s;
+ }
CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
offscreen = off ? off : CGBitmapContextCreate(calloc(W*H,4), W, H, 8, W*4, lut, kCGImageAlphaPremultipliedLast);
CGColorSpaceRelease(lut);
driver(new Fl_Quartz_Graphics_Driver);
CGContextTranslateCTM(offscreen, 0.5, -0.5); // as when drawing to a window
if (high_res) {
- CGContextScaleCTM(offscreen, 2, 2);
+ CGContextScaleCTM(offscreen, s, s);
}
CGContextSetShouldAntialias(offscreen, false);
CGContextTranslateCTM(offscreen, 0, height);