update [LV2] Plugin Inline Display API: drop cairo dependency
authorRobin Gareus <robin@gareus.org>
Mon, 14 Mar 2016 15:44:20 +0000 (16:44 +0100)
committerRobin Gareus <robin@gareus.org>
Mon, 14 Mar 2016 15:45:27 +0000 (16:45 +0100)
libs/ardour/ardour/lv2_extensions.h
libs/ardour/ardour/lv2_plugin.h
libs/ardour/ardour/plugin.h
libs/ardour/lv2_plugin.cc

index 5fd69cfe997cf051ae2e4fc73b417876e5c38e88..139e1a6594436710848634e43086b5cc9f5388c6 100644 (file)
 /** Opaque handle for LV2_Inline_Display::queue_draw() */
 typedef void* LV2_Inline_Display_Handle;
 
-/** Alias for cairo_image_surface_t */
-typedef void* LV2_Inline_Display_Image_Surface;
+/** raw image pixmap format is ARGB32,
+ * the data pointer is owned by the plugin and must be valid
+ * from the first call to render until cleanup.
+ */
+typedef struct {
+       unsigned char *data;
+       int width;
+       int height;
+       int stride;
+} LV2_Inline_Display_Image_Surface;
 
+/** a LV2 Feature provided by the Host to the plugin */
 typedef struct {
        /** Opaque host data */
        LV2_Inline_Display_Handle handle;
-       /** Request from run() that the host should call render() */
+       /** Request from run() that the host should call render() at a later time
+        * to update the inline display */
        void (*queue_draw)(LV2_Inline_Display_Handle handle);
 } LV2_Inline_Display;
 
@@ -53,12 +63,15 @@ typedef struct {
        /**
         * The render method. This is called by the host in a non-realtime context,
         * usually the main GUI thread.
+        * The data pointer is owned by the plugin and must be valid
+        * from the first call to render until cleanup.
         *
         * @param instance The LV2 instance
         * @param w the max available width
-        * @return pointer to a cairo image surface or NULL
+        * @param h the max available height
+        * @return pointer to a LV2_Inline_Display_Image_Surface or NULL
         */
-       LV2_Inline_Display_Image_Surface (*render)(LV2_Handle instance, uint32_t w, uint32_t h);
+       LV2_Inline_Display_Image_Surface* (*render)(LV2_Handle instance, uint32_t w, uint32_t h);
 } LV2_Inline_Display_Interface;
 
 /**
index 020cddf34be7fddcc54a7f33d4e943ded873a53a..936fd9019f6b03e14393008140fa6a5f564ac82d 100644 (file)
@@ -301,7 +301,7 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
 
 #ifdef LV2_EXTENDED
        bool has_inline_display ();
-       void* render_inline_display (uint32_t, uint32_t);
+       Plugin::Display_Image_Surface* render_inline_display (uint32_t, uint32_t);
 #endif
 
        void latency_compute_run ();
index 17ac4e04d9dd41c993bcb2836d0cd2c85af05679..084f5a876d03d611d7876aae94d1671c7ade909e 100644 (file)
@@ -111,8 +111,15 @@ class LIBARDOUR_API Plugin : public PBD::StatefulDestructible, public Latent
        void realtime_locate ();
        void monitoring_changed ();
 
+       typedef struct {
+               unsigned char *data;
+               int width;
+               int height;
+               int stride;
+       } Display_Image_Surface;
+
        virtual bool has_inline_display () { return false; }
-       virtual void* render_inline_display (uint32_t, uint32_t) { return NULL; }
+       virtual Display_Image_Surface* render_inline_display (uint32_t, uint32_t) { return NULL; }
        PBD::Signal0<void> QueueDraw;
 
        struct PresetRecord {
index 8283062f3f1db3d112c36162b150da8afb857326..1f0e20f779fed485261f88f5faa1ba01ddee5ecd 100644 (file)
@@ -866,10 +866,12 @@ LV2Plugin::has_inline_display () {
        return _display_interface ? true : false;
 }
 
-void*
+Plugin::Display_Image_Surface*
 LV2Plugin::render_inline_display (uint32_t w, uint32_t h) {
        if (_display_interface) {
-               return _display_interface->render ((void*)_impl->instance->lv2_handle, w, h);
+               /* Plugin::Display_Image_Surface is identical to
+                * LV2_Inline_Display_Image_Surface */
+               return (Plugin::Display_Image_Surface*) _display_interface->render ((void*)_impl->instance->lv2_handle, w, h);
        }
        return NULL;
 }