X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbcwindowdraw.C;h=73b3d03437a04e03a2a9737d139901b5451d7ec7;hb=5616fa8528aa382cef440a88ffd0d87ed3bbfda2;hp=eb35b63e7ca34e2cf0fed664a641e2926d24b187;hpb=9e3d90a964c0fbe97c0b58235336a47111932d5d;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/guicast/bcwindowdraw.C b/cinelerra-5.1/guicast/bcwindowdraw.C index eb35b63e..73b3d034 100644 --- a/cinelerra-5.1/guicast/bcwindowdraw.C +++ b/cinelerra-5.1/guicast/bcwindowdraw.C @@ -388,11 +388,18 @@ void BC_WindowBase::draw_center_text(int x, int y, const char *text, int length) draw_text(x, y, text, length); } +void BC_WindowBase::draw_pix(int x, int y, BC_Pixmap *pixmap) +{ // draw_pixel, no BT test + XDrawPoint(top_level->display, + pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, + top_level->gc, x, y); +} + void BC_WindowBase::draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap) { BT // Some X drivers can't draw 0 length lines if( x1 == x2 && y1 == y2 ) { - draw_pixel(x1, y1, pixmap); + draw_pix(x1, y1, pixmap); } else { XDrawLine(top_level->display, @@ -401,6 +408,43 @@ void BC_WindowBase::draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap) } } +void BC_WindowBase::draw_bline(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap) +{ BT +// Short lines are all overhead to hw or sw setup, use bresenhams + if( y1 > y2 ) { + int tx = x1; x1 = x2; x2 = tx; + int ty = y1; y1 = y2; y2 = ty; + } + + int x = x1, y = y1; + int dx = x2-x1, dy = y2-y1; + int dx2 = 2*dx, dy2 = 2*dy; + if( dx < 0 ) dx = -dx; + int r = dx > dy ? dx : dy, n = r; + int dir = 0; + if( dx2 < 0 ) dir += 1; + if( dy >= dx ) { + if( dx2 >= 0 ) do { /* +Y, +X */ + draw_pix(x, y++, pixmap); + if( (r -= dx2) < 0 ) { r += dy2; ++x; } + } while( --n >= 0 ); + else do { /* +Y, -X */ + draw_pix(x, y++, pixmap); + if( (r += dx2) < 0 ) { r += dy2; --x; } + } while( --n >= 0 ); + } + else { + if( dx2 >= 0 ) do { /* +X, +Y */ + draw_pix(x++, y, pixmap); + if( (r -= dy2) < 0 ) { r += dx2; ++y; } + } while( --n >= 0 ); + else do { /* -X, +Y */ + draw_pix(x--, y, pixmap); + if( (r -= dy2) < 0 ) { r -= dx2; ++y; } + } while( --n >= 0 ); + } +} + void BC_WindowBase::draw_polygon(ArrayList *x, ArrayList *y, BC_Pixmap *pixmap) { BT int npoints = MIN(x->total, y->total);