gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, openvg, updated. 72a14c765d49f465f450


From: Rob Savoye
Subject: [Gnash-commit] [SCM] Gnash branch, openvg, updated. 72a14c765d49f465f450faa3da27017bcb6827c6
Date: Mon, 27 Dec 2010 17:23:16 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, openvg has been updated
       via  72a14c765d49f465f450faa3da27017bcb6827c6 (commit)
       via  dbe19ce421773a770aa6b941877ca6a346bf4ad2 (commit)
       via  b39e768f65b52ae2c00617b57269089b31c76837 (commit)
       via  7ced366eb15fc90bc9742f3ff4a3b6ab665973ac (commit)
       via  331626f482ddae654c86a1a3fece2791fa04b54c (commit)
       via  f60fadc4e7047f40208b687db6a7b38fe3397608 (commit)
       via  b25fcfb99c955b4cfcee7657b97cf2dea2873308 (commit)
       via  a2448311a0f940481860a22db7164ba0df3a9c4b (commit)
       via  187a59c14e44776eb08efd2584221172eb7898c1 (commit)
      from  17a0b5ea7b995d5245c078a8589c8a429274340f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=72a14c765d49f465f450faa3da27017bcb6827c6


commit 72a14c765d49f465f450faa3da27017bcb6827c6
Author: Rob Savoye <address@hidden>
Date:   Mon Dec 27 10:06:31 2010 -0700

    handle multiple attributes fot the EGL configuration so they can be changed 
dynamically.

diff --git a/libdevice/egl/eglDevice.cpp b/libdevice/egl/eglDevice.cpp
index 4a8fe35..b3dc1ce 100644
--- a/libdevice/egl/eglDevice.cpp
+++ b/libdevice/egl/eglDevice.cpp
@@ -89,6 +89,16 @@ static EGLint const attrib16_list[] = {
     EGL_NONE
 };
 
+// These are the same EGL config settings as used by the Mesa
+// examples, which run on X11
+static const EGLint attrib1_list[] = {
+    EGL_RED_SIZE, 1,
+    EGL_GREEN_SIZE, 1,
+    EGL_BLUE_SIZE, 1,
+    EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
+    EGL_NONE
+};
+
 const EGLint window_attrib_list[] = {
     // Back buffering is used for window and pbuffer surfaces. Windows
     // require eglSwapBuffers() to become visible, and pbuffers don't.   
@@ -164,10 +174,13 @@ EGLDevice::EGLDevice()
 #endif
 {
     GNASH_REPORT_FUNCTION;
+    
+    setAttrib(_bpp);
 }
 
 EGLDevice::EGLDevice(int argc, char *argv[])
-    : _eglConfig(0),
+    :  _attrib(0),
+       _eglConfig(0),
       _eglContext(EGL_NO_CONTEXT),
       _eglSurface(EGL_NO_SURFACE),
       _eglDisplay(EGL_NO_DISPLAY),
@@ -180,13 +193,17 @@ EGLDevice::EGLDevice(int argc, char *argv[])
 #endif
 {
     GNASH_REPORT_FUNCTION;
+
+    setAttrib(_bpp);
+
     if (!initDevice(argc, argv)) {
         log_error("Couldn't initialize EGL device!");
     }
 }
 
 EGLDevice::EGLDevice(GnashDevice::rtype_t rtype)
-    : _eglConfig(0),
+    :  _attrib(0),
+       _eglConfig(0),
       _eglContext(EGL_NO_CONTEXT),
       _eglSurface(EGL_NO_SURFACE),
       _eglDisplay(EGL_NO_DISPLAY),
@@ -200,6 +217,8 @@ EGLDevice::EGLDevice(GnashDevice::rtype_t rtype)
 {
     GNASH_REPORT_FUNCTION;
     
+    setAttrib(_bpp);
+
     if (!initDevice(0, 0)) {
         log_error("Couldn't initialize EGL device!");
     }
@@ -208,6 +227,22 @@ EGLDevice::EGLDevice(GnashDevice::rtype_t rtype)
     }
 }
 
+void
+EGLDevice::setAttrib(int bpp)
+{ 
+    switch (bpp) {
+    case 32:
+        _attrib = attrib32_list;
+        break;
+    case 16:
+        _attrib = attrib16_list;
+        break;
+    case 1:
+        _attrib = attrib1_list;
+        break;
+    }
+}
+
 EGLDevice::~EGLDevice()
 {
     GNASH_REPORT_FUNCTION;
@@ -226,9 +261,6 @@ EGLDevice::~EGLDevice()
         if (_eglSurface != EGL_NO_SURFACE)
             eglDestroySurface(_eglDisplay, _eglSurface);
         
-        // if (_eglwin_native)
-        //     free(_eglwin_native);
-        
         eglTerminate(_eglDisplay);
     }
 }
@@ -252,7 +284,9 @@ bool
 EGLDevice::initDevice(int argc, char *argv[])
 {
     EGLDevice::rtype_t rtype;
-    
+
+    dbglogfile.setVerbosity(2);
+
     GNASH_REPORT_FUNCTION;
     
     // see egl_config.c for a list of supported configs, this looks for
@@ -277,8 +311,8 @@ EGLDevice::initDevice(int argc, char *argv[])
     // step2 - bind to the wanted client API
     /// This is done by bindClient() later on
     // bindClient(GnashDevice::OPENVG);
-    // queryEGLConfig(_eglDisplay);
-    
+    queryEGLConfig(_eglDisplay);
+   
     log_debug("EGL_CLIENT_APIS = %s", eglQueryString(_eglDisplay, 
EGL_CLIENT_APIS));
     log_debug("EGL_EXTENSIONS = %s",  eglQueryString(_eglDisplay, 
EGL_EXTENSIONS));
     log_debug("EGL_VERSION = %s, EGL_VENDOR = %s",
@@ -286,7 +320,17 @@ EGLDevice::initDevice(int argc, char *argv[])
               eglQueryString(_eglDisplay, EGL_VENDOR));
 
     // step3 - find a suitable config
+#if 1
+    printEGLAttribs(_attrib);
+    if (EGL_FALSE == eglChooseConfig(_eglDisplay, _attrib, &_eglConfig,
+                                     1, &_eglNumOfConfigs)) {
+        log_error("eglChooseConfig(32) failed (error %s)", 
+                  getErrorString(eglGetError()));
+        return false;
+    }
+#else
     if (_bpp == 32) {
+        printEGLAttribs(attrib32_list);
         if (EGL_FALSE == eglChooseConfig(_eglDisplay, attrib32_list, 
&_eglConfig,
                                           1, &_eglNumOfConfigs)) {
             log_error("eglChooseConfig(32) failed (error %s)", 
@@ -294,6 +338,7 @@ EGLDevice::initDevice(int argc, char *argv[])
             return false;
         }
     } else if (_bpp == 16) {
+        printEGLAttribs(attrib16_list);
         if (EGL_FALSE == eglChooseConfig(_eglDisplay, attrib16_list, 
&_eglConfig,
                                          1, &_eglNumOfConfigs)) {
             log_error("eglChooseConfig(16) failed (error %s)",
@@ -303,6 +348,7 @@ EGLDevice::initDevice(int argc, char *argv[])
     } else {
         log_error("No supported bpp value!");
     }
+#endif
 
     if (0 == _eglNumOfConfigs) {
         log_error("eglChooseConfig() was unable to find a suitable config");
@@ -581,7 +627,7 @@ EGLDevice::queryEGLConfig(EGLDisplay display)
 #if 0
      // This prints out all the configurations, so it can be quite large
      for (int i=0; i<max_num_config; i++ ) {
-         std::cerr << "Config[" << i << "] is:" << i << std::endl;
+         std::cerr << "Config[" << i << "] is:" << std::endl;
          printEGLConfig(configs[i]);
      }
 #endif
@@ -590,6 +636,46 @@ EGLDevice::queryEGLConfig(EGLDisplay display)
 }
 
 void
+EGLDevice::printEGLAttribs(const EGLint *attrib)
+{
+    if (attrib) {
+        std::cout << "Printing EGL Attributes list" << std::endl;
+        int i = 0;
+        while (attrib[i] != EGL_NONE) {
+            switch (attrib[i]) {
+            case EGL_RED_SIZE:
+                std::cout << "\tRed: " << attrib[i+1];
+                break;
+            case EGL_GREEN_SIZE:
+                std::cout << ", Green: " << attrib[i+1];
+                break;
+            case EGL_BLUE_SIZE:
+                std::cout << ", Blue: " << attrib[i+1] << std::endl;
+                break;
+            case EGL_DEPTH_SIZE:
+                std::cout << ", Depth: " << attrib[i+1] << std::endl;
+                break;
+            case EGL_RENDERABLE_TYPE:
+                if (attrib[i+1] & EGL_OPENVG_BIT) {
+                    std::cout << "\tOpenVG Renderable" << std::endl;
+                }
+                if (attrib[i+1] & EGL_OPENGL_ES_BIT) {
+                    std::cout << "\tOpenGLES1 Renderable" << std::endl;
+                }
+                if (attrib[i+1] & EGL_OPENGL_ES2_BIT) {
+                    std::cout << "\tOpenGLES2 Renderable" << std::endl;
+                }
+                break;
+            default:
+                break;
+            }
+            i+=2;
+        }
+    }
+    std::cout << "----------------------------------" << std::endl;
+}
+
+void
 EGLDevice::printEGLConfig(EGLConfig config)
 {
     EGLint red, blue, green;
@@ -652,6 +738,8 @@ EGLDevice::printEGLConfig(EGLConfig config)
     } else {
           std::cout <<"\tEGL_SURFACE_TYPE (default)" << std::endl;
     }
+    eglGetConfigAttrib(_eglDisplay, config, EGL_NATIVE_VISUAL_ID, &value);
+    std::cout << "\tX11 Visual is: " << value << std::endl;
 }
 
 void
diff --git a/libdevice/egl/eglDevice.h b/libdevice/egl/eglDevice.h
index b7f009f..9be1576 100644
--- a/libdevice/egl/eglDevice.h
+++ b/libdevice/egl/eglDevice.h
@@ -25,6 +25,7 @@
 #endif
 
 #include <boost/scoped_array.hpp>
+#include <boost/scoped_ptr.hpp>
 
 #ifdef HAVE_X11_X_H
 #include "x11/X11Device.h"
@@ -183,6 +184,7 @@ class EGLDevice : public GnashDevice
     void printEGLContext(EGLContext context);
     void printEGLSurface() { return printEGLSurface(_eglSurface); };
     void printEGLSurface(EGLSurface surface);
+    void printEGLAttribs(const EGLint *attrib);
     
     // Create Pbuffers for offscreen rendering
     EGLSurface createPbuffer(int width, int height);
@@ -197,9 +199,11 @@ class EGLDevice : public GnashDevice
     // directly.
     // Swap to the default surface
     bool swapBuffers() {
+        GNASH_REPORT_FUNCTION;
         return eglSwapBuffers(_eglDisplay, _eglSurface);
     }
     bool copyPbuffers(size_t x) {
+        GNASH_REPORT_FUNCTION;
         if (x < _pbuffers.size()) {
             NativePixmapType pix;
             if (!eglCopyBuffers(_eglDisplay, _pbuffers[x], pix)) {
@@ -341,6 +345,7 @@ class EGLDevice : public GnashDevice
         return value;
     }
     
+    void setAttrib(int bpp);
 protected:
     EGLConfig           _eglConfig;
     EGLContext          _eglContext;
@@ -350,6 +355,7 @@ protected:
     EGLNativeWindowType _nativeWindow;
     EGLNativePixmapType _nativePixmap;
     EGLint              _max_num_config;
+    const EGLint       *_attrib;
     unsigned int        _bpp;
     std::vector<EGLSurface> _pbuffers;
 };
diff --git a/libdevice/egl/test_egl.cpp b/libdevice/egl/test_egl.cpp
index 1461d60..64269b8 100644
--- a/libdevice/egl/test_egl.cpp
+++ b/libdevice/egl/test_egl.cpp
@@ -144,7 +144,10 @@ test_egl(EGLDevice &egl, GnashDevice::rtype_t rtype, int 
argc, char *argv[])
 
     // Init'ing to zero uses the root screen as the display. Otherwise
     // the argument should be an EGLNativeWindowType.
-    int fd = open("/dev/fb0", O_RDWR);
+    int fd = 0;
+#ifndef BUILD_X11_DEVICE
+    fd = open("/dev/fb0", O_RDWR);
+#endif
     if (egl.attachWindow(fd)) {
         runtest.pass("EGLDevice::attachWindow(0)");
     } else {

http://git.savannah.gnu.org/cgit//commit/?id=dbe19ce421773a770aa6b941877ca6a346bf4ad2


commit dbe19ce421773a770aa6b941877ca6a346bf4ad2
Author: Rob Savoye <address@hidden>
Date:   Mon Dec 27 10:05:23 2010 -0700

    getDrawableWindow() has been replaced by getHandle()

diff --git a/libdevice/x11/X11Device.h b/libdevice/x11/X11Device.h
index 81c84a1..65b2c56 100644
--- a/libdevice/x11/X11Device.h
+++ b/libdevice/x11/X11Device.h
@@ -92,8 +92,6 @@ class X11Device : public GnashDevice
     // Using X11 always means a native renderer
     bool isNativeRender() { return true; }
 
-    Window getDrawableWindow() { return _window; };
-
     int getHandle() { return _window; };
     
     //

http://git.savannah.gnu.org/cgit//commit/?id=b39e768f65b52ae2c00617b57269089b31c76837


commit b39e768f65b52ae2c00617b57269089b31c76837
Author: Rob Savoye <address@hidden>
Date:   Mon Dec 27 10:04:48 2010 -0700

    return false for bindClient() and swapBuffer() if not derived

diff --git a/libdevice/GnashDevice.h b/libdevice/GnashDevice.h
index e4bdb15..5f9cc92 100644
--- a/libdevice/GnashDevice.h
+++ b/libdevice/GnashDevice.h
@@ -119,9 +119,12 @@ struct GnashDevice
     // bindClient() is used by OpenVG, OpenGLES1, and OpenGLES2
     // to bind the client type to the EGL surface. This method
     // is unused by the RawFB, DirectFB, and X11 Devices.
-    virtual bool bindClient(GnashDevice::rtype_t rtype) {};
+    virtual bool bindClient(GnashDevice::rtype_t rtype) { return false; };
     
-    virtual bool swapBuffers() {};
+    virtual bool swapBuffers() {
+        GNASH_REPORT_FUNCTION;
+        return false;
+    };
 };
     
 } // namespace renderer

http://git.savannah.gnu.org/cgit//commit/?id=7ced366eb15fc90bc9742f3ff4a3b6ab665973ac


commit 7ced366eb15fc90bc9742f3ff4a3b6ab665973ac
Author: Rob Savoye <address@hidden>
Date:   Mon Dec 27 10:02:37 2010 -0700

    clear the device list before appending to it so we don't get duplicates

diff --git a/configure.ac b/configure.ac
index ac5b22e..b9c8e1d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1135,6 +1135,8 @@ ndevice=2
 AC_ARG_ENABLE(device,
   AC_HELP_STRING([--enable-device], [Specify which hardware abstraction to use 
to support to enable (none,openmax,egl,directfb,rawfb,x11,vaapi)]),
   enableval=`echo ${enableval} | tr '\054' ' ' `
+  device_list=""
+  ndevice=0
   while test -n "${enableval}" ; do
     val=`echo ${enableval} | cut -d ' ' -f 1`
     [case "${val}" in

http://git.savannah.gnu.org/cgit//commit/?id=331626f482ddae654c86a1a3fece2791fa04b54c


commit 331626f482ddae654c86a1a3fece2791fa04b54c
Author: Rob Savoye <address@hidden>
Date:   Mon Dec 27 10:02:00 2010 -0700

    correct note, bitmap_info is now CachedBitmap

diff --git a/librender/Renderer.h b/librender/Renderer.h
index 052396f..616751f 100644
--- a/librender/Renderer.h
+++ b/librender/Renderer.h
@@ -217,7 +217,7 @@ public:
     /// ==================================================================
     
     /// \brief
-    /// Given an image, returns a pointer to a bitmap_info class
+    /// Given an image, returns a pointer to a CachedBitmap class
     /// that can later be passed to FillStyleX_bitmap(), to set a
     /// bitmap fill style.
     virtual CachedBitmap *

http://git.savannah.gnu.org/cgit//commit/?id=f60fadc4e7047f40208b687db6a7b38fe3397608


commit f60fadc4e7047f40208b687db6a7b38fe3397608
Author: Rob Savoye <address@hidden>
Date:   Mon Dec 27 10:01:29 2010 -0700

    add raw framebuffer support, fix tests to match rality of real OpenVG on a 
real 16bit touchscreen

diff --git a/librender/testr.cpp b/librender/testr.cpp
index c8e481e..424f717 100644
--- a/librender/testr.cpp
+++ b/librender/testr.cpp
@@ -31,6 +31,9 @@
 #include <boost/assign/list_of.hpp>
 #include <boost/date_time/date.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 
 #include "log.h"
 #include "dejagnu.h"
@@ -51,9 +54,12 @@
 #endif
 #ifdef RENDERER_OPENVG
 #include "openvg/Renderer_ovg.h"
-//#include <VG/openvg.h>
 #include <VG/vgu.h>
-#include <VG/ext.h>
+#ifdef HAVE_VG_VGEXT_H
+# include <VG/vgext.h>
+#else
+# include <VG/ext.h>
+#endif
 #endif
 #ifdef RENDERER_GLES1
 #include "opengles1/Renderer_gles1.h"
@@ -147,21 +153,37 @@ main(int argc, char *argv[])
     dbglogfile.setVerbosity();
 
     const char *pixelformat = "RGB24";
+    int fd = 0;
+
+#ifdef BUILD_RAWFB_DEVICE_XXX
+    rawfb::RawFBDevice rawfb(argc, argv);
+    fd = rawfb.getHandle();
+#endif  // BUILD_RAWFB_DEVICE
+
+#if defined(BUILD_EGL_DEVICE) && !defined(BUILD_X11_DEVICE)
+    // Setup EGL, OpenVG needs it
+    EGLDevice egl(argc, argv);
+    egl.bindClient(GnashDevice::OPENVG);
+    fd = open("/dev/fb0", O_RDWR);
+    egl.attachWindow(fd);
+#endif  // BUILD_EGL_DEVICE
     
 #ifdef BUILD_X11_DEVICE
     // Setup EGL, OpenVG needs it
-    EGLDevice egl(argc, argv);
+    EGLDevice egl;
+    //egl.setAttrib(1);
+    egl.initDevice(argc, argv);
     int vid = egl.getNativeVisual();
+    egl.bindClient(GnashDevice::OPENVG);
 
     // Create an X11 device for the display. This is for libMesa
     // where we can also run OpenVG on the desktop.
     x11::X11Device x11(vid);
     //x11.initDevice(argc, argv);
     x11.createWindow("TestR", 0, 0, 640, 480);
-    egl.bindClient(GnashDevice::OPENVG);
     
     // This is the window that gets rendered in
-    Window win = x11.getDrawableWindow();
+    Window win = x11.getHandle();
     if (win) {
         egl.attachWindow(win);
     } else {
@@ -180,7 +202,7 @@ main(int argc, char *argv[])
     std::cerr << "Hello World!" << std::endl;
     x11.eventLoop(10);
 #endif
-#if 0
+
 #ifdef RENDERER_AGG
     Timer tagg("AGG");
     Renderer *renderer1 = create_Renderer_agg(pixelformat);
@@ -275,7 +297,6 @@ main(int argc, char *argv[])
     cerr << "OpenGL tests took " << tgl.elapsed() << endl;
 #endif
 #endif    
-#endif    
 }
 
 // Each Renderer has an associated display device, currently EGL
@@ -289,7 +310,7 @@ main(int argc, char *argv[])
 void
 test_device(Renderer *renderer, const std::string &type)
 {
-    cout << "Testing " << type << " Device" << endl;
+    cout << endl << "Testing " << type << " Device" << endl;
 
 #if 0
     boost::shared_array<renderer::GnashDevice::dtype_t> devs = 
renderer->probeDevices();
@@ -354,37 +375,23 @@ test_renderer(Renderer *renderer, const std::string &type)
     }
 #endif
     
-    image::GnashImage *frame1 = new image::ImageRGBA(10, 10);
+    image::GnashImage *frame1 = new image::ImageRGBA(10, 12);
     std::auto_ptr<image::GnashImage> im1(frame1);
     CachedBitmap *cb = renderer->createCachedBitmap(im1);
     if (cb) {
-        runtest.pass("createCachedBitmap()");
+        image::GnashImage &gi = cb->image();
+        if ((gi.width() == 10) && (gi.height() == 12)) {
+            runtest.pass("createCachedBitmap()");
+        } else {
+            runtest.fail("createCachedBitmap()");
+        }
     } else {
-        runtest.fail("createCachedBitmap()");
+        runtest.unresolved("createCachedBitmap()");
     }
 
-#ifdef HAVE_GTK2_XX
-    GtkWidget *canvas = create_GTK_window();
-    if (type == "AGG") {
-        GdkVisual* visual = gdk_drawable_get_visual(canvas->window);
-        GdkImage *offscreenbuf = gdk_image_new (GDK_IMAGE_FASTEST, visual, 200,
-                                                200);;
-        static_cast<Renderer_agg_base *>(renderer)->init_buffer(
-            (unsigned char*) offscreenbuf->mem,
-            offscreenbuf->bpl * offscreenbuf->height,
-            offscreenbuf->width,
-            offscreenbuf->height,
-            offscreenbuf->bpl);    
-    }
-            
-    if ((type == "OpenVG") && (type == "OpenGLES1") && (type == "OpenGLES2")) {
-        EGLDevice *ovg = dynamic_cast<EGLDevice *>(renderer);
-        ovg->initDevice(0, 0);
-//        ovg->initDevice(EGLDevice::OPENVG);
-        ovg->attachWindow(*(reinterpret_cast<EGLNativeWindowType *>(canvas)));
-    }
-#else
 #if 0
+    // FIXME: initTestBuffer() is going away, replaced by the fake
+    // framebuffer code.
     // Initializes the renderer for off-screen rendering used by the testsuite.
     if (renderer->initTestBuffer(10, 10)) {
         runtest.pass("initTestBuffer()");
@@ -392,7 +399,6 @@ test_renderer(Renderer *renderer, const std::string &type)
         runtest.fail("initTestBuffer()");
     }
 #endif
-#endif
     
     /// @coords an array of 16-bit signed integer coordinates. Even indices
     ///         (and 0) are x coordinates, while uneven ones are y coordinates.

http://git.savannah.gnu.org/cgit//commit/?id=b25fcfb99c955b4cfcee7657b97cf2dea2873308


commit b25fcfb99c955b4cfcee7657b97cf2dea2873308
Author: Rob Savoye <address@hidden>
Date:   Mon Dec 27 10:00:31 2010 -0700

    derived methods aren't virtual

diff --git a/librender/agg/Renderer_agg_bitmap.h 
b/librender/agg/Renderer_agg_bitmap.h
index 681fd5e..47f6155 100644
--- a/librender/agg/Renderer_agg_bitmap.h
+++ b/librender/agg/Renderer_agg_bitmap.h
@@ -26,7 +26,6 @@
 #include "GnashImage.h"
 #include "CachedBitmap.h"
 
-
 namespace gnash {
 
 class agg_bitmap_info : public CachedBitmap
@@ -45,11 +44,11 @@ public:
         return *_image;
     }
   
-    virtual void dispose() {
+    void dispose() {
         _image.reset();
     }
 
-    virtual bool disposed() const {
+    bool disposed() const {
         return !_image.get();
     }
    

http://git.savannah.gnu.org/cgit//commit/?id=a2448311a0f940481860a22db7164ba0df3a9c4b


commit a2448311a0f940481860a22db7164ba0df3a9c4b
Author: Rob Savoye <address@hidden>
Date:   Mon Dec 27 09:59:39 2010 -0700

    add libsound.la to eliminate linking issues under ltib.

diff --git a/librender/Makefile.am b/librender/Makefile.am
index 2cb6048..4459872 100644
--- a/librender/Makefile.am
+++ b/librender/Makefile.am
@@ -172,6 +172,7 @@ testr_CPPFLAGS = \
 testr_LDADD = \
        libgnashrender.la \
        ../libdevice/libgnashdevice.la \
+       ../libsound/libgnashsound.la \
        $(GTK2_LIBS) \
        $(EXTRA_EGL_LIBS) \
        $(EGL_LIBS) \

http://git.savannah.gnu.org/cgit//commit/?id=187a59c14e44776eb08efd2584221172eb7898c1


commit 187a59c14e44776eb08efd2584221172eb7898c1
Author: Rob Savoye <address@hidden>
Date:   Mon Dec 27 09:58:59 2010 -0700

    add helper classes for boost::variant. Implement all the types in 
apply_fill_style

diff --git a/librender/openvg/Renderer_ovg.cpp 
b/librender/openvg/Renderer_ovg.cpp
index 465e702..d02860c 100644
--- a/librender/openvg/Renderer_ovg.cpp
+++ b/librender/openvg/Renderer_ovg.cpp
@@ -16,7 +16,9 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
 ///
-/// original author: Visor <address@hidden>
+/// Original author: Visor <address@hidden>
+/// Heavily hacked by Rob <address@hidden> to work with Gnash
+/// git master.
 ///
 
 #ifdef HAVE_CONFIG_H
@@ -35,6 +37,7 @@
 #include "GnashImage.h"
 #include "GnashNumeric.h"
 #include "FillStyle.h"
+#include "LineStyle.h"
 #include "Transform.h"
 #include "log.h"
 #include "utility.h"
@@ -73,6 +76,62 @@ namespace renderer {
 
 namespace openvg {
 
+namespace {
+
+// FIXME: These helper classes should be moved to their own file.
+
+/// @note These helper functions are used by the boost::variant used
+/// for fill styles. A variant is a C++ style version of the C union.
+/// Before accessing any of the data of the variant, we have to use
+/// boost::apply_visitor() to bind one of these classes to the style
+/// to extract the data.
+
+/// Get the color of a style from the variant
+class GetColor : public boost::static_visitor<rgba>
+{
+public:
+    rgba operator()(const SolidFill& f) const {
+        return f.color();
+    }
+    rgba operator()(const GradientFill&) const {
+        return rgba();
+    }
+    rgba operator()(const BitmapFill&) const {
+        return rgba();
+    }
+};
+
+/// Get the bitmap data of a style from the variant
+class GetBitmap : public boost::static_visitor<const CachedBitmap *>
+{
+public:
+    const CachedBitmap *operator()(const SolidFill&) const {
+        return 0;
+    }
+    const CachedBitmap *operator()(const GradientFill&) const {
+        return 0;
+    }
+    const CachedBitmap *operator()(const BitmapFill& b) const {
+        return b.bitmap();
+    }
+};
+
+/// Get the matrix of a style from the variant
+class GetMatrix : public boost::static_visitor<SWFMatrix>
+{
+public:
+    SWFMatrix operator()(const SolidFill&) const {
+    }
+    SWFMatrix operator()(const GradientFill& g) const {
+        return g.matrix();
+    }
+    SWFMatrix operator()(const BitmapFill& b) const {
+        return b.matrix();
+    }
+};
+
+}
+
 class eglScopeMatrix : public boost::noncopyable
 {
 public:
@@ -164,42 +223,42 @@ preparepath(VGPath path, const std::vector<Edge>& edges,
         vgAppendPathData (path, scount, gseg, gdata);
 }
 
+#if 0
 // Use the image class copy constructor; it's not important any more
 // what kind of image it is.
 bitmap_info_ovg::bitmap_info_ovg(std::auto_ptr<gnash::image::GnashImage> img,
-                                 VGImageFormat pixelformat, VGPaint paint)
-:
-    _img(img.release()),
-    _pixel_format(pixelformat),
-    _paint(paint),
-    _orig_width(_img->width()),
-    _orig_height(_img->height())
+                                 VGImageFormat pixelformat, VGPaint vgpaint)
+    : _image(img.release()),
+      _pixel_format(pixelformat),
+      _vgpaint(vgpaint)
 {
     GNASH_REPORT_FUNCTION;
 
-    _width = _img->width();
-    _height = _img->height();
+    size_t width = _image->width();
+    size_t height = _image->height();
   
-    if (_pixel_format == VG_sARGB_8888) {
-        _image = vgCreateImage(VG_sARGB_8888, _width, _height, 
GNASH_IMAGE_QUALITY);    
+    _vgimage = vgCreateImage(VG_sRGB_565, width, height, GNASH_IMAGE_QUALITY); 
   
     
-        vgImageSubData(_image, _img->begin(), _width * 4, VG_sARGB_8888,
-                       0, 0, _width, _height);
-    }
-    
-    tex_size += _width * _height * 4;
-    log_debug("Add Texture size:%d (%d x %d x %dbpp)", _width * _height * 4, 
_width, _height, 4);
+    vgImageSubData(_vgimage, _image->begin(), width * 4, VG_sRGB_565,
+                   0, 0, width, height);
+
+    tex_size += width * height * 4;
+    log_debug("Add Texture size:%d (%d x %d x %dbpp)", width * height * 4, 
+              width, height, 4);
     log_debug("Current Texture size: %d", tex_size);
 }   
-    
+
 bitmap_info_ovg::~bitmap_info_ovg()
 {
     GNASH_REPORT_FUNCTION;
-    tex_size -= _width * _height * 4;
-    log_debug(_("Remove Texture size:%d (%d x %d x %dbpp)"), _width * _height 
* 4, _width, _height, 4);
+
+    tex_size -= _image->width() * _image->height() * 4;
+    log_debug(_("Remove Texture size:%d (%d x %d x %dbpp)"),
+              _image->width() * _image->height() * 4,
+              _image->width(), _image->height(), 4);
     log_debug(_("Current Texture size: %d"), tex_size);
 
-    vgDestroyImage(_image);
+    vgDestroyImage(_vgimage);
 }
 
 void
@@ -212,8 +271,8 @@ bitmap_info_ovg::apply(const gnash::SWFMatrix& 
bitmap_matrix,
     
     mat = bitmap_matrix;
 
-    vgSetParameteri (_paint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
-    vgPaintPattern (_paint, _image);
+    vgSetParameteri (_vgpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
+    vgPaintPattern (_vgpaint, _vgimage);
     
     mat.invert();
     memset(vmat, 0, sizeof(vmat));
@@ -231,11 +290,12 @@ bitmap_info_ovg::apply(const gnash::SWFMatrix& 
bitmap_matrix,
     vgSeti (VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
 
     if (wrap_mode == WRAP_CLAMP) {  
-        vgSetParameteri (_paint, VG_PAINT_PATTERN_TILING_MODE, VG_TILE_PAD);
+        vgSetParameteri (_vgpaint, VG_PAINT_PATTERN_TILING_MODE, VG_TILE_PAD);
     } else {
-        vgSetParameteri (_paint, VG_PAINT_PATTERN_TILING_MODE, VG_TILE_REPEAT);
+        vgSetParameteri (_vgpaint, VG_PAINT_PATTERN_TILING_MODE, 
VG_TILE_REPEAT);
     }
 }
+#endif
 
 template<typename C, typename T, typename R, typename A>
 void 
@@ -251,12 +311,9 @@ Renderer_ovg::Renderer_ovg()
       _drawing_mask(false)
 {
     GNASH_REPORT_FUNCTION;
-#ifdef BUILD_EGL_DEVICE
-//    _device.reset(new renderer::EGLDevice);
-#endif      
 }
 
-Renderer_ovg::Renderer_ovg(renderer::GnashDevice::dtype_t dtype)
+Renderer_ovg::Renderer_ovg(renderer::GnashDevice::dtype_t /* dtype */)
     : _display_width(0.0),
       _display_height(0.0),
       _drawing_mask(false)
@@ -317,23 +374,9 @@ CachedBitmap *
 Renderer_ovg::createCachedBitmap(std::auto_ptr<image::GnashImage> im)
 {
     GNASH_REPORT_FUNCTION;
-    
-    // OpenVG don't support 24bit RGB, need translate colorspace
-    switch (im->type()) {
-      case image::TYPE_RGBA:   
-          return new bitmap_info_ovg(im, VG_sARGB_8888, m_fillpaint);
-          break;
-      case image::TYPE_RGB:
-      default:
-          log_error("Can't create a cached bitmap! Unsuppored type: %d",
-                    im->type());
-          std::abort();
-    }
 
-   const CachedBitmap* bi = createCachedBitmap(
-                    static_cast<std::auto_ptr<image::GnashImage> >(im));
-
-    return 0;
+    // OpenVG don't support 24bit RGB, need translate colorspace
+    return reinterpret_cast<CachedBitmap *>(new bitmap_info_ovg(im, 
VG_sRGB_565, 0));
 }
 
 // Since we store drawing operations in display lists, we take special care
@@ -502,11 +545,6 @@ Renderer_ovg::drawPoly(const point* corners, size_t 
corner_count,
     int         scount = 0;
     int         dcount = 0;
 
-    if (!_device) {
-        log_error("No Device specified for OpenVG to draw on!");
-        return;
-    }
-    
     if (corner_count < 1) {
         return;
     }
@@ -726,7 +764,8 @@ Renderer_ovg::find_connecting_path(const Path& to_connect,
 PathVec
 Renderer_ovg::normalize_paths(const PathVec &paths)
 {
-    GNASH_REPORT_FUNCTION;
+    // GNASH_REPORT_FUNCTION;
+
     PathVec normalized;
     
     for (PathVec::const_iterator it = paths.begin(), end = paths.end();
@@ -774,7 +813,8 @@ void
 Renderer_ovg::analyze_paths(const PathVec &paths, bool& have_shape,
                             bool& have_outline) 
 {
-    GNASH_REPORT_FUNCTION;
+    // GNASH_REPORT_FUNCTION;
+
     have_shape=false;
     have_outline=false;
     
@@ -798,12 +838,11 @@ Renderer_ovg::analyze_paths(const PathVec &paths, bool& 
have_shape,
 }
 
 void
-Renderer_ovg::apply_fill_style(const FillStyle& style, const SWFMatrix& /* mat 
*/,
+Renderer_ovg::apply_fill_style(const FillStyle& style, const SWFMatrix& mat,
                                const SWFCxForm& cx)
 {
-    GNASH_REPORT_FUNCTION;
+    //    GNASH_REPORT_FUNCTION;
 
-#if 0
     //    FIXME fill_style changed to FillStyle
     SWF::FillType fill_type = SWF::FILL_SOLID; // style.get_type();
     
@@ -813,25 +852,34 @@ Renderer_ovg::apply_fill_style(const FillStyle& style, 
const SWFMatrix& /* mat *
       case SWF::FILL_RADIAL_GRADIENT:
       case SWF::FILL_FOCAL_GRADIENT:
       {
-          gnash::GradientFill f();
-          const bitmap_info_ovg* binfo = static_cast<const bitmap_info_ovg*>(
-#if 0                           // original
-              style.need_gradient_bitmap(*this));   
-#else
-          createGradientBitmap(&f, *this));
-#endif
-          binfo->apply(style.getGradientMatrix(), 
bitmap_info_ovg::WRAP_CLAMP); 
+          GradientFill::Type gr;
+          switch (fill_type) {
+          case SWF::FILL_LINEAR_GRADIENT:
+              gr = GradientFill::LINEAR;
+              break;
+          case SWF::FILL_RADIAL_GRADIENT:
+          case SWF::FILL_FOCAL_GRADIENT:
+              gr = GradientFill::RADIAL;
+              break;
+          default:
+              std::abort();
+          }
+          GradientFill gf(gr, mat);
+
+          const bitmap_info_ovg* binfo = reinterpret_cast<const 
bitmap_info_ovg *>(
+               createGradientBitmap(gf, this));
+
+          binfo->apply(gf.matrix(), bitmap_info_ovg::WRAP_CLAMP); 
           vgSetParameteri (m_fillpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
           break;
       }
-#if 0
       case SWF::FILL_TILED_BITMAP_HARD:
       case SWF::FILL_TILED_BITMAP:
       {
-          const bitmap_info_ovg* binfo = static_cast<const bitmap_info_ovg*>(
-              style.get_bitmap_info(*this));
-          
-          binfo->apply(style.getBitmapMatrix(), bitmap_info_ovg::WRAP_REPEAT);
+          const CachedBitmap *cb = boost::apply_visitor(GetBitmap(), 
style.fill);
+          const bitmap_info_ovg* binfo = dynamic_cast<const bitmap_info_ovg 
*>(cb);
+          SWFMatrix sm = boost::apply_visitor(GetMatrix(), style.fill);        
  
+          binfo->apply(sm, bitmap_info_ovg::WRAP_REPEAT);
           vgSetParameteri (m_fillpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
           break;
       }
@@ -839,17 +887,18 @@ Renderer_ovg::apply_fill_style(const FillStyle& style, 
const SWFMatrix& /* mat *
       case SWF::FILL_CLIPPED_BITMAP:
       case SWF::FILL_CLIPPED_BITMAP_HARD:
       {     
-          const bitmap_info_ovg* binfo = dynamic_cast<const bitmap_info_ovg*>(
-              style.get_bitmap_info(*this));
-          
-          binfo->apply(style.getBitmapMatrix(), bitmap_info_ovg::WRAP_CLAMP);
+          const CachedBitmap *cb = boost::apply_visitor(GetBitmap(), 
style.fill);
+          const bitmap_info_ovg* binfo = dynamic_cast<const bitmap_info_ovg 
*>(cb);     
+
+          SWFMatrix sm = boost::apply_visitor(GetMatrix(), style.fill);
+          binfo->apply(sm, bitmap_info_ovg::WRAP_CLAMP);
           vgSetParameteri (m_fillpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
           break;
       } 
-#endif 
       case SWF::FILL_SOLID:
       {
-          rgba c = cx.transform(style.get_color());
+          rgba fc = boost::apply_visitor(GetColor(), style.fill);
+          rgba c = cx.transform(fc);
           VGfloat color[] = {
               c.m_r / 255.0f,
               c.m_g / 255.0f,
@@ -862,13 +911,13 @@ Renderer_ovg::apply_fill_style(const FillStyle& style, 
const SWFMatrix& /* mat *
       }
       
     } // switch
-#endif
 }
 
 bool
-Renderer_ovg::apply_line_style(const LineStyle& style, const SWFCxForm& cx, 
const SWFMatrix& mat)
+Renderer_ovg::apply_line_style(const LineStyle& style, const SWFCxForm& cx, 
+                               const SWFMatrix& mat)
 {
-    GNASH_REPORT_FUNCTION;
+    // GNASH_REPORT_FUNCTION;
     
     bool rv = true;
     
@@ -947,7 +996,8 @@ void
 Renderer_ovg::draw_outlines(const PathVec& path_vec, const SWFMatrix& mat,
                             const SWFCxForm& cx, const std::vector<LineStyle>& 
line_styles)
 {
-    GNASH_REPORT_FUNCTION;
+    // GNASH_REPORT_FUNCTION;
+
     for (PathVec::const_iterator it = path_vec.begin(), end = path_vec.end();
          it != end; ++it) {
         
@@ -976,7 +1026,8 @@ Renderer_ovg::draw_outlines(const PathVec& path_vec, const 
SWFMatrix& mat,
 std::list<PathPtrVec>
 Renderer_ovg::get_contours(const PathPtrVec &paths)
 {
-    GNASH_REPORT_FUNCTION;
+    // GNASH_REPORT_FUNCTION;
+
     std::list<const Path*> path_refs;
     std::list<PathPtrVec> contours;
     
@@ -1260,11 +1311,7 @@ Renderer_ovg::drawGlyph(const SWF::ShapeRecord& rec, 
const rgba& c,
     SWFCxForm dummy_cx;
     std::vector<FillStyle> glyph_fs;
     
-#if 0                           // original
-    FillStyle coloring = SolidFill(c);
-#else
     FillStyle coloring = FillStyle(SolidFill(c));
-#endif
 
     glyph_fs.push_back(coloring);
 
@@ -1601,6 +1648,8 @@ Renderer *
 Renderer_ovg::startInternalRender(gnash::image::GnashImage&)
 {
     // GNASH_REPORT_FUNCTION;
+
+    return 0;
 }
 
 void
@@ -1612,7 +1661,7 @@ Renderer_ovg::endInternalRender()
 void
 Renderer_ovg::begin_display(gnash::rgba const&, int, int, float, float, float, 
float)
 {
-    GNASH_REPORT_FUNCTION;
+    // GNASH_REPORT_FUNCTION;
 
 }
 void
@@ -1627,6 +1676,110 @@ Renderer_ovg::getBitsPerPixel()
     return 0;
 }
 
+namespace {
+
+// TODO: this function is rubbish and shouldn't survive a rewritten OGL
+// renderer.
+rgba
+sampleGradient(const GradientFill& fill, boost::uint8_t ratio)
+{
+
+    // By specs, first gradient should *always* be 0, 
+    // anyway a malformed SWF could break this,
+    // so we cannot rely on that information...
+    if (ratio < fill.record(0).ratio) {
+        return fill.record(0).color;
+    }
+
+    if (ratio >= fill.record(fill.recordCount() - 1).ratio) {
+        return fill.record(fill.recordCount() - 1).color;
+    }
+        
+    for (size_t i = 1, n = fill.recordCount(); i < n; ++i) {
+
+        const GradientRecord& gr1 = fill.record(i);
+        if (gr1.ratio < ratio) continue;
+
+        const GradientRecord& gr0 = fill.record(i - 1);
+        if (gr0.ratio > ratio) continue;
+
+        float f = 0.0f;
+
+        if (gr0.ratio != gr1.ratio) {
+            f = (ratio - gr0.ratio) / float(gr1.ratio - gr0.ratio);
+        }
+        else {
+            // Ratios are equal IFF first and second GradientRecord
+            // have the same ratio. This would be a malformed SWF.
+            IF_VERBOSE_MALFORMED_SWF(
+                log_swferror(_("two gradients in a FillStyle "
+                    "have the same position/ratio: %d"),
+                    gr0.ratio);
+            );
+        }
+
+        rgba result;
+        result.set_lerp(gr0.color, gr1.color, f);
+        return result;
+    }
+
+    // Assuming gradients are ordered by ratio? see start comment
+    return fill.record(fill.recordCount() - 1).color;
+}
+
+const CachedBitmap*
+createGradientBitmap(const GradientFill& gf, Renderer_ovg *renderer)
+{
+    GNASH_REPORT_FUNCTION;
+    
+    std::auto_ptr<image::ImageRGBA> im;
+
+    switch (gf.type())
+    {
+        case GradientFill::LINEAR:
+            // Linear gradient.
+            im.reset(new image::ImageRGBA(256, 1));
+
+            for (size_t i = 0; i < im->width(); i++) {
+
+                rgba sample = sampleGradient(gf, i);
+                im->setPixel(i, 0, sample.m_r, sample.m_g,
+                        sample.m_b, sample.m_a);
+            }
+            break;
+
+        case GradientFill::RADIAL:
+            // Focal gradient.
+            im.reset(new image::ImageRGBA(64, 64));
+
+            for (size_t j = 0; j < im->height(); j++)
+            {
+                for (size_t i = 0; i < im->width(); i++)
+                {
+                    float radiusy = (im->height() - 1) / 2.0f;
+                    float radiusx = radiusy + std::abs(radiusy * 
gf.focalPoint());
+                    float y = (j - radiusy) / radiusy;
+                    float x = (i - radiusx) / radiusx;
+                    int ratio = std::floor(255.5f * std::sqrt(x*x + y*y));
+                    
+                    if (ratio > 255) ratio = 255;
+
+                    rgba sample = sampleGradient(gf, ratio);
+                    im->setPixel(i, j, sample.m_r, sample.m_g,
+                            sample.m_b, sample.m_a);
+                }
+            }
+            break;
+        default:
+            break;
+    }
+
+    const CachedBitmap* bi = renderer->createCachedBitmap(
+                    static_cast<std::auto_ptr<image::GnashImage> >(im));
+
+    return bi;
+}
+}
 
 } // namespace gnash::renderer::gles1
 } // namespace gnash::renderer
diff --git a/librender/openvg/Renderer_ovg.h b/librender/openvg/Renderer_ovg.h
index 21da7ad..87cab34 100644
--- a/librender/openvg/Renderer_ovg.h
+++ b/librender/openvg/Renderer_ovg.h
@@ -18,7 +18,7 @@
 ///
 /// Original Author: Visor <address@hidden>.
 /// Heavily hacked by Rob <address@hidden> to work with Gnash
-/// gitmaster.
+/// git master.
 ///
 
 #ifndef GNASH_RENDER_HANDLER_OVG_H
@@ -55,11 +55,6 @@ namespace renderer {
 
 namespace openvg {
 
-namespace {
-    const CachedBitmap* createGradientBitmap(const GradientFill& gf,
-            Renderer& renderer);
-}
-
 typedef std::vector<const Path*> PathRefs;
 typedef std::vector<Path> PathVec;
 typedef std::vector<geometry::Range2d<int> > ClipBounds;
@@ -201,6 +196,11 @@ public:
     boost::scoped_ptr<renderer::GnashDevice> _device;
 };
 
+namespace {
+    const CachedBitmap* createGradientBitmap(const GradientFill& gf,
+                                  renderer::openvg::Renderer_ovg *renderer);
+}
+
 DSOEXPORT Renderer* create_handler(const char *pixelformat);
 
 } // namespace gnash::renderer::openvg
diff --git a/librender/openvg/Renderer_ovg_bitmap.h 
b/librender/openvg/Renderer_ovg_bitmap.h
index 254b3a9..6e92063 100644
--- a/librender/openvg/Renderer_ovg_bitmap.h
+++ b/librender/openvg/Renderer_ovg_bitmap.h
@@ -17,6 +17,8 @@
 
 ///
 /// Author: Visor <address@hidden>
+/// Heavily hacked by Rob <address@hidden> to work with Gnash
+/// git master.
 ///
 
 #ifndef GNASH_RENDER_HANDLER_OVG_BITMAP_H
@@ -26,6 +28,7 @@
 #include "CachedBitmap.h"
 #include "GnashImage.h"
 #include "Renderer.h"
+#include "openvg/Renderer_ovg.h"
 
 namespace gnash {
 
@@ -33,67 +36,110 @@ namespace renderer {
 
 namespace openvg {
 
-class bitmap_info_ovg : public CachedBitmap
+// FIXME: this should really be derived from CachedBitmap
+class bitmap_info_ovg //: public CachedBitmap
 {
 public:
-  
     /// Set line and fill styles for mesh & line_strip rendering.
-    enum bitmap_wrap_mode
-    {
-        WRAP_REPEAT,
-        WRAP_CLAMP
-    };
+    enum bitmap_wrap_mode { WRAP_REPEAT, WRAP_CLAMP };
     
-    bitmap_info_ovg(std::auto_ptr<image::GnashImage> img,
-                    VGImageFormat pixelformat, VGPaint paint);
-    ~bitmap_info_ovg();
-
-    void dispose() {
-        _img.reset();
+    bitmap_info_ovg(std::auto_ptr<image::GnashImage> im)
+        : _image(im.release())
+    {
+        GNASH_REPORT_FUNCTION;
     }
-
-    bool disposed() const {
-        return !_img.get();
+  
+    bitmap_info_ovg(std::auto_ptr<image::GnashImage> im,
+                    VGImageFormat pixelformat, VGPaint vgpaint)
+        : _image(im.release()),
+          _pixel_format(pixelformat),
+          _vgpaint(vgpaint)
+    {
+        GNASH_REPORT_FUNCTION;
+        
+        size_t width = _image->width();
+        size_t height = _image->height();
+        
+        _vgimage = vgCreateImage(VG_sRGB_565, width, height,
+                                 VG_IMAGE_QUALITY_FASTER);    
+        
+        vgImageSubData(_vgimage, _image->begin(), width * 4, VG_sRGB_565,
+                       0, 0, width, height);
+        
+        _tex_size += width * height * 4;
+        log_debug("Add Texture size:%d (%d x %d x %dbpp)", width * height * 4, 
+                  width, height, 4);
+        log_debug("Current Texture size: %d", _tex_size);
+    } 
+
+    ~bitmap_info_ovg()
+    {
+        GNASH_REPORT_FUNCTION;
+        
+        _tex_size -= _image->width() * _image->height() * 4;
+        log_debug(_("Remove Texture size:%d (%d x %d x %dbpp)"),
+                  _image->width() * _image->height() * 4,
+                  _image->width(), _image->height(), 4);
+        log_debug(_("Current Texture size: %d"), _tex_size);
+        
+        vgDestroyImage(_vgimage);
     }
 
-    void apply(const gnash::SWFMatrix& bitmap_matrix,
-               bitmap_wrap_mode wrap_mode) const;
+    void disposed()  { _image.reset(); }
+    bool disposed() const { return !_image.get(); }
 
-    virtual image::GnashImage& image() {
+    image::GnashImage& image() {
         GNASH_REPORT_FUNCTION;
-        if (_cache.get()) {
-            return *_cache;
-        }
-        log_error("Image not cached!");
-#if 0
-        switch (_pixel_format) {
-            case GL_RGB:
-                _cache.reset(new image::ImageRGB(_orig_width, _orig_height));
-                break;
-            case GL_RGBA:
-                _cache.reset(new image::ImageRGBA(_orig_width, _orig_height));
-                break;
-            default:
-                std::abort();
+        if (_image) {
+            return *_image;
         }
-#endif
-        std::fill(_cache->begin(), _cache->end(), 0xff);
+    }    
 
-        return *_cache;
+    void apply(const gnash::SWFMatrix& bitmap_matrix,
+               bitmap_wrap_mode wrap_mode) const
+    {
+        GNASH_REPORT_FUNCTION;
+        gnash::SWFMatrix mat;
+        VGfloat     vmat[9];
+        
+        mat = bitmap_matrix;
+        
+        vgSetParameteri (_vgpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
+        vgPaintPattern (_vgpaint, _vgimage);
+        
+        mat.invert();
+        memset(vmat, 0, sizeof(vmat));
+        vmat[0] = mat.sx  / 65536.0f;
+        vmat[1] = mat.shx / 65536.0f;
+        vmat[3] = mat.shy / 65536.0f;
+        vmat[4] = mat.sy  / 65536.0f;
+        vmat[6] = mat.tx;
+        vmat[7] = mat.ty;
+        
+        vgSeti (VG_MATRIX_MODE, VG_MATRIX_FILL_PAINT_TO_USER);
+        vgLoadMatrix (vmat);
+        vgSeti (VG_MATRIX_MODE, VG_MATRIX_STROKE_PAINT_TO_USER);
+        vgLoadMatrix (vmat);
+        vgSeti (VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
+        
+        if (wrap_mode == WRAP_CLAMP) {  
+            vgSetParameteri (_vgpaint, VG_PAINT_PATTERN_TILING_MODE, 
VG_TILE_PAD);
+        } else {
+            vgSetParameteri (_vgpaint, VG_PAINT_PATTERN_TILING_MODE, 
VG_TILE_REPEAT);
+        }
     }
-    
-    int _width;
-    int _height;
 
-private:
-    
-    mutable boost::scoped_ptr<image::GnashImage> _img;
-    mutable boost::scoped_ptr<image::GnashImage> _cache;
+    // Accessors for the GnashImage internal data
+    int getWidth() { return _image->width(); };
+    int getHeight() { return _image->height(); };
+    boost::uint8_t *getData() const { return _image->begin(); };
+
+private:    
+    boost::scoped_ptr<image::GnashImage> _image;
     VGImageFormat   _pixel_format;
-    mutable VGImage _image;
-    VGPaint         _paint;
-    size_t          _orig_width;
-    size_t          _orig_height;
+    mutable VGImage _vgimage;
+    VGPaint         _vgpaint;
+    int             _tex_size;
 };
 
 } // namespace gnash::renderer::openvg

-----------------------------------------------------------------------

Summary of changes:
 configure.ac                           |    2 +
 libdevice/GnashDevice.h                |    7 +-
 libdevice/egl/eglDevice.cpp            |  106 ++++++++++-
 libdevice/egl/eglDevice.h              |    6 +
 libdevice/egl/test_egl.cpp             |    5 +-
 libdevice/x11/X11Device.h              |    2 -
 librender/Makefile.am                  |    1 +
 librender/Renderer.h                   |    2 +-
 librender/agg/Renderer_agg_bitmap.h    |    5 +-
 librender/openvg/Renderer_ovg.cpp      |  323 +++++++++++++++++++++++---------
 librender/openvg/Renderer_ovg.h        |   12 +-
 librender/openvg/Renderer_ovg_bitmap.h |  140 +++++++++-----
 librender/testr.cpp                    |   72 ++++----
 13 files changed, 494 insertions(+), 189 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]