summaryrefslogtreecommitdiff
path: root/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-10-10 21:19:39 +0000
committerManolo Gouy <Manolo>2016-10-10 21:19:39 +0000
commita6a79d80f380ef0b45e8144159ba72c452300511 (patch)
tree7502f4fefa817c01a2bf67c3f3ce50daec93bac1 /src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
parent0250b4af12b044158ea3921d3ca17e86f0756383 (diff)
Re-organisation of code to support CoreText and ATSU for drawing text.
We avoid using one CoreText-related and one ATSU-related derived classes of class Fl_Quartz_Graphics_Driver. Thus, class Fl_Quartz_Graphics_Driver can be derived if useful and still support both text APIs. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@12022 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx')
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx56
1 files changed, 40 insertions, 16 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
index 4dd21f587..5fd811e1a 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
@@ -16,33 +16,57 @@
// http://www.fltk.org/str.php
//
-
#include "../../config_lib.h"
#include "Fl_Quartz_Graphics_Driver.H"
#include "../Darwin/Fl_Darwin_System_Driver.H"
#include <FL/x.H>
+Fl_Quartz_Graphics_Driver::pter_to_draw_member Fl_Quartz_Graphics_Driver::CoreText_or_ATSU_draw;
+Fl_Quartz_Graphics_Driver::pter_to_width_member Fl_Quartz_Graphics_Driver::CoreText_or_ATSU_width;
+
+int Fl_Quartz_Graphics_Driver::CoreText_or_ATSU = 0;
+
+void Fl_Quartz_Graphics_Driver::init_CoreText_or_ATSU()
+{
+#if HAS_ATSU && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+ if (Fl_Darwin_System_Driver::calc_mac_os_version() < 100500) {
+ // before Mac OS 10.5, only ATSU is available
+ CoreText_or_ATSU = use_ATSU;
+ CoreText_or_ATSU_draw = &Fl_Quartz_Graphics_Driver::draw_ATSU;
+ CoreText_or_ATSU_width = &Fl_Quartz_Graphics_Driver::width_ATSU;
+ } else {
+ CoreText_or_ATSU = use_CoreText;
+ CoreText_or_ATSU_draw = &Fl_Quartz_Graphics_Driver::draw_CoreText;
+ CoreText_or_ATSU_width = &Fl_Quartz_Graphics_Driver::width_CoreText;
+ }
+#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
+ CoreText_or_ATSU = use_ATSU;
+ CoreText_or_ATSU_draw = &Fl_Quartz_Graphics_Driver::draw_ATSU;
+ CoreText_or_ATSU_width = &Fl_Quartz_Graphics_Driver::width_ATSU;
+#else
+ CoreText_or_ATSU = use_CoreText;
+ CoreText_or_ATSU_draw = &Fl_Quartz_Graphics_Driver::draw_CoreText;
+ CoreText_or_ATSU_width = &Fl_Quartz_Graphics_Driver::width_CoreText;
+#endif
+}
+
/*
* By linking this module, the following static method will instantiate the
* OS X Quartz Graphics driver as the main display driver.
*/
Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver()
{
-#if HAS_ATSU
- static int option = 0; // 0: not initialized, 1: use CoreText, 2: use ATSU
- if (!option) {
- option = 2;
- if (Fl_Darwin_System_Driver::calc_mac_os_version() >= Fl_Quartz_Graphics_Driver::CoreText_threshold) {
- option = 1;
- }
- }
- if (option == 2) return new Fl_ATSU_Graphics_Driver();
-#endif // HAS_ATSU
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- return new Fl_CoreText_Graphics_Driver();
-#else
- return NULL; // should not happen
-#endif
+ return new Fl_Quartz_Graphics_Driver();
+}
+
+Fl_Quartz_Graphics_Driver::Fl_Quartz_Graphics_Driver() : Fl_Graphics_Driver(), gc_(NULL), p_size(0), p(NULL) {
+ quartz_line_width_ = 1.f;
+ quartz_line_cap_ = kCGLineCapButt;
+ quartz_line_join_ = kCGLineJoinMiter;
+ quartz_line_pattern = 0;
+ quartz_line_pattern_size = 0;
+ high_resolution_ = false;
+ if (!CoreText_or_ATSU) init_CoreText_or_ATSU();
}
char Fl_Quartz_Graphics_Driver::can_do_alpha_blending() {