summaryrefslogtreecommitdiff
path: root/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2021-02-26 18:00:07 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2021-05-31 08:28:06 +0200
commitb027d2ba57a8e0d6f0862e0a891ddd5dee4b02e2 (patch)
tree3ed894bd9a891337804367a09de500ff060be640 /src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx
parentd95dd7acc4af3a4bd521d151ba3576b91d8ace53 (diff)
Windows platform: use GDI+ to antialias oblique lines and curves.
Diffstat (limited to 'src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx')
-rw-r--r--src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx
index 3fe721907..0ee5cf99f 100644
--- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx
+++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx
@@ -22,15 +22,58 @@
#include <FL/fl_draw.H>
#include "../../Fl_Screen_Driver.H"
+#if USE_GDIPLUS
+static ULONG_PTR gdiplusToken = 0;
+
+Fl_GDIplus_Graphics_Driver::Fl_GDIplus_Graphics_Driver() : Fl_GDI_Graphics_Driver() {
+ if (!fl_current_xmap) color(FL_BLACK);
+ pen_ = new Gdiplus::Pen(gdiplus_color_, 1);
+ pen_->SetLineJoin(Gdiplus::LineJoinRound);
+ pen_->SetStartCap(Gdiplus::LineCapFlat);
+ pen_->SetEndCap(Gdiplus::LineCapFlat);
+ brush_ = new Gdiplus::SolidBrush(gdiplus_color_);
+ active = true;
+}
+
+Fl_GDIplus_Graphics_Driver::~Fl_GDIplus_Graphics_Driver() {
+ delete pen_;
+ delete brush_;
+}
+
+void Fl_GDIplus_Graphics_Driver::antialias(int state) {
+ active = state;
+}
+
+int Fl_GDIplus_Graphics_Driver::antialias() {
+ return active;
+}
+
+#endif
+
/*
* By linking this module, the following static method will instantiate the
* Windows GDI Graphics driver as the main display driver.
*/
Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver()
{
+#if USE_GDIPLUS
+ // Initialize GDI+.
+ static Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ if (gdiplusToken == 0) GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
+
+ Fl_Graphics_Driver *driver = new Fl_GDIplus_Graphics_Driver();
+ return driver;
+#else
return new Fl_GDI_Graphics_Driver();
+#endif
}
+#if USE_GDIPLUS
+void Fl_GDIplus_Graphics_Driver::shutdown() {
+ Gdiplus::GdiplusShutdown(gdiplusToken);
+}
+#endif
+
// Code used to switch output to an off-screen window. See macros in
// win32.H which save the old state in local variables.