summaryrefslogtreecommitdiffstats
path: root/x11vnc/scan.c
diff options
context:
space:
mode:
authorrunge <runge>2008-10-19 16:16:41 +0000
committerrunge <runge>2008-10-19 16:16:41 +0000
commit1c03dd4d51a35103e93c3adaf1f619c868324c77 (patch)
treeacbd2c41501e1c491023ab36717febdab32aff03 /x11vnc/scan.c
parent16c7ea1b357ab518ee5a40f2a663843f064479a9 (diff)
downloadlibvncserver-1c03dd4d51a35103e93c3adaf1f619c868324c77.zip
libvncserver-1c03dd4d51a35103e93c3adaf1f619c868324c77.tar.gz
x11vnc: -chatwindow, -scale WxH, -enc changes.
Diffstat (limited to 'x11vnc/scan.c')
-rw-r--r--x11vnc/scan.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/x11vnc/scan.c b/x11vnc/scan.c
index 33a983e..a89e1c8 100644
--- a/x11vnc/scan.c
+++ b/x11vnc/scan.c
@@ -24,7 +24,7 @@ void free_tiles(void);
void shm_delete(XShmSegmentInfo *shm);
void shm_clean(XShmSegmentInfo *shm, XImage *xim);
void initialize_polling_images(void);
-void scale_rect(double factor, int blend, int interpolate, int Bpp,
+void scale_rect(double factor_x, double factor_y, int blend, int interpolate, int Bpp,
char *src_fb, int src_bytes_per_line, char *dst_fb, int dst_bytes_per_line,
int Nx, int Ny, int nx, int ny, int X1, int Y1, int X2, int Y2, int mark);
void scale_and_mark_rect(int X1, int Y1, int X2, int Y2, int mark);
@@ -428,7 +428,7 @@ void initialize_polling_images(void) {
if (! shm_create(&fullscreen_shm, &fullscreen, dpy_x,
dpy_y/fs_factor, "fullscreen")) {
clean_up_exit(1);
- }
+ }
}
if (use_snapfb) {
if (! fs_factor) {
@@ -437,7 +437,7 @@ void initialize_polling_images(void) {
} else if (! shm_create(&snaprect_shm, &snaprect, dpy_x,
dpy_y/fs_factor, "snaprect")) {
clean_up_exit(1);
- }
+ }
}
/*
@@ -737,7 +737,7 @@ weights for this scaled pixel are:
* the loop over the 4 pixels.
*/
-void scale_rect(double factor, int blend, int interpolate, int Bpp,
+void scale_rect(double factor_x, double factor_y, int blend, int interpolate, int Bpp,
char *src_fb, int src_bytes_per_line, char *dst_fb, int dst_bytes_per_line,
int Nx, int Ny, int nx, int ny, int X1, int Y1, int X2, int Y2, int mark) {
/*
@@ -773,7 +773,7 @@ void scale_rect(double factor, int blend, int interpolate, int Bpp,
int b, k;
double pixave[4]; /* for averaging pixel values */
- if (factor <= 1.0) {
+ if (factor_x <= 1.0 && factor_y <= 1.0) {
shrink = 1;
} else {
shrink = 0;
@@ -787,8 +787,8 @@ void scale_rect(double factor, int blend, int interpolate, int Bpp,
* This new way is probably the best we can do, take the inverse
* of the scaling factor to double precision.
*/
- dx = 1.0/factor;
- dy = 1.0/factor;
+ dx = 1.0/factor_x;
+ dy = 1.0/factor_y;
/*
* There is some speedup if the pixel weights are constant, so
@@ -797,15 +797,18 @@ void scale_rect(double factor, int blend, int interpolate, int Bpp,
* If scale = 1/n and n divides Nx and Ny, the pixel weights
* are constant (e.g. 1/2 => equal on 2x2 square).
*/
- if (factor != last_factor || Nx != last_Nx || Ny != last_Ny) {
+ if (factor_x != last_factor || Nx != last_Nx || Ny != last_Ny) {
constant_weights = -1;
mag_int = -1;
last_Nx = Nx;
last_Ny = Ny;
- last_factor = factor;
+ last_factor = factor_x;
}
+ if (constant_weights < 0 && factor_x != factor_y) {
+ constant_weights = 0;
+ mag_int = 0;
- if (constant_weights < 0) {
+ } else if (constant_weights < 0) {
int n = 0;
constant_weights = 0;
@@ -814,7 +817,7 @@ void scale_rect(double factor, int blend, int interpolate, int Bpp,
for (i = 2; i<=128; i++) {
double test = ((double) 1)/ i;
double diff, eps = 1.0e-7;
- diff = factor - test;
+ diff = factor_x - test;
if (-eps < diff && diff < eps) {
n = i;
break;
@@ -839,18 +842,18 @@ void scale_rect(double factor, int blend, int interpolate, int Bpp,
for (i = 2; i<=32; i++) {
double test = (double) i;
double diff, eps = 1.0e-7;
- diff = factor - test;
+ diff = factor_x - test;
if (-eps < diff && diff < eps) {
n = i;
break;
}
}
- if (! blend && factor > 1.0 && n) {
+ if (! blend && factor_x > 1.0 && n) {
mag_int = n;
}
}
- if (mark && factor > 1.0 && blend) {
+ if (mark && factor_x > 1.0 && blend) {
/*
* kludge: correct for interpolating blurring leaking
* up or left 1 destination pixel.
@@ -1296,7 +1299,7 @@ void scale_and_mark_rect(int X1, int Y1, int X2, int Y2, int mark) {
dst_fb = rfb_fb;
dst_bpl = rfb_bytes_per_line;
- scale_rect(scale_fac, scaling_blend, scaling_interpolate, fac * Bpp,
+ scale_rect(scale_fac_x, scale_fac_y, scaling_blend, scaling_interpolate, fac * Bpp,
src_fb, fac * main_bytes_per_line, dst_fb, dst_bpl, dpy_x, dpy_y,
scaled_x, scaled_y, X1, Y1, X2, Y2, mark);
}
@@ -2623,7 +2626,7 @@ static void nap_set(int tile_cnt) {
if (! nap_ok && client_count) {
if(now > last_fb_bytes_sent + no_fbu_blank) {
if (debug_tiles > 1) {
- printf("nap_set: nap_ok=1: now: %d last: %d\n",
+ fprintf(stderr, "nap_set: nap_ok=1: now: %d last: %d\n",
(int) now, (int) last_fb_bytes_sent);
}
nap_ok = 1;
@@ -2683,10 +2686,16 @@ static void nap_check(int tile_cnt) {
dt_fbu = (int) (now - last_fb_bytes_sent);
if (dt_fbu > screen_blank) {
/* sleep longer for no fb requests */
+ if (debug_tiles > 1) {
+ fprintf(stderr, "screen blank sleep1: %d ms / 16\n", 2 * ms);
+ }
nap_sleep(2 * ms, 16);
return;
}
if (dt_ev > screen_blank) {
+ if (debug_tiles > 1) {
+ fprintf(stderr, "screen blank sleep2: %d ms / 8\n", ms);
+ }
nap_sleep(ms, 8);
return;
}
@@ -2699,6 +2708,9 @@ static void nap_check(int tile_cnt) {
} else if (now - last_local_input <= 3) {
nap_ok = 0;
} else {
+ if (debug_tiles > 1) {
+ fprintf(stderr, "nap_check sleep: %d ms / 1\n", ms);
+ }
nap_sleep(ms, 1);
}
}
OpenPOWER on IntegriCloud