diff --git a/clipboard.cc b/clipboard.cc index 0e2cf82..2f6bc20 100644 --- a/clipboard.cc +++ b/clipboard.cc @@ -1,6 +1,7 @@ #if __ORCAC__ #pragma lint -1 #pragma noroot +segment "VNCview GS"; #endif #include diff --git a/colortables.cc b/colortables.cc index 5166cc7..27ed613 100644 --- a/colortables.cc +++ b/colortables.cc @@ -1,6 +1,7 @@ #if __ORCAC__ #pragma lint -1 #pragma noroot +segment "VNCview GS"; #endif #include diff --git a/copyrect.cc b/copyrect.cc index ac34e2f..b89fddb 100644 --- a/copyrect.cc +++ b/copyrect.cc @@ -1,6 +1,7 @@ #if __ORCAC__ #pragma lint -1 #pragma noroot +segment "VNCview GS"; #endif #include diff --git a/desktopsize.cc b/desktopsize.cc index 6620efc..5aeaaea 100644 --- a/desktopsize.cc +++ b/desktopsize.cc @@ -1,6 +1,7 @@ #if __ORCAC__ #pragma lint -1 #pragma noroot +segment "VNCview GS"; #endif #include @@ -53,8 +54,8 @@ void DoDesktopSize (void) { oldWinHeight = winHeight; oldWinWidth = winWidth; - winHeight = 174; - winWidth = (hRez == 640) ? 613 : 302; + winHeight = WIN_HEIGHT; + winWidth = (hRez == 640) ? WIN_WIDTH_640 : WIN_WIDTH_320; if (fbWidth < winWidth) winWidth = fbWidth; if (fbHeight < winHeight) diff --git a/hextile.cc b/hextile.cc index 227d5de..98c6ca4 100644 --- a/hextile.cc +++ b/hextile.cc @@ -1,6 +1,7 @@ #if __ORCAC__ #pragma lint -1 #pragma noroot +segment "VNCview GS"; #endif #include diff --git a/keyboard.cc b/keyboard.cc index 11f70d7..6d59f85 100644 --- a/keyboard.cc +++ b/keyboard.cc @@ -1,6 +1,7 @@ #if __ORCAC__ #pragma lint -1 #pragma noroot +segment "VNCview GS"; #endif #include diff --git a/mouse.cc b/mouse.cc index 8bbfdb0..997f862 100644 --- a/mouse.cc +++ b/mouse.cc @@ -1,6 +1,7 @@ #if __ORCAC__ #pragma lint -1 #pragma noroot +segment "VNCview GS"; #endif #include diff --git a/raw.cc b/raw.cc index 629f12b..c3f8e18 100644 --- a/raw.cc +++ b/raw.cc @@ -1,6 +1,7 @@ #if __ORCAC__ #pragma lint -1 #pragma noroot +segment "VNCview GS"; #endif #include @@ -39,6 +40,11 @@ static unsigned long pixels; static unsigned int drawingLine; /* Line to be drawn while displaying */ static BOOLEAN extraByteAdvance; +/* Buffer to hold all SHR pixel data from one update (defined in tables.asm). + * Must be big enough: at least (WIN_WIDTH_640/4 + 1) * WIN_HEIGHT. */ +#define DESTBUF_SIZE 0x8001 +extern unsigned char destBuf[]; + static unsigned char *destPtr; /* Ends drawing of a raw rectangle when it is complete or aborted @@ -46,7 +52,6 @@ static unsigned char *destPtr; */ static void StopRawDrawing (void) { HUnlock(readBufferHndl); - free(srcLocInfo.ptrToPixImage); /* Allocated as destPtr */ displayInProgress = FALSE; @@ -274,11 +279,7 @@ static void RawDrawLine (void) { lineBytes = rectWidth/2; } - destPtr = calloc(lineBytes, 1); - if (!destPtr) { /* Couldn't allocate memory */ - DoClose(vncWindow); - return; - } + destPtr = destBuf; srcLocInfo.ptrToPixImage = destPtr; srcLocInfo.width = lineBytes; @@ -350,8 +351,6 @@ static void RawDrawLine (void) { /* Process rectangle data in raw encoding and write it to screen. */ void DoRawRect (void) { - unsigned long bufferLength; - pixels = (unsigned long) rectWidth * rectHeight; /* Try to read data */ @@ -370,11 +369,9 @@ void DoRawRect (void) { if (hRez == 640) { if (rectWidth & 0x03) { /* Width not an exact multiple of 4 */ lineBytes = rectWidth/4 + 1; - extraByteAdvance = TRUE; } else { /* Width is a multiple of 4 */ lineBytes = rectWidth/4; - extraByteAdvance = FALSE; } } else { /* 320 mode */ @@ -388,12 +385,21 @@ void DoRawRect (void) { } } - bufferLength = lineBytes * rectHeight; - destPtr = calloc(bufferLength, 1); - if (!destPtr) { /* Couldn't allocate memory */ - DoClose(vncWindow); + /* If we get an oversized update, ignore it and ask for another one. + * Shouldn't normally happen, except possibly if there are outstanding + * update requests for multiple screen regions due to scrolling. + */ + if (lineBytes * rectHeight >= DESTBUF_SIZE) { + unsigned long contentOrigin; + Point * contentOriginPtr = (void *) &contentOrigin; + + contentOrigin = GetContentOrigin(vncWindow); + SendFBUpdateRequest(FALSE, contentOriginPtr->h, contentOriginPtr->v, + winWidth, winHeight); + StopRawDrawing(); return; } + destPtr = destBuf; srcLocInfo.ptrToPixImage = destPtr; srcLocInfo.width = lineBytes; diff --git a/tables.asm b/tables.asm index d60c30a..4ce3964 100644 --- a/tables.asm +++ b/tables.asm @@ -30,3 +30,10 @@ bigcoltab640b data bigcoltab320 data dc i4'BCT320' end + +* Buffer for SHR pixel data generated during raw decoding +* Must be big enough to hold at least the full window area full of pixels. + +destBuf data + ds $8001 + end diff --git a/vncdisplay.cc b/vncdisplay.cc index e59b46c..ee99fe3 100644 --- a/vncdisplay.cc +++ b/vncdisplay.cc @@ -1,6 +1,7 @@ #if __ORCAC__ #pragma lint -1 #pragma noroot +segment "VNCview GS"; #endif #include @@ -95,8 +96,8 @@ static void ChangeResolution(int rez) { hRez = rez; - winHeight = 174; - winWidth = (rez == 640) ? 613 : 302; + winHeight = WIN_HEIGHT; + winWidth = (rez == 640) ? WIN_WIDTH_640 : WIN_WIDTH_320; /* Set up pixel translation table for correct graphics mode */ if (rez == 320) diff --git a/vncdisplay.h b/vncdisplay.h index 12f6fd8..adc2916 100644 --- a/vncdisplay.h +++ b/vncdisplay.h @@ -17,6 +17,10 @@ extern unsigned int rectHeight; #define encodingCursor 0xffffff11 #define encodingDesktopSize 0xffffff21 +#define WIN_WIDTH_320 302 +#define WIN_WIDTH_640 613 +#define WIN_HEIGHT 174 + extern GrafPortPtr vncWindow; /* VNC session window dimensions */ diff --git a/vncsession.cc b/vncsession.cc index dde3f6c..1ec94d6 100644 --- a/vncsession.cc +++ b/vncsession.cc @@ -6,6 +6,7 @@ #if __ORCAC__ #pragma lint -1 #pragma noroot +segment "VNCview GS"; #endif #if DEBUG diff --git a/vncview.cc b/vncview.cc index 7144833..a827024 100644 --- a/vncview.cc +++ b/vncview.cc @@ -4,6 +4,7 @@ #if __ORCAC__ #pragma lint -1 +segment "VNCview GS"; #endif #if DEBUG