[vlc-commits] Implement a first try for the WindowLess on Linux

Cheng Sun git at videolan.org
Thu Dec 13 15:51:52 CET 2012


npapi-vlc | branch: windowless | Cheng Sun <chengsun9 at gmail.com> | Thu Dec 13 15:11:37 2012 +0100| [5ce5f3897d5aedc04af85d5ae941d2383c1d4ca2] | committer: Jean-Baptiste Kempf

Implement a first try for the WindowLess on Linux

This is too slow, so far

> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=5ce5f3897d5aedc04af85d5ae941d2383c1d4ca2
---

 npapi/Makefile.am           |    4 +++
 npapi/vlcplugin.h           |    3 +++
 npapi/vlcwindowless_X11.cpp |   63 +++++++++++++++++++++++++++++++++++++++++++
 npapi/vlcwindowless_X11.h   |   38 ++++++++++++++++++++++++++
 4 files changed, 108 insertions(+)

diff --git a/npapi/Makefile.am b/npapi/Makefile.am
index 499d04a..2db531c 100644
--- a/npapi/Makefile.am
+++ b/npapi/Makefile.am
@@ -67,6 +67,10 @@ SOURCES_support = \
 	vlcplugin_xcb.h
 endif # !USE_GTK
 
+SOURCES_support += \
+	vlcwindowless_X11.cpp \
+	vlcwindowless_X11.h
+
 else # Win32
 
 # Under Win32|Mac, Mozilla plugins need to be named NP******.DLL, but under Unix
diff --git a/npapi/vlcplugin.h b/npapi/vlcplugin.h
index d18b782..bfbb946 100644
--- a/npapi/vlcplugin.h
+++ b/npapi/vlcplugin.h
@@ -12,6 +12,9 @@
 #       include "vlcplugin_xcb.h"
         typedef VlcPluginXcb VlcPlugin;
 #   endif
+#   define WINDOWLESS
+#   include "vlcwindowless_X11.h"
+    typedef VlcWindowlessX11 VlcWindowless;
 #elif defined(XP_WIN)
 #   include "vlcplugin_win.h"
     typedef VlcPluginWin VlcPlugin;
diff --git a/npapi/vlcwindowless_X11.cpp b/npapi/vlcwindowless_X11.cpp
new file mode 100644
index 0000000..5f2f18e
--- /dev/null
+++ b/npapi/vlcwindowless_X11.cpp
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * vlcwindowless_X11.cpp: a VLC plugin for Mozilla (X11 windowless)
+ *****************************************************************************
+ * Copyright © 2012 VideoLAN
+ * $Id$
+ *
+ * Authors: Cheng Sun <chengsun9 at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include "vlcwindowless_X11.h"
+
+#include <cstring>
+#include <cstdlib>
+
+VlcWindowlessX11::VlcWindowlessX11(NPP instance, NPuint16_t mode) :
+    VlcWindowlessBase(instance, mode)
+{
+}
+
+bool VlcWindowlessX11::handle_event(void *event)
+{
+#warning FIXME: this is waaayyy too slow!
+    XEvent *xevent = static_cast<XEvent *>(event);
+    switch (xevent->type) {
+    case GraphicsExpose:
+        XGraphicsExposeEvent *xgeevent = reinterpret_cast<XGraphicsExposeEvent *>(xevent);
+        Display *display = xgeevent->display;
+
+        int screen = XDefaultScreen(display);
+        XVisualInfo visual;
+        XMatchVisualInfo(display, screen, 24, TrueColor, &visual);
+        XImage *image = XCreateImage(display, visual.visual, 24, ZPixmap,
+                                    0, &m_frame_buf[0],
+                                    m_media_width, m_media_height,
+                                    DEF_PIXEL_BYTES*8,
+                                    m_media_width * DEF_PIXEL_BYTES);
+
+        const NPRect &clip = npwindow.clipRect;
+        XPutImage(display, xgeevent->drawable,
+                  XDefaultGCOfScreen(XScreenOfDisplay(display, screen)), image,
+                  clip.left - npwindow.x, clip.top - npwindow.y,
+                  clip.left, clip.top,
+                  clip.right - clip.left, clip.bottom - clip.top);
+        XFree(image);
+
+        return true;
+    }
+    return VlcWindowlessBase::handle_event(event);
+}
diff --git a/npapi/vlcwindowless_X11.h b/npapi/vlcwindowless_X11.h
new file mode 100644
index 0000000..ce5e5d8
--- /dev/null
+++ b/npapi/vlcwindowless_X11.h
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * vlcwindowless_X11.h: a VLC plugin for Mozilla (X11 windowless)
+ *****************************************************************************
+ * Copyright © 2012 VideoLAN
+ * $Id$
+ *
+ * Authors: Cheng Sun <chengsun9 at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef __VLCWINDOWLESS_X11_H__
+#define __VLCWINDOWLESS_X11_H__
+
+#include "vlcplugin_base.h"
+
+class VlcWindowlessX11 : public VlcWindowlessBase
+{
+public:
+    VlcWindowlessX11(NPP instance, NPuint16_t mode);
+
+    bool handle_event(void *event);
+};
+
+
+#endif /* __VLCWINDOWLESS_X11_H__ */



More information about the vlc-commits mailing list