[comp.windows.news] fast bitmaps

hjelm@G.GP.CS.CMU.EDU (Mark Hjelm) (10/14/87)

I am in the process of porting a window manager to run under NeWS that
relies heavily on ropping pixrects to the screen.  I am not satisfied at all
with the performance I'm getting.  Is there anything I can to better?
Does NeWS support Unix domain sockets in any way?  Here's my code:

Postscript:

cdef news_win_update(id,width,height,x,y)
	{	%% assumes everything is on a byte boundary
	    /win Windows id get def
	    win /Canvas get setcanvas
	    /str width 8 idiv string def
	    gsave
	    x y translate
	    width height scale
	    width height 1 [ width 0 0 height neg 0 height ]
	        { currentfile str readstring pop } image
	    grestore
	} exec	%% so it doesn't interfere with readstring


C:

void do_update(pr,width,height,x,y)

struct pixrect *pr;
int width, height, x, y;

{

    int d, i;
    struct mpr_data *mpr;
    char *data;

    d = x % 8;	/* align on byte boundary */
    x -= d;
    width += d;
    width = (width + 7) / 8 * 8;

    news_win_update(ID,width,height,x,WINDOW_HEIGHT-(y+height));

    mpr = (string mpr_data *) pr->pr_data;
    data = (char *) mpr->md_image;
    data += (y * mpr->md_linebytes) + (x / 8);
    for (i=0; i<height; i++) {
        fwrite(data,width/8,1,PostScript);
        data += mpr->md_linebytes;
    }

}


Thanks,
Mark


ARPA:   hjelm@g.gp.cs.cmu.edu
UUCP:   seismo!g.gp.cs.cmu.edu!hjelm
CSNET:  hjelm%pt.cs.cmu.edu@csnet-relay

don@BRILLIG.UMD.EDU (Don Hopkins) (10/16/87)

One thing you might experiment with is having your client write out a
pixrect file, then hand the server the file name, which it can read
with 'readcanvas', and then use 'imagecanvas', which is much faster
than 'image'. (This kind of stuff is one reason that NFS mounted file
systems should be set up so that file names are consistant from
machine to machine.) (Be warned that /tmp is usually an exception!)

I agree that there really should be a good way of sending a canvas
over the wire efficiently. i.e. you should be able to have a pixrect
as a cps function argument, which shows up in the server as a canvas,
akin to the way readcanvas works.

	-Don

singer@spar.SPAR.SLB.COM (David Singer) (10/21/87)

I've achieved better bitmap drawing/re-drawing by using buildimage and
then imagecanvas/imagemaskcanvas as appropriate, using the canvas as
a cache for the application bitmap.  Of course this is only useful if
you expect to display the same bitmap many times.  Also you may have
to cope with a bitmap editor (I do) and other events that should
invalidate your cache.  Finally you have to decide when to use
imagemask (typically when your source is 1-bit deep, and you want to
draw in the window's default colours), and when to use image (when your
source has true colours in it all by itself).  You should be aware that
1.0 has at least one and possibly several polarity bugs in imagemask and
imagemaskcanvas (i.e. pushing paint through the 1 bits instead of 0), and
for me this varied if the destination was mapped or not ...