changeset 603:39d27911c3ae openvg

Remove mbe_image_surface_create_for_data()
author Thinker K.F. Li <thinker@branda.to>
date Sun, 04 Jul 2010 00:16:43 +0800
parents ac2e6468a22a
children 38514a7c6b26
files configure.ac include/mb_graph_engine_cairo.h include/mb_graph_engine_dummy.h include/mb_graph_engine_openvg.h include/mb_graph_engine_skia.h src/graph_engine_skia.cpp
diffstat 6 files changed, 27 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Fri Jul 02 13:42:22 2010 +0800
+++ b/configure.ac	Sun Jul 04 00:16:43 2010 +0800
@@ -135,11 +135,11 @@
 AC_CHECK_HEADERS([GL/glut.h],, [AC_MSG_ERROR([can not find GL/glut.h])])
 [fi]
 
+PKG_CHECK_MODULES([imlib2], [imlib2 >= 1.4.1], , AC_MSG_ERROR([imlib2 >= 1.4.1 not found]))
 [if [ x"${cairo}" = xtrue ]; then]
 PKG_CHECK_MODULES([cairo], [cairo >= 1.6], , AC_MSG_ERROR([cairo >= 1.6 not found]))
 PKG_CHECK_MODULES([pangocairo], [pangocairo >= 1.0], , AC_MSG_ERROR([pangocairo >= 1.0 not found]))
 [fi]
