Removed unused bitblt code. - sam - An updated version of the sam text editor.
 (HTM) git clone git://vernunftzentrum.de/sam.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit 88e512d6b6c80963bb5c123b7daaf48298fb86c7
 (DIR) parent 1cff9deb7a8839bff68b86fa5c5c4a21049bc849
 (HTM) Author: Rob King <jking@deadpixi.com>
       Date:   Tue,  6 Sep 2016 17:38:28 -0500
       
       Removed unused bitblt code.
       
       Diffstat:
         libXg/Makefile                      |      12 ++++++------
         libXg/arc.c                         |      45 -------------------------------
         libXg/bitbltclip.c                  |      68 -------------------------------
         libXg/circle.c                      |      23 -----------------------
         libXg/clipline.c                    |     225 -------------------------------
         libXg/copymasked.c                  |      49 -------------------------------
         libXg/ellipse.c                     |      23 -----------------------
         libXg/polysegment.c                 |      27 ---------------------------
         libXg/rdbitmapfile.c                |      65 -------------------------------
         libXg/segment.c                     |      25 -------------------------
         libXg/wrbitmapfile.c                |      50 -------------------------------
       
       11 files changed, 6 insertions(+), 606 deletions(-)
       ---
 (DIR) diff --git a/libXg/Makefile b/libXg/Makefile
       @@ -23,12 +23,12 @@ LIB=libXg.a
        CFLAGS=$(STANDARDS) $(INCS) $(INCLUDES)
        CC?=c99
        
       -OBJS=        arc.o arith.o balloc.o bitblt.o bitbltclip.o border.o bscreenrect.o\
       -        circle.o clipline.o clipr.o copymasked.o cursorset.o cursorswitch.o\
       -        disc.o ellipse.o font.o gcs.o getrect.o gwin.o ldconvert.o latin1.o\
       -        menuhit.o point.o polysegment.o rdbitmap.o rdbitmapfile.o\
       -        rectclip.o rune.o segment.o string.o strwidth.o texture.o\
       -        wrbitmap.o wrbitmapfile.o xtbinit.o
       +OBJS=          arith.o balloc.o bitblt.o   border.o bscreenrect.o\
       +          clipr.o   cursorset.o cursorswitch.o\
       +           font.o gcs.o getrect.o gwin.o ldconvert.o latin1.o\
       +        menuhit.o point.o   rdbitmap.o \
       +        rectclip.o rune.o  string.o strwidth.o texture.o\
       +        wrbitmap.o   xtbinit.o
        
        all install:        $(LIB)
        compile:        $(LIB)
 (DIR) diff --git a/libXg/arc.c b/libXg/arc.c
       @@ -1,45 +0,0 @@
       -/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
       -#include <u.h>
       -#include <libc.h>
       -#include <libg.h>
       -#include "libgint.h"
       -#include <math.h>
       -
       -#define rad2deg(x) 180*((x)/3.1415926535897932384626433832795028841971693993751)
       -
       -void
       -arc(Bitmap *b, Point p0, Point p1, Point p2, int v, Fcode f)
       -{
       -    unsigned int d;
       -    int x, y, r, start, end, delta;
       -    GC g;
       -
       -    p1.x -= p0.x;
       -    p1.y -= p0.y;
       -    p2.x -= p0.x;
       -    p2.y -= p0.y;
       -    r = (int)sqrt((double)(p1.x*p1.x + p1.y*p1.y));
       -    start = (int)(64*rad2deg(atan2(-p2.y, p2.x)));
       -    end = (int)(64*rad2deg(atan2(-p1.y, p1.x)));
       -    if(start < 0)
       -        start += 64*360;
       -    if(end < 0)
       -        end += 64*360;
       -    delta = end - start;
       -    if(delta < 0)
       -        delta += 64*360;
       -    x = p0.x - r;
       -    y = p0.y - r;
       -    if(b->flag&SHIFT){
       -        x -= b->r.min.x;
       -        y -= b->r.min.y;
       -    }
       -    d = 2*r;
       -    g = _getfillgc(f, b, v);
       -    /*
       -     * delta is positive, so this draws counterclockwise arc
       -     * from start to start+delta
       -     */
       -    XDrawArc(_dpy, (Drawable)b->id, g, x, y, d, d, start, delta);
       -}
       -
 (DIR) diff --git a/libXg/bitbltclip.c b/libXg/bitbltclip.c
       @@ -1,68 +0,0 @@
       -/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
       -#include <u.h>
       -#include <libc.h>
       -#include <libg.h>
       -#include "libgint.h"
       -
       -int
       -bitbltclip(void *vp)
       -{
       -    int dx, dy;
       -    int i;
       -    struct bbcarg{
       -        Bitmap *dm;
       -        Point p;
       -        Bitmap *sm;
       -        Rectangle r;
       -        Fcode f;
       -    }*bp;
       -
       -    bp = (struct bbcarg *)vp;
       -    dx = Dx(bp->r);
       -    dy = Dy(bp->r);
       -    if(bp->p.x < bp->dm->clipr.min.x){
       -        i = bp->dm->clipr.min.x-bp->p.x;
       -        bp->r.min.x += i;
       -        bp->p.x += i;
       -        dx -= i;
       -    }
       -    if(bp->p.y < bp->dm->clipr.min.y){
       -        i = bp->dm->clipr.min.y-bp->p.y;
       -        bp->r.min.y += i;
       -        bp->p.y += i;
       -        dy -= i;
       -    }
       -    if(bp->p.x+dx > bp->dm->clipr.max.x){
       -        i = bp->p.x+dx-bp->dm->clipr.max.x;
       -        bp->r.max.x -= i;
       -        dx -= i;
       -    }
       -    if(bp->p.y+dy > bp->dm->clipr.max.y){
       -        i = bp->p.y+dy-bp->dm->clipr.max.y;
       -        bp->r.max.y -= i;
       -        dy -= i;
       -    }
       -    if(bp->r.min.x < bp->sm->clipr.min.x){
       -        i = bp->sm->clipr.min.x-bp->r.min.x;
       -        bp->p.x += i;
       -        bp->r.min.x += i;
       -        dx -= i;
       -    }
       -    if(bp->r.min.y < bp->sm->clipr.min.y){
       -        i = bp->sm->clipr.min.y-bp->r.min.y;
       -        bp->p.y += i;
       -        bp->r.min.y += i;
       -        dy -= i;
       -    }
       -    if(bp->r.max.x > bp->sm->clipr.max.x){
       -        i = bp->r.max.x-bp->sm->clipr.max.x;
       -        bp->r.max.x -= i;
       -        dx -= i;
       -    }
       -    if(bp->r.max.y > bp->sm->clipr.max.y){
       -        i = bp->r.max.y-bp->sm->clipr.max.y;
       -        bp->r.max.y -= i;
       -        dy -= i;
       -    }
       -    return dx>0 && dy>0;
       -}
 (DIR) diff --git a/libXg/circle.c b/libXg/circle.c
       @@ -1,23 +0,0 @@
       -/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
       -#include <u.h>
       -#include <libc.h>
       -#include <libg.h>
       -#include "libgint.h"
       -
       -void
       -circle(Bitmap *b, Point p, int r, int v, Fcode f)
       -{
       -    unsigned int d;
       -    int x, y;
       -    GC g;
       -
       -    x = p.x - r;
       -    y = p.y - r;
       -    if (b->flag&SHIFT){
       -        x -= b->r.min.x;
       -        y -= b->r.min.y;
       -    }
       -    d = 2*r;
       -    g = _getfillgc(f, b, v);
       -    XDrawArc(_dpy, (Drawable)b->id, g, x, y, d, d, 0, 23040/* 360 deg */);
       -}
 (DIR) diff --git a/libXg/clipline.c b/libXg/clipline.c
       @@ -1,225 +0,0 @@
       -/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
       -#include <u.h>
       -#include <libc.h>
       -#include <libg.h>
       -#include "libgint.h"
       -
       -typedef struct Linedesc
       -{
       -    int x0;
       -    int y0;
       -    char    xmajor;
       -    char    slopeneg;
       -    long    dminor;
       -    long    dmajor;
       -} Linedesc;
       -
       -int  _clipline(Rectangle, Point*, Point*, Linedesc*);
       -
       -#define XYswap(p)   t=(p)->x, (p)->x=(p)->y, (p)->y=t
       -#define Swap(x, y)  t=x, x=y, y=t
       -
       -static long
       -lfloor(long x, long y)  /* first integer <= x/y */
       -{
       -    if(y <= 0){
       -        if(y == 0)
       -            return x;
       -        y = -y;
       -        x = -x;
       -    }
       -    if(x < 0){  /* be careful; C div. is undefined */
       -        x = -x;
       -        x += y-1;
       -        return -(x/y);
       -    }
       -    return x/y;
       -}
       -
       -static long
       -lceil(long x, long y)   /* first integer >= x/y */
       -{
       -    if(y <= 0){
       -        if(y == 0)
       -            return x;
       -        y = -y;
       -        x = -x;
       -    }
       -    if(x < 0){
       -        x = -x;
       -        return -(x/y);
       -    }
       -    x += y-1;
       -    return x/y;
       -}
       -
       -int
       -_gminor(long x, Linedesc *l)
       -{
       -    long y;
       -
       -    y = 2*(x-l->x0)*l->dminor + l->dmajor;
       -    y = lfloor(y, 2*l->dmajor) + l->y0;
       -    return l->slopeneg? -y : y;
       -}
       -
       -int
       -_gmajor(long y, Linedesc *l)
       -{
       -    long x;
       -
       -    x = 2*((l->slopeneg? -y : y)-l->y0)*l->dmajor - l->dminor;
       -    x = lceil(x, 2*l->dminor) + l->x0;
       -    if(l->dminor)
       -        while(_gminor(x-1, l) == y)
       -            x--;
       -    return x;
       -}
       -
       -void
       -gsetline(Point *pp0, Point *pp1, Linedesc *l)
       -{
       -    long dx, dy, t;
       -    Point endpt;
       -    int swapped;
       -    Point p0, p1;
       -
       -    swapped = 0;
       -    p0 = *pp0;
       -    p1 = *pp1;
       -    l->xmajor = 1;
       -    l->slopeneg = 0;
       -    dx = p1.x - p0.x;
       -    dy = p1.y - p0.y;
       -    if(abs(dy) > abs(dx)){  /* Steep */
       -        l->xmajor = 0;
       -        XYswap(&p0);
       -        XYswap(&p1);
       -        Swap(dx, dy);
       -    }
       -    if(dx < 0){
       -        swapped++;
       -        Swap(p0.x, p1.x);
       -        Swap(p0.y, p1.y);
       -        dx = -dx;
       -        dy = -dy;
       -    }
       -    if(dy < 0){
       -        l->slopeneg = 1;
       -        dy = -dy;
       -        p0.y = -p0.y;
       -    }
       -    l->dminor = dy;
       -    l->dmajor = dx;
       -    l->x0 = p0.x;
       -    l->y0 = p0.y;
       -    p1.x = swapped? p0.x+1 : p1.x-1;
       -    p1.y = _gminor(p1.x, l);
       -    if(l->xmajor == 0){
       -        XYswap(&p0);
       -        XYswap(&p1);
       -    }
       -    if(pp0->x > pp1->x){
       -        *pp1 = *pp0;
       -        *pp0 = p1;
       -    }else
       -        *pp1 = p1;
       -}
       -/*
       - * Modified clip-to-rectangle algorithm
       - *  works in bitmaps
       - *  Everything in SCREEN coordinates.
       - *
       - *  Newman & Sproull 124 (1st edition)
       - */
       -
       -static int
       -code(Point *p, Rectangle *r)
       -{
       -    return( (p->x<r->min.x? 1 : p->x>=r->max.x? 2 : 0) |
       -        (p->y<r->min.y? 4 : p->y>=r->max.y? 8 : 0));
       -}
       -
       -int
       -clipline(Rectangle r, Point *p0, Point *p1)
       -{
       -    Linedesc l;
       -
       -    return _clipline(r, p0, p1, &l);
       -}
       -
       -int
       -_clipline(Rectangle r, Point *p0, Point *p1, Linedesc *l)
       -{
       -    int c0, c1, n;
       -    long t, ret;
       -    Point temp;
       -    int swapped;
       -
       -    if(p0->x==p1->x && p0->y==p1->y)
       -        return 0;
       -    gsetline(p0, p1, l);
       -    /* line is now closed */
       -    if(l->xmajor == 0){
       -        XYswap(p0);
       -        XYswap(p1);
       -        XYswap(&r.min);
       -        XYswap(&r.max);
       -    }
       -    c0 = code(p0, &r);
       -    c1 = code(p1, &r);
       -    ret = 1;
       -    swapped = 0;
       -    n = 0;
       -    while(c0 | c1){
       -        if(c0 & c1){    /* no point of line in r */
       -            ret = 0;
       -            goto Return;
       -        }
       -        if(++n > 10){   /* horrible points; overflow etc. etc. */
       -            ret = 0;
       -            goto Return;
       -        }
       -        if(c0 == 0){    /* swap points */
       -            temp = *p0;
       -            *p0 = *p1;
       -            *p1 = temp;
       -            Swap(c0, c1);
       -            swapped ^= 1;
       -        }
       -        if(c0 == 0)
       -            break;
       -        if(c0 & 1){     /* push towards left edge */
       -            p0->x = r.min.x;
       -            p0->y = _gminor(p0->x, l);
       -        }else if(c0 & 2){   /* push towards right edge */
       -            p0->x = r.max.x-1;
       -            p0->y = _gminor(p0->x, l);
       -        }else if(c0 & 4){   /* push towards top edge */
       -            p0->y = r.min.y;
       -            if(l->slopeneg)
       -                p0->x = _gmajor(p0->y-1, l)-1;
       -            else
       -                p0->x = _gmajor(p0->y, l);
       -        }else if(c0 & 8){   /* push towards bottom edge */
       -            p0->y = r.max.y-1;
       -            if(l->slopeneg)
       -                p0->x = _gmajor(p0->y, l);
       -            else
       -                p0->x = _gmajor(p0->y+1, l)-1;
       -        }
       -        c0 = code(p0, &r);
       -    }
       -
       -    Return:
       -    if(l->xmajor == 0){
       -        XYswap(p0);
       -        XYswap(p1);
       -    }
       -    if(swapped){
       -        temp = *p0;
       -        *p0 = *p1;
       -        *p1 = temp;
       -    }
       -    return ret;
       -}
 (DIR) diff --git a/libXg/copymasked.c b/libXg/copymasked.c
       @@ -1,49 +0,0 @@
       -/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
       -#include <u.h>
       -#include <libc.h>
       -#include <libg.h>
       -#include "libgint.h"
       -
       -/*
       - * m should be a 1-bit-deep bitmap with origin (0,0) and the
       - * same extents as r.  s should have the same depth as d.
       - * Rectangle r of s is copied to d wherever corresponding
       - * bits of m are 1
       - */
       -void
       -copymasked(Bitmap *d, Point p, Bitmap *s, Bitmap *m, Rectangle r)
       -{
       -    int sx, sy, dx, dy;
       -    XGCValues gcv;
       -    GC g;
       -
       -    if(Dx(r)<=0 || Dy(r)<=0)
       -        return;
       -    sx = r.min.x;
       -    sy = r.min.y;
       -    if(s->flag&SHIFT){
       -        sx -= s->r.min.x;
       -        sy -= s->r.min.y;
       -    }
       -    dx = p.x;
       -    dy = p.y;
       -    if(d->flag&SHIFT){
       -        dx -= d->r.min.x;
       -        dy -= d->r.min.y;
       -    }
       -    gcv.fill_style = FillStippled;
       -    gcv.stipple = (Pixmap)m->id;
       -    gcv.function = GXclear;
       -    gcv.ts_x_origin = dx;
       -    gcv.ts_y_origin = dy;
       -    gcv.fill_style = FillStippled;
       -    g = _getgc(d, GCFunction|GCStipple|GCTileStipXOrigin
       -        |GCTileStipYOrigin|GCFillStyle, &gcv);
       -    XFillRectangle(_dpy, (Drawable)d->id, g,
       -            dx, dy, Dx(r), Dy(r));
       -    gcv.function = GXor;
       -    gcv.fill_style = FillSolid;
       -    g = _getgc(d, GCFunction|GCFillStyle, &gcv);
       -    XCopyArea(_dpy, (Drawable)s->id, (Drawable)d->id, g,
       -            sx, sy, Dx(r), Dy(r), dx, dy);
       -}
 (DIR) diff --git a/libXg/ellipse.c b/libXg/ellipse.c
       @@ -1,23 +0,0 @@
       -/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
       -#include <u.h>
       -#include <libc.h>
       -#include <libg.h>
       -#include "libgint.h"
       -
       -/* e(x,y) = b*b*x*x + a*a*y*y - a*a*b*b */
       -
       -void
       -ellipse(Bitmap *bp, Point p, int a, int b, int v, Fcode f)
       -{
       -    int x, y;
       -    GC g;
       -
       -    x = p.x - a;
       -    y = p.y - b;
       -    if (bp->flag&SHIFT){
       -        x -= bp->r.min.x;
       -        y -= bp->r.min.y;
       -    }
       -    g = _getfillgc(f, bp, v);
       -    XDrawArc(_dpy, (Drawable)bp->id, g, x, y, 2*a, 2*b, 0, 23040/* 360 deg */);
       -}
 (DIR) diff --git a/libXg/polysegment.c b/libXg/polysegment.c
       @@ -1,27 +0,0 @@
       -/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
       -#include <u.h>
       -#include <libc.h>
       -#include <libg.h>
       -#include "libgint.h"
       -
       -void
       -polysegment(Bitmap *d, int n, Point *pp, int v, Fcode f)
       -{
       -    XPoint *xp;
       -    int i;
       -    GC g;
       -
       -    if (!(xp = (XPoint *)calloc(n, sizeof(XPoint))))
       -        berror("polysegment: could not allocate XPoints");
       -    for (i = 0; i < n; i++, pp++)
       -        if(d->flag&SHIFT){
       -            xp[i].x = pp->x - d->r.min.x;
       -            xp[i].y = pp->y - d->r.min.y;
       -        } else {
       -            xp[i].x = pp->x;
       -            xp[i].y = pp->y;
       -        }
       -    g = _getfillgc(f, d, v);
       -    XDrawLines(_dpy, (Drawable)d->id, g, xp, n, CoordModeOrigin);
       -    free(xp);
       -}
 (DIR) diff --git a/libXg/rdbitmapfile.c b/libXg/rdbitmapfile.c
       @@ -1,65 +0,0 @@
       -/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
       -#include <u.h>
       -#include <libc.h>
       -#include <libg.h>
       -#include "libgint.h"
       -
       -#define CHUNK 6000
       -
       -Bitmap*
       -rdbitmapfile(int fd)
       -{
       -    char hdr[5*12+1];
       -    unsigned char *data;
       -    long dy, px;
       -    unsigned long l, t, n;
       -    long miny, maxy;
       -    Rectangle r;
       -    int ld;
       -    Bitmap *b;
       -
       -    if(read(fd, hdr, 5*12)!=5*12)
       -        berror("rdbitmapfile read");
       -    ld = atoi(hdr+0*12);
       -    r.min.x = atoi(hdr+1*12);
       -    r.min.y = atoi(hdr+2*12);
       -    r.max.x = atoi(hdr+3*12);
       -    r.max.y = atoi(hdr+4*12);
       -    if(ld<0 || ld>1)
       -        berror("rdbitmapfile ldepth");
       -    if(r.min.x>r.max.x || r.min.y>r.max.y)
       -        berror("rdbitmapfile rectangle");
       -
       -    miny = r.min.y;
       -    maxy = r.max.y;
       -    px = 1<<(3-ld); /* pixels per byte */
       -    /* set l to number of bytes of data per scan line */
       -    if(r.min.x >= 0)
       -        l = (r.max.x+px-1)/px - r.min.x/px;
       -    else{   /* make positive before divide */
       -        t = (-r.min.x)+px-1;
       -        t = (t/px)*px;
       -        l = (t+r.max.x+px-1)/px;
       -    }
       -    b = balloc(r, ld);
       -    if(b == 0)
       -        return 0;
       -    data = (unsigned char *)malloc(CHUNK);
       -    if(data == 0)
       -        berror("rdbitmapfile malloc");
       -    while(maxy > miny){
       -        dy = maxy - miny;
       -        if(dy*l > CHUNK)
       -            dy = CHUNK/l;
       -        n = dy*l;
       -        if(read(fd, data, n) != n){
       -            free(data);
       -            bfree(b);
       -            berror("rdbitmapfile read");
       -        }
       -        wrbitmap(b, miny, miny+dy, data);
       -        miny += dy;
       -    }
       -    free(data);
       -    return b;
       -}
 (DIR) diff --git a/libXg/segment.c b/libXg/segment.c
       @@ -1,25 +0,0 @@
       -/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
       -#include <u.h>
       -#include <libc.h>
       -#include <libg.h>
       -#include "libgint.h"
       -
       -void
       -segment(Bitmap *d, Point p1, Point p2, int v, Fcode f)
       -{
       -    int x1, y1, x2, y2;
       -    GC g;
       -
       -    x1 = p1.x;
       -    y1 = p1.y;
       -    x2 = p2.x;
       -    y2 = p2.y;
       -    if(d->flag&SHIFT){
       -        x1 -= d->r.min.x;
       -        y1 -= d->r.min.y;
       -        x2 -= d->r.min.x;
       -        y2 -= d->r.min.y;
       -    }
       -    g = _getfillgc(f, d, v);
       -    XDrawLine(_dpy, (Drawable)d->id, g, x1, y1, x2, y2);
       -}
 (DIR) diff --git a/libXg/wrbitmapfile.c b/libXg/wrbitmapfile.c
       @@ -1,50 +0,0 @@
       -/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
       -#include <u.h>
       -#include <libc.h>
       -#include <libg.h>
       -#include "libgint.h"
       -
       -#define CHUNK   4096
       -
       -void
       -wrbitmapfile(int fd, Bitmap *b)
       -{
       -    char hdr[5*12+1];
       -    unsigned char *data;
       -    long dy, px;
       -    unsigned long l, t, n;
       -    long miny, maxy;
       -
       -    sprint(hdr, "%11d %11d %11d %11d %11d ",
       -        b->ldepth, b->r.min.x, b->r.min.y, b->r.max.x, b->r.max.y);
       -    if(write(fd, hdr, 5*12) != 5*12)
       -        berror("wrbitmapfile write");
       -
       -    px = 1<<(3-b->ldepth);  /* pixels per byte */
       -    /* set l to number of bytes of data per scan line */
       -    if(b->r.min.x >= 0)
       -        l = (b->r.max.x+px-1)/px - b->r.min.x/px;
       -    else{   /* make positive before divide */
       -        t = (-b->r.min.x)+px-1;
       -        t = (t/px)*px;
       -        l = (t+b->r.max.x+px-1)/px;
       -    }
       -    miny = b->r.min.y;
       -    maxy = b->r.max.y;
       -    data = (unsigned char *)malloc(CHUNK);
       -    if(data == 0)
       -        berror("wrbitmapfile malloc");
       -    while(maxy > miny){
       -        dy = maxy - miny;
       -        if(dy*l > CHUNK)
       -            dy = CHUNK/l;
       -        rdbitmap(b, miny, miny+dy, data);
       -        n = dy*l;
       -        if(write(fd, data, n) != n){
       -            free(data);
       -            berror("wrbitmapfile write");
       -        }
       -        miny += dy;
       -    }
       -    free(data);
       -}