[beast/devel: 7/16] SFIDL: disabled BBlock use in IDL files



commit dd8e92167626433fde40a86e6ca5edb604ecb0cc
Author: Tim Janik <timj gnu org>
Date:   Tue Dec 25 20:28:49 2012 +0100

    SFIDL: disabled BBlock use in IDL files

 beast-gtk/bstcanvassource.cc |    7 ++++---
 beast-gtk/bstsnetrouter.cc   |   10 ++++++----
 beast-gtk/bstutils.cc        |   10 ++++++----
 bse/bsecore.idl              |   12 +++++++-----
 bse/bseutils.cc              |   17 +++++++++++------
 sfi/sfidl-parser.cc          |    2 +-
 tests/bse/testplugin.idl     |    2 +-
 7 files changed, 36 insertions(+), 24 deletions(-)
---
diff --git a/beast-gtk/bstcanvassource.cc b/beast-gtk/bstcanvassource.cc
index 98c825a..c693ef6 100644
--- a/beast-gtk/bstcanvassource.cc
+++ b/beast-gtk/bstcanvassource.cc
@@ -506,12 +506,13 @@ bst_canvas_icon_set (GnomeCanvasItem *item,
 {
   GdkPixbuf *pixbuf;
   gboolean need_unref = FALSE;
-  if (icon && icon->pixels->bytes)
+  if (icon && icon->pixel_seq->n_pixels)
     {
+      g_assert (icon->width * icon->height == int (icon->pixel_seq->n_pixels));
       icon = bse_icon_copy_shallow (icon);
-      pixbuf = gdk_pixbuf_new_from_data (icon->pixels->bytes, GDK_COLORSPACE_RGB, icon->bytes_per_pixel == 4,
+      pixbuf = gdk_pixbuf_new_from_data ((guchar*) icon->pixel_seq->pixels, GDK_COLORSPACE_RGB, true,
 					 8, icon->width, icon->height,
-					 icon->width * icon->bytes_per_pixel,
+					 icon->width * 4,
 					 NULL, NULL);
       g_object_set_data_full (G_OBJECT (pixbuf),
 			      "BseIcon",
diff --git a/beast-gtk/bstsnetrouter.cc b/beast-gtk/bstsnetrouter.cc
index 6d8e9d5..401ea3c 100644
--- a/beast-gtk/bstsnetrouter.cc
+++ b/beast-gtk/bstsnetrouter.cc
@@ -985,10 +985,12 @@ bst_snet_router_init (BstSNetRouter      *self)
         const gchar *stock_id;
         if (cat->icon)
           {
-            bst_stock_register_icon (cat->category, cat->icon->bytes_per_pixel,
-                                     cat->icon->width, cat->icon->height,
-                                     cat->icon->width * cat->icon->bytes_per_pixel,
-                                     cat->icon->pixels->bytes);
+            BseIcon *icon = cat->icon;
+            g_assert (icon->width * icon->height == int (icon->pixel_seq->n_pixels));
+            bst_stock_register_icon (cat->category, 4,
+                                     icon->width, icon->height,
+                                     icon->width * 4,
+                                     (guchar*) icon->pixel_seq->pixels);
             stock_id = cat->category;
           }
         else
diff --git a/beast-gtk/bstutils.cc b/beast-gtk/bstutils.cc
index 064403c..1099a3b 100644
--- a/beast-gtk/bstutils.cc
+++ b/beast-gtk/bstutils.cc
@@ -459,10 +459,12 @@ bst_action_list_add_cat (GxkActionList          *alist,
   const gchar *p, *stock_id;
   if (cat->icon)
     {
-      bst_stock_register_icon (cat->category, cat->icon->bytes_per_pixel,
-                               cat->icon->width, cat->icon->height,
-                               cat->icon->width * cat->icon->bytes_per_pixel,
-                               cat->icon->pixels->bytes);
+      BseIcon *icon = cat->icon;
+      g_assert (icon->width * icon->height == int (icon->pixel_seq->n_pixels));
+      bst_stock_register_icon (cat->category, 4,
+                               icon->width, icon->height,
+                               icon->width * 4,
+                               (guchar*) icon->pixel_seq->pixels);
       stock_id = cat->category;
     }
   else
diff --git a/bse/bsecore.idl b/bse/bsecore.idl
index c6d5ac4..7dee200 100644
--- a/bse/bsecore.idl
+++ b/bse/bsecore.idl
@@ -567,13 +567,15 @@ record NoteSequence
   Int     offset = Note ("Note Offset", "Center/base note", KAMMER_NOTE, ":readwrite");
   NoteSeq notes  = ("Notes", "Sequence of notes", ":readwrite");
 };
+sequence PixelSeq {
+  Int	pixels;
+};
 record Icon
 {
-  Info   blurb           = "BSE icon representation.";
-  Int    bytes_per_pixel = ("Bytes Per Pixel", "Bytes Per Pixel (3:RGB, 4:RGBA, 0:NONE)", 4, 3, 4, 1, ":readwrite");
-  Int    width           = ("Width", "Width in pixels or 0 for no icon", 0, 0, MAXINT, 1, ":readwrite");
-  Int    height          = ("Height", "Height in pixels or 0 for no icon", 0, 0, MAXINT, 1, ":readwrite");
-  BBlock pixels          = ("Pixels", "Pixel array of width*height*bytes_per_pixel bytes", ":readwrite");
+  Info     blurb     = "BSE icon representation.";
+  Int      width     = ("Width", "Width in pixels or 0 for no icon", 0, 0, MAXINT, 1, ":readwrite");
+  Int      height    = ("Height", "Height in pixels or 0 for no icon", 0, 0, MAXINT, 1, ":readwrite");
+  PixelSeq pixel_seq = ("Pixels", "Pixel array of width*height ARGB pixels", ":readwrite");
 };
 record Category
 {
diff --git a/bse/bseutils.cc b/bse/bseutils.cc
index 280c79a..c881eef 100644
--- a/bse/bseutils.cc
+++ b/bse/bseutils.cc
@@ -265,14 +265,13 @@ bse_icon_from_pixdata (const BsePixdata *pixdata)
   if (!pixdata->encoded_pix_data)
     return NULL;
   icon = bse_icon_new ();
-  icon->bytes_per_pixel = bpp;
   icon->width = pixdata->width;
   icon->height = pixdata->height;
-  sfi_bblock_resize (icon->pixels, icon->width * icon->height * icon->bytes_per_pixel);
+  bse_pixel_seq_resize (icon->pixel_seq, icon->width * icon->height);
+  guint8 *image_buffer = (guint8*) icon->pixel_seq->pixels;
   if (encoding == BSE_PIXDATA_1BYTE_RLE)
     {
       const guint8 *rle_buffer = pixdata->encoded_pix_data;
-      guint8 *image_buffer = icon->pixels->bytes;
       guint8 *image_limit = image_buffer + icon->width * icon->height * bpp;
       while (image_buffer < image_limit)
 	{
@@ -288,7 +287,8 @@ bse_icon_from_pixdata (const BsePixdata *pixdata)
 		do
 		  {
 		    memcpy (image_buffer, rle_buffer, 3);
-		    image_buffer += 3;
+                    image_buffer[3] = 0xff;
+		    image_buffer += 4;
 		  }
 		while (--length);
 	      else
@@ -306,7 +306,12 @@ bse_icon_from_pixdata (const BsePixdata *pixdata)
 	      check_overrun = image_buffer + length > image_limit;
 	      if (check_overrun)
 		length = image_limit - image_buffer;
-	      memcpy (image_buffer, rle_buffer, length);
+              for (uint i = 0; i < length / bpp; i++)
+                {
+                  memcpy (image_buffer + i * 4, rle_buffer + i * bpp, bpp);
+                  if (bpp == 3)
+                    *(image_buffer + i * 4 + 3) = 0xff;
+                }
 	      image_buffer += length;
 	      rle_buffer += length;
 	    }
@@ -315,7 +320,7 @@ bse_icon_from_pixdata (const BsePixdata *pixdata)
         }
     }
   else
-    memcpy (icon->pixels->bytes, pixdata->encoded_pix_data, icon->width * icon->height * bpp);
+    memcpy (image_buffer, pixdata->encoded_pix_data, icon->width * icon->height * bpp);
   return icon;
 }
 static inline const guint8 *
diff --git a/sfi/sfidl-parser.cc b/sfi/sfidl-parser.cc
index 59aa5dc..2b4289e 100644
--- a/sfi/sfidl-parser.cc
+++ b/sfi/sfidl-parser.cc
@@ -742,7 +742,7 @@ bool Parser::parse (const String& filename)
   defineSymbol ("Num");
   defineSymbol ("Real");
   defineSymbol ("String");
-  defineSymbol ("BBlock");
+  // deprecated: defineSymbol ("BBlock");
   defineSymbol ("FBlock");
   defineSymbol ("Rec");
   leaveNamespace ();
diff --git a/tests/bse/testplugin.idl b/tests/bse/testplugin.idl
index e58e972..512c747 100644
--- a/tests/bse/testplugin.idl
+++ b/tests/bse/testplugin.idl
@@ -26,7 +26,7 @@ interface TestObject : Bse::Effect {
   property Int aninteger;
   property TestRecord r;
   property TestSequence s;
-  property BBlock bb;
+  // deprecated: property BBlock bb;
   property FBlock fb;
   property Rec rr;
   property Bse::Effect ef; // C++ Object 



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