summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Graphics_Driver.cxx46
-rw-r--r--src/drivers/GDI/Fl_GDI_Graphics_Driver.H4
-rw-r--r--src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx38
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H4
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx74
5 files changed, 49 insertions, 117 deletions
diff --git a/src/Fl_Graphics_Driver.cxx b/src/Fl_Graphics_Driver.cxx
index d246ea149..eb3c48c27 100644
--- a/src/Fl_Graphics_Driver.cxx
+++ b/src/Fl_Graphics_Driver.cxx
@@ -220,7 +220,14 @@ Fl_Scalable_Graphics_Driver::Fl_Scalable_Graphics_Driver() : Fl_Graphics_Driver(
void Fl_Scalable_Graphics_Driver::rect(int x, int y, int w, int h)
{
- rect_unscaled(x * scale_, y * scale_, w * scale_, h * scale_);
+ if (int(scale_) == scale_) {
+ rect_unscaled(x * scale_, y * scale_, w * scale_, h * scale_);
+ } else {
+ xyline(x, y, x+w-1);
+ yxline(x, y, y+h-1);
+ yxline(x+w-1, y, y+h-1);
+ xyline(x, y+h-1, x+w-1);
+ }
}
void Fl_Scalable_Graphics_Driver::rectf(int x, int y, int w, int h)
@@ -233,31 +240,46 @@ void Fl_Scalable_Graphics_Driver::point(int x, int y) {
}
void Fl_Scalable_Graphics_Driver::line(int x, int y, int x1, int y1) {
- line_unscaled( x*scale_, y*scale_, x1*scale_, y1*scale_);
+ if (y == y1) xyline(x, y, x1);
+ else if (x == x1) yxline(x, y, y1);
+ else line_unscaled( x*scale_, y*scale_, x1*scale_, y1*scale_);
}
void Fl_Scalable_Graphics_Driver::line(int x, int y, int x1, int y1, int x2, int y2) {
- line_unscaled( x*scale_, y*scale_, x1*scale_, y1*scale_, x2*scale_, y2*scale_);
+ if ( (y == y1 || x == x1) && (y2 == y1 || x2 == x1) ) { // only horizontal or vertical lines
+ line(x, y, x1, y1);
+ line(x1, y1, x2, y2);
+ } else line_unscaled( x*scale_, y*scale_, x1*scale_, y1*scale_, x2*scale_, y2*scale_);
}
void Fl_Scalable_Graphics_Driver::xyline(int x, int y, int x1) {
xyline_unscaled(x*scale_, y*scale_, x1*scale_);
}
+
void Fl_Scalable_Graphics_Driver::xyline(int x, int y, int x1, int y2) {
- xyline_unscaled(x*scale_, y*scale_, x1*scale_, y2*scale_);
+ xyline(x, y, x1);
+ yxline(x1, y, y2);
}
+
void Fl_Scalable_Graphics_Driver::xyline(int x, int y, int x1, int y2, int x3) {
- xyline_unscaled(x*scale_, y*scale_, x1*scale_, y2*scale_, x3*scale_);
+ xyline(x, y, x1);
+ yxline(x1, y, y2);
+ xyline(x1, y2, x3);
}
void Fl_Scalable_Graphics_Driver::yxline(int x, int y, int y1) {
yxline_unscaled(x*scale_, y*scale_, y1*scale_);
}
+
void Fl_Scalable_Graphics_Driver::yxline(int x, int y, int y1, int x2) {
- yxline_unscaled(x*scale_, y*scale_, y1*scale_, x2*scale_);
+ yxline(x, y, y1);
+ xyline(x, y1, x2);
}
+
void Fl_Scalable_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3) {
- yxline_unscaled(x*scale_, y*scale_, y1*scale_, x2*scale_, y3*scale_);
+ yxline(x, y, y1);
+ xyline(x, y1, x2);
+ yxline(x2, y1, y3);
}
void Fl_Scalable_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, int y2) {
@@ -265,7 +287,15 @@ void Fl_Scalable_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, i
}
void Fl_Scalable_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
- loop_unscaled(x0*scale_, y0*scale_, x1*scale_, y1*scale_, x2*scale_, y2*scale_, x3*scale_, y3*scale_);
+ if ( (x0==x1 || y0==y1) && (x2==x1 || y2==y1) && (x2==x3 || y2==y3) && (x0==x3 || y0==y3) ) {
+ // only horizontal and vertical lines
+ line(x0, y0, x1, y1);
+ line(x1, y1, x2, y2);
+ line(x2, y2, x3, y3);
+ line(x3, y3, x0, y0);
+ } else {
+ loop_unscaled(x0*scale_, y0*scale_, x1*scale_, y1*scale_, x2*scale_, y2*scale_, x3*scale_, y3*scale_);
+ }
}
void Fl_Scalable_Graphics_Driver::polygon(int x0, int y0, int x1, int y1, int x2, int y2) {
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H
index 30ff4aa32..fea0ccac4 100644
--- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H
+++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H
@@ -104,11 +104,7 @@ protected:
virtual void line_unscaled(float x, float y, float x1, float y1);
virtual void line_unscaled(float x, float y, float x1, float y1, float x2, float y2);
virtual void xyline_unscaled(float x, float y, float x1);
- virtual void xyline_unscaled(float x, float y, float x1, float y2);
- virtual void xyline_unscaled(float x, float y, float x1, float y2, float x3);
virtual void yxline_unscaled(float x, float y, float y1);
- virtual void yxline_unscaled(float x, float y, float y1, float x2);
- virtual void yxline_unscaled(float x, float y, float y1, float x2, float y3);
virtual void loop_unscaled(float x0, float y0, float x1, float y1, float x2, float y2);
virtual void loop_unscaled(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3);
virtual void polygon_unscaled(float x0, float y0, float x1, float y1, float x2, float y2);
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx
index c414393f9..435364160 100644
--- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx
+++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx
@@ -104,25 +104,6 @@ void Fl_GDI_Graphics_Driver::xyline_unscaled(float x, float y, float x1) {
//fprintf(LOG,"xyline_unscaled tw=%d s=%f gc_=%p\n",tw,scale_,gc_);fflush(LOG);
}
-void Fl_GDI_Graphics_Driver::xyline_unscaled(float x, float y, float x1, float y2) {
- /*if (y2 < y) y2--;
- else y2++;
- MoveToEx(gc_, x, y, 0L);
- LineTo(gc_, x1, y);
- LineTo(gc_, x1, y2);*/
- xyline_unscaled(x, y, x1);
- yxline_unscaled(x1, y, y2);
-}
-
-void Fl_GDI_Graphics_Driver::xyline_unscaled(float x, float y, float x1, float y2, float x3) {
- if(x3 < x1) x3--;
- else x3++;
- MoveToEx(gc_, x, y, 0L);
- LineTo(gc_, x1, y);
- LineTo(gc_, x1, y2);
- LineTo(gc_, x3, y2);
-}
-
void Fl_GDI_Graphics_Driver::yxline_unscaled(float x, float y, float y1) {
if (y1 < y) { float exch = y; y = y1; y1 = exch;}
int line_delta_ = (scale_ > 1.75 ? 1 : 0);
@@ -140,25 +121,6 @@ void Fl_GDI_Graphics_Driver::yxline_unscaled(float x, float y, float y1) {
}
-void Fl_GDI_Graphics_Driver::yxline_unscaled(float x, float y, float y1, float x2) {
- /*if (x2 > x) x2++;
- else x2--;
- MoveToEx(gc_, x, y, 0L);
- LineTo(gc_, x, y1);
- LineTo(gc_, x2, y1);*/
- yxline_unscaled(x, y, y1);
- xyline_unscaled(x, y1, x2);
-}
-
-void Fl_GDI_Graphics_Driver::yxline_unscaled(float x, float y, float y1, float x2, float y3) {
- if(y3<y1) y3--;
- else y3++;
- MoveToEx(gc_, x, y, 0L);
- LineTo(gc_, x, y1);
- LineTo(gc_, x2, y1);
- LineTo(gc_, x2, y3);
-}
-
void Fl_GDI_Graphics_Driver::loop_unscaled(float x, float y, float x1, float y1, float x2, float y2) {
MoveToEx(gc_, x, y, 0L);
LineTo(gc_, x1, y1);
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
index c274edc8b..1648d7c57 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
@@ -145,11 +145,7 @@ protected:
virtual void line_unscaled(float x, float y, float x1, float y1);
virtual void line_unscaled(float x, float y, float x1, float y1, float x2, float y2);
virtual void xyline_unscaled(float x, float y, float x1);
- virtual void xyline_unscaled(float x, float y, float x1, float y2);
- virtual void xyline_unscaled(float x, float y, float x1, float y2, float x3);
virtual void yxline_unscaled(float x, float y, float y1);
- virtual void yxline_unscaled(float x, float y, float y1, float x2);
- virtual void yxline_unscaled(float x, float y, float y1, float x2, float y3);
virtual void loop_unscaled(float x0, float y0, float x1, float y1, float x2, float y2);
virtual void loop_unscaled(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3);
virtual void polygon_unscaled(float x0, float y0, float x1, float y1, float x2, float y2);
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx
index 89da64a60..6d0f60f38 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx
@@ -158,14 +158,14 @@ void Fl_Xlib_Graphics_Driver::XDestroyRegion(Fl_Region r) {
// --- line and polygon drawing
-
+// called only when scale_ has integer value
void Fl_Xlib_Graphics_Driver::rect_unscaled(float fx, float fy, float fw, float fh) {
if (fw<=0 || fh<=0) return;
int deltaf = scale_ >= 2 ? scale_-1 : 0;
fx += offset_x_*scale_; fy += offset_y_*scale_;
int x = fx; int y = fy;
- int w = int(int(fx/scale_+fw/scale_+0.5)*scale_) - x - 1 - deltaf;
- int h = int(int(fy/scale_+fh/scale_+0.5)*scale_) - y - 1 - deltaf;
+ int w = int(fw) - 1 - deltaf;
+ int h = int(fh) - 1 - deltaf;
if (!clip_to_short(x, y, w, h, line_width_))
XDrawRectangle(fl_display, fl_window, gc_, x+line_delta_, y+line_delta_, w, h);
}
@@ -203,86 +203,34 @@ void Fl_Xlib_Graphics_Driver::line_unscaled(float x, float y, float x1, float y1
XDrawLines(fl_display, fl_window, gc_, p, 3, 0);
}
-void Fl_Xlib_Graphics_Driver::xyline_unscaled(float x, float y, float x1) {//OK
+void Fl_Xlib_Graphics_Driver::xyline_unscaled(float x, float y, float x1) {
x+=offset_x_*scale_; y+=offset_y_*scale_; x1 += offset_x_*scale_;
int tw = line_width_ ? line_width_ : 1; // true line width
if (x > x1) { float exch = x; x = x1; x1 = exch; }
int ix = clip_x(x+line_delta_); if (scale_ >= 2) ix -= int(scale_/2);
int iy = clip_x(y+line_delta_);
- int ix1 = int(x1/scale_+1.5)*scale_-1; // extend line to pixel before line beginning at x1/scale_ + 1
+ // make sure that line output by xyline(a,b,c) extends to pixel just at left of where xyline(c+1,b,d) begins
+ int ix1 = int(x1/scale_+1.5)*scale_-1;
ix1 += line_delta_; if (scale_ >= 4) ix1 -= 1;
XDrawLine(fl_display, fl_window, gc_, ix, iy, ix1, iy);
- // try and make sure no unfilled area lies between xyline(x,y,x1) and xyline(x,y+1,x1)
+ // make sure no unfilled area lies between xyline(x,y,x1) and xyline(x,y+1,x1)
if (y+line_delta_ + scale_ >= iy + tw+1 - 0.001 ) XDrawLine(fl_display, fl_window, gc_, ix, iy+1, ix1, iy+1);
}
-void Fl_Xlib_Graphics_Driver::xyline_unscaled(float x, float y, float x1, float y2) {//OK
- x+=offset_x_*scale_; y+=offset_y_*scale_; x1 += offset_x_*scale_; y2+=offset_y_*scale_;
- if (scale_ >= 2) {
- int delta = int(scale_/2 + 0.5);
- if (x > x1) x += delta; else x -= delta;
- if (y2 > y) y2 += delta; else y2 -= delta;
- }
- XPoint p[3];
- p[0].x = clip_x(x+line_delta_); p[0].y = p[1].y = clip_x(y+line_delta_);
- p[1].x = p[2].x = clip_x(x1+line_delta_); p[2].y = clip_x(y2+line_delta_);
- XDrawLines(fl_display, fl_window, gc_, p, 3, 0);
-}
-
-void Fl_Xlib_Graphics_Driver::xyline_unscaled(float x, float y, float x1, float y2, float x3) {
- x+=offset_x_*scale_; y+=offset_y_*scale_; x1 += offset_x_*scale_; y2+=offset_y_*scale_; x3 += offset_x_*scale_;
- if (scale_ >= 2) {
- int delta = int(scale_/2 + 0.5);
- if (x > x1) x += delta; else x -= delta;
- if (x3 > x1) x3 += delta; else x3 -= delta;
- }
- XPoint p[4];
- p[0].x = clip_x(x+line_delta_); p[0].y = p[1].y = clip_x(y+line_delta_);
- p[1].x = p[2].x = clip_x(x1+line_delta_); p[2].y = p[3].y = clip_x(y2+line_delta_);
- p[3].x = clip_x(x3+line_delta_);
- XDrawLines(fl_display, fl_window, gc_, p, 4, 0);
-}
-
-void Fl_Xlib_Graphics_Driver::yxline_unscaled(float x, float y, float y1) {//OK
+void Fl_Xlib_Graphics_Driver::yxline_unscaled(float x, float y, float y1) {
x+=offset_x_*scale_; y+=offset_y_*scale_; y1 += offset_y_*scale_;
int tw = line_width_ ? line_width_ : 1; // true line width
if (y > y1) { float exch = y; y = y1; y1 = exch; }
int ix = clip_x(x+line_delta_);
int iy = clip_x(y+line_delta_); if (scale_ >= 2) iy -= int(scale_/2);
int iy1 = int(y1/scale_+1.5)*scale_-1;
- iy1 += line_delta_; if (scale_ >= 4) iy1 -= 1; // extend line to pixel before line beginning at y1/scale_ + 1
+ // make sure that line output by yxline(a,b,c) extends to pixel just above where yxline(a,c+1,d) begins
+ iy1 += line_delta_; if (scale_ >= 4) iy1 -= 1;
XDrawLine(fl_display, fl_window, gc_, ix, iy, ix, iy1);
- // try and make sure no unfilled area lies between yxline(x,y,y1) and yxline(x+1,y,y1)
+ // make sure no unfilled area lies between yxline(x,y,y1) and yxline(x+1,y,y1)
if (x+line_delta_+scale_ >= ix + tw+1 -0.001) XDrawLine(fl_display, fl_window, gc_, ix+1, iy, ix+1, iy1);
}
-void Fl_Xlib_Graphics_Driver::yxline_unscaled(float x, float y, float y1, float x2) {
- x+=offset_x_*scale_; y+=offset_y_*scale_; y1 += offset_y_*scale_; x2+=offset_x_*scale_;
- if (scale_ >= 2) {
- int delta = int(scale_/2 + 0.5);
- if (y > y1) y += delta; else y -= delta;
- if (x2 > x) x2 += delta; else x2 -= delta;
- }
- XPoint p[3];
- p[0].x = p[1].x = clip_x(x+line_delta_); p[0].y = clip_x(y+line_delta_);
- p[1].y = p[2].y = clip_x(y1+line_delta_); p[2].x = clip_x(x2+line_delta_);
- XDrawLines(fl_display, fl_window, gc_, p, 3, 0);
-}
-
-void Fl_Xlib_Graphics_Driver::yxline_unscaled(float x, float y, float y1, float x2, float y3) {
- x+=offset_x_*scale_; y+=offset_y_*scale_; y1 += offset_y_*scale_; x2+=offset_x_*scale_; y3 += offset_y_*scale_;
- if (scale_ >= 2) {
- int delta = int(scale_/2 + 0.5);
- if (y > y1) y += delta; else y -= delta;
- if (y3 > y1) y3 += delta; else y3 -= delta;
- }
- XPoint p[4];
- p[0].x = p[1].x = clip_x(x+line_delta_); p[0].y = clip_x(y+line_delta_);
- p[1].y = p[2].y = clip_x(y1+line_delta_); p[2].x = p[3].x = clip_x(x2+line_delta_);
- p[3].y = clip_x(y3+line_delta_);
- XDrawLines(fl_display, fl_window, gc_, p, 4, 0);
-}
-
void Fl_Xlib_Graphics_Driver::loop_unscaled(float x, float y, float x1, float y1, float x2, float y2) {
XPoint p[4];
p[0].x = x +offset_x_*scale_+line_delta_; p[0].y = y +offset_y_*scale_+line_delta_;