mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-31 14:02:05 -06:00
vnc: tight: split send_sub_rect
Split send_sub_rect in send_sub_rect_jpeg and send_sub_rect_nojpeg to remove all these #ifdef CONFIG_JPEG. Signed-off-by: Corentin Chary <corentincj@iksaif.net> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
4043a0137b
commit
03817eb874
1 changed files with 62 additions and 32 deletions
|
@ -1452,6 +1452,60 @@ static void vnc_tight_stop(VncState *vs)
|
||||||
vs->output = vs->tight.tmp;
|
vs->output = vs->tight.tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int send_sub_rect_nojpeg(VncState *vs, int x, int y, int w, int h,
|
||||||
|
int bg, int fg, int colors, VncPalette *palette)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (colors == 0) {
|
||||||
|
if (tight_detect_smooth_image(vs, w, h)) {
|
||||||
|
ret = send_gradient_rect(vs, x, y, w, h);
|
||||||
|
} else {
|
||||||
|
ret = send_full_color_rect(vs, x, y, w, h);
|
||||||
|
}
|
||||||
|
} else if (colors == 1) {
|
||||||
|
ret = send_solid_rect(vs);
|
||||||
|
} else if (colors == 2) {
|
||||||
|
ret = send_mono_rect(vs, x, y, w, h, bg, fg);
|
||||||
|
} else if (colors <= 256) {
|
||||||
|
ret = send_palette_rect(vs, x, y, w, h, palette);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_VNC_JPEG
|
||||||
|
static int send_sub_rect_jpeg(VncState *vs, int x, int y, int w, int h,
|
||||||
|
int bg, int fg, int colors,
|
||||||
|
VncPalette *palette)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (colors == 0) {
|
||||||
|
if (tight_detect_smooth_image(vs, w, h)) {
|
||||||
|
int quality = tight_conf[vs->tight.quality].jpeg_quality;
|
||||||
|
|
||||||
|
ret = send_jpeg_rect(vs, x, y, w, h, quality);
|
||||||
|
} else {
|
||||||
|
ret = send_full_color_rect(vs, x, y, w, h);
|
||||||
|
}
|
||||||
|
} else if (colors == 1) {
|
||||||
|
ret = send_solid_rect(vs);
|
||||||
|
} else if (colors == 2) {
|
||||||
|
ret = send_mono_rect(vs, x, y, w, h, bg, fg);
|
||||||
|
} else if (colors <= 256) {
|
||||||
|
if (colors > 96 &&
|
||||||
|
tight_detect_smooth_image(vs, w, h)) {
|
||||||
|
int quality = tight_conf[vs->tight.quality].jpeg_quality;
|
||||||
|
|
||||||
|
ret = send_jpeg_rect(vs, x, y, w, h, quality);
|
||||||
|
} else {
|
||||||
|
ret = send_palette_rect(vs, x, y, w, h, palette);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int send_sub_rect(VncState *vs, int x, int y, int w, int h)
|
static int send_sub_rect(VncState *vs, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
VncPalette *palette = NULL;
|
VncPalette *palette = NULL;
|
||||||
|
@ -1467,40 +1521,16 @@ static int send_sub_rect(VncState *vs, int x, int y, int w, int h)
|
||||||
|
|
||||||
colors = tight_fill_palette(vs, x, y, w * h, &fg, &bg, &palette);
|
colors = tight_fill_palette(vs, x, y, w * h, &fg, &bg, &palette);
|
||||||
|
|
||||||
if (colors == 0) {
|
|
||||||
if (tight_detect_smooth_image(vs, w, h)) {
|
|
||||||
if (vs->tight.quality == -1) {
|
|
||||||
ret = send_gradient_rect(vs, x, y, w, h);
|
|
||||||
} else {
|
|
||||||
#ifdef CONFIG_VNC_JPEG
|
#ifdef CONFIG_VNC_JPEG
|
||||||
int quality = tight_conf[vs->tight.quality].jpeg_quality;
|
if (vs->tight.quality != -1) {
|
||||||
|
ret = send_sub_rect_jpeg(vs, x, y, w, h, bg, fg, colors, palette);
|
||||||
ret = send_jpeg_rect(vs, x, y, w, h, quality);
|
|
||||||
#else
|
|
||||||
ret = send_full_color_rect(vs, x, y, w, h);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ret = send_full_color_rect(vs, x, y, w, h);
|
ret = send_sub_rect_nojpeg(vs, x, y, w, h, bg, fg, colors, palette);
|
||||||
}
|
|
||||||
} else if (colors == 1) {
|
|
||||||
ret = send_solid_rect(vs);
|
|
||||||
} else if (colors == 2) {
|
|
||||||
ret = send_mono_rect(vs, x, y, w, h, bg, fg);
|
|
||||||
} else if (colors <= 256) {
|
|
||||||
#ifdef CONFIG_VNC_JPEG
|
|
||||||
if (colors > 96 && vs->tight.quality != -1 && vs->tight.quality <= 3 &&
|
|
||||||
tight_detect_smooth_image(vs, w, h)) {
|
|
||||||
int quality = tight_conf[vs->tight.quality].jpeg_quality;
|
|
||||||
|
|
||||||
ret = send_jpeg_rect(vs, x, y, w, h, quality);
|
|
||||||
} else {
|
|
||||||
ret = send_palette_rect(vs, x, y, w, h, palette);
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ret = send_palette_rect(vs, x, y, w, h, palette);
|
ret = send_sub_rect_nojpeg(vs, x, y, w, h, bg, fg, colors, palette);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
palette_destroy(palette);
|
palette_destroy(palette);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue