| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Why is this so slow? |
SO> If I got it right, I may use WinBeginPaint() ... WinEndPaint()
SO> without having to wait for the receipt of a WM_PAINT message.
Ok, I found out, that I have to use WinGetPS() and WinReleasePS().
But this still does not work unless I surround the painting code
by calls to WinEnableWindowUpdate(). And worse, the following
routine takes about 4 seconds (!!!):
void TVioWindow :: ScrollUp ( int leftCol,
int topRow,
int rightCol,
int bottomRow,
int count,
int attr )
{
int row,
lastRow,
chCount,
dstPos,
srcPos;
HPS hps;
WinEnableWindowUpdate ( hWindow, FALSE );
if ( bottomRow >= maxRows )
bottomRow = maxRows - 1;
if ( rightCol >= maxCols )
rightCol = maxCols - 1;
dstPos = maxCols * topRow + leftCol; // destination offset
srcPos = dstPos + maxCols * count; // source offset
chCount = rightCol - leftCol + 1; // characters per line
lastRow = bottomRow + 1 - count;
for ( row = topRow; row <= lastRow; row++, count-- )
{
memcpy ( textBuf + dstPos, textBuf + srcPos, chCount );
memcpy ( attrBuf + dstPos, attrBuf + srcPos, chCount );
srcPos += maxCols;
dstPos += maxCols;
}
while ( row < bottomRow )
{
memset ( textBuf + dstPos, ' ', chCount );
memset ( attrBuf + dstPos, attr, chCount );
dstPos += maxCols;
row++;
}
hps = WinGetPS ( hWindow );
if ( NULLHANDLE != hps )
{
RECTL srcRect,
dstRect;
srcRect.xLeft = leftCol * charWidth;
srcRect.yTop = clientHeight - (topRow + count) * charHeight;
srcRect.xRight = (rightCol + 1) * charWidth - 1;
srcRect.yBottom = clientHeight - (bottomRow + 1) * charHeight;
dstRect.xLeft = srcRect.xLeft;
dstRect.yTop = clientHeight - topRow * charHeight;
dstRect.xRight = srcRect.xRight;
dstRect.yBottom = clientHeight - (bottomRow - count + 1) * charHeight;
#if 0
WinCopyRect ( hab, &dstRect, &srcRect );
// ---------------------------------------------------
// Fill the remainder with the desired color attribute
// ---------------------------------------------------
dstRect.yTop = dstRect.yBottom - 1;
dstRect.yBottom = srcRect.yBottom;
WinFillRect ( hps, &dstRect, BGColorFromAttr (attr) );
#else
POINTL ptlArray [3];
ptlArray [0].x = dstRect.xLeft;
ptlArray [0].y = dstRect.yBottom;
ptlArray [1].x = dstRect.xRight;
ptlArray [1].y = dstRect.yTop;
ptlArray [2].x = srcRect.xLeft;
ptlArray [2].y = srcRect.yBottom;
GpiBitBlt ( hpsMemory, // destination
hpsMemory, // source
3L, // # of items in ptlArray
ptlArray, // array of points
ROP_SRCCOPY, // copy mode
BBO_IGNORE );
// ---------------------------------------------------
// Fill the remainder with the desired color attribute
// ---------------------------------------------------
ptlArray [0].y = srcRect.yBottom;
ptlArray [1].y = dstRect.yTop;
ptlArray [2].y = srcRect.yBottom;
dstRect.yTop = dstRect.yBottom - 1;
dstRect.yBottom = srcRect.yBottom;
GpiMove ( hpsMemory, (PPOINTL) &dstRect );
GpiSetColor ( hpsMemory, BGColorFromAttr (attr) );
GpiBox ( hpsMemory, DRO_FILL, (PPOINTL) &dstRect.xRight, 0L, 0L );
// ---------------------------------------------------
// Copy result to the window's presentation space
// ---------------------------------------------------
GpiBitBlt ( hps, // destination
hpsMemory, // source
3L, // # of items in ptlArray
ptlArray, // array of points
ROP_SRCCOPY, // copy mode
BBO_IGNORE );
#endif
WinReleasePS ( hps );
}
WinEnableWindowUpdate ( hWindow, TRUE );
}
Changing "#if 0" to "#if 1" makes the code neither faster nor
slower. How can it be that a simple bit block transfer (in a
maximized window) is so terribly slow? There _must_ be a way
to do it (much) faster. Lots of editor and terminal programs
available for OS/2 PM prove this, and I doubt that they all
use Vio...() calls.
Tschuess, Steffen
--- FastEcho 1.45+
* Origin: Sprach's und verschwand von der Bildflaeche (2:2433/1860)SEEN-BY: 270/101 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407 SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809 @PATH: 2433/1860 1800 1200 225 270/101 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.