[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 17/18] vnc: tight: split send_sub_rect
From: |
Corentin Chary |
Subject: |
[Qemu-devel] [PATCH v2 17/18] vnc: tight: split send_sub_rect |
Date: |
Wed, 7 Jul 2010 20:58:05 +0200 |
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 <address@hidden>
---
ui/vnc-enc-tight.c | 80 +++++++++++++++++++++++++++++++++++----------------
1 files changed, 55 insertions(+), 25 deletions(-)
diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index eaa88ce..86bb49a 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -1452,34 +1452,39 @@ static void vnc_tight_stop(VncState *vs)
vs->output = vs->tight.tmp;
}
-static int send_sub_rect(VncState *vs, int x, int y, int w, int h)
+static int send_sub_rect_nojpeg(VncState *vs, int x, int y, int w, int h,
+ int bg, int fg, int colors, VncPalette
*palette)
{
- VncPalette *palette = NULL;
- uint32_t bg = 0, fg = 0;
- int colors;
- int ret = 0;
-
- vnc_framebuffer_update(vs, x, y, w, h, vs->tight.type);
+ int ret;
- vnc_tight_start(vs);
- vnc_raw_send_framebuffer_update(vs, x, y, w, h);
- vnc_tight_stop(vs);
+ 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;
+}
- colors = tight_fill_palette(vs, x, y, w * h, &fg, &bg, &palette);
+#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)) {
- if (vs->tight.quality == -1) {
- ret = send_gradient_rect(vs, x, y, w, h);
- } else {
-#ifdef CONFIG_VNC_JPEG
- int quality = tight_conf[vs->tight.quality].jpeg_quality;
+ 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);
-#endif
- }
+ ret = send_jpeg_rect(vs, x, y, w, h, quality);
} else {
ret = send_full_color_rect(vs, x, y, w, h);
}
@@ -1488,8 +1493,7 @@ static int send_sub_rect(VncState *vs, int x, int y, int
w, int h)
} 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 &&
+ if (colors > 96 &&
tight_detect_smooth_image(vs, w, h)) {
int quality = tight_conf[vs->tight.quality].jpeg_quality;
@@ -1497,10 +1501,36 @@ static int send_sub_rect(VncState *vs, int x, int y,
int w, int h)
} else {
ret = send_palette_rect(vs, x, y, w, h, palette);
}
-#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)
+{
+ VncPalette *palette = NULL;
+ uint32_t bg = 0, fg = 0;
+ int colors;
+ int ret = 0;
+
+ vnc_framebuffer_update(vs, x, y, w, h, vs->tight.type);
+
+ vnc_tight_start(vs);
+ vnc_raw_send_framebuffer_update(vs, x, y, w, h);
+ vnc_tight_stop(vs);
+
+ colors = tight_fill_palette(vs, x, y, w * h, &fg, &bg, &palette);
+
+#ifdef CONFIG_VNC_JPEG
+ if (vs->tight.quality != -1) {
+ ret = send_sub_rect_jpeg(vs, x, y, w, h, bg, fg, colors, palette);
+ } else {
+ ret = send_sub_rect_nojpeg(vs, x, y, w, h, bg, fg, colors, palette);
}
+#else
+ ret = send_sub_rect_nojpeg(vs, x, y, w, h, bg, fg, colors, palette);
+#endif
+
palette_destroy(palette);
return ret;
}
--
1.7.1
- [Qemu-devel] [PATCH v2 02/18] vnc: JPEG should be disabled if the client don't set tight quality, (continued)
- [Qemu-devel] [PATCH v2 02/18] vnc: JPEG should be disabled if the client don't set tight quality, Corentin Chary, 2010/07/07
- [Qemu-devel] [PATCH v2 05/18] vnc: rename vnc-encoding-* vnc-enc-*, Corentin Chary, 2010/07/07
- [Qemu-devel] [PATCH v2 04/18] ui: move all ui components in ui/, Corentin Chary, 2010/07/07
- [Qemu-devel] [PATCH v2 07/18] vnc: tight: remove a memleak in send_jpeg_rect(), Corentin Chary, 2010/07/07
- [Qemu-devel] [PATCH v2 01/18] vnc: tight: add JPEG and gradient subencoding with smooth image detection, Corentin Chary, 2010/07/07
- [Qemu-devel] [PATCH v2 09/18] vnc: tight: specific zlib level and filters for each compression level, Corentin Chary, 2010/07/07
- [Qemu-devel] [PATCH v2 12/18] vnc: fix tight png memory leak, Corentin Chary, 2010/07/07
- [Qemu-devel] [PATCH v2 06/18] vnc: tight: don't forget do at the last color, Corentin Chary, 2010/07/07
- [Qemu-devel] [PATCH v2 16/18] vnc: tight: fix rgb_prepare_row, Corentin Chary, 2010/07/07
- [Qemu-devel] [PATCH v2 10/18] vnc: tight: stop using qdict for palette stuff, Corentin Chary, 2010/07/07
- [Qemu-devel] [PATCH v2 17/18] vnc: tight: split send_sub_rect,
Corentin Chary <=
- [Qemu-devel] [PATCH v2 13/18] qemu-thread: add qemu_mutex/cond_destroy and qemu_mutex_exit, Corentin Chary, 2010/07/07
- [Qemu-devel] [PATCH v2 18/18] vnc: better default values for VNC options, Corentin Chary, 2010/07/07
- [Qemu-devel] [PATCH v2 15/18] vnc: add missing lock for vnc_cursor_define(), Corentin Chary, 2010/07/07
- [Qemu-devel] [PATCH v2 08/18] vnc: tight add PNG encoding, Corentin Chary, 2010/07/07
[Qemu-devel] [PATCH v2 11/18] vnc: encapsulate encoding members, Corentin Chary, 2010/07/07