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

Cheng Sun git at videolan.org
Thu Dec 13 15:19:23 CET 2012


npapi-vlc | branch: master | Cheng Sun <chengsun9 at gmail.com> | Thu Dec 13 15:11:37 2012 +0100| [fe079cd311b6bb7ac6ee03a2f528b6d964bc7a59] | 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=fe079cd311b6bb7ac6ee03a2f528b6d964bc7a59
---

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

diff --git a/npapi/Makefile.am b/npapi/Makefile.am
index cf78967..0efbef0 100644
--- a/npapi/Makefile.am
+++ b/npapi/Makefile.am
@@ -67,6 +67,10 @@ SOURCES_support = \
 	vlcplugin_xcb.h
 endif # !USE_GTK
 
+SOURCES_support += \
+	vlcwindowless_linux.cpp \
+	vlcwindowless_linux.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..351a444 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_linux.h"
+    typedef VlcWindowlessLinux VlcWindowless;
 #elif defined(XP_WIN)
 #   include "vlcplugin_win.h"
     typedef VlcPluginWin VlcPlugin;
diff --git a/npapi/vlcwindowless_linux.cpp b/npapi/vlcwindowless_linux.cpp
new file mode 100644
index 0000000..1bea76c
--- /dev/null
+++ b/npapi/vlcwindowless_linux.cpp
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * vlcwindowless_linux.cpp: a VLC plugin for Mozilla (Linux 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_linux.h"
+
+#include <cstring>
+#include <cstdlib>
+
+VlcWindowlessLinux::VlcWindowlessLinux(NPP instance, NPuint16_t mode) :
+    VlcWindowlessBase(instance, mode)
+{
+}
+
+bool VlcWindowlessLinux::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_linux.h b/npapi/vlcwindowless_linux.h
new file mode 100644
index 0000000..0607bba
--- /dev/null
+++ b/npapi/vlcwindowless_linux.h
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * vlcwindowless_linux.h: a VLC plugin for Mozilla (Linux 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_LINUX_H__
+#define __VLCWINDOWLESS_LINUX_H__
+
+#include "vlcplugin_base.h"
+
+class VlcWindowlessLinux : public VlcWindowlessBase
+{
+public:
+    VlcWindowlessLinux(NPP instance, NPuint16_t mode);
+
+    bool handle_event(void *event);
+};
+
+
+#endif /* __VLCWINDOWLESS_LINUX_H__ */



More information about the vlc-commits mailing list