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. 1432ffc95b31a81e3c56


From: Rob Savoye
Subject: [Gnash-commit] [SCM] Gnash branch, openvg, updated. 1432ffc95b31a81e3c56f0c3b0b70737abdaa047
Date: Thu, 25 Nov 2010 22:00:22 +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  1432ffc95b31a81e3c56f0c3b0b70737abdaa047 (commit)
      from  9d4b136c579618ad2b9738857da7871b9d6d14a8 (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=1432ffc95b31a81e3c56f0c3b0b70737abdaa047


commit 1432ffc95b31a81e3c56f0c3b0b70737abdaa047
Author: Rob Savoye <address@hidden>
Date:   Thu Nov 25 14:59:51 2010 -0700

    open an X11 window and start an event_loop. These are only used for 
testing, and use Xlib instead of GTK for potrability

diff --git a/librender/Renderer.h b/librender/Renderer.h
index 42f57a1..7c8f05e 100644
--- a/librender/Renderer.h
+++ b/librender/Renderer.h
@@ -505,9 +505,12 @@ public:
         return devs;
     }
 
+    void resetDevice() { _device.reset(); };
+    
     renderer::GnashDevice::dtype_t getDevice()
     {
         if (_device) {
+            return _device->getType();
         }
         return renderer::GnashDevice::NODEV;
     }
diff --git a/librender/testr.cpp b/librender/testr.cpp
index 5a30977..cf2aa60 100644
--- a/librender/testr.cpp
+++ b/librender/testr.cpp
@@ -32,14 +32,6 @@
 #include <boost/date_time/date.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 
-// FIXME: this should be a command line option
-#undef GTK_TEST_RENDER
-
-#ifdef HAVE_GTK2_XX
-# include <gtk/gtk.h>
-# include <gdk/gdk.h>
-#endif
-
 #include "log.h"
 #include "dejagnu.h"
 #include "SWFMatrix.h"
@@ -75,6 +67,16 @@
 # error "This file needs EGL"
 #endif
 
+#ifdef BUILD_EGL_DEVICE
+# include <eglDevice.h>
+#endif
+#ifdef BUILD_DIRECTFB_DEVICE
+# include <directfb/directfb.h>
+#endif
+#ifdef BUILD_X11_DEVICE
+# include <x11/X11Device.h>
+#endif
+
 TestState runtest;
 
 using namespace gnash; 
@@ -90,10 +92,6 @@ void test_iterators(Renderer *renderer, const std::string 
&type);
 // The debug log used by all the gnash libraries.
 static LogFile& dbglogfile = LogFile::getDefaultInstance();
 
-#ifdef HAVE_GTK2_XX
-GtkWidget *create_GTK_window();
-#endif
-
 // Simple class to do nanosecond based timing for performance analysis
 class Timer {
 public:
@@ -160,23 +158,21 @@ main(int argc, char *argv[])
         tmpimage->bpp * 8);
 #endif  // end of GTK_TEST_RENDER
 
+#ifdef BUILD_X11_DEVICE
+    x11::X11Device x11;
+    x11.initDevice(0, 0);
+    x11.createWindow("Foo", 0, 0, 640, 480);
+    x11.event_loop(10);
+    std::cerr << "Hello World!" << std::endl;
+    x11.event_loop(10);
+#endif
 #ifdef RENDERER_AGG
     Timer tagg("AGG");
     Renderer *renderer1 = create_Renderer_agg(pixelformat);
