[gtk-vnc] Remove jpeg_render function and use gdk-pixbuf directly



commit 9b62b98ae4bdf20f4884ef63947723a5c8e45e0b
Author: Daniel P. Berrange <berrange redhat com>
Date:   Fri Nov 20 20:21:14 2009 +0000

    Remove jpeg_render function and use gdk-pixbuf directly

 src/vncconnection.c |   48 +++++++++++++++++++++++-------------------------
 src/vncconnection.h |    6 +-----
 src/vncdisplay.c    |   34 +---------------------------------
 3 files changed, 25 insertions(+), 63 deletions(-)
---
diff --git a/src/vncconnection.c b/src/vncconnection.c
index c10cae1..178143b 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -47,6 +47,7 @@
 #include "utils.h"
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
 
 #if HAVE_SASL
 #include <sasl/sasl.h>
@@ -58,7 +59,7 @@
 
 #include <zlib.h>
 
-#include <gdk/gdkkeysyms.h>
+//#include <gdk/gdkkeysyms.h>
 
 #include "getaddrinfo.h"
 #include "dh.h"
@@ -2133,26 +2134,34 @@ static void vnc_connection_tight_update_gradient(VncConnection *conn,
 	g_free(last_row);
 }
 
-static void jpeg_draw(void *opaque, int x, int y, int w, int h,
-		      guint8 *data, int stride)
-{
-	VncConnection *conn = opaque;
-	VncConnectionPrivate *priv = conn->priv;
-
-	vnc_framebuffer_rgb24_blt(priv->fb, data, stride, x, y, w, h);
-}
 
 static void vnc_connection_tight_update_jpeg(VncConnection *conn, guint16 x, guint16 y,
 					     guint16 width, guint16 height,
 					     guint8 *data, size_t length)
 {
 	VncConnectionPrivate *priv = conn->priv;
+	GdkPixbufLoader *loader = gdk_pixbuf_loader_new();
+	GdkPixbuf *p;
+	guint8 *pixels;
 
-	if (priv->ops.render_jpeg == NULL)
+	if (!gdk_pixbuf_loader_write(loader, data, length, NULL)) {
+		priv->has_error = TRUE;
 		return;
+	}
+
+	gdk_pixbuf_loader_close(loader, NULL);
+
+	p = g_object_ref(gdk_pixbuf_loader_get_pixbuf(loader));
+	g_object_unref(loader);
 
-	priv->ops.render_jpeg(priv->ops_data, jpeg_draw, conn,
-			      x, y, width, height, data, length);
+	pixels = gdk_pixbuf_get_pixels(p);
+
+	vnc_framebuffer_rgb24_blt(priv->fb,
+				  gdk_pixbuf_get_pixels(p),
+				  gdk_pixbuf_get_rowstride(p),
+				  x, y, width, height);
+
+	g_object_unref(p);
 }
 
 static void vnc_connection_tight_update(VncConnection *conn,
@@ -3977,21 +3986,10 @@ void vnc_connection_init(VncConnection *fb)
 }
 
 
-VncConnection *vnc_connection_new(const struct vnc_connection_ops *ops, gpointer ops_data)
+VncConnection *vnc_connection_new(void)
 {
-	VncConnection *conn;
-	VncConnectionPrivate *priv;
-
-	conn = VNC_CONNECTION(g_object_new(VNC_TYPE_CONNECTION,
+	return VNC_CONNECTION(g_object_new(VNC_TYPE_CONNECTION,
 					   NULL));
-
-	priv = conn->priv;
-
-	/* XXX kill this */
-	memcpy(&priv->ops, ops, sizeof(*ops));
-	priv->ops_data = ops_data;
-
-	return conn;
 }
 
 void vnc_connection_close(VncConnection *conn)
diff --git a/src/vncconnection.h b/src/vncconnection.h
index b5b52fc..6c9cd11 100644
--- a/src/vncconnection.h
+++ b/src/vncconnection.h
@@ -66,13 +66,9 @@ struct _VncConnectionClass
 	void (*vnc_auth_choose_subtype)(VncConnection *conn, unsigned int type, GValueArray *subtypes);
 };
 
-typedef void (rgb24_render_func)(void *, int, int, int, int, guint8 *, int);
-
 struct vnc_connection_ops
 {
 	gboolean (*set_color_map_entry)(void *, int, int, int, int);
-	gboolean (*render_jpeg)(void *, rgb24_render_func *render, void *,
-				int, int, int, int, guint8 *, int);
 };
 
 
@@ -145,7 +141,7 @@ typedef enum
 
 GType vnc_connection_get_type(void) G_GNUC_CONST;
 
-VncConnection *vnc_connection_new(const struct vnc_connection_ops *ops, gpointer ops_data);
+VncConnection *vnc_connection_new(void);
 
 void vnc_connection_close(VncConnection *conn);
 void vnc_connection_shutdown(VncConnection *conn);
diff --git a/src/vncdisplay.c b/src/vncdisplay.c
index f88f50b..0ced644 100644
--- a/src/vncdisplay.c
+++ b/src/vncdisplay.c
@@ -1256,38 +1256,6 @@ static gboolean check_pixbuf_support(const char *name)
 	return !!(i);
 }
 
-static gboolean on_render_jpeg(void *opaque G_GNUC_UNUSED,
-			       rgb24_render_func *render, void *render_opaque,
-			       int x, int y, int w, int h,
-			       guint8 *data, int size)
-{
-	GdkPixbufLoader *loader = gdk_pixbuf_loader_new();
-	GdkPixbuf *p;
-	guint8 *pixels;
-
-	if (!gdk_pixbuf_loader_write(loader, data, size, NULL))
-		return FALSE;
-
-	gdk_pixbuf_loader_close(loader, NULL);
-
-	p = g_object_ref(gdk_pixbuf_loader_get_pixbuf(loader));
-	g_object_unref(loader);
-
-	pixels = gdk_pixbuf_get_pixels(p);
-
-	render(render_opaque, x, y, w, h,
-	       gdk_pixbuf_get_pixels(p),
-	       gdk_pixbuf_get_rowstride(p));
-
-	g_object_unref(p);
-
-	return TRUE;
-}
-
-static const struct vnc_connection_ops vnc_display_ops = {
-	.render_jpeg = on_render_jpeg,
-};
-
 /* we use an idle function to allow the coroutine to exit before we actually
  * unref the object since the coroutine's state is part of the object */
 static gboolean delayed_unref_object(gpointer data)
@@ -1972,7 +1940,7 @@ static void vnc_display_init(VncDisplay *display)
 	 */
 	priv->preferable_auths = g_slist_append (priv->preferable_auths, GUINT_TO_POINTER (GVNC_AUTH_NONE));
 
-	priv->conn = vnc_connection_new(&vnc_display_ops, obj);
+	priv->conn = vnc_connection_new();
 
 	g_signal_connect(G_OBJECT(priv->conn), "vnc-cursor-changed",
 			 G_CALLBACK(on_cursor_changed), display);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]