FLTK logo

[master] b771ee5 - Remove duplicated code between derived classes of Fl_Graphics_Driver - cont'd.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] b771ee5 - Remove duplicated code between derived classes of Fl_Graphics_Driver - cont'd. "ManoloFLTK" Mar 01, 2021  
 
commit b771ee53b9e7c9a182764994ddd0852d91cc833f
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Mon Mar 1 15:47:23 2021 +0100
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Mon Mar 1 15:47:30 2021 +0100

    Remove duplicated code between derived classes of Fl_Graphics_Driver - cont'd.

 FL/Fl_Graphics_Driver.H                            |  1 +
 src/Fl_Graphics_Driver.cxx                         | 25 ++++++++++++++++---
 src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx  |  3 +--
 src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H     |  4 ---
 .../Quartz/Fl_Quartz_Graphics_Driver_vertex.cxx    | 25 -------------------
 src/drivers/SVG/Fl_SVG_File_Surface.cxx            | 29 ----------------------
 src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H         |  1 -
 .../Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx        |  5 ----
 8 files changed, 24 insertions(+), 69 deletions(-)

diff --git FL/Fl_Graphics_Driver.H FL/Fl_Graphics_Driver.H
index f3ed53d..845b416 100644
--- FL/Fl_Graphics_Driver.H
+++ FL/Fl_Graphics_Driver.H
@@ -311,6 +311,7 @@ public:
   virtual void end_points();
   virtual void end_line();
   virtual void end_loop();
+  virtual void fixloop();
   virtual void end_polygon();
   virtual void end_complex_polygon();
   virtual void gap();
diff --git src/Fl_Graphics_Driver.cxx src/Fl_Graphics_Driver.cxx
index be8849d..f1164c1 100644
--- src/Fl_Graphics_Driver.cxx
+++ src/Fl_Graphics_Driver.cxx
@@ -496,7 +496,10 @@ int Fl_Graphics_Driver::clip_box(int x, int y, int w, int h, int &X, int &Y, int
 int Fl_Graphics_Driver::not_clipped(int x, int y, int w, int h) {return 1;}
 
 /** see fl_begin_complex_polygon() */
-void Fl_Graphics_Driver::begin_complex_polygon() {}
+void Fl_Graphics_Driver::begin_complex_polygon() {
+  begin_polygon();
+  gap_ = 0;
+}
 
 /** see fl_transformed_vertex() */
 void Fl_Graphics_Driver::transformed_vertex(double xf, double yf) {
@@ -514,8 +517,16 @@ void Fl_Graphics_Driver::end_points() {}
 /** see fl_end_line() */
 void Fl_Graphics_Driver::end_line() {}
 
+void Fl_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--;
+}
+
 /** see fl_end_loop() */
-void Fl_Graphics_Driver::end_loop() {}
+void Fl_Graphics_Driver::end_loop() {
+  fixloop();
+  if (n>2) transformed_vertex((float)p[0].x, (float)p[0].y);
+  end_line();
+}
 
 /** see fl_end_polygon() */
 void Fl_Graphics_Driver::end_polygon() {}
@@ -524,7 +535,15 @@ void Fl_Graphics_Driver::end_polygon() {}
 void Fl_Graphics_Driver::end_complex_polygon() {}
 
 /** see fl_gap() */
-void Fl_Graphics_Driver::gap() {}
+void Fl_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((float)p[gap_].x, (float)p[gap_].y);
+    gap_ = n;
+  } else {
+    n = gap_;
+  }
+}
 
 /** see fl_circle() */
 void Fl_Graphics_Driver::circle(double x, double y, double r) {}
diff --git src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx
index 87e694f..2f8e802 100644
--- src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx
+++ src/drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx
@@ -59,8 +59,7 @@ void Fl_GDI_Graphics_Driver::end_polygon() {
 }
 
 void Fl_GDI_Graphics_Driver::begin_complex_polygon() {
-  begin_polygon();
-  gap_ = 0;
+  Fl_Graphics_Driver::begin_complex_polygon();
   numcount = 0;
 }
 
diff --git src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H
index 388fefd..4f86823 100644
--- src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H
+++ src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H
@@ -87,7 +87,6 @@ public:
   void XDestroyRegion(Fl_Region r);
   void high_resolution(bool b) { high_resolution_ = b; }
 protected:
-  void fixloop();
   void point(int x, int y);
   void rect(int x, int y, int w, int h);
   void focus_rect(int x, int y, int w, int h);
@@ -109,13 +108,10 @@ protected:
   int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
   int not_clipped(int x, int y, int w, int h);
   void restore_clip();
-  void begin_complex_polygon();
   void end_points();
   void end_line();
-  void end_loop();
   void end_polygon();
   void end_complex_polygon();