-#ifdef HAVE_GTK2_XX
-    GtkWidget *canvas = create_GTK_window();
-    GdkVisual* visual = gdk_drawable_get_visual(canvas->window);
-    GdkImage *offscreenbuf = gdk_image_new (GDK_IMAGE_FASTEST, visual, 
200,200);
-    static_cast<Renderer_agg_base *>(renderer1)->init_buffer(
-        (unsigned char*) offscreenbuf->mem,
-        offscreenbuf->bpl * offscreenbuf->height,
-        offscreenbuf->width,
-        offscreenbuf->height,
-        offscreenbuf->bpl);
-#endif
-    
     if (renderer1) {
         test_device(renderer1, "EGL");
+        test_device(renderer1, "DIRECTFB");
+        test_device(renderer1, "X11");
     }
     if (renderer1) {
         test_renderer(renderer1, "AGG");
@@ -262,15 +258,17 @@ main(int argc, char *argv[])
     tgl.stop();
     cerr << "OpenGL tests took " << tgl.elapsed() << endl;
 #endif
-#endif
-    
-#ifdef HAVE_GTK2_XX
-    gtk_main();
-    gtk_main_quit();
-    gtk_exit(0);
-#endif
+#endif    
 }
 
+// Each Renderer has an associated display device, currently EGL
+// for OpenVG, OpenGLES1, and OpenGLES2. The DirectFB device is
+// also available for these three renderers. The EGL device can
+// also be run under X11 using the Mesa libraries. Both EGL and
+// DirectFB are primarily for framebuffers. While all of the methods
+// of each device class are available to the Renderer, most aren't
+// exposed with more accesors beyond these for manipulating the
+// device setting itself.
 void
 test_device(Renderer *renderer, const std::string &type)
 {
@@ -282,6 +280,25 @@ test_device(Renderer *renderer, const std::string &type)
     } else {
         runtest.fail("Renderer::probeDevices()");
     }
+
+    // Be default, there should be no device associated with this
+    // renderer yet.
+    if (renderer->getDevice() == GnashDevice::NODEV) {
+        runtest.pass("Renderer::getDevice()");
+    } else {
+        runtest.fail("Renderer::getDevice()");
+    }
+
+    // Set to a device and see if it's axctually set
+    renderer->setDevice(GnashDevice::X11);
+    if (renderer->getDevice() == GnashDevice::X11) {
+        runtest.pass("Renderer::setDevice()");
+    } else {
+        runtest.fail("Renderer::setDevice()");
+    }
+
+    // reset to the original value so we don't screw up future tests
+    renderer->resetDevice();
 }
 
 void
diff --git a/librender/x11/X11Device.cpp b/librender/x11/X11Device.cpp
index 3748f11..2a1c3a6 100644
--- a/librender/x11/X11Device.cpp
+++ b/librender/x11/X11Device.cpp
@@ -36,6 +36,7 @@
 # include <X11/X.h>
 # include <X11/Xlib.h>
 # include <X11/Xutil.h>
+#include <X11/keysym.h>
 #else
 # error "This file needs X11"
 #endif
@@ -65,23 +66,19 @@ X11Device::X11Device()
       _vinfo(0)
 {
     GNASH_REPORT_FUNCTION;
+    dbglogfile.setVerbosity();
 }
 
 X11Device::~X11Device()
 {
     GNASH_REPORT_FUNCTION;
-    
-// #ifdef HAVE_GTK2_XX
-//     gdk_exit(0);
-// #else
-    // if (_display && _window) {
-    //     XDestroyWindow(_display, _window);
-    // }
     if (_display) {
+        if (_window) {
+            XDestroyWindow(_display, _window);
+        }
         XCloseDisplay(_display);
     }
     XFree(_vinfo);
-// #endif
 }
 
 bool
@@ -225,13 +222,109 @@ X11Device::getErrorString(int error)
     return msg;
 }
 
