Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
dcommander committed Sep 18, 2024
2 parents dcf222a + 9c2cd7f commit 22a8c85
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions unix/Xvnc/programs/Xserver/hw/vnc/rfb.h
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,8 @@ static const char subsampStr[TVNC_SAMPOPT][5] = { "1X", "4X", "2X", "Gray" };
#define TIGHT_DEFAULT_SUBSAMP TVNC_1X
#define TIGHT_DEFAULT_QUALITY 95

extern int rfbMaxTightRectSize;

extern int rfbNumCodedRectsTight(rfbClientPtr cl, int x, int y, int w, int h);
extern Bool rfbSendRectEncodingTight(rfbClientPtr cl, int x, int y, int w,
int h);
Expand Down
9 changes: 9 additions & 0 deletions unix/Xvnc/programs/Xserver/hw/vnc/rfbserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,15 @@ static rfbClientPtr rfbNewClient(int sock)
if (combine > 0 && combine <= 65000) rfbCombineRect = combine;
}

if ((env = getenv("TVNC_MAXTIGHTRECTSIZE")) != NULL) {
int maxTightRectSize = atoi(env);
if (maxTightRectSize > 0) {
RFBLOGID("Maximum Tight subrectangle size: %d pixels\n",
maxTightRectSize);
rfbMaxTightRectSize = maxTightRectSize;
}
}

cl->firstUpdate = TRUE;
/* The TigerVNC Viewer won't enable remote desktop resize until it receives
a desktop resize message from the server, so we give it one with the
Expand Down
13 changes: 9 additions & 4 deletions unix/Xvnc/programs/Xserver/hw/vnc/tight.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ static TIGHT_CONF tightConf[4] = {
{ 65536, 2048, 32, 7, 7, 5, 96, 256 } /* 9 */
};

int rfbMaxTightRectSize = 0;
#define MAXRECTSIZE \
(rfbMaxTightRectSize ? rfbMaxTightRectSize : \
tightConf[compressLevel].maxRectSize)

static int compressLevel;
static int qualityLevel;
static int subsampLevel;
Expand Down Expand Up @@ -220,7 +225,7 @@ int rfbNumCodedRectsTight(rfbClientPtr cl, int x, int y, int w, int h)
if (cl->enableLastRectEncoding && w * h >= MIN_SPLIT_RECT_SIZE)
return 0;

maxRectSize = tightConf[compressLevel].maxRectSize;
maxRectSize = MAXRECTSIZE;
maxRectWidth = tightConf[compressLevel].maxRectWidth;

if (w > maxRectWidth || w * h > maxRectSize) {
Expand Down Expand Up @@ -400,7 +405,7 @@ Bool rfbSendRectEncodingTight(rfbClientPtr cl, int x, int y, int w, int h)
else
usePixelFormat24 = FALSE;

nt = min(rfbNumThreads, w * h / tightConf[compressLevel].maxRectSize);
nt = min(rfbNumThreads, w * h / MAXRECTSIZE);
if (nt < 1) nt = 1;

for (i = 0; i < nt; i++) {
Expand Down Expand Up @@ -497,7 +502,7 @@ static Bool SendRectEncodingTight(threadparam *t, int x, int y, int w, int h)
{
int maxRectSize, maxRectWidth, nMaxWidth;

maxRectSize = tightConf[compressLevel].maxRectSize;
maxRectSize = MAXRECTSIZE;
maxRectWidth = tightConf[compressLevel].maxRectWidth;
nMaxWidth = (w > maxRectWidth) ? maxRectWidth : w;
nMaxRows = maxRectSize / nMaxWidth;
Expand Down Expand Up @@ -741,7 +746,7 @@ static Bool SendRectSimple(threadparam *t, int x, int y, int w, int h)
int rw, rh;
rfbClientPtr cl = t->cl;

maxRectSize = tightConf[compressLevel].maxRectSize;
maxRectSize = MAXRECTSIZE;
maxRectWidth = tightConf[compressLevel].maxRectWidth;

maxBeforeSize = maxRectSize * (cl->format.bitsPerPixel / 8);
Expand Down

0 comments on commit 22a8c85

Please sign in to comment.