summaryrefslogtreecommitdiff
path: root/src/Fl_Graphics_Driver.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2021-03-01 15:10:52 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2021-03-01 15:11:00 +0100
commit0623a8d4b9e8a56cc435dc550c6b56fa1a9607e9 (patch)
tree48e6487325011a59b6016d0c43d2c1f78a6f1612 /src/Fl_Graphics_Driver.cxx
parent37175d17571e075324fb5cb3c651e45b236cd6e5 (diff)
Remove duplicated code between derived classes of Fl_Graphics_Driver.
Diffstat (limited to 'src/Fl_Graphics_Driver.cxx')
-rw-r--r--src/Fl_Graphics_Driver.cxx24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/Fl_Graphics_Driver.cxx b/src/Fl_Graphics_Driver.cxx
index 547526ed3..be8849dd4 100644
--- a/src/Fl_Graphics_Driver.cxx
+++ b/src/Fl_Graphics_Driver.cxx
@@ -49,6 +49,8 @@ Fl_Graphics_Driver::Fl_Graphics_Driver()
fl_matrix = &m;
font_descriptor_ = NULL;
scale_ = 1;
+ p_size = 0;
+ p = NULL;
};
/** Return the graphics driver used when drawing to the platform's display */
@@ -497,10 +499,14 @@ int Fl_Graphics_Driver::not_clipped(int x, int y, int w, int h) {return 1;}
void Fl_Graphics_Driver::begin_complex_polygon() {}
/** see fl_transformed_vertex() */
-void Fl_Graphics_Driver::transformed_vertex(double xf, double yf) {}
+void Fl_Graphics_Driver::transformed_vertex(double xf, double yf) {
+ transformed_vertex0(float(xf), float(yf));
+}
/** see fl_vertex() */
-void Fl_Graphics_Driver::vertex(double x, double y) {}
+void Fl_Graphics_Driver::vertex(double x, double y) {
+ transformed_vertex(x*m.a + y*m.c + m.x, x*m.b + y*m.d + m.y);
+}
/** see fl_end_points() */
void Fl_Graphics_Driver::end_points() {}
@@ -633,6 +639,18 @@ float Fl_Graphics_Driver::override_scale() { return scale();}
void Fl_Graphics_Driver::restore_scale(float) { }
+void Fl_Graphics_Driver::transformed_vertex0(float x, float 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++;
+ }
+}
+
/**
\}
\endcond
@@ -980,8 +998,6 @@ void Fl_Scalable_Graphics_Driver::draw_image_mono_unscaled(const uchar* buf, int
void Fl_Scalable_Graphics_Driver::draw_image_mono_unscaled(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D) {}
-void Fl_Scalable_Graphics_Driver::transformed_vertex0(float x, float y) {}
-
float Fl_Scalable_Graphics_Driver::override_scale() {
float s = scale();
if (s != 1.f) {