Le 14/12/2010 03:15, jhliu a écrit :
The 3rd and 4th 'line' commands seems to be drew in the memory and then be displayed at the next 'GrSetContext' and 'GrBitBltNC' commands. But the remaining problem is the 'GrBitBltNC' takes about 0.1~0.2 seconds on my Linux system, is there any other alternate method to speed-up this ?
You seem to have a speed problem on your (old ?) machine.
I have currently no direct access to a linux system, because I am out of lab. I have a (4 year old) laptop, centrino duo 2.2 Ghz, nVidia Quadro FX 1500M graphics card, with Windows XP. On it I have installed both a djgpp and a mingw32 system, and compliled grx on both. main gcc is 4.4.4 (djgpp) 4.5.0 (mingw) (grx 2.4.8 with all patches is compiled with it) gpc is 20070904 with 3.4.4 backend (djgpp) and 3.4.5 backend (mingw) I run the following gpc program, which is an adaptation of yours: pure grx instead of mixed graph and grx, time measurement, and a 1000x loop over the second GrBitBlt to have measurable times --------------------------------------------------------------------- program page2(input); {$X+} uses gpc,grx;
VAR scrgrc,bufgrc:GrContextPtr; t1,t2:UnixTimeType; ms1,ms2:CInteger; i:integer; msg: string(80); BEGIN GrSetDriver('win32 gw 640 gh 480 nc 256'); GrSetMode(GR_default_graphics,0,0,0,0,0);
scrgrc:=GrScreenContext; bufgrc:=GrCreateContext(GrMaxX,GrMaxY,NIL,NIL);
GrLine(GrMaxX,GrMaxY,0,0,GrWhite); GrLine(GrMaxX,0,0,GrMaxY,GrWhite); GrKeyRead;
{ copy whole screen context to bufgrc } GrBitBlt(bufgrc,0,0,NIL,0,0,GrMaxX,GrMaxY,GrWRITE);
{ clear screen } GrClearScreen(GrBlack); GrKeyRead;
{ set new drawings to bufgrc } GrSetContext(bufgrc); GrLine(0,GrMaxY DIV 2,GrMaxX,GrMaxY DIV 2,GrWhite); GrLine(GrMaxX DIV 2,0,GrMaxX DIV 2,GrMaxY,GrWhite);
{ copy bufgrc back to screen } GrSetContext(scrgrc); t1:=GetUnixTime(ms1); for i:=1 to 1000 do GrBitBlt(NIL,0,0,bufgrc,0,0,GrMaxX,GrMaxY,GrWRITE); t2:=GetUnixTime(ms2);
WriteStr(msg,(t2-t1)+(ms2-ms1)/1e6); GrTextXY(0, GrMaxY div 2,msg,grWhite,GrBlack); GrKeyRead;
END. ----------------------------------------------------------------------------- I compile without any optimisation (no -Ox) The only change is the driver name in GrSetDriver
The times are for _one_ GrBitBlt
Win32 0.106 milliseconds VESA 6 milliseconds STDVGA 15 milliseconds
Furthermore I can compile and run on a lab machine (64 bits) with linux (Fedora Core) through a VNC I get there XWIN 0.78 milliseconds
So your times are much too longer. For that reason I suppose you have a very slow machine/ graphics card.
The only remedy I can imagine is to use the two pages mechanism available with VESA, implemented ib graph/BGI. But I do not know how to access the VESA functions on a linuw system, and I have currently no access to such a system.
Maurice