summaryrefslogtreecommitdiff
path: root/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-02-18 16:21:51 +0000
committerManolo Gouy <Manolo>2016-02-18 16:21:51 +0000
commitf33b45f1d30653fb5da4817089e38ff0a2413cfb (patch)
tree9edc759690defa581b00b6ada80bb334f4ac5da8 /src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
parent6ce27012a9412c4964e0ae40c81ea92ff39a61d3 (diff)
Remove all uses of the fl_gc global variable. Towards a clean driver model.
fl_gc remains usable by the application as a hook into the system. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11189 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx')
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
index d3fc9e79d..1d909b488 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
@@ -580,7 +580,7 @@ if (fl_mac_os_version >= Fl_X::CoreText_threshold) {
// activate the current GC
iSize = sizeof(CGContextRef);
iTag = kATSUCGContextTag;
- iValuePtr = &fl_gc;
+ iValuePtr = &gc;
ATSUSetLayoutControls(layout, 1, &iTag, &iSize, &iValuePtr);
// now measure the bounding box
err = ATSUSetTextPointerLocation(layout, txt, kATSUFromTextBeginning, n, n);
@@ -632,10 +632,10 @@ if (fl_mac_os_version >= Fl_X::CoreText_threshold) {
CFRelease(str16);
CTLineRef ctline = CTLineCreateWithAttributedString(mastr);
CFRelease(mastr);
- CGContextSetTextPosition(fl_gc, 0, 0);
- CGContextSetShouldAntialias(fl_gc, true);
- CGRect rect = CTLineGetImageBounds(ctline, fl_gc);
- CGContextSetShouldAntialias(fl_gc, false);
+ CGContextSetTextPosition(gc, 0, 0);
+ CGContextSetShouldAntialias(gc, true);
+ CGRect rect = CTLineGetImageBounds(ctline, gc);
+ CGContextSetShouldAntialias(gc, false);
CFRelease(ctline);
dx = floor(rect.origin.x + 0.5);
dy = floor(- rect.origin.y - rect.size.height + 0.5);
@@ -657,7 +657,7 @@ else {
// activate the current GC
iSize = sizeof(CGContextRef);
iTag = kATSUCGContextTag;
- iValuePtr = &fl_gc;
+ iValuePtr = &gc;
ATSUSetLayoutControls(layout, 1, &iTag, &iSize, &iValuePtr);
// now measure the bounding box
err = ATSUSetTextPointerLocation(layout, txt, kATSUFromTextBeginning, n, n);
@@ -704,11 +704,12 @@ static void fl_mac_draw(const char *str, int n, float x, float y, Fl_Graphics_Dr
CFRelease(color);
CTLineRef ctline = CTLineCreateWithAttributedString(mastr);
CFRelease(mastr);
- CGContextSetTextMatrix(fl_gc, font_mx);
- CGContextSetTextPosition(fl_gc, x, y);
- CGContextSetShouldAntialias(fl_gc, true);
- CTLineDraw(ctline, fl_gc);
- CGContextSetShouldAntialias(fl_gc, false);
+ CGContextRef gc = (CGContextRef)driver->get_gc();
+ CGContextSetTextMatrix(gc, font_mx);
+ CGContextSetTextPosition(gc, x, y);
+ CGContextSetShouldAntialias(gc, true);
+ CTLineDraw(ctline, gc);
+ CGContextSetShouldAntialias(gc, false);
CFRelease(ctline);
} else {
#endif
@@ -719,13 +720,13 @@ static void fl_mac_draw(const char *str, int n, float x, float y, Fl_Graphics_Dr
ByteCount iSize = sizeof(CGContextRef);
ATSUAttributeTag iTag = kATSUCGContextTag;
- ATSUAttributeValuePtr iValuePtr=&fl_gc;
+ ATSUAttributeValuePtr iValuePtr=&gc;
ATSUSetLayoutControls(layout, 1, &iTag, &iSize, &iValuePtr);
err = ATSUSetTextPointerLocation(layout, uniStr, kATSUFromTextBeginning, n, n);
- CGContextSetShouldAntialias(fl_gc, true);
+ CGContextSetShouldAntialias(gc, true);
err = ATSUDrawText(layout, kATSUFromTextBeginning, n, FloatToFixed(x), FloatToFixed(y));
- CGContextSetShouldAntialias(fl_gc, false);
+ CGContextSetShouldAntialias(gc, false);
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
}
@@ -745,11 +746,11 @@ void Fl_Quartz_Graphics_Driver::draw(const char* str, int n, int x, int y) {
}
void Fl_Quartz_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) {
- CGContextSaveGState(fl_gc);
- CGContextTranslateCTM(fl_gc, x, y);
- CGContextRotateCTM(fl_gc, - angle*(M_PI/180) );
+ CGContextSaveGState(gc);
+ CGContextTranslateCTM(gc, x, y);
+ CGContextRotateCTM(gc, - angle*(M_PI/180) );
draw(str, n, 0, 0);
- CGContextRestoreGState(fl_gc);
+ CGContextRestoreGState(gc);
}
void Fl_Quartz_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {