summaryrefslogtreecommitdiff
path: root/src/drivers/Quartz
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2019-07-08 08:56:07 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2019-07-08 08:56:07 +0200
commit58dad3bda20c880777c1f35dace07b460f49800f (patch)
tree49dbb8dd479956064d4eede5397350822876d1bb /src/drivers/Quartz
parent3c41e2d372d35c6a9681b50750486543ea01577b (diff)
Fl_Quartz_Copy_Surface_Driver: minor code reorganisation.
Diffstat (limited to 'src/drivers/Quartz')
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H2
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.cxx50
2 files changed, 20 insertions, 32 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H b/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H
index 938600dac..087a9fe4c 100644
--- a/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H
+++ b/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H
@@ -28,8 +28,6 @@ class Fl_Quartz_Copy_Surface_Driver : public Fl_Copy_Surface_Driver {
protected:
CFMutableDataRef pdfdata;
CGContextRef gc;
- void prepare_copy_pdf_and_tiff(int w, int h);
- void init_PDF_context(int w, int h);
static size_t MyPutBytes(void* info, const void* buffer, size_t count);
Fl_Quartz_Copy_Surface_Driver(int w, int h);
// implemented in Fl_cocoa.mm because uses Objective-c
diff --git a/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.cxx
index 9c8e71671..c525d2985 100644
--- a/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.cxx
@@ -3,7 +3,7 @@
//
// Copy-to-clipboard code for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2018 by Bill Spitzak and others.
+// Copyright 1998-2019 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -43,24 +43,6 @@ Fl_Copy_Surface_Driver *Fl_Copy_Surface_Driver::newCopySurfaceDriver(int w, int
Fl_Quartz_Copy_Surface_Driver::Fl_Quartz_Copy_Surface_Driver(int w, int h) : Fl_Copy_Surface_Driver(w, h) {
driver(new Fl_Quartz_Printer_Graphics_Driver);
- prepare_copy_pdf_and_tiff(w, h);
-}
-
-void Fl_Quartz_Copy_Surface_Driver::set_current() {
- driver()->gc(gc);
- fl_window = (Window)1;
- Fl_Surface_Device::set_current();
-}
-
-size_t Fl_Quartz_Copy_Surface_Driver::MyPutBytes(void* info, const void* buffer, size_t count)
-{
- CFDataAppendBytes ((CFMutableDataRef) info, (const UInt8 *)buffer, count);
- return count;
-}
-
-void Fl_Quartz_Copy_Surface_Driver::init_PDF_context(int w, int h)
-{
- CGRect bounds = CGRectMake(0, 0, w, h );
pdfdata = CFDataCreateMutable(NULL, 0);
CGDataConsumerRef myconsumer;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
@@ -71,21 +53,29 @@ void Fl_Quartz_Copy_Surface_Driver::init_PDF_context(int w, int h)
#endif
{
static CGDataConsumerCallbacks callbacks = { Fl_Quartz_Copy_Surface_Driver::MyPutBytes, NULL };
- myconsumer = CGDataConsumerCreate ((void*) pdfdata, &callbacks);
+ myconsumer = CGDataConsumerCreate((void*) pdfdata, &callbacks);
+ }
+ CGRect bounds = CGRectMake(0, 0, w, h );
+ gc = CGPDFContextCreate(myconsumer, &bounds, NULL);
+ CGDataConsumerRelease(myconsumer);
+ if (gc) {
+ CGContextBeginPage(gc, &bounds);
+ CGContextTranslateCTM(gc, 0, h);
+ CGContextScaleCTM(gc, 1.0f, -1.0f);
+ CGContextSaveGState(gc);
}
- gc = CGPDFContextCreate (myconsumer, &bounds, NULL);
- CGDataConsumerRelease (myconsumer);
}
-void Fl_Quartz_Copy_Surface_Driver::prepare_copy_pdf_and_tiff(int w, int h)
+void Fl_Quartz_Copy_Surface_Driver::set_current() {
+ driver()->gc(gc);
+ fl_window = (Window)1;
+ Fl_Surface_Device::set_current();
+}
+
+size_t Fl_Quartz_Copy_Surface_Driver::MyPutBytes(void* info, const void* buffer, size_t count)
{
- init_PDF_context(w, h);
- if (gc == NULL) return;
- CGRect bounds = CGRectMake(0, 0, w, h );
- CGContextBeginPage (gc, &bounds);
- CGContextTranslateCTM(gc, 0, h);
- CGContextScaleCTM(gc, 1.0f, -1.0f);
- CGContextSaveGState(gc);
+ CFDataAppendBytes ((CFMutableDataRef) info, (const UInt8 *)buffer, count);
+ return count;
}
void Fl_Quartz_Copy_Surface_Driver::translate(int x, int y) {