-#if 0
-int
-X11Device::getDepth(DFBSurfacePixelFormat format)
+// Create an X11 window to render in. This is only used by testing
+void
+X11Device::createWindow(const char *name, int x, int y, int width, int height)
 {
-    return 0;
+    GNASH_REPORT_FUNCTION;
+
+    if (!_display) {
+        log_error("No Display device set!");
+        return;
+    }
+    
+    if (!_window) {
+        log_error("No drawable window set!");
+        return;
+    }
+
+    XSetWindowAttributes attr;
+    unsigned long mask;
+    Window root;
+    XVisualInfo visTemplate;
+    int num_visuals;
+
+    // window attributes
+    attr.background_pixel = 0;
+    attr.border_pixel = 0;
+    attr.colormap = XCreateColormap(_display, _window, _vinfo->visual, 
AllocNone);
+    attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+    mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+    
+    _window = XCreateWindow(_display, _window, 0, 0, width, width,
+                        0, _vinfo->depth, InputOutput,
+                        _vinfo->visual, mask, &attr);
+    
+    // set hints and properties
+    XSizeHints sizehints;
+    sizehints.x = x;
+    sizehints.y = y;
+    sizehints.width  = width;
+    sizehints.height = height;
+    sizehints.flags = USSize | USPosition;
+    XSetNormalHints(_display, _window, &sizehints);
+    XSetStandardProperties(_display, _window, name, name, None, (char **)NULL,
+                           0, &sizehints);
+
+    XMapWindow(_display, _window);
+//    reshape(width, height);
+
+
+}
+
+void
+X11Device::event_loop(size_t passes)
+{
+    while (passes--) {
+        int redraw = 0;
+        XEvent event;
+        int width, height;
+        
+        reshape_func reshape = 0;
+        key_func     keyPress = 0;
+        draw_func    draw = 0;
+        
+        XNextEvent(_display, &event);
+        
+        switch (event.type) {
+          case Expose:
+              redraw = 1;
+              break;
+          case ConfigureNotify:
+              if (reshape) {
+                  width = event.xconfigure.width;
+                  height = event.xconfigure.height;
+                  reshape(event.xconfigure.width, event.xconfigure.height);
+              }
+              break;
+          case KeyPress:
+          {
+              char buffer[10];
+              int r, code;
+              code = XLookupKeysym(&event.xkey, 0);
+              if (!keyPress || !keyPress(code)) {
+                  r = XLookupString(&event.xkey, buffer, sizeof(buffer),
+                                    NULL, NULL);
+                  if (buffer[0] == 27) {
+                      // escape
+                      return;
+                  } else {
+                      std::cerr << buffer;
+                  }
+              }
+          }
+          redraw = 1;
+          break;
+          default:
+              ; // no-op
+        }
+        
+        if (redraw) {
+//            draw();
+//            eglSwapBuffers(egl_dpy, egl_surf);
+        }
+    } // end of while passes
 }
-#endif
 
 } // namespace x11
 } // namespace renderer
diff --git a/librender/x11/X11Device.h b/librender/x11/X11Device.h
index 9f54f9a..0ef2cec 100644
--- a/librender/x11/X11Device.h
+++ b/librender/x11/X11Device.h
@@ -89,7 +89,17 @@ class X11Device : public GnashDevice
     
     // Using X11 always means a native renderer
     bool isNativeRender() { return true; }
-    
+
+    // Create an X11 window to render in. This is only used by testing
+    void createWindow(const char *name, int x, int y, int width, int height);
+
+    /// Start an X11 event loop. This is only used by testing. Note that
+    /// calling this function blocks until the specified number of events
+    /// have been handled. The first 5 are used up by creating the window.
+    ///
+    /// @param passes the number of events to process before returning.
+    void event_loop(size_t passes);
+
 protected:
     Display    *_display;
     int         _screennum;
@@ -101,6 +111,11 @@ protected:
     XVisualInfo *_vinfo;
 };
 
+typedef void (*init_func)();
+typedef void (*reshape_func)(int, int);
+typedef void (*draw_func)();
+typedef int  (*key_func)(unsigned key);
+
 } // namespace x11
 } // namespace renderer
 } // namespace gnash

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

Summary of changes:
 librender/Renderer.h        |    3 +
 librender/testr.cpp         |   79 +++++++++++++++++-----------
 librender/x11/X11Device.cpp |  119 ++++++++++++++++++++++++++++++++++++++-----
 librender/x11/X11Device.h   |   17 ++++++-
 4 files changed, 173 insertions(+), 45 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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