-  void gap();
   void circle(double x, double y, double r);
   void arc(int x, int y, int w, int h, double a1, double a2);
   void pie(int x, int y, int w, int h, double a1, double a2);
diff --git src/drivers/Quartz/Fl_Quartz_Graphics_Driver_vertex.cxx src/drivers/Quartz/Fl_Quartz_Graphics_Driver_vertex.cxx
index 952c65b..56f7e7a 100644
--- src/drivers/Quartz/Fl_Quartz_Graphics_Driver_vertex.cxx
+++ src/drivers/Quartz/Fl_Quartz_Graphics_Driver_vertex.cxx
@@ -51,12 +51,6 @@ void Fl_Quartz_Graphics_Driver::end_line() {
   CGContextSetShouldAntialias(gc_, false);
 }
 
-void Fl_Quartz_Graphics_Driver::end_loop() {
-  fixloop();
-  if (n>2) transformed_vertex((float)p[0].x, (float)p[0].y);
-  end_line();
-}
-
 void Fl_Quartz_Graphics_Driver::end_polygon() {
   fixloop();
   if (n < 3) {
@@ -73,21 +67,6 @@ void Fl_Quartz_Graphics_Driver::end_polygon() {
   CGContextSetShouldAntialias(gc_, false);
 }
 
-void Fl_Quartz_Graphics_Driver::begin_complex_polygon() {
-  begin_polygon();
-  gap_ = 0;
-}
-
-void Fl_Quartz_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((float)p[gap_].x, (float)p[gap_].y);
-    gap_ = n;
-  } else {
-    n = gap_;
-  }
-}
-
 void Fl_Quartz_Graphics_Driver::end_complex_polygon() {
   gap();
   if (n < 3) {
@@ -121,7 +100,3 @@ void Fl_Quartz_Graphics_Driver::circle(double x, double y,double r) {
   (what == POLYGON ? CGContextFillPath : CGContextStrokePath)(gc_);
   CGContextSetShouldAntialias(gc_, false);
 }
-
-void Fl_Quartz_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--;
-}
diff --git src/drivers/SVG/Fl_SVG_File_Surface.cxx src/drivers/SVG/Fl_SVG_File_Surface.cxx
index 2ca5437..08727c8 100644
--- src/drivers/SVG/Fl_SVG_File_Surface.cxx
+++ src/drivers/SVG/Fl_SVG_File_Surface.cxx
@@ -112,11 +112,7 @@ protected:
   void point(int x, int y);
   void end_points();
   void end_line();
-  void fixloop();
-  void end_loop();
   void end_polygon();
-  void begin_complex_polygon();
-  void gap();
   void end_complex_polygon();
   void circle(double x, double y,double r);
   void arc(int x,int y,int w,int h,double a1,double a2);
@@ -876,16 +872,6 @@ void Fl_SVG_Graphics_Driver::end_line() {
           red_, green_, blue_, width_, dasharray_, linecap_, linejoin_);
 }
 
-void Fl_SVG_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--;
-}
-
-void Fl_SVG_Graphics_Driver::end_loop() {
-  fixloop();
-  if (n>2) transformed_vertex((float)p[0].x, (float)p[0].y);
-  end_line();
-}
-
 void Fl_SVG_Graphics_Driver::end_polygon() {
   fixloop();
   if (n < 3) {
@@ -916,21 +902,6 @@ void Fl_SVG_Graphics_Driver::circle(double x, double y, double r) {
   fprintf(out_, "=\"rgb(%u,%u,%u)\" />\n", red_, green_, blue_);
 }
 
-void Fl_SVG_Graphics_Driver::begin_complex_polygon() {
-  begin_polygon();
-  gap_ = 0;
-}
-
-void Fl_SVG_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((float)p[gap_].x, (float)p[gap_].y);
-    gap_ = n;
-  } else {
-    n = gap_;
-  }
-}
-
 void Fl_SVG_Graphics_Driver::end_complex_polygon() {
   gap();
   if (n < 3) {
diff --git src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
index d3222b2..7f86680 100644
--- src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
+++ src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
@@ -187,7 +187,6 @@ protected:
   int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
   int not_clipped(int x, int y, int w, int h);
   void restore_clip();
-  void begin_complex_polygon();
   void end_points();
   void end_line();
   void end_loop();
diff --git src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx
index f94b685..2f1608d 100644
--- src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx
+++ src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx
@@ -57,11 +57,6 @@ void Fl_Xlib_Graphics_Driver::end_polygon() {
   if (n>2) XFillPolygon(fl_display, fl_window, gc_, (XPoint*)p, n, Convex, 0);
 }
 
-void Fl_Xlib_Graphics_Driver::begin_complex_polygon() {
-  begin_polygon();
-  gap_ = 0;
-}
-
 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) {
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.