-PKG_CHECK_MODULES([imlib2], [imlib2 >= 1.4.1], , AC_MSG_ERROR([imlib2 >= 1.4.1 not found]))
 
 AC_CONFIG_FILES([Makefile
                  libmbfly.pc
--- a/include/mb_graph_engine_cairo.h	Fri Jul 02 13:42:22 2010 +0800
+++ b/include/mb_graph_engine_cairo.h	Sun Jul 04 00:16:43 2010 +0800
@@ -137,33 +137,6 @@
     return scaled;
 }
 
-static mbe_surface_t *
-mbe_image_surface_create_for_data(unsigned char *data,
-				  mb_img_fmt_t fmt,
-				  int width, int height,
-				  int stride) {
-    cairo_format_t _fmt;
-    
-    switch(fmt) {
-    case MB_IFMT_ARGB32:
-	_fmt = CAIRO_FORMAT_ARGB32;
-	break;
-    case MB_IFMT_RGB24:
-	_fmt = CAIRO_FORMAT_RGB24;
-	break;
-    case MB_IFMT_A8:
-	_fmt = CAIRO_FORMAT_A8;
-	break;
-    case MB_IFMT_A1:
-	_fmt = CAIRO_FORMAT_A1;
-	break;
-    default:
-	return NULL;
-    }
-    return cairo_image_surface_create_for_data(data, _fmt,
-					       width, height, stride);
-}
-
 static mb_img_fmt_t
 mbe_image_surface_get_format(mbe_surface_t *surface) {
     cairo_format_t _fmt;
--- a/include/mb_graph_engine_dummy.h	Fri Jul 02 13:42:22 2010 +0800
+++ b/include/mb_graph_engine_dummy.h	Sun Jul 04 00:16:43 2010 +0800
@@ -11,8 +11,6 @@
 /*! \defgroup mb_ge_cairo MadButterfly Graphic Engine with Cairo
  * @{
  */
-#define mbe_image_surface_create_for_data(data, fmt, w, h, stride)	\
-    ((mbe_surface_t *)NULL)
 #define mbe_pattern_create_for_surface(canvas) ((mbe_pattern_t *)NULL)
 #define mbe_scaled_font_text_extents(scaled, utf8, extents)
 #define mbe_image_surface_get_stride(surface) (20)
--- a/include/mb_graph_engine_openvg.h	Fri Jul 02 13:42:22 2010 +0800
+++ b/include/mb_graph_engine_openvg.h	Sun Jul 04 00:16:43 2010 +0800
@@ -11,8 +11,6 @@
 /*! \defgroup mb_ge_cairo MadButterfly Graphic Engine with Cairo
  * @{
  */
-#define mbe_image_surface_create_for_data(data, fmt, w, h, stride)	\
-    ((mbe_surface_t *)NULL)
 #define mbe_pattern_create_for_surface(canvas) ((mbe_pattern_t *)NULL)
 #define mbe_scaled_font_text_extents(scaled, utf8, extents)
 #define mbe_image_surface_get_stride(surface) (20)
@@ -71,6 +69,7 @@
 typedef struct _ge_openvg_surface mbe_surface_t;
 typedef struct _ge_openvg_pattern mbe_pattern_t;
 typedef struct _ge_openvg_mbe mbe_t;
+typedef struct _ge_openvg_img _ge_openvg_img_t;
 
 struct _mbe_text_extents_t {
     co_aix x_bearing;
@@ -95,15 +94,35 @@
     void *surface;
     mbe_t *asso_mbe;		/* There is a association between
 				 * surface and mbe */
+    _ge_openvg_img_t *asso_img;
     int w, h;
 };
 
 struct _ge_openvg_pattern {
-    void *pattern;
-    void *asso_img;
+    _ge_openvg_img_t *asso_img;
     VGPaint paint;
 };
 
+/*! \brief Information associated with VGImage.
+ *
+ * A VGImage can associated one of pattern or surface.  This type is
+ * used to make sure previous associated pattern or surface being
+ * released before new association.
+ *
+ * Functions must release assocation specified by
+ * _ge_openvg_img::asso_pattern or _ge_openvg_img::asso_surface before
+ * new association, and record new association as one of thes two
+ * vairables.
+ *
+ * \sa _ge_openvg_img_t
+ * \note This is type is for internal using of OpenVG graphic engine.
+ */
+struct _ge_openvg_img {
+    VGImage img;
+    mbe_pattern_t *asso_pattern;
+    mbe_surface_t *asso_surface;
+};
+
 #define MB_MATRIX_2_OPENVG(vgmtx, mtx) do {	\
 	(vgmtx)[0] = (mtx)[0];			\
 	(vgmtx)[1] = (mtx)[1];			\
@@ -171,6 +190,9 @@
     
     if(surface->asso_mbe)
 	surface->asso_mbe->tgt = NULL;
+
+    if(surface->asso_img)
+	surface->asso_img->asso_surface = NULL;
     
     free(surface);
 }
--- a/include/mb_graph_engine_skia.h	Fri Jul 02 13:42:22 2010 +0800
+++ b/include/mb_graph_engine_skia.h	Sun Jul 04 00:16:43 2010 +0800
@@ -50,10 +50,6 @@
 extern int mbe_image_surface_get_width(mbe_surface_t *surface);
 extern unsigned char *mbe_image_surface_get_data(mbe_surface_t *surface);
 extern mbe_surface_t *
-mbe_image_surface_create_for_data(unsigned char *data,
-				  mb_img_fmt_t fmt,
-				  int width, int height,
-				  int stride);
 extern mb_img_fmt_t mbe_image_surface_get_format(mbe_surface_t *surface);
 extern mbe_surface_t *
 mbe_image_surface_create(mb_img_fmt_t fmt, int width, int height);
--- a/src/graph_engine_skia.cpp	Fri Jul 02 13:42:22 2010 +0800
+++ b/src/graph_engine_skia.cpp	Sun Jul 04 00:16:43 2010 +0800
@@ -386,42 +386,6 @@
     return (unsigned char *)((SkBitmap *)surface)->getPixels();
 }
 
-mbe_surface_t *
-mbe_image_surface_create_for_data(unsigned char *data,
-				  mb_img_fmt_t fmt,
-				  int width, int height,
-				  int stride) {
-    SkBitmap *bitmap;
-    SkBitmap::Config cfg;
-
-    switch(fmt) {
-    case MB_IFMT_ARGB32:
-	cfg = SkBitmap::kARGB_8888_Config; break;
-	
-    case MB_IFMT_A8:
-	cfg = SkBitmap::kA8_Config; break;
-	
-    case MB_IFMT_A1:
-	cfg = SkBitmap::kA1_Config; break;
-	
-    case MB_IFMT_RGB16_565:
-	cfg = SkBitmap::kRGB_565_Config; break;
-	
-    case MB_IFMT_RGB24:
-    default:
-	return NULL;
-    }
-    
-    bitmap = new SkBitmap();
-    if(bitmap == NULL)
-	return NULL;
-    
-    bitmap->setConfig(cfg, width, height, stride);
-    bitmap->setPixels(data);
-
-    return (mbe_surface_t *)bitmap;
-}
-
 mb_img_fmt_t mbe_image_surface_get_format(mbe_surface_t *surface) {
     SkBitmap *bitmap = (SkBitmap *)surface;
     mb_img_fmt_t fmt;