summaryrefslogtreecommitdiff
path: root/src/drivers/Xlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/Xlib')
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx1
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H7
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx19
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx1
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx16
5 files changed, 36 insertions, 8 deletions
diff --git a/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
index 8615fbb8b..3cb07dbd5 100644
--- a/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
@@ -21,6 +21,7 @@
#ifdef FL_CFG_GFX_XLIB
#include <FL/Fl_Copy_Surface.H>
#include <FL/Fl.H>
+#include <FL/x.H>
#include <FL/fl_draw.H>
#include "Fl_Translated_Xlib_Graphics_Driver.H"
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
index d9f0d7135..4d4a1ab30 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
@@ -26,6 +26,7 @@
#define FL_CFG_GFX_XLIB_H
#include <FL/Fl_Graphics_Driver.H>
+#include <FL/x.H>
/**
\brief The Xlib-specific graphics class.
@@ -38,8 +39,12 @@ protected:
uchar **mask_bitmap_;
uchar **mask_bitmap() {return mask_bitmap_;}
void mask_bitmap(uchar **value) { mask_bitmap_ = value; }
+ int p_size;
+ typedef struct {short x, y;} XPOINT;
+ XPOINT *p;
public:
Fl_Xlib_Graphics_Driver(void);
+ virtual ~Fl_Xlib_Graphics_Driver() { if (p) free(p); }
virtual int has_feature(driver_feature mask) { return mask & NATIVE; }
virtual void *gc() { return gc_; }
virtual void gc(void *value);
@@ -75,6 +80,8 @@ public:
void copy_offscreen_with_alpha(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
#endif
protected:
+ void transformed_vertex0(short x, short y);
+ void fixloop();
// --- implementation is in src/fl_rect.cxx which includes src/cfg_gfx/xlib_rect.cxx
void point(int x, int y);
void rect(int x, int y, int w, int h);
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
index 967712490..aa82393fe 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
@@ -20,6 +20,7 @@
#include "../../config_lib.h"
#include "Fl_Xlib_Graphics_Driver.H"
#include <FL/fl_draw.H>
+#include <FL/x.H>
#include <string.h>
@@ -51,6 +52,8 @@ GC Fl_Xlib_Graphics_Driver::gc_ = NULL;
Fl_Xlib_Graphics_Driver::Fl_Xlib_Graphics_Driver(void) {
mask_bitmap_ = NULL;
+ p_size = 0;
+ p = NULL;
}
void Fl_Xlib_Graphics_Driver::gc(void *value) {
@@ -105,6 +108,22 @@ void Fl_Graphics_Driver::add_rectangle_to_region(Fl_Region r, int X, int Y, int
XUnionRectWithRegion(&R, r, r);
}
+void Fl_Xlib_Graphics_Driver::transformed_vertex0(short x, short y) {
+ if (!n || x != p[n-1].x || y != p[n-1].y) {
+ if (n >= p_size) {
+ p_size = p ? 2*p_size : 16;
+ p = (XPOINT*)realloc((void*)p, p_size*sizeof(*p));
+ }
+ p[n].x = x;
+ p[n].y = y;
+ n++;
+ }
+}
+
+void Fl_Xlib_Graphics_Driver::fixloop() { // remove equal points from closed path
+ while (n>2 && p[n-1].x == p[0].x && p[n-1].y == p[0].y) n--;
+}
+
//
// End of "$Id$".
//
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx
index a47e605b6..fcad6fd5f 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx
@@ -19,6 +19,7 @@
#include <config.h>
#include "Fl_Xlib_Graphics_Driver.H"
#include <FL/fl_draw.H>
+#include <FL/x.H>
/**
\file Fl_Xlib_Graphics_Driver_arci.cxx
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx
index 99f1da627..05c58eb8d 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx
@@ -31,15 +31,15 @@
void Fl_Xlib_Graphics_Driver::transformed_vertex(double xf, double yf) {
- transformed_vertex0(COORD_T(rint(xf)), COORD_T(rint(yf)));
+ transformed_vertex0(short(rint(xf)), short(rint(yf)));
}
void Fl_Xlib_Graphics_Driver::vertex(double x,double y) {
- transformed_vertex0(COORD_T(x*m.a + y*m.c + m.x), COORD_T(x*m.b + y*m.d + m.y));
+ transformed_vertex0(short(x*m.a + y*m.c + m.x), short(x*m.b + y*m.d + m.y));
}
void Fl_Xlib_Graphics_Driver::end_points() {
- if (n>1) XDrawPoints(fl_display, fl_window, gc_, p, n, 0);
+ if (n>1) XDrawPoints(fl_display, fl_window, gc_, (XPoint*)p, n, 0);
}
void Fl_Xlib_Graphics_Driver::end_line() {
@@ -47,12 +47,12 @@ void Fl_Xlib_Graphics_Driver::end_line() {
end_points();
return;
}
- if (n>1) XDrawLines(fl_display, fl_window, gc_, p, n, 0);
+ if (n>1) XDrawLines(fl_display, fl_window, gc_, (XPoint*)p, n, 0);
}
void Fl_Xlib_Graphics_Driver::end_loop() {
fixloop();
- if (n>2) transformed_vertex((COORD_T)p[0].x, (COORD_T)p[0].y);
+ if (n>2) transformed_vertex((short)p[0].x, (short)p[0].y);
end_line();
}
@@ -62,7 +62,7 @@ void Fl_Xlib_Graphics_Driver::end_polygon() {
end_line();
return;
}
- if (n>2) XFillPolygon(fl_display, fl_window, gc_, p, n, Convex, 0);
+ if (n>2) XFillPolygon(fl_display, fl_window, gc_, (XPoint*)p, n, Convex, 0);
}
void Fl_Xlib_Graphics_Driver::begin_complex_polygon() {
@@ -73,7 +73,7 @@ void Fl_Xlib_Graphics_Driver::begin_complex_polygon() {
void Fl_Xlib_Graphics_Driver::gap() {
while (n>gap_+2 && p[n-1].x == p[gap_].x && p[n-1].y == p[gap_].y) n--;
if (n > gap_+2) {
- transformed_vertex((COORD_T)p[gap_].x, (COORD_T)p[gap_].y);
+ transformed_vertex((short)p[gap_].x, (short)p[gap_].y);
gap_ = n;
} else {
n = gap_;
@@ -86,7 +86,7 @@ void Fl_Xlib_Graphics_Driver::end_complex_polygon() {
end_line();
return;
}
- if (n>2) XFillPolygon(fl_display, fl_window, gc_, p, n, 0, 0);
+ if (n>2) XFillPolygon(fl_display, fl_window, gc_, (XPoint*)p, n, 0, 0);
}
// shortcut the closed circles so they use XDrawArc: