changeset 1105:1b3e295f3acb

Add a dummy image loader. It is used with --with-image-loader=dummy of configure. It is a dummy image load that always abort the program when the program try to load or free an image. This module can be used for early stage of a new platform backend.
author Thinker K.F. Li <thinker@codemud.net>
date Sun, 05 Dec 2010 21:04:12 +0800
parents 9d52dda8d49f
children b5145de15ace
files configure.ac include/mb_config.h.in src/Makefile.am src/img_ldr_dummy.c
diffstat 4 files changed, 55 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Sun Dec 05 14:27:17 2010 +0800
+++ b/configure.ac	Sun Dec 05 21:04:12 2010 +0800
@@ -105,7 +105,7 @@
 	[case "${withval}" in
 	    ('cairo') image_loader="cairo" ;;
 	    ('imlib2') image_loader="imlib2" ;;
-	    ('no') image_loader="none" ;;
+	    ('dummy') image_loader="dummy" ;;
 	    (*) AC_MSG_ERROR([bad value ${withval} for --with-image-loader])
 	    	;;
 	esac], [image_loader="cairo"])
@@ -123,7 +123,7 @@
 
 # Validate options
 [case "${backend}-${graphic_engine}-${image_loader}" in
-    X-cairo-*|X-openvg-imlib2) ;;
+    X-cairo-*|X-openvg-imlib2|X-openvg-dummy) ;;
     dfb-cairo-*) ;;
     none-*-*) ;;
     *)] AC_MSG_ERROR([The combination of --with-backend=${backend}, --with-graphic-engine=${graphic_engine} and --with-image-loader=${image_loader} is invalid]) [;;
@@ -202,6 +202,13 @@
     AC_DEFINE([IMLIB2_IMG_LOADER])
 [fi]
 
+AM_CONDITIONAL([DUMMY_IMG_LOADER],
+	[test x"${image_loader}" = x"dummy"])
+
+[if [ x"${image_loader}" = x"dummy" ]; then]
+    AC_DEFINE([DUMMY_IMG_LOADER])
+[fi]
+
 AM_CONDITIONAL([XSHM],
 	[test x"${xshm}" = xtrue -a x"${graphic_engine}" = x"cairo" -a x$backend = x'X'])
 
@@ -252,6 +259,7 @@
 AH_TEMPLATE([DFB_GRAPH_ENGINE], [Enable DirectFB Graphic Engine])
 AH_TEMPLATE([CAIRO_IMG_LOADER], [Enable Cairo Image Loader])
 AH_TEMPLATE([IMLIB2_IMG_LOADER], [Enable Imlib2 Image Loader])
+AH_TEMPLATE([DUMMY_IMG_LOADER], [Enable Dummy Image Loader])
 AH_TEMPLATE([X_BACKEND], [Enable X backend])
 AH_TEMPLATE([DFB_BACKEND], [Enable DirectFB backend])
 AH_TEMPLATE([XSHM], [Enable XSHM])
--- a/include/mb_config.h.in	Sun Dec 05 14:27:17 2010 +0800
+++ b/include/mb_config.h.in	Sun Dec 05 21:04:12 2010 +0800
@@ -21,6 +21,9 @@
 /* Enable Imlib2 Image Loader */
 #undef IMLIB2_IMG_LOADER
 
+/* Enable Dummy Image Loader */
+#undef DUMMY_IMG_LOADER
+
 /* Enable sh_text */
 #undef SH_TEXT
 
--- a/src/Makefile.am	Sun Dec 05 14:27:17 2010 +0800
+++ b/src/Makefile.am	Sun Dec 05 21:04:12 2010 +0800
@@ -56,6 +56,10 @@
 libmbfly_la_LDFLAGS += @imlib2_LIBS@
 endif
 
+if DUMMY_IMG_LOADER
+libmbfly_la_SOURCES += img_ldr_dummy.c
+endif
+
 if CAIRO_GRAPH_ENGINE
 libmbfly_la_SOURCES += graph_engine_cairo.c
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/img_ldr_dummy.c	Sun Dec 05 21:04:12 2010 +0800
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include "mb_img_ldr.h"
+
+static mb_img_data_t *img_ldr_dummy_load(mb_img_ldr_t *ldr,
+					 const char *img_id);
+static void img_ldr_dummy_free(mb_img_ldr_t *ldr);
+
+static mb_img_ldr_t img_ldr = {
+    img_ldr_dummy_load,
+    img_ldr_dummy_free
+};
+
+#ifndef ERR
+#include <stdio.h>
+#include <stdlib.h>
+#define ERR(msg) do { fprintf(stderr, __FILE__ ":%d: %s", __LINE__, msg); abort(); } while(0)
+#endif
+#ifndef NOT_IMPLEMENT
+#define NOT_IMPLEMENT(func)			\
+    ERR(func " is not impmemented\n")
+#endif
+
+static mb_img_data_t *
+img_ldr_dummy_load(mb_img_ldr_t *ldr, const char *img_id) {
+    NOT_IMPLEMENT("img_ldr_dummy_load");
+    return NULL;
+}
+
+static void
+img_ldr_dummy_free(mb_img_ldr_t *ldr) {
+    NOT_IMPLEMENT("img_ldr_dummy_free");
+}
+
+mb_img_ldr_t *
+simple_mb_img_ldr_new(const char *img_repository) {
+    return &img_ldr;
+}
+