Commit 26706414 authored by steven_carr's avatar steven_carr

Client Independent Server Side Scaling is now supported

Both PalmVNC and UltraVNC SetScale messages are supported
parent afa9fae0
2006-05-03 Steven Carr <scarr@jsa-usa.com>
* Server Side Scaling is now supported in libvncserver
Both PalmVNC and UltraVNC SetScale messages are supported
2006-05-02 Steven Carr <scarr@jsa-usa.com> 2006-05-02 Steven Carr <scarr@jsa-usa.com>
* Ultra Encoding added. Tested against UltraVNC V1.01 * Ultra Encoding added. Tested against UltraVNC V1.01
* libvncclient/rfbproto.c CopyRectangle() BPP!=8 bug fixed. * libvncclient/rfbproto.c CopyRectangle() BPP!=8 bug fixed.
......
...@@ -19,7 +19,7 @@ include_HEADERS=../rfb/rfb.h ../rfb/rfbconfig.h ../rfb/rfbint.h \ ...@@ -19,7 +19,7 @@ include_HEADERS=../rfb/rfb.h ../rfb/rfbconfig.h ../rfb/rfbint.h \
../rfb/rfbproto.h ../rfb/keysym.h ../rfb/rfbregion.h ../rfb/rfbclient.h ../rfb/rfbproto.h ../rfb/keysym.h ../rfb/rfbregion.h ../rfb/rfbclient.h
noinst_HEADERS=d3des.h ../rfb/default8x16.h zrleoutstream.h \ noinst_HEADERS=d3des.h ../rfb/default8x16.h zrleoutstream.h \
zrlepalettehelper.h zrletypes.h private.h minilzo.h lzoconf.h \ zrlepalettehelper.h zrletypes.h private.h minilzo.h lzoconf.h scale.h \
$(TIGHTVNCFILETRANSFERHDRS) $(TIGHTVNCFILETRANSFERHDRS)
EXTRA_DIST=tableinit24.c tableinittctemplate.c tabletranstemplate.c \ EXTRA_DIST=tableinit24.c tableinittctemplate.c tabletranstemplate.c \
...@@ -36,7 +36,7 @@ endif ...@@ -36,7 +36,7 @@ endif
LIB_SRCS = main.c rfbserver.c rfbregion.c auth.c sockets.c \ LIB_SRCS = main.c rfbserver.c rfbregion.c auth.c sockets.c \
stats.c corre.c hextile.c rre.c translate.c cutpaste.c \ stats.c corre.c hextile.c rre.c translate.c cutpaste.c \
httpd.c cursor.c font.c \ httpd.c cursor.c font.c \
draw.c selbox.c d3des.c vncauth.c cargs.c minilzo.c ultra.c \ draw.c selbox.c d3des.c vncauth.c cargs.c minilzo.c ultra.c scale.c \
$(ZLIBSRCS) $(JPEGSRCS) $(TIGHTVNCFILETRANSFERSRCS) $(ZLIBSRCS) $(JPEGSRCS) $(TIGHTVNCFILETRANSFERSRCS)
libvncserver_a_SOURCES=$(LIB_SRCS) libvncserver_a_SOURCES=$(LIB_SRCS)
......
...@@ -97,10 +97,10 @@ rfbSendSmallRectEncodingCoRRE(rfbClientPtr cl, ...@@ -97,10 +97,10 @@ rfbSendSmallRectEncodingCoRRE(rfbClientPtr cl,
rfbRREHeader hdr; rfbRREHeader hdr;
int nSubrects; int nSubrects;
int i; int i;
char *fbptr = (cl->screen->frameBuffer + (cl->screen->paddedWidthInBytes * y) char *fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y)
+ (x * (cl->screen->bitsPerPixel / 8))); + (x * (cl->scaledScreen->bitsPerPixel / 8)));
int maxRawSize = (cl->screen->width * cl->screen->height int maxRawSize = (cl->scaledScreen->width * cl->scaledScreen->height
* (cl->format.bitsPerPixel / 8)); * (cl->format.bitsPerPixel / 8));
if (rreBeforeBufSize < maxRawSize) { if (rreBeforeBufSize < maxRawSize) {
...@@ -121,7 +121,7 @@ rfbSendSmallRectEncodingCoRRE(rfbClientPtr cl, ...@@ -121,7 +121,7 @@ rfbSendSmallRectEncodingCoRRE(rfbClientPtr cl,
(*cl->translateFn)(cl->translateLookupTable,&(cl->screen->serverFormat), (*cl->translateFn)(cl->translateLookupTable,&(cl->screen->serverFormat),
&cl->format, fbptr, rreBeforeBuf, &cl->format, fbptr, rreBeforeBuf,
cl->screen->paddedWidthInBytes, w, h); cl->scaledScreen->paddedWidthInBytes, w, h);
switch (cl->format.bitsPerPixel) { switch (cl->format.bitsPerPixel) {
case 8: case 8:
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include <rfb/rfbregion.h> #include <rfb/rfbregion.h>
#include "private.h" #include "private.h"
void rfbScaledScreenUpdate(rfbScreenInfoPtr screen, int x1, int y1, int x2, int y2);
/* /*
* Send cursor shape either in X-style format or in client pixel format. * Send cursor shape either in X-style format or in client pixel format.
*/ */
...@@ -42,6 +44,8 @@ rfbSendCursorShape(rfbClientPtr cl) ...@@ -42,6 +44,8 @@ rfbSendCursorShape(rfbClientPtr cl)
uint8_t *bitmapData; uint8_t *bitmapData;
uint8_t bitmapByte; uint8_t bitmapByte;
/* TODO: scale the cursor data to the correct size */
pCursor = cl->screen->getCursorPtr(cl); pCursor = cl->screen->getCursorPtr(cl);
/*if(!pCursor) return TRUE;*/ /*if(!pCursor) return TRUE;*/
...@@ -461,6 +465,9 @@ void rfbHideCursor(rfbClientPtr cl) ...@@ -461,6 +465,9 @@ void rfbHideCursor(rfbClientPtr cl)
memcpy(s->frameBuffer+(y1+j)*rowstride+x1*bpp, memcpy(s->frameBuffer+(y1+j)*rowstride+x1*bpp,
s->underCursorBuffer+j*x2*bpp, s->underCursorBuffer+j*x2*bpp,
x2*bpp); x2*bpp);
/* Copy to all scaled versions */
rfbScaledScreenUpdate(s, x1, y1, x1+x2, y1+y2);
UNLOCK(s->cursorMutex); UNLOCK(s->cursorMutex);
} }
...@@ -619,6 +626,9 @@ void rfbShowCursor(rfbClientPtr cl) ...@@ -619,6 +626,9 @@ void rfbShowCursor(rfbClientPtr cl)
c->richSource+(j+j1)*c->width*bpp+(i+i1)*bpp,bpp); c->richSource+(j+j1)*c->width*bpp+(i+i1)*bpp,bpp);
} }
/* Copy to all scaled versions */
rfbScaledScreenUpdate(s, x1, y1, x1+x2, y1+y2);
UNLOCK(s->cursorMutex); UNLOCK(s->cursorMutex);
} }
......
...@@ -126,12 +126,12 @@ sendHextiles##bpp(rfbClientPtr cl, int rx, int ry, int rw, int rh) { ...@@ -126,12 +126,12 @@ sendHextiles##bpp(rfbClientPtr cl, int rx, int ry, int rw, int rh) {
return FALSE; \ return FALSE; \
} \ } \
\ \
fbptr = (cl->screen->frameBuffer + (cl->screen->paddedWidthInBytes * y) \ fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y) \
+ (x * (cl->screen->bitsPerPixel / 8))); \ + (x * (cl->scaledScreen->bitsPerPixel / 8))); \
\ \
(*cl->translateFn)(cl->translateLookupTable, &(cl->screen->serverFormat), \ (*cl->translateFn)(cl->translateLookupTable, &(cl->screen->serverFormat), \
&cl->format, fbptr, (char *)clientPixelData, \ &cl->format, fbptr, (char *)clientPixelData, \
cl->screen->paddedWidthInBytes, w, h); \ cl->scaledScreen->paddedWidthInBytes, w, h); \
\ \
startUblen = cl->ublen; \ startUblen = cl->ublen; \
cl->updateBuf[startUblen] = 0; \ cl->updateBuf[startUblen] = 0; \
...@@ -175,7 +175,7 @@ sendHextiles##bpp(rfbClientPtr cl, int rx, int ry, int rw, int rh) { ...@@ -175,7 +175,7 @@ sendHextiles##bpp(rfbClientPtr cl, int rx, int ry, int rw, int rh) {
(*cl->translateFn)(cl->translateLookupTable, \ (*cl->translateFn)(cl->translateLookupTable, \
&(cl->screen->serverFormat), &cl->format, fbptr, \ &(cl->screen->serverFormat), &cl->format, fbptr, \
(char *)clientPixelData, \ (char *)clientPixelData, \
cl->screen->paddedWidthInBytes, w, h); \ cl->scaledScreen->paddedWidthInBytes, w, h); \
\ \
memcpy(&cl->updateBuf[cl->ublen], (char *)clientPixelData, \ memcpy(&cl->updateBuf[cl->ublen], (char *)clientPixelData, \
w * h * (bpp/8)); \ w * h * (bpp/8)); \
......
...@@ -48,9 +48,9 @@ static MUTEX(extMutex); ...@@ -48,9 +48,9 @@ static MUTEX(extMutex);
static int rfbEnableLogging=1; static int rfbEnableLogging=1;
#ifdef LIBVNCSERVER_WORDS_BIGENDIAN #ifdef LIBVNCSERVER_WORDS_BIGENDIAN
char rfbEndianTest = 0; char rfbEndianTest = (1==0);
#else #else
char rfbEndianTest = -1; char rfbEndianTest = (1==1);
#endif #endif
/* /*
...@@ -407,6 +407,7 @@ void rfbMarkRegionAsModified(rfbScreenInfoPtr screen,sraRegionPtr modRegion) ...@@ -407,6 +407,7 @@ void rfbMarkRegionAsModified(rfbScreenInfoPtr screen,sraRegionPtr modRegion)
rfbReleaseClientIterator(iterator); rfbReleaseClientIterator(iterator);
} }
void rfbScaledScreenUpdate(rfbScreenInfoPtr screen, int x1, int y1, int x2, int y2);
void rfbMarkRectAsModified(rfbScreenInfoPtr screen,int x1,int y1,int x2,int y2) void rfbMarkRectAsModified(rfbScreenInfoPtr screen,int x1,int y1,int x2,int y2)
{ {
sraRegionPtr region; sraRegionPtr region;
...@@ -421,7 +422,10 @@ void rfbMarkRectAsModified(rfbScreenInfoPtr screen,int x1,int y1,int x2,int y2) ...@@ -421,7 +422,10 @@ void rfbMarkRectAsModified(rfbScreenInfoPtr screen,int x1,int y1,int x2,int y2)
if(y1<0) y1=0; if(y1<0) y1=0;
if(y2>screen->height) y2=screen->height; if(y2>screen->height) y2=screen->height;
if(y1==y2) return; if(y1==y2) return;
/* update scaled copies for this rectangle */
rfbScaledScreenUpdate(screen,x1,y1,x2,y2);
region = sraRgnCreateRect(x1,y1,x2,y2); region = sraRgnCreateRect(x1,y1,x2,y2);
rfbMarkRegionAsModified(screen,region); rfbMarkRegionAsModified(screen,region);
sraRgnDestroy(region); sraRgnDestroy(region);
...@@ -959,6 +963,17 @@ void rfbScreenCleanup(rfbScreenInfoPtr screen) ...@@ -959,6 +963,17 @@ void rfbScreenCleanup(rfbScreenInfoPtr screen)
#ifdef LIBVNCSERVER_HAVE_LIBJPEG #ifdef LIBVNCSERVER_HAVE_LIBJPEG
rfbTightCleanup(screen); rfbTightCleanup(screen);
#endif #endif
/* free all 'scaled' versions of this screen */
while (screen->scaledScreenNext!=NULL)
{
rfbScreenInfoPtr ptr;
ptr = screen->scaledScreenNext;
screen->scaledScreenNext = ptr->scaledScreenNext;
free(ptr->frameBuffer);
free(ptr);
}
#endif #endif
free(screen); free(screen);
} }
......
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
#define DEBUGPROTO(x) #define DEBUGPROTO(x)
#endif #endif
#include <scale.h>
static void rfbProcessClientProtocolVersion(rfbClientPtr cl); static void rfbProcessClientProtocolVersion(rfbClientPtr cl);
static void rfbProcessClientNormalMessage(rfbClientPtr cl); static void rfbProcessClientNormalMessage(rfbClientPtr cl);
...@@ -250,6 +251,9 @@ rfbNewTCPOrUDPClient(rfbScreenInfoPtr rfbScreen, ...@@ -250,6 +251,9 @@ rfbNewTCPOrUDPClient(rfbScreenInfoPtr rfbScreen,
cl->screen = rfbScreen; cl->screen = rfbScreen;
cl->sock = sock; cl->sock = sock;
cl->viewOnly = FALSE; cl->viewOnly = FALSE;
/* setup pseudo scaling */
cl->scaledScreen = rfbScreen;
cl->scaledScreen->scaledScreenRefCount++;
rfbResetStats(cl); rfbResetStats(cl);
...@@ -446,6 +450,9 @@ rfbClientConnectionGone(rfbClientPtr cl) ...@@ -446,6 +450,9 @@ rfbClientConnectionGone(rfbClientPtr cl)
if(cl->sock>0) if(cl->sock>0)
close(cl->sock); close(cl->sock);
if (cl->scaledScreen!=NULL)
cl->scaledScreen->scaledScreenRefCount--;
#ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBZ
rfbFreeZrleData(cl); rfbFreeZrleData(cl);
#endif #endif
...@@ -711,21 +718,31 @@ rfbProcessClientInitMessage(rfbClientPtr cl) ...@@ -711,21 +718,31 @@ rfbProcessClientInitMessage(rfbClientPtr cl)
} }
} }
/* The values come in based on the scaled screen, we need to convert them to
* values based on the man screen's coordinate system
*/
static rfbBool rectSwapIfLEAndClip(uint16_t* x,uint16_t* y,uint16_t* w,uint16_t* h, static rfbBool rectSwapIfLEAndClip(uint16_t* x,uint16_t* y,uint16_t* w,uint16_t* h,
rfbScreenInfoPtr screen) rfbClientPtr cl)
{ {
*x=Swap16IfLE(*x); int x1=Swap16IfLE(*x);
*y=Swap16IfLE(*y); int y1=Swap16IfLE(*y);
*w=Swap16IfLE(*w); int w1=Swap16IfLE(*w);
*h=Swap16IfLE(*h); int h1=Swap16IfLE(*h);
if(*w>screen->width-*x)
*w=screen->width-*x; rfbScaledCorrection(cl->scaledScreen, cl->screen, &x1, &y1, &w1, &h1, "rectSwapIfLEAndClip");
*x = x1;
*y = y1;
*w = w1;
*h = h1;
if(*w>cl->screen->width-*x)
*w=cl->screen->width-*x;
/* possible underflow */ /* possible underflow */
if(*w>screen->width-*x) if(*w>cl->screen->width-*x)
return FALSE; return FALSE;
if(*h>screen->height-*y) if(*h>cl->screen->height-*y)
*h=screen->height-*y; *h=cl->screen->height-*y;
if(*h>screen->height-*y) if(*h>cl->screen->height-*y)
return FALSE; return FALSE;
return TRUE; return TRUE;
...@@ -1062,10 +1079,17 @@ rfbProcessClientNormalMessage(rfbClientPtr cl) ...@@ -1062,10 +1079,17 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
return; return;
} }
if(!rectSwapIfLEAndClip(&msg.fur.x,&msg.fur.y,&msg.fur.w,&msg.fur.h,
cl->screen))
return;
/* The values come in based on the scaled screen, we need to convert them to
* values based on the main screen's coordinate system
*/
if(!rectSwapIfLEAndClip(&msg.fur.x,&msg.fur.y,&msg.fur.w,&msg.fur.h,cl))
{
rfbLog("Warning, ignoring rfbFramebufferUpdateRequest: %dXx%dY-%dWx%dH\n",msg.fur.x, msg.fur.y, msg.fur.w, msg.fur.h);
return;
}
tmpRegion = tmpRegion =
sraRgnCreateRect(msg.fur.x, sraRgnCreateRect(msg.fur.x,
msg.fur.y, msg.fur.y,
...@@ -1142,18 +1166,19 @@ rfbProcessClientNormalMessage(rfbClientPtr cl) ...@@ -1142,18 +1166,19 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
if (msg.pe.buttonMask != cl->lastPtrButtons || if (msg.pe.buttonMask != cl->lastPtrButtons ||
cl->screen->deferPtrUpdateTime == 0) { cl->screen->deferPtrUpdateTime == 0) {
cl->screen->ptrAddEvent(msg.pe.buttonMask, cl->screen->ptrAddEvent(msg.pe.buttonMask,
Swap16IfLE(msg.pe.x), Swap16IfLE(msg.pe.y), cl); ScaleX(cl->scaledScreen, cl->screen, Swap16IfLE(msg.pe.x)),
ScaleY(cl->scaledScreen, cl->screen, Swap16IfLE(msg.pe.y)),
cl);
cl->lastPtrButtons = msg.pe.buttonMask; cl->lastPtrButtons = msg.pe.buttonMask;
} else { } else {
cl->lastPtrX = Swap16IfLE(msg.pe.x); cl->lastPtrX = ScaleX(cl->scaledScreen, cl->screen, Swap16IfLE(msg.pe.x));
cl->lastPtrY = Swap16IfLE(msg.pe.y); cl->lastPtrY = ScaleY(cl->scaledScreen, cl->screen, Swap16IfLE(msg.pe.y));
cl->lastPtrButtons = msg.pe.buttonMask; cl->lastPtrButtons = msg.pe.buttonMask;
} }
} }
return; return;
case rfbClientCutText: case rfbClientCutText:
if ((n = rfbReadExact(cl, ((char *)&msg) + 1, if ((n = rfbReadExact(cl, ((char *)&msg) + 1,
...@@ -1183,6 +1208,23 @@ rfbProcessClientNormalMessage(rfbClientPtr cl) ...@@ -1183,6 +1208,23 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
return; return;
case rfbPalmVNCSetScaleFactor:
cl->PalmVNC = TRUE;
case rfbSetScale:
if ((n = rfbReadExact(cl, ((char *)&msg) + 1,
sz_rfbSetScaleMsg - 1)) <= 0) {
if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read");
rfbCloseClient(cl);
return;
}
rfbLog("rfbSetScale(%d)\n", msg.ssc.scale);
rfbScalingSetup(cl,cl->screen->width/msg.ssc.scale, cl->screen->height/msg.ssc.scale);
rfbSendNewScaleSize(cl);
return;
default: default:
{ {
...@@ -1245,7 +1287,7 @@ rfbSendFramebufferUpdate(rfbClientPtr cl, ...@@ -1245,7 +1287,7 @@ rfbSendFramebufferUpdate(rfbClientPtr cl,
fu->type = rfbFramebufferUpdate; fu->type = rfbFramebufferUpdate;
fu->nRects = Swap16IfLE(1); fu->nRects = Swap16IfLE(1);
cl->ublen = sz_rfbFramebufferUpdateMsg; cl->ublen = sz_rfbFramebufferUpdateMsg;
if (!rfbSendNewFBSize(cl, cl->screen->width, cl->screen->height)) { if (!rfbSendNewFBSize(cl, cl->scaledScreen->width, cl->scaledScreen->height)) {
return FALSE; return FALSE;
} }
return rfbSendUpdateBuf(cl); return rfbSendUpdateBuf(cl);
...@@ -1401,6 +1443,9 @@ rfbSendFramebufferUpdate(rfbClientPtr cl, ...@@ -1401,6 +1443,9 @@ rfbSendFramebufferUpdate(rfbClientPtr cl,
int y = rect.y1; int y = rect.y1;
int w = rect.x2 - x; int w = rect.x2 - x;
int h = rect.y2 - y; int h = rect.y2 - y;
/* We need to count the number of rects in the scaled screen */
if (cl->screen!=cl->scaledScreen)
rfbScaledCorrection(cl->screen, cl->scaledScreen, &x, &y, &w, &h, "rfbSendFramebufferUpdate");
int rectsPerRow = (w-1)/cl->correMaxWidth+1; int rectsPerRow = (w-1)/cl->correMaxWidth+1;
int rows = (h-1)/cl->correMaxHeight+1; int rows = (h-1)/cl->correMaxHeight+1;
nUpdateRegionRects += rectsPerRow*rows; nUpdateRegionRects += rectsPerRow*rows;
...@@ -1414,6 +1459,9 @@ rfbSendFramebufferUpdate(rfbClientPtr cl, ...@@ -1414,6 +1459,9 @@ rfbSendFramebufferUpdate(rfbClientPtr cl,
int y = rect.y1; int y = rect.y1;
int w = rect.x2 - x; int w = rect.x2 - x;
int h = rect.y2 - y; int h = rect.y2 - y;
/* We need to count the number of rects in the scaled screen */
if (cl->screen!=cl->scaledScreen)
rfbScaledCorrection(cl->screen, cl->scaledScreen, &x, &y, &w, &h, "rfbSendFramebufferUpdate");
nUpdateRegionRects += (((h-1) / (ULTRA_MAX_SIZE( w ) / w)) + 1); nUpdateRegionRects += (((h-1) / (ULTRA_MAX_SIZE( w ) / w)) + 1);
} }
sraRgnReleaseIterator(i); sraRgnReleaseIterator(i);
...@@ -1426,6 +1474,9 @@ rfbSendFramebufferUpdate(rfbClientPtr cl, ...@@ -1426,6 +1474,9 @@ rfbSendFramebufferUpdate(rfbClientPtr cl,
int y = rect.y1; int y = rect.y1;
int w = rect.x2 - x; int w = rect.x2 - x;
int h = rect.y2 - y; int h = rect.y2 - y;
/* We need to count the number of rects in the scaled screen */
if (cl->screen!=cl->scaledScreen)
rfbScaledCorrection(cl->screen, cl->scaledScreen, &x, &y, &w, &h, "rfbSendFramebufferUpdate");
nUpdateRegionRects += (((h-1) / (ZLIB_MAX_SIZE( w ) / w)) + 1); nUpdateRegionRects += (((h-1) / (ZLIB_MAX_SIZE( w ) / w)) + 1);
} }
sraRgnReleaseIterator(i); sraRgnReleaseIterator(i);
...@@ -1438,6 +1489,9 @@ rfbSendFramebufferUpdate(rfbClientPtr cl, ...@@ -1438,6 +1489,9 @@ rfbSendFramebufferUpdate(rfbClientPtr cl,
int y = rect.y1; int y = rect.y1;
int w = rect.x2 - x; int w = rect.x2 - x;
int h = rect.y2 - y; int h = rect.y2 - y;
/* We need to count the number of rects in the scaled screen */
if (cl->screen!=cl->scaledScreen)
rfbScaledCorrection(cl->screen, cl->scaledScreen, &x, &y, &w, &h, "rfbSendFramebufferUpdate");
int n = rfbNumCodedRectsTight(cl, x, y, w, h); int n = rfbNumCodedRectsTight(cl, x, y, w, h);
if (n == 0) { if (n == 0) {
nUpdateRegionRects = 0xFFFF; nUpdateRegionRects = 0xFFFF;
...@@ -1509,6 +1563,10 @@ rfbSendFramebufferUpdate(rfbClientPtr cl, ...@@ -1509,6 +1563,10 @@ rfbSendFramebufferUpdate(rfbClientPtr cl,
int w = rect.x2 - x; int w = rect.x2 - x;
int h = rect.y2 - y; int h = rect.y2 - y;
/* We need to count the number of rects in the scaled screen */
if (cl->screen!=cl->scaledScreen)
rfbScaledCorrection(cl->screen, cl->scaledScreen, &x, &y, &w, &h, "rfbSendFramebufferUpdate");
cl->rawBytesEquivalent += (sz_rfbFramebufferUpdateRectHeader cl->rawBytesEquivalent += (sz_rfbFramebufferUpdateRectHeader
+ w * (cl->format.bitsPerPixel / 8) * h); + w * (cl->format.bitsPerPixel / 8) * h);
...@@ -1598,12 +1656,19 @@ rfbSendCopyRegion(rfbClientPtr cl, ...@@ -1598,12 +1656,19 @@ rfbSendCopyRegion(rfbClientPtr cl,
/* printf("copyrect: "); sraRgnPrint(reg); putchar('\n');fflush(stdout); */ /* printf("copyrect: "); sraRgnPrint(reg); putchar('\n');fflush(stdout); */
i = sraRgnGetReverseIterator(reg,dx>0,dy>0); i = sraRgnGetReverseIterator(reg,dx>0,dy>0);
/* correct for the scale of the screen */
dx = ScaleX(cl->screen, cl->scaledScreen, dx);
dy = ScaleX(cl->screen, cl->scaledScreen, dy);
while(sraRgnIteratorNext(i,&rect1)) { while(sraRgnIteratorNext(i,&rect1)) {
x = rect1.x1; x = rect1.x1;
y = rect1.y1; y = rect1.y1;
w = rect1.x2 - x; w = rect1.x2 - x;
h = rect1.y2 - y; h = rect1.y2 - y;
/* correct for scaling (if necessary) */
rfbScaledCorrection(cl->screen, cl->scaledScreen, &x, &y, &w, &h, "copyrect");
rect.r.x = Swap16IfLE(x); rect.r.x = Swap16IfLE(x);
rect.r.y = Swap16IfLE(y); rect.r.y = Swap16IfLE(y);
rect.r.w = Swap16IfLE(w); rect.r.w = Swap16IfLE(w);
...@@ -1644,8 +1709,8 @@ rfbSendRectEncodingRaw(rfbClientPtr cl, ...@@ -1644,8 +1709,8 @@ rfbSendRectEncodingRaw(rfbClientPtr cl,
rfbFramebufferUpdateRectHeader rect; rfbFramebufferUpdateRectHeader rect;
int nlines; int nlines;
int bytesPerLine = w * (cl->format.bitsPerPixel / 8); int bytesPerLine = w * (cl->format.bitsPerPixel / 8);
char *fbptr = (cl->screen->frameBuffer + (cl->screen->paddedWidthInBytes * y) char *fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y)
+ (x * (cl->screen->bitsPerPixel / 8))); + (x * (cl->scaledScreen->bitsPerPixel / 8)));
/* Flush the buffer to guarantee correct alignment for translateFn(). */ /* Flush the buffer to guarantee correct alignment for translateFn(). */
if (cl->ublen > 0) { if (cl->ublen > 0) {
...@@ -1675,7 +1740,7 @@ rfbSendRectEncodingRaw(rfbClientPtr cl, ...@@ -1675,7 +1740,7 @@ rfbSendRectEncodingRaw(rfbClientPtr cl,
(*cl->translateFn)(cl->translateLookupTable, (*cl->translateFn)(cl->translateLookupTable,
&(cl->screen->serverFormat), &(cl->screen->serverFormat),
&cl->format, fbptr, &cl->updateBuf[cl->ublen], &cl->format, fbptr, &cl->updateBuf[cl->ublen],
cl->screen->paddedWidthInBytes, w, nlines); cl->scaledScreen->paddedWidthInBytes, w, nlines);
cl->ublen += nlines * bytesPerLine; cl->ublen += nlines * bytesPerLine;
h -= nlines; h -= nlines;
...@@ -1688,7 +1753,7 @@ rfbSendRectEncodingRaw(rfbClientPtr cl, ...@@ -1688,7 +1753,7 @@ rfbSendRectEncodingRaw(rfbClientPtr cl,
if (!rfbSendUpdateBuf(cl)) if (!rfbSendUpdateBuf(cl))
return FALSE; return FALSE;
fbptr += (cl->screen->paddedWidthInBytes * nlines); fbptr += (cl->scaledScreen->paddedWidthInBytes * nlines);
nlines = (UPDATE_BUF_SIZE - cl->ublen) / bytesPerLine; nlines = (UPDATE_BUF_SIZE - cl->ublen) / bytesPerLine;
if (nlines == 0) { if (nlines == 0) {
...@@ -1752,6 +1817,11 @@ rfbSendNewFBSize(rfbClientPtr cl, ...@@ -1752,6 +1817,11 @@ rfbSendNewFBSize(rfbClientPtr cl,
return FALSE; return FALSE;
} }
if (cl->PalmVNC==TRUE)
rfbLog("Sending a rfbEncodingNewFBSize in response to a PalmVNC style frameuffer resize request (%dx%d)\n", w, h);
else
rfbLog("Sending a rfbEncodingNewFBSize in response to a UltraVNC style frameuffer resize request (%dx%d)\n", w, h);
rect.encoding = Swap32IfLE(rfbEncodingNewFBSize); rect.encoding = Swap32IfLE(rfbEncodingNewFBSize);
rect.r.x = 0; rect.r.x = 0;
rect.r.y = 0; rect.r.y = 0;
......
...@@ -63,10 +63,10 @@ rfbSendRectEncodingRRE(rfbClientPtr cl, ...@@ -63,10 +63,10 @@ rfbSendRectEncodingRRE(rfbClientPtr cl,
rfbRREHeader hdr; rfbRREHeader hdr;
int nSubrects; int nSubrects;
int i; int i;
char *fbptr = (cl->screen->frameBuffer + (cl->screen->paddedWidthInBytes * y) char *fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y)
+ (x * (cl->screen->bitsPerPixel / 8))); + (x * (cl->scaledScreen->bitsPerPixel / 8)));
int maxRawSize = (cl->screen->width * cl->screen->height int maxRawSize = (cl->scaledScreen->width * cl->scaledScreen->height
* (cl->format.bitsPerPixel / 8)); * (cl->format.bitsPerPixel / 8));
if (rreBeforeBufSize < maxRawSize) { if (rreBeforeBufSize < maxRawSize) {
...@@ -88,7 +88,7 @@ rfbSendRectEncodingRRE(rfbClientPtr cl, ...@@ -88,7 +88,7 @@ rfbSendRectEncodingRRE(rfbClientPtr cl,
(*cl->translateFn)(cl->translateLookupTable, (*cl->translateFn)(cl->translateLookupTable,
&(cl->screen->serverFormat), &(cl->screen->serverFormat),
&cl->format, fbptr, rreBeforeBuf, &cl->format, fbptr, rreBeforeBuf,
cl->screen->paddedWidthInBytes, w, h); cl->scaledScreen->paddedWidthInBytes, w, h);
switch (cl->format.bitsPerPixel) { switch (cl->format.bitsPerPixel) {
case 8: case 8:
......
This diff is collapsed.
int ScaleX(rfbScreenInfoPtr from, rfbScreenInfoPtr to, int x);
int ScaleY(rfbScreenInfoPtr from, rfbScreenInfoPtr to, int y);
void rfbScaledCorrection(rfbScreenInfoPtr from, rfbScreenInfoPtr to, int *x, int *y, int *w, int *h, char *function);
void rfbScaledScreenUpdateRect(rfbScreenInfoPtr screen, rfbScreenInfoPtr ptr, int x0, int y0, int w0, int h0);
void rfbScaledScreenUpdate(rfbScreenInfoPtr screen, int x1, int y1, int x2, int y2);
rfbScreenInfoPtr rfbScaledScreenAllocate(rfbClientPtr cl, int width, int height);
rfbScreenInfoPtr rfbScalingFind(rfbClientPtr cl, int width, int height);
void rfbScalingSetup(rfbClientPtr cl, int width, int height);
int rfbSendNewScaleSize(rfbClientPtr cl);
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
static const char* encNames[] = { static const char* encNames[] = {
"raw", "copyRect", "RRE", "[encoding 3]", "CoRRE", "hextile", "raw", "copyRect", "RRE", "[encoding 3]", "CoRRE", "hextile",
"zlib", "tight", "[encoding 8]", "[encoding 9]", "[encoding 10]", "zlib", "tight", "[encoding 8]", "ultra", "[encoding 10]",
"[encoding 11]", "[encoding 12]", "[encoding 13]", "[encoding 14]", "[encoding 11]", "[encoding 12]", "[encoding 13]", "[encoding 14]",
"[encoding 15]", "[encoding 15]",
"ZRLE", "[encoding 17]", "[encoding 18]", "[encoding 19]", "[encoding 20]" "ZRLE", "[encoding 17]", "[encoding 18]", "[encoding 19]", "[encoding 20]"
......
...@@ -332,13 +332,13 @@ rfbSendRectEncodingTight(rfbClientPtr cl, ...@@ -332,13 +332,13 @@ rfbSendRectEncodingTight(rfbClientPtr cl,
if (!SendTightHeader(cl, x_best, y_best, w_best, h_best)) if (!SendTightHeader(cl, x_best, y_best, w_best, h_best))
return FALSE; return FALSE;
fbptr = (cl->screen->frameBuffer + fbptr = (cl->scaledScreen->frameBuffer +
(cl->screen->paddedWidthInBytes * y_best) + (cl->scaledScreen->paddedWidthInBytes * y_best) +
(x_best * (cl->screen->bitsPerPixel / 8))); (x_best * (cl->scaledScreen->bitsPerPixel / 8)));
(*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat, (*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat,
&cl->format, fbptr, tightBeforeBuf, &cl->format, fbptr, tightBeforeBuf,
cl->screen->paddedWidthInBytes, 1, 1); cl->scaledScreen->paddedWidthInBytes, 1, 1);
if (!SendSolidRect(cl)) if (!SendSolidRect(cl))
return FALSE; return FALSE;
...@@ -486,7 +486,7 @@ CheckSolidTile##bpp(rfbClientPtr cl, int x, int y, int w, int h, \ ...@@ -486,7 +486,7 @@ CheckSolidTile##bpp(rfbClientPtr cl, int x, int y, int w, int h, \
int dx, dy; \ int dx, dy; \
\ \
fbptr = (uint##bpp##_t *) \ fbptr = (uint##bpp##_t *) \
&cl->screen->frameBuffer[y * cl->screen->paddedWidthInBytes + x * (bpp/8)]; \ &cl->scaledScreen->frameBuffer[y * cl->scaledScreen->paddedWidthInBytes + x * (bpp/8)]; \
\ \
colorValue = *fbptr; \ colorValue = *fbptr; \
if (needSameColor && (uint32_t)colorValue != *colorPtr) \ if (needSameColor && (uint32_t)colorValue != *colorPtr) \
...@@ -497,7 +497,7 @@ CheckSolidTile##bpp(rfbClientPtr cl, int x, int y, int w, int h, \ ...@@ -497,7 +497,7 @@ CheckSolidTile##bpp(rfbClientPtr cl, int x, int y, int w, int h, \
if (colorValue != fbptr[dx]) \ if (colorValue != fbptr[dx]) \
return FALSE; \ return FALSE; \
} \ } \
fbptr = (uint##bpp##_t *)((uint8_t *)fbptr + cl->screen->paddedWidthInBytes); \ fbptr = (uint##bpp##_t *)((uint8_t *)fbptr + cl->scaledScreen->paddedWidthInBytes); \
} \ } \
\ \
*colorPtr = (uint32_t)colorValue; \ *colorPtr = (uint32_t)colorValue; \
...@@ -580,12 +580,12 @@ SendSubrect(rfbClientPtr cl, ...@@ -580,12 +580,12 @@ SendSubrect(rfbClientPtr cl,
if (!SendTightHeader(cl, x, y, w, h)) if (!SendTightHeader(cl, x, y, w, h))
return FALSE; return FALSE;
fbptr = (cl->screen->frameBuffer + (cl->screen->paddedWidthInBytes * y) fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y)
+ (x * (cl->screen->bitsPerPixel / 8))); + (x * (cl->scaledScreen->bitsPerPixel / 8)));
(*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat, (*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat,
&cl->format, fbptr, tightBeforeBuf, &cl->format, fbptr, tightBeforeBuf,
cl->screen->paddedWidthInBytes, w, h); cl->scaledScreen->paddedWidthInBytes, w, h);
paletteMaxColors = w * h / tightConf[compressLevel].idxMaxColorsDivisor; paletteMaxColors = w * h / tightConf[compressLevel].idxMaxColorsDivisor;
if ( paletteMaxColors < 2 && if ( paletteMaxColors < 2 &&
...@@ -1723,7 +1723,7 @@ PrepareRowForJpeg24(rfbClientPtr cl, ...@@ -1723,7 +1723,7 @@ PrepareRowForJpeg24(rfbClientPtr cl,
uint32_t pix; uint32_t pix;
fbptr = (uint32_t *) fbptr = (uint32_t *)
&cl->screen->frameBuffer[y * cl->screen->paddedWidthInBytes + x * 4]; &cl->scaledScreen->frameBuffer[y * cl->scaledScreen->paddedWidthInBytes + x * 4];
while (count--) { while (count--) {
pix = *fbptr++; pix = *fbptr++;
...@@ -1742,7 +1742,7 @@ PrepareRowForJpeg##bpp(rfbClientPtr cl, uint8_t *dst, int x, int y, int count) { ...@@ -1742,7 +1742,7 @@ PrepareRowForJpeg##bpp(rfbClientPtr cl, uint8_t *dst, int x, int y, int count) {
int inRed, inGreen, inBlue; \ int inRed, inGreen, inBlue; \
\ \
fbptr = (uint##bpp##_t *) \ fbptr = (uint##bpp##_t *) \
&cl->screen->frameBuffer[y * cl->screen->paddedWidthInBytes + \ &cl->scaledScreen->frameBuffer[y * cl->scaledScreen->paddedWidthInBytes + \
x * (bpp / 8)]; \ x * (bpp / 8)]; \
\ \
while (count--) { \ while (count--) { \
......
...@@ -43,8 +43,8 @@ rfbSendOneRectEncodingUltra(rfbClientPtr cl, ...@@ -43,8 +43,8 @@ rfbSendOneRectEncodingUltra(rfbClientPtr cl,
rfbZlibHeader hdr; rfbZlibHeader hdr;
int deflateResult; int deflateResult;
int i; int i;
char *fbptr = (cl->screen->frameBuffer + (cl->screen->paddedWidthInBytes * y) char *fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y)
+ (x * (cl->screen->bitsPerPixel / 8))); + (x * (cl->scaledScreen->bitsPerPixel / 8)));
int maxRawSize; int maxRawSize;
int maxCompSize; int maxCompSize;
...@@ -78,7 +78,7 @@ rfbSendOneRectEncodingUltra(rfbClientPtr cl, ...@@ -78,7 +78,7 @@ rfbSendOneRectEncodingUltra(rfbClientPtr cl,
*/ */
(*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat, (*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat,
&cl->format, fbptr, lzoBeforeBuf, &cl->format, fbptr, lzoBeforeBuf,
cl->screen->paddedWidthInBytes, w, h); cl->scaledScreen->paddedWidthInBytes, w, h);
if ( cl->compStreamInitedLZO == FALSE ) { if ( cl->compStreamInitedLZO == FALSE ) {
cl->compStreamInitedLZO = TRUE; cl->compStreamInitedLZO = TRUE;
......
...@@ -64,13 +64,13 @@ rfbSendOneRectEncodingZlib(rfbClientPtr cl, ...@@ -64,13 +64,13 @@ rfbSendOneRectEncodingZlib(rfbClientPtr cl,
int deflateResult; int deflateResult;
int previousOut; int previousOut;
int i; int i;
char *fbptr = (cl->screen->frameBuffer + (cl->screen->paddedWidthInBytes * y) char *fbptr = (cl->scaledScreen->frameBuffer + (cl->scaledScreen->paddedWidthInBytes * y)
+ (x * (cl->screen->bitsPerPixel / 8))); + (x * (cl->scaledScreen->bitsPerPixel / 8)));
int maxRawSize; int maxRawSize;
int maxCompSize; int maxCompSize;
maxRawSize = (cl->screen->width * cl->screen->height maxRawSize = (cl->scaledScreen->width * cl->scaledScreen->height
* (cl->format.bitsPerPixel / 8)); * (cl->format.bitsPerPixel / 8));
if (zlibBeforeBufSize < maxRawSize) { if (zlibBeforeBufSize < maxRawSize) {
...@@ -84,7 +84,7 @@ rfbSendOneRectEncodingZlib(rfbClientPtr cl, ...@@ -84,7 +84,7 @@ rfbSendOneRectEncodingZlib(rfbClientPtr cl,
/* zlib compression is not useful for very small data sets. /* zlib compression is not useful for very small data sets.
* So, we just send these raw without any compression. * So, we just send these raw without any compression.
*/ */
if (( w * h * (cl->screen->bitsPerPixel / 8)) < if (( w * h * (cl->scaledScreen->bitsPerPixel / 8)) <
VNC_ENCODE_ZLIB_MIN_COMP_SIZE ) { VNC_ENCODE_ZLIB_MIN_COMP_SIZE ) {
int result; int result;
...@@ -126,7 +126,7 @@ rfbSendOneRectEncodingZlib(rfbClientPtr cl, ...@@ -126,7 +126,7 @@ rfbSendOneRectEncodingZlib(rfbClientPtr cl,
*/ */
(*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat, (*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat,
&cl->format, fbptr, zlibBeforeBuf, &cl->format, fbptr, zlibBeforeBuf,
cl->screen->paddedWidthInBytes, w, h); cl->scaledScreen->paddedWidthInBytes, w, h);
cl->compStream.next_in = ( Bytef * )zlibBeforeBuf; cl->compStream.next_in = ( Bytef * )zlibBeforeBuf;
cl->compStream.avail_in = w * h * (cl->format.bitsPerPixel / 8); cl->compStream.avail_in = w * h * (cl->format.bitsPerPixel / 8);
......
...@@ -30,13 +30,13 @@ ...@@ -30,13 +30,13 @@
#define GET_IMAGE_INTO_BUF(tx,ty,tw,th,buf) \ #define GET_IMAGE_INTO_BUF(tx,ty,tw,th,buf) \
{ char *fbptr = (cl->screen->frameBuffer \ { char *fbptr = (cl->scaledScreen->frameBuffer \
+ (cl->screen->paddedWidthInBytes * ty) \ + (cl->scaledScreen->paddedWidthInBytes * ty) \
+ (tx * (cl->screen->bitsPerPixel / 8))); \ + (tx * (cl->scaledScreen->bitsPerPixel / 8))); \
\ \
(*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat,\ (*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat,\
&cl->format, fbptr, (char*)buf, \ &cl->format, fbptr, (char*)buf, \
cl->screen->paddedWidthInBytes, tw, th); } cl->scaledScreen->paddedWidthInBytes, tw, th); }
#define EXTRA_ARGS , rfbClientPtr cl #define EXTRA_ARGS , rfbClientPtr cl
......
...@@ -201,6 +201,10 @@ typedef struct _rfbExtensionData { ...@@ -201,6 +201,10 @@ typedef struct _rfbExtensionData {
typedef struct _rfbScreenInfo typedef struct _rfbScreenInfo
{ {
/* this structure has children that are scaled versions of this screen */
struct _rfbScreenInfo *scaledScreenNext;
int scaledScreenRefCount;
int width; int width;
int paddedWidthInBytes; int paddedWidthInBytes;
int height; int height;
...@@ -348,6 +352,12 @@ typedef struct _rfbClientRec { ...@@ -348,6 +352,12 @@ typedef struct _rfbClientRec {
/* back pointer to the screen */ /* back pointer to the screen */
rfbScreenInfoPtr screen; rfbScreenInfoPtr screen;
/* points to a scaled version of the screen buffer in cl->scaledScreenList */
rfbScreenInfoPtr scaledScreen;
/* how did the client tell us it wanted the screen changed? Ultra style or palm style? */
rfbBool PalmVNC;
/* private data. You should put any application client specific data /* private data. You should put any application client specific data
* into a struct and let clientData point to it. Don't forget to * into a struct and let clientData point to it. Don't forget to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment