[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ./ChangeLog plugin/Makefile.am plugin/pla...
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash ./ChangeLog plugin/Makefile.am plugin/pla... |
Date: |
Sat, 25 Feb 2006 05:19:16 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Branch:
Changes by: Rob Savoye <address@hidden> 06/02/25 05:19:16
Modified files:
. : ChangeLog
plugin : Makefile.am player.cpp plugin.cpp plugin.h
Removed files:
plugin : ogl_sdl.cpp ogl_sdl.h
Log message:
* plugin/Makefile.am: Add flags for GTKGLExt
dependancies. Remove ogl_sdl.cpp and ogl_sdl.h. Use -d instead of
-z to see if the directory exists.
* plugin/plugin.cpp: Don't use ogl_sdl, move the functionality
into the nsPluginInstance class. Add locking around all GL and X11
calls. Add Doxygen style comments blocks.
* plugin/plugin.h: Don't use ogl_sdl, move the definitions
into the nsPluginInstance class.
* plugin/ogl_sdl.{h,cpp}: Move functionality into nsPluginInstance
class. Remove files.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/ChangeLog.diff?tr1=1.156&tr2=1.157&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/Makefile.am.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/player.cpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/plugin.cpp.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/plugin.h.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
Patches:
Index: gnash/ChangeLog
diff -u gnash/ChangeLog:1.156 gnash/ChangeLog:1.157
--- gnash/ChangeLog:1.156 Sat Feb 25 03:54:03 2006
+++ gnash/ChangeLog Sat Feb 25 05:19:15 2006
@@ -78,6 +78,17 @@
2006-02-23 Rob Savoye <address@hidden>
+ * plugin/Makefile.am: Add flags for GTKGLExt
+ dependancies. Remove ogl_sdl.cpp and ogl_sdl.h. Use -d instead of
+ -z to see if the directory exists.
+ * plugin/plugin.cpp: Don't use ogl_sdl, move the functionality
+ into the nsPluginInstance class. Add locking around all GL and X11
+ calls. Add Doxygen style comments blocks.
+ * plugin/plugin.h: Don't use ogl_sdl, move the definitions
+ into the nsPluginInstance class.
+ * plugin/ogl_sdl.{h,cpp}: Move functionality into nsPluginInstance
+ class. Remove files.
+
* doc/C/sources.html: Add section on cross compiling Gnash.
* libgeometry/kd_tree_packed.cpp: Comment out the two somewhat
bogus assertions so this file can be cross compiled.
@@ -117,7 +128,7 @@
* macros/atk.m4: New file to look for Gnome ATK, which is
unfortunately a dependancy of GtkGlext.
* macros/cairo.m4: New file to look for Cairo, which we wanted to
- do eventually anyway, byt GtkGlext needs it too.
+ do eventually anyway, by GtkGlext needs it too.
* macros/glib.m4: New file to look for Glib, which is
unfortunately a dependancy of GtkGlext.
* macros/gtk2.m4: New file to look for GTK+ version 2.x, which is
Index: gnash/plugin/Makefile.am
diff -u gnash/plugin/Makefile.am:1.11 gnash/plugin/Makefile.am:1.12
--- gnash/plugin/Makefile.am:1.11 Thu Feb 9 19:49:14 2006
+++ gnash/plugin/Makefile.am Sat Feb 25 05:19:15 2006
@@ -41,6 +41,12 @@
-I$(srcdir)/mozilla-sdk \
$(LIBXML_CFLAGS) \
$(FIREFOX_CFLAGS) \
+ $(GLEXT_CFLAGS) \
+ $(GTK2_CFLAGS) \
+ $(PANGO_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(CAIRO_CFLAGS) \
+ $(ATK_CFLAGS) \
$(SDL_CFLAGS) \
$(SDL_MIXER_CFLAGS) \
$(X_CFLAGS) \
@@ -55,23 +61,30 @@
# api gets control.
AM_CPPFLAGS = -Wall -DPLUGIN_TRACE -DXP_UNIX $(FIREFOX_DEFS)
AM_LDFLAGS = $(FIREFOX_LIBS) $(X_LIBS) -lX11 -lXi -lXmu \
- $(SDL_LIBS)\
+ $(SDL_LIBS) \
$(SDL_MIXER_LIBS)\
- $(OPENGL_LIBS)\
- $(LIBXML_LIBS)\
- $(JPEG_LIBS)\
- $(PNG_LIBS)\
- $(DMALLOC_LIBS)\
- $(OGG_LIBS)\
+ $(OPENGL_LIBS) \
+ $(GLEXT_LIBS) \
+ $(GTK2_LIBS) \
+ $(PANGO_LIBS) \
+ $(CAIRO_LIBS) \
+ $(ATK_LIBS) \
+ $(GLIB_LIBS) \
+ $(LIBXML_LIBS) \
+ $(JPEG_LIBS) \
+ $(PNG_LIBS) \
+ $(DMALLOC_LIBS) \
+ $(OGG_LIBS) \
$(DMALLOC_LIBS)
+
# $(X_LIBS)\
# $(X_EXTRA_LIBS)
plugin_LTLIBRARIES = libgnashplugin.la
-noinst_HEADERS = plugin.h player.h ogl_sdl.h
+noinst_HEADERS = plugin.h player.h
-libgnashplugin_la_SOURCES = plugin.cpp player.cpp ogl_sdl.cpp
+libgnashplugin_la_SOURCES = plugin.cpp player.cpp
libgnashplugin_la_LIBADD = $(AM_LDFLAGS) \
mozilla-sdk/libmozsdk.la\
../backend/libgnashbackend.la\
@@ -79,18 +92,19 @@
../server/libgnashserver.la\
../libgeometry/libgnashgeo.la\
../libbase/libgnashbase.la
-libgnashplugin_la_LDFLAGS = -module -avoid-version -no-undefined
+libgnashplugin_la_LDFLAGS = -L$(plugindir) -module -avoid-version -no-undefined
# For now the plugin has to be installed in the root plugin
# directory for Firefox. For some reason if the same file is
# installed in the users $(HOME)/.firefox.plugins, the plugin
# won't load due to errors with an undefined MaiAtkObject.
install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
- test -z "$(plugindir)" || $(mkdir_p) "$(DESTDIR)$(plugindir)"
-# cp .libs/libgnashplugin.so $(DESTDIR)$(plugindir)/libgnashplugin.so
+ test -d "$(plugindir)" || mkdir "$(DESTDIR)$(plugindir)"
+# cp .libs/libgnashplugin.so $(DESTDIR)$(plugindir)/libgnashplugin.so
$(LIBTOOL) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG)
$(plugin_LTLIBRARIES) "$(DESTDIR)$(plugindir)/$(plugin_LTLIBRARIES)"
$(RM) $(DESTDIR)$(plugindir)/libgnashplugin.*a
+
# install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
# if test -d $(HOME)/.firefox ; then \
# $(mkinstalldirs) $(HOME)/.firefox/plugins; \
@@ -101,4 +115,4 @@
# fi
uninstall-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
- -rm -f $(DESTDIR)$(plugindir)/libgnashplugin.so
\ No newline at end of file
+ rm -f $(DESTDIR)$(plugindir)/libgnashplugin.so
Index: gnash/plugin/player.cpp
diff -u gnash/plugin/player.cpp:1.4 gnash/plugin/player.cpp:1.5
--- gnash/plugin/player.cpp:1.4 Sun Feb 5 22:17:49 2006
+++ gnash/plugin/player.cpp Sat Feb 25 05:19:16 2006
@@ -35,7 +35,6 @@
#include "tu_file.h"
#include "tu_types.h"
#include "xmlsocket.h"
-#include "ogl_sdl.h"
#ifdef HAVE_LIBXML
bool gofast = false; // FIXME: this flag gets set based on
@@ -72,7 +71,7 @@
static bool s_event_thread = false;
static bool s_start_waiting = false;
-int drawGLScene(GLvoid);
+SDL_mutex *Pmutex;
static void
message_log(const char* message)
@@ -126,6 +125,8 @@
bool sdl_abort = false;
int delay = 31;
float tex_lod_bias;
+
+ Pmutex = SDL_CreateMutex();
const char *infile = inst->getFilename();
@@ -164,6 +165,7 @@
gnash::set_sound_handler(sound);
}
#endif
+ inst->lockX();
render = gnash::create_render_handler_ogl();
gnash::set_render_handler(render);
@@ -186,9 +188,7 @@
printf("Calculated width is %d, height is %d\n", width, height);
//atexit(SDL_Quit);
- SDL_EnableKeyRepeat(250, 33);
-
- printf("%s: at line %d\n", __PRETTY_FUNCTION__, __LINE__);
+// printf("%s: at line %d\n", __PRETTY_FUNCTION__, __LINE__);
// Load the actual movie.
gnash::movie_definition* md = gnash::create_library_movie(infile);
@@ -203,7 +203,8 @@
exit(1);
}
gnash::set_current_root(m);
-
+ inst->freeX();
+
// Mouse state.
int mouse_x = 0;
@@ -216,22 +217,21 @@
Uint32 last_ticks = start_ticks;
int frame_counter = 0;
int last_logged_fps = last_ticks;
-
+
for (;;) {
- Uint32 ticks;
+ Uint32 ticks;
ticks = SDL_GetTicks();
- int delta_ticks = ticks - last_ticks;
- float delta_t = delta_ticks / 1000.f;
- last_ticks = ticks;
+ int delta_ticks = ticks - last_ticks;
+ float delta_t = delta_ticks / 1000.f;
+ last_ticks = ticks;
// Check auto timeout counter.
- if (exit_timeout > 0
- && ticks - start_ticks > (Uint32) (exit_timeout * 1000)) {
- // Auto exit now.
- break;
- }
-
-// drawGLScene();
+ if (exit_timeout > 0
+ && ticks - start_ticks > (Uint32) (exit_timeout * 1000)) {
+ // Auto exit now.
+ break;
+ }
+ inst->lockX();
m = gnash::get_current_root();
gnash::delete_unused_root();
@@ -239,26 +239,35 @@
// m->set_background_alpha(s_background ? 1.0f : 0.05f);
m->notify_mouse_state(mouse_x, mouse_y, mouse_buttons);
m->advance(delta_t * speed_scale);
-
// if (do_render) {
// glDisable(GL_DEPTH_TEST); // Disable depth testing.
// glDrawBuffer(GL_BACK);
// }
- SDL_mutexP(mutex);
- m->display();
- frame_counter++;
- SDL_GL_SwapBuffers();
- SDL_mutexV(mutex);
+#ifdef TEST_GRAPHIC
+ inst->drawTestScene();
+#else
+ inst->setGL();
+ m->display();
+ inst->freeX();
+#endif
+ frame_counter++;
+
+ // See if we should exit. FIXME:
+ if (m->get_current_frame() + 1 == md->get_frame_count()) {
+ // We're reached the end of the movie; exit.
+ break;
+ }
+
//glPopAttrib ();
// Don't hog the CPU.
- SDL_Delay(delay);
- }
-
+ sleep(delay);
+ }
// SDL_KillThread(thread); // kill the network read thread
-// SDL_Q217.22.58.161uit();
+// SDL_Quit();
+ inst->lockX();
if (md) {
md->drop_ref();
}
@@ -271,6 +280,7 @@
// Clean up as much as possible, so valgrind will help find actual leaks.
gnash::clear();
+ inst->freeX();
return 0;
}
@@ -340,28 +350,32 @@
int
playerThread(void *arg)
{
- printf("%s:\n", __PRETTY_FUNCTION__);
+ printf("%s: at pid %d\n", __PRETTY_FUNCTION__, getpid());
nsPluginInstance *inst = (nsPluginInstance *)arg;
- int retries;
-
- if (!GLinitialized) {
- initGL(inst);
- GLinitialized = true;
+ int retries = 0;
+
+#ifdef TEST_GRAPHIC
+ while (!inst->getShutting()) {
+ inst->lockX();
+ inst->setGL();
+ inst->drawTestScene();
+ inst->swapBuffers();
+ inst->freeX();
+ sleep(15);
}
-
- while (retries++ < 2) {
-#if 0
- drawGLScene();
#else
- main_loop(inst);
+ main_loop(inst);
#endif
- SDL_Delay(20); // don't trash the CPU
+
+
+
+//#endif
+// SDL_Delay(20); // don't trash the CPU
// So we don't run forever for now.
- printf("%s(%d): FIXME: loop timed out\n",
- __PRETTY_FUNCTION__, __LINE__);
- break;
- }
-
+// printf("%s(%d): FIXME: loop timed out\n",
+// __PRETTY_FUNCTION__, __LINE__);
+// }
+
return 0;
}
Index: gnash/plugin/plugin.cpp
diff -u gnash/plugin/plugin.cpp:1.13 gnash/plugin/plugin.cpp:1.14
--- gnash/plugin/plugin.cpp:1.13 Sat Feb 25 03:15:51 2006
+++ gnash/plugin/plugin.cpp Sat Feb 25 05:19:16 2006
@@ -23,13 +23,17 @@
#define MIME_TYPES_HANDLED "application/x-shockwave-flash"
// The name must be this value to get flash movies that check the
// plugin version to load.
-#define PLUGIN_NAME "Shockwave Flash 7.0"
+#define PLUGIN_NAME "Shockwave Flash 8.0"
#define MIME_TYPES_DESCRIPTION MIME_TYPES_HANDLED":swf:"PLUGIN_NAME
-#define PLUGIN_DESCRIPTION "Gnash, a GPL\'d FLash Player. More details at
http://www.gnu.org/software/gnash/"
+#define PLUGIN_DESCRIPTION "Gnash, a GPL\'d Flash Player. More details at
http://www.gnu.org/software/gnash/"
+#include <GL/glx.h>
#include <GL/gl.h>
#include <GL/glu.h>
-
+//#include <X11/extensions/xf86vmode.h>
+#ifdef HAVE_GTK_GTKGL_H
+#include <gtk/gtkgl.h>
+#endif
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -44,7 +48,6 @@
#include <string>
-#include "ogl_sdl.h"
#include "player.h"
#include "xmlsocket.h"
@@ -53,16 +56,35 @@
using namespace std;
-extern bool GLinitialized;
extern bool processing;
-static int streamfd = -1;
-static float s_scale = 1.0f;
-static bool s_verbose = false;
-static int doneYet = 0;
+// Static members. We have to share this data amongst all
+NPBool nsPluginInstance::_plugInitialized = FALSE;
+
+// These aren't static members of the class because we have to
+// call these from the C callback for the Mozilla SDK.
+Display *gxDisplay;
+SDL_mutex *glMutex;
+
+// static int streamfd = -1;
+// static float s_scale = 1.0f;
+// static bool s_verbose = false;
+// static int doneYet = 0;
static bool waitforgdb = false;
const int INBUFSIZE = 1024;
+static void xt_event_handler(Widget xtwidget, nsPluginInstance *plugin,
+ XEvent *xevent, Boolean *b);
+
+
+//Display *_xDisplay = NULL;
+
+#if 0
+static int attributeList_noFSAA[] = { GLX_RGBA, GLX_DOUBLEBUFFER,
GLX_STENCIL_SIZE, 1, None };
+#else
+static int attributeList_noFSAA[] = { GLX_RGBA, GLX_DOUBLEBUFFER, None };
+#endif
+static int attributeList_FSAA[] = { GLX_RGBA, GLX_DOUBLEBUFFER,
GLX_STENCIL_SIZE, 1, GLX_SAMPLE_BUFFERS_ARB, 1,GLX_SAMPLES_ARB, 1, None };
#ifdef HAVE_LIBXML
extern int xml_fd; // FIXME: this is the file descriptor
@@ -71,54 +93,76 @@
// the layers properly, but first I
// want to make sure it all works.
#endif // HAVE_LIBXML
-static int eventThread(void *inst);
-int playswf(nsPluginInstance *inst);
-
-SDL_Thread *thread = NULL;
+/// \brief Return the MIME Type description for this plugin.
char*
NPP_GetMIMEDescription(void)
{
return(MIME_TYPES_DESCRIPTION);
}
-static void
-log_callback(bool error, const char* message)
-// Error callback for handling messages.
-{
- if (error) {
- printf(message);
- }
-}
-
-
-/////////////////////////////////////
+//
// general initialization and shutdown
//
+
+/// \brief Initialize the plugin
+///
+/// This C function gets called once when the plugin is loaded,
+/// regardless of how many instantiations there is actually playing
+/// movies. So this is where all the one time only initialization
+/// stuff goes.
NPError
NS_PluginInitialize()
{
- printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ printf("%s: Initializing the Plugin\n",
+ __PRETTY_FUNCTION__);
+// SDL_Init(SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE);
+ glMutex = SDL_CreateMutex();
+ gxDisplay = XOpenDisplay(NULL);
+
return NPERR_NO_ERROR;
}
+/// \brief Shutdown the plugin
+///
+/// This C function gets called once when the plugin is being
+/// shutdown, regardless of how many instantiations actually are
+/// playing movies. So this is where all the one time only
+/// shutdown stuff goes.
void
NS_PluginShutdown()
{
- printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ printf("%s(%d): Shutting down the plugin\n", __PRETTY_FUNCTION__,
__LINE__);
+ XCloseDisplay(gxDisplay);
+ gxDisplay = NULL;
+ SDL_DestroyMutex(glMutex);
+// SDL_Quit();
}
-// get values per plugin
+/// \brief Retrieve values from the plugin for the Browser
+///
+/// This C function is called by the browser to get certain
+/// information is needs from the plugin. This information is the
+/// plugin name, a description, etc...
NPError
NS_PluginGetValue(NPPVariable aVariable, void *aValue)
{
+ char tmp[1024];
NPError err = NPERR_NO_ERROR;
+
switch (aVariable) {
case NPPVpluginNameString:
*((char **)aValue) = PLUGIN_NAME;
break;
+ // This becomes the description field you see below the opening
+ // text when you type about:plugins
case NPPVpluginDescriptionString:
- *((char **)aValue) = PLUGIN_DESCRIPTION;
+ snprintf(tmp, 1024,
+ "Gnash, a GPL\'d Flash Player. More details at "
+ "<a href=http://www.gnu.org/software/gnash/>"
+ "http://www.gnu.org/software/gnash</a>"
+ );
+ *((char **)aValue) = tmp;
break;
case NPPVpluginTimerInterval:
case NPPVpluginNeedsXEmbed:
@@ -130,10 +174,10 @@
return err;
}
-/////////////////////////////////////////////////////////////
-//
-// construction and destruction of our plugin instance object
-//
+/// \brief construct our plugin instance object
+///
+/// This instantiates a new object via a C function used by the
+/// browser.
nsPluginInstanceBase *
NS_NewPluginInstance(nsPluginCreateData * aCreateDataStruct)
{
@@ -146,260 +190,277 @@
return plugin;
}
+/// \brief destroy our plugin instance object
+///
+/// This destroys our instantiated object via a C function used by the
+/// browser.
void
NS_DestroyPluginInstance(nsPluginInstanceBase * aPlugin)
{
printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
- if(aPlugin)
+ if (aPlugin) {
delete (nsPluginInstance *)aPlugin;
+ }
}
-////////////////////////////////////////
//
// nsPluginInstance class implementation
//
+
+/// \brief Construct a new nsPluginInstance object
nsPluginInstance::nsPluginInstance(NPP aInstance) : nsPluginInstanceBase(),
mInstance(aInstance),
- mInitialized(FALSE),
mWindow(0),
mXtwidget(0),
mFontInfo(0),
- thr_count(0)
+ mContext(NULL),
+ _glInitialized(FALSE)
{
printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+// _plugInitialized(FALSE);
+ bShutting = FALSE;
+ mThread = NULL;
+// mMutex = SDL_CreateMutex();
}
-// Cleanup resources
+/// \brief Destroy a nsPluginInstance object
nsPluginInstance::~nsPluginInstance()
{
printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
-
+// if (mThread != NULL) {
+// SDL_KillThread(mThread);
+// }
#if 0
if (cond) {
SDL_DestroyCond(cond);
}
- if (mutex) {
- SDL_DestroyMutex(mutex);
- }
- if (thread) {
- SDL_KillThread(thread);
- }
- SDL_Quit();
#endif
}
-static void
-xt_event_handler(Widget xtwidget, nsPluginInstance *plugin, XEvent *xevent,
Boolean *b)
+/// \brief Initialize an instance of the plugin object
+///
+/// This methods initializes the plugin object, and is called for
+/// every movie that gets played. This is where the movie playing
+/// specific initialization goes.
+NPBool
+nsPluginInstance::init(NPWindow* aWindow)
{
- int keycode;
- KeySym keysym;
-#if 0
- SDL_Event sdl_event;
- SDL_keysym sdl_keysym;
-
- // handleKeyPress((SDL_keysym)keysym);
- printf("Peep Event returned %d\n", SDL_PeepEvents(&sdl_event, 1,
SDL_PEEKEVENT,
SDL_USEREVENT|SDL_ACTIVEEVENT|SDL_KEYDOWN|SDL_KEYUP|SDL_MOUSEBUTTONUP|SDL_MOUSEBUTTONDOWN));
-
- if (SDL_PollEvent(&sdl_event)) {
- switch(sdl_event.type) {
- case SDL_ACTIVEEVENT:
- case SDL_VIDEORESIZE:
- case SDL_KEYDOWN:
- /* handle key presses */
- handleKeyPress( &sdl_event.key.keysym );
- break;
- default:
- break;
-
- }
+ if(aWindow == NULL) {
+ printf("%s: ERROR: Window handle was bogus!\n", __PRETTY_FUNCTION__);
+ return FALSE;
+ } else {
+ printf("%s: X origin = %d, Y Origin = %d, Width = %d,"
+ " Height = %d WindowID = %p this = %p\n",
+ __PRETTY_FUNCTION__,
+ aWindow->x, aWindow->y, aWindow->width, aWindow->height,
+ aWindow->window, this);
}
-#endif
-
- switch (xevent->type) {
- case Expose:
- // get rid of all other exposure events
- if (plugin) {
- if (GLinitialized) {
-// drawGLScene();
- printf("HACK ALERT! ignoring expose event!\n");
- } else {
- printf("GL Surface not initialized yet, ignoring expose
event!\n");
- }
- }
- break;
- case ButtonPress:
-// fe.type = FeButtonPress;
- printf("Button Press\n");
- break;
- case ButtonRelease:
- // fe.type = FeButtonRelease;
- printf("Button Release\n");
- break;
- case KeyPress:
- keycode = xevent->xkey.keycode;
- keysym = XLookupKeysym((XKeyEvent*)xevent, 0);
- printf ("%s(%d): Keysym is %s\n", __PRETTY_FUNCTION__, __LINE__,
- XKeysymToString(keysym));
- switch (keysym) {
- case XK_Up:
- printf("Key Up\n");
- break;
- case XK_Down:
- printf("Key Down\n");
- break;
- case XK_Left:
- printf("Key Left\n");
- break;
- case XK_Right:
- printf("Key Right\n");
- break;
- case XK_Return:
- printf("Key Return\n");
- break;
-
- default:
- break;
- }
+ // Only for developers. Make the plugin block here so we can
+ // attach GDB to it.
+ bool gdb = false;
+ while (gdb) {
+ printf ("Waiting for GDB for pid %d\n", getpid());
+ sleep(5);
+ }
+
+ if (_plugInitialized) {
+ printf("%s Already initialized...\n", __PRETTY_FUNCTION__);
+ return TRUE;
}
-}
-NPBool nsPluginInstance::init(NPWindow* aWindow)
-{
- printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ initGL();
-// initGL(this);
-// surface_activated = true;
+ _plugInitialized = TRUE;
- mutex = SDL_CreateMutex();
+// char SDL_windowhack[32];
+// sprintf (SDL_windowhack,"SDL_WINDOWID=%d", aWindow->window);
+// putenv (SDL_windowhack);
- if(aWindow == NULL) {
- return FALSE;
- }
-
- if (SetWindow(aWindow)) {
- mInitialized = TRUE;
- }
-
- return mInitialized;
-}
-
-void nsPluginInstance::shut()
-{
- printf("%s(%d): Entering. Thread_count is %d\n", __PRETTY_FUNCTION__,
__LINE__, thr_count);
- mInitialized = FALSE;
+// _plugInitialized = TRUE;
+ // We're only keeping track of the instantiations for debugging
+ // purposes, so this variable should basically be ignored.
+// _instantiations++;
+// char tmp[100];
+// memset(tmp, 0, 100);
+// sprintf(tmp, "%s: Instantiations count: %d\n",
+// __PRETTY_FUNCTION__, _instantiations);
+// WriteStatus(tmp);
- GLinitialized = false;
-
-#if 0
- if (cond) {
- SDL_DestroyCond(cond);
- }
-#endif
- if (mutex) {
- SDL_DestroyMutex(mutex);
- mutex = NULL;
- }
- if (thread) {
- SDL_KillThread(thread);
- thread = NULL;
- }
-
- if (thr_count-- >= 1) {
- SDL_Quit();
- }
+ return TRUE;
}
-const char * nsPluginInstance::getVersion()
+/// \brief Shutdown an instantiated object
+///
+/// This shuts down an object, and is called for every movie that gets
+/// played. This is where the movie playing specific shutdown code
+/// goes.
+void
+nsPluginInstance::shut()
{
- return NPN_UserAgent(mInstance);
-}
+ printf("%s(%d): Entering. \n", __PRETTY_FUNCTION__, __LINE__);
-NPError nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
+ destroyContext();
+
+ if (mThread) {
+ SDL_KillThread(mThread);
+ mThread = NULL;
+ }
+
+ // We're only keeping track of the instantiations for debugging
+ // purposes, so this variable should basically be ignored.
+// _instantiations--;
+// char tmp[100];
+// memset(tmp, 0, 100);
+// sprintf(tmp, "%s: Instantiations count: %d\n",
+// __PRETTY_FUNCTION__, _instantiations);
+// WriteStatus(tmp);
+}
+
+/// \brief Set the window to be used to render in
+///
+/// This sets up the window the plugin is supposed to render
+/// into. This calls passes in various information used by the plugin
+/// to setup the window. This may get called multiple times by each
+/// instantiated object, so it can't do much but window specific
+/// setup here.
+NPError
+nsPluginInstance::SetWindow(NPWindow* aWindow)
{
- NPError err = NPERR_NO_ERROR;
- switch (aVariable) {
- case NPPVpluginNameString:
- case NPPVpluginDescriptionString:
- return NS_PluginGetValue(aVariable, aValue) ;
- break;
- default:
- err = NPERR_INVALID_PARAM;
- break;
+ if(aWindow == NULL) {
+ printf("%s: ERROR: Window handle was bogus!\n", __PRETTY_FUNCTION__);
+ return FALSE;
+ } else {
+ printf("%s: X origin = %d, Y Origin = %d, Width = %d,"
+ " Height = %d WindowID = %p this = %p\n",
+ __PRETTY_FUNCTION__,
+ aWindow->x, aWindow->y, aWindow->width, aWindow->height,
+ aWindow->window, this);
+ }
+
+ if (_glInitialized) {
+ printf("%s Already initialized...\n", __PRETTY_FUNCTION__);
+ return TRUE;
}
- return err;
-
-}
-
-NPError nsPluginInstance::SetWindow(NPWindow* aWindow)
-{
+
if(aWindow == NULL)
return FALSE;
-
+
+ if (aWindow->x == mX && aWindow->y == mY
+ && aWindow->width == mWidth
+ && aWindow->height == mHeight
+ && (unsigned int)(aWindow->window) == mWindow) {
+ return TRUE;
+ }
+
mX = aWindow->x;
mY = aWindow->y;
mWidth = aWindow->width;
mHeight = aWindow->height;
-
- printf("%s: X origin = %d, Y Origin = %d, Width = %d, Height = %d\n",
- __PRETTY_FUNCTION__, mX, mY, mWidth, mHeight);
-
+
if (mWindow == (Window) aWindow->window) {
// The page with the plugin is being resized.
// Save any UI information because the next time
// around expect a SetWindow with a new window id.
+ printf("Error: Setwindow() called with same window handle - but
resizing plugin unhandled!\n");
} else {
mWindow = (Window) aWindow->window;
NPSetWindowCallbackStruct *ws_info = (NPSetWindowCallbackStruct
*)aWindow->ws_info;
- mDisplay = ws_info->display;
- mVisual = ws_info->visual;
+ mVisual = ws_info->visual;
mDepth = ws_info->depth;
mColormap = ws_info->colormap;
if (!mFontInfo) {
- if (!(mFontInfo = XLoadQueryFont(mDisplay, "9x15")))
+ if (!(mFontInfo = XLoadQueryFont(gxDisplay, "9x15")))
printf("Cannot open 9X15 font\n");
}
+
+ XVisualInfo *vi = glXChooseVisual(gxDisplay, DefaultScreen(gxDisplay),
attributeList_FSAA);
+ if (vi == NULL) {
+ vi = glXChooseVisual(gxDisplay, DefaultScreen(gxDisplay),
attributeList_noFSAA);
+ } else {
+ vi->visual = mVisual;
+ }
+
+ mContext = glXCreateContext(gxDisplay, vi, 0, GL_TRUE);
+ if (mContext) {
+ printf("Got new glx Context\n");
+ _glInitialized = TRUE;
+ setGL();
+ }
- // add xt event handler
- Widget xtwidget = XtWindowToWidget(mDisplay, mWindow);
- if (xtwidget && mXtwidget != xtwidget) {
- mXtwidget = xtwidget;
- // mask values are:
- // KeyPress, KeyRelease, ButtonPress, ButtonRelease,
- // PointerMotion, Button1Motion, Button2Motion, Button3Motion,
- // Button4Motion, Button5Motion
- long event_mask =
ExposureMask|KeyPress|KeyRelease|ButtonPress|ButtonRelease;
- XSelectInput(mDisplay, mWindow, event_mask);
- XtAddEventHandler(xtwidget, event_mask, False,
(XtEventHandler)xt_event_handler, this);
- }
- }
-
#if 0
- if (aWindow->type == NPWindowTypeWindow) {
- WriteStatus("Window type is \"Windowed\"");
- }
- if (aWindow->type == NPWindowTypeDrawable) {
- WriteStatus("Window type is \"Drawable\"");
- }
+ // add xt event handler
+ Widget xtwidget = XtWindowToWidget(gxDisplay, mWindow);
+ printf("After XtWindowToWidget!\n");
+ if (xtwidget && mXtwidget != xtwidget) {
+ mXtwidget = xtwidget;
+ // mask values are:
+ // KeyPress, KeyRelease, ButtonPress, ButtonRelease,
+ // PointerMotion, Button1Motion, Button2Motion, Button3Motion,
+ // Button4Motion, Button5Motion
+ long event_mask =
ExposureMask|KeyPress|KeyRelease|ButtonPress|ButtonRelease;
+ XSelectInput(gxDisplay, mWindow, event_mask);
+ printf("After XSelectInput!\n");
+ XtAddEventHandler(xtwidget, event_mask, False,
(XtEventHandler)xt_event_handler, this);
+ printf("After XtAddEventHandler!\n");
+ }
#endif
+ }
- return TRUE;
+ resizeWindow(mWidth,mHeight);
+
+ return NPERR_NO_ERROR;
+}
+
+const char *
+nsPluginInstance::getVersion()
+{
+ printf("%s(%d): Entering. \n", __PRETTY_FUNCTION__, __LINE__);
+ return NPN_UserAgent(mInstance);
+}
+
+NPError
+nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
+{
+ NPError err = NPERR_NO_ERROR;
+ switch (aVariable) {
+ case NPPVpluginNameString:
+ case NPPVpluginDescriptionString:
+ return NS_PluginGetValue(aVariable, aValue) ;
+ break;
+ default:
+ err = NPERR_INVALID_PARAM;
+ break;
+ }
+ return err;
+
}
-// Write a status message to the status line and the console.
+/// \brief Write a status message
+///
+/// This writes a status message to the status line at the bottom of
+/// the browser window and the console firefox was started from.
NPError
nsPluginInstance::WriteStatus(char *msg) const
{
NPN_Status(mInstance, msg);
printf("%s\n", msg);
+
+ return NPERR_NO_ERROR;
}
-// Open a new incoming data stream, which is the flash movie we want to play.
-// A URL can be pretty ugly, like in this example:
-//
http://www.shockwave.com/swf/navbar/navbar_sw.swf?atomfilms=http%3a//www.atomfilms.com/af/home/&shockwave=http%3a//www.shockwave.com&gameblast=http%3a//gameblast.shockwave.com/gb/gbHome.jsp&known=0
-//
../flash/gui.swf?ip_addr=foobar.com&ip_port=3660&show_cursor=true&path_prefix=../flash/&trapallkeys=true"
+/// \brief Open a new data stream
+///
+/// Opens a new incoming data stream, which is the flash movie we want
+/// to play.
+/// A URL can be pretty ugly, like in this example:
+///
http://www.shockwave.com/swf/navbar/navbar_sw.swf?atomfilms=http%3a//www.atomfilms.com/af/home/&shockwave=http%3a//www.shockwave.com&gameblast=http%3a//gameblast.shockwave.com/gb/gbHome.jsp&known=0
+///
../flash/gui.swf?ip_addr=foobar.com&ip_port=3660&show_cursor=true&path_prefix=../flash/&trapallkeys=true"
+///
+/// So this is where we parse the URL to get all the options passed in
+/// when invoking the plugin.
NPError
nsPluginInstance::NewStream(NPMIMEType type, NPStream * stream,
NPBool seekable, uint16 * stype)
@@ -408,7 +469,7 @@
memset(tmp, 0, 300);
string url = stream->url;
string fname, opts;
- string::size_type start, end, eq;
+ unsigned int start, end, eq;
bool dumpopts = false;
end = url.find(".swf", 0) + 4;
@@ -425,17 +486,6 @@
printf("The full URL is %s\n", url.c_str());
while (opts.size() > 0) {
- // Wait for GDB
- if (waitforgdb) {
- printf("Attach GDB to PID %d to debug!\n", getpid());
- printf("This thread will block until then!...\n");
- printf("Once blocked here, you can set other breakpoints.\n");
- printf("do a \"set variable waitforgdb=false\" to continue\n");
- while (waitforgdb) {
- sleep(1);
- }
- }
-
start = 0;
eq = opts.find("=", 0);
if (opts[0] == '&') {
@@ -474,15 +524,15 @@
// printf("%s: URL is %s\n", __PRETTY_FUNCTION__, url.c_str());
printf("%s: Open stream for %s (%d, %d)\n", __PRETTY_FUNCTION__,
fname.c_str(), start, end);
- sprintf(tmp, "Loading Shockwave file %s", fname.c_str());
+ sprintf(tmp, "Loading Flash movie %s", fname.c_str());
WriteStatus(tmp);
- streamfd = open(fname.c_str(), O_CREAT | O_WRONLY,
S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
- if (streamfd < 0) {
+ _streamfd = open(fname.c_str(), O_CREAT | O_WRONLY,
S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
+ if (_streamfd < 0) {
sprintf(tmp,"%s can't be opened, check your permissions!\n",
fname.c_str());
WriteStatus(tmp);
- streamfd = open(fname.c_str(), O_TRUNC | O_WRONLY,
S_IRUSR|S_IRGRP|S_IROTH);
- if (streamfd < 0) {
+ _streamfd = open(fname.c_str(), O_TRUNC | O_WRONLY,
S_IRUSR|S_IRGRP|S_IROTH);
+ if (_streamfd < 0) {
sprintf(tmp,"%s can't be created, check your permissions!\n",
fname.c_str());
WriteStatus(tmp);
}
@@ -490,28 +540,40 @@
swf_file = fname;
processing = true;
+
return NPERR_NO_ERROR;
}
+/// \brief Destroy the data stream we've been reading.
NPError
nsPluginInstance::DestroyStream(NPStream * stream, NPError reason)
{
printf("%s (%i): %s\n", __PRETTY_FUNCTION__, reason, stream->url);
processing = false;
- if (streamfd) {
- close(streamfd);
- streamfd = -1;
+ if (_streamfd) {
+ close(_streamfd);
+ _streamfd = -1;
+ }
+
+ // Wait for GDB
+ if (waitforgdb) {
+ printf("Attach GDB to PID %d to debug!\n", getpid());
+ printf("This thread will block until then!...\n");
+ printf("Once blocked here, you can set other breakpoints.\n");
+ printf("do a \"set variable waitforgdb=false\" to continue\n");
+ while (waitforgdb) {
+ sleep(1);
+ }
}
// cond = SDL_CreateCond();
- thr_count++;
-// thread = SDL_CreateThread(playerThread, (void *)this);
- thread = SDL_CreateThread(eventThread, (void *)this);
-
-// SDL_mutexP(mutex);
+// mThread = SDL_CreateThread(playerThread, (void *)this);
// SDL_CondSignal(cond);
+ drawTestScene();
+
+ return NPERR_NO_ERROR;
}
void
@@ -522,7 +584,7 @@
printf("URL: %s\nReason %i\n", url, reason);
}
-// Return how many bytes we can read into the buffer
+/// \brief Return how many bytes we can read into the buffer
int32
nsPluginInstance::WriteReady(NPStream * stream)
{
@@ -532,7 +594,9 @@
return INBUFSIZE;
}
-// Read the daat stream from Mozilla/Firefox
+/// \brief Read the data stream from Mozilla/Firefox
+///
+/// For now we read the bytes and write them to a disk file.
int32
nsPluginInstance::Write(NPStream * stream, int32 offset, int32 len,
void *buffer)
@@ -541,36 +605,273 @@
// printf("Reading Stream %s, offset is %d, length = %d \n",
// stream->url, offset, len);
- write(streamfd, buffer, len);
+ return write(_streamfd, buffer, len);
}
-static int
-eventThread(void *arg)
+/// \brief Initialize OpenGL
+///
+void
+nsPluginInstance::initGL()
{
- printf("%s: \n", __PRETTY_FUNCTION__);
- int retries = 0;
+ printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+
+ if (_glInitialized) {
+ printf("%s: OpenGL already initialized...\n", __PRETTY_FUNCTION__);
+ return;
+ }
+
+ // Grab control of the display
+ lockGL();
+ setGL();
+ lockX();
+
+ printf("%s: Initializing OpenGL...\n", __PRETTY_FUNCTION__);
+
+ // Enable smooth shading
+ glShadeModel(GL_SMOOTH);
+
+ // Set the background black
+ glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ // Depth buffer setup
+ glClearDepth(1.0f);
- nsPluginInstance *inst = (nsPluginInstance *)arg;
+ // Enables Depth Testing
+ glEnable(GL_DEPTH_TEST);
+
+ // The Type Of Depth Test To Do
+ glDepthFunc(GL_LEQUAL);
+
+ // Really Nice Perspective Calculations
+ glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
+
+ // Release control of the display
+ freeX();
+ freeGL();
+}
+
+/// \brief Shutdown OpenGL
+void
+nsPluginInstance::destroyContext()
+{
+ printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+
+ if (!_glInitialized) {
+ printf("%s: OpenGL already killed...\n", __PRETTY_FUNCTION__);
+ return;
+ }
- if (!GLinitialized) {
- initGL(inst);
- GLinitialized = true;
+ if (gxDisplay && mContext) {
+ // Grab control of the display
+ lockGL();
+ setGL();
+ lockX();
+
+ printf("%s: Destroying GLX Context...\n", __PRETTY_FUNCTION__);
+ glXDestroyContext(gxDisplay, mContext);
+ _glInitialized = FALSE;
+ mContext = NULL;
+
+ // Release control of the display
+ freeX();
+ freeGL();
+ }
+}
+
+/// \brief Resize our viewport after a window resize event
+int
+nsPluginInstance::resizeWindow( int width, int height )
+{
+ printf("%s(%d): Width = %d, Height = %d\n",
+ __PRETTY_FUNCTION__, __LINE__, width, height);
+
+ if (!_plugInitialized) {
+ printf("%s: OpenGL not initialized...\n", __PRETTY_FUNCTION__);
+ return true;
}
+
+ // Grab control of the display
+ lockGL();
+ setGL();
+ lockX();
- while (retries++ < 2) {
-#if 1
- drawGLScene();
-#else
- main_loop(inst);
+ printf("%s: Resizing window...\n", __PRETTY_FUNCTION__);
+
+ // Height / width ration
+ GLfloat ratio;
+
+ // Protect against a divide by zero
+ if (height == 0) {
+ height = 1;
+ }
+
+ ratio = (GLfloat)width / (GLfloat)height;
+
+ // Setup our viewport.
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ // change to the projection matrix and set our viewing volume.
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+
+ // Set our perspective
+ gluPerspective(45.0f, ratio, 0.1f, 100.0f);
+
+ // Make sure we're changing the model view and not the projection
+ glMatrixMode(GL_MODELVIEW);
+
+ // Reset The View
+// glLoadIdentity();
+
+ // Release control of the display
+ freeX();
+ freeGL();
+
+ return(true);
+}
+
+/// \brief Draw a hardcoded image
+///
+/// This draws a hardcoded OpenGL graphic into the window, and is only
+/// used for testing by developers.
+void
+nsPluginInstance::drawTestScene( void )
+{
+ printf("%s: \n", __PRETTY_FUNCTION__);
+
+ // Grab control of the display
+ lockGL();
+ setGL();
+ lockX();
+
+ printf("%s: Drawing graphic...\n", __PRETTY_FUNCTION__);
+
+ // Clear The Screen And The Depth Buffer
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ // Move Left 1.5 Units And Into The Screen 6.0
+ glLoadIdentity();
+ glTranslatef( -1.5f, 0.0f, -6.0f );
+
+ glColor3f(1.0f,1.0f,1.0f);
+
+ glBegin( GL_TRIANGLES ); // Drawing Using Triangles
+ glVertex3f( 0.0f, 1.0f, 0.0f ); // Top
+ glVertex3f( -1.0f, -1.0f, 0.0f ); // Botom Left
+ glVertex3f( 1.0f, -1.0f, 0.0f ); // Bottom Rigt
+ glEnd( ); // Finished Drawing The Triangle
+
+ /* Move Right 3 Units */
+ glTranslatef( 3.0f, 0.0f, 0.0f );
+
+ glBegin( GL_QUADS ); // Draw A Quad
+ glVertex3f( -1.0f, 1.0f, 0.0f ); // Top Left
+ glVertex3f( 1.0f, 1.0f, 0.0f ); // Top Right
+ glVertex3f( 1.0f, -1.0f, 0.0f ); // Bottom Right
+ glVertex3f( -1.0f, -1.0f, 0.0f ); // Bottom Left
+ glEnd( ); // Done Drawing The Quad
+
+ swapBuffers();
+ // Release control of the display
+ freeX();
+ freeGL();
+}
+
+/// \brief Handle X events
+///
+/// This C function handles events from X, like keyboard events, or
+/// Expose events that we're interested in.
+static void
+xt_event_handler(Widget xtwidget, nsPluginInstance *plugin,
+ XEvent *xevent, Boolean *b)
+{
+ printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ int keycode;
+ KeySym keysym;
+#if 0
+ SDL_Event sdl_event;
+ SDL_keysym sdl_keysym;
+
+ // handleKeyPress((SDL_keysym)keysym);
+ printf("Peep Event returned %d\n", SDL_PeepEvents(&sdl_event, 1,
SDL_PEEKEVENT,
SDL_USEREVENT|SDL_ACTIVEEVENT|SDL_KEYDOWN|SDL_KEYUP|SDL_MOUSEBUTTONUP|SDL_MOUSEBUTTONDOWN));
+
+ if (SDL_PollEvent(&sdl_event)) {
+ switch(sdl_event.type) {
+ case SDL_ACTIVEEVENT:
+ case SDL_VIDEORESIZE:
+ case SDL_KEYDOWN:
+ /* handle key presses */
+ handleKeyPress( &sdl_event.key.keysym );
+ break;
+ default:
+ break;
+
+ }
+ }
#endif
- SDL_Delay(20); // don't trash the CPU
- }
- printf("%s(%d): FIXME: loop timed out\n",
- __PRETTY_FUNCTION__, __LINE__);
- return 0;
+ switch (xevent->type) {
+ case Expose:
+ // get rid of all other exposure events
+ if (plugin) {
+// if (_glInitialized) {
+// plugin->setGL();
+// #ifdef TEST_GRAPHIC
+// plugin->drawTestScene();
+// plugin->swapBuffers();
+// plugin->freeX();
+// #else
+// gnash::movie_interface *m = gnash::get_current_root();
+// if (m != NULL) {
+// m->display();
+// }
+// #endif
+// printf("Drawing GL Scene for expose event!\n");
+// } else {
+ printf("GL Surface not initialized yet, ignoring expose
event!\n");
+// }
+ }
+ break;
+ case ButtonPress:
+// fe.type = FeButtonPress;
+ printf("Button Press\n");
+ break;
+ case ButtonRelease:
+ // fe.type = FeButtonRelease;
+ printf("Button Release\n");
+ break;
+ case KeyPress:
+ keycode = xevent->xkey.keycode;
+ plugin->lockX();
+ keysym = XLookupKeysym((XKeyEvent*)xevent, 0);
+ printf ("%s(%d): Keysym is %s\n", __PRETTY_FUNCTION__, __LINE__,
+ XKeysymToString(keysym));
+ plugin->freeX();
+
+ switch (keysym) {
+ case XK_Up:
+ printf("Key Up\n");
+ break;
+ case XK_Down:
+ printf("Key Down\n");
+ break;
+ case XK_Left:
+ printf("Key Left\n");
+ break;
+ case XK_Right:
+ printf("Key Right\n");
+ break;
+ case XK_Return:
+ printf("Key Return\n");
+ break;
+
+ default:
+ break;
+ }
+ }
}
+
// Local Variables:
// mode: C++
// indent-tabs-mode: t
Index: gnash/plugin/plugin.h
diff -u gnash/plugin/plugin.h:1.5 gnash/plugin/plugin.h:1.6
--- gnash/plugin/plugin.h:1.5 Sun Feb 5 22:17:49 2006
+++ gnash/plugin/plugin.h Sat Feb 25 05:19:16 2006
@@ -19,13 +19,18 @@
#ifndef __PLUGIN_H__
#define __PLUGIN_H__
+#define TEST_GRAPHIC
+
/* Xlib/Xt stuff */
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/cursorfont.h>
+#include <GL/glx.h>
#include <string>
#include <map>
#include "pluginbase.h"
+#include <SDL.h>
+#include <SDL_thread.h>
/* ascii codes for various special keys */
#define ESCAPE 27
@@ -36,6 +41,9 @@
#define LEFT_ARROW 75
#define RIGHT_ARROW 77
+extern Display *gxDisplay;
+extern SDL_mutex *glMutex;
+
class nsPluginInstance : public nsPluginInstanceBase
{
public:
@@ -43,8 +51,7 @@
virtual ~nsPluginInstance();
NPBool init(NPWindow *aWindow);
- void shut();
- NPBool isInitialized() {return mInitialized;}
+ NPBool isInitialized() {return _plugInitialized;}
NPError GetValue(NPPVariable variable, void *value);
NPError SetWindow(NPWindow *aWindow);
NPError NewStream(NPMIMEType type, NPStream *stream, NPBool seekable,
@@ -54,36 +61,78 @@
int32 WriteReady(NPStream *stream);
int32 Write(NPStream *stream, int32 offset, int32 len, void *buffer);
NPError WriteStatus(char *msg) const;
+ void shut();
- void draw();
-
// accessors
const char *getVersion();
Window getWindow() { return mWindow; };
- Display *getDisplay() { return mDisplay; };
+// Display *getDisplay() { return gxDisplay; };
unsigned int getDepth() { return mDepth; };
int getWidth() { return mWidth; };
int getHeight() { return mHeight; };
const char *getFilename() { return swf_file.c_str(); };
+
+ // Set the current GL context
+ void setGL() {
+// printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ glXMakeCurrent(gxDisplay, mWindow, mContext);
+ }
+ // Protect the GL state from multiple threads
+ void lockGL() {
+// printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ SDL_mutexP(glMutex);
+ }
+ void freeGL() {
+// printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ SDL_mutexV(glMutex);
+ }
+
+ // Protect the X context
+ void lockX() {
+// printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ XLockDisplay(gxDisplay);
+ }
+ void freeX() {
+// printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ XUnlockDisplay(gxDisplay);
+ }
+ void swapBuffers() {
+// printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+ glXSwapBuffers(gxDisplay, mWindow);
+ }
+ void drawTestScene();
+ bool getShutting() { return bShutting; }
+
+ void initGL();
+ void destroyContext();
+ int resizeWindow(int width,int height);
+
private:
- NPP mInstance;
- NPBool mInitialized;
- Widget mXtwidget;
- XFontStruct *mFontInfo;
- std::string swf_file;
- Window mWindow;
- Display *mDisplay;
- int mX;
- int mY;
- int mWidth;
- int mHeight;
- Visual *mVisual;
- Colormap mColormap;
- unsigned int mDepth;
-// GC mGC;
- int thr_count;
+ // This is a data is unique for each thread
+ NPP mInstance;
+ Widget mXtwidget;
+ XFontStruct *mFontInfo;
+ std::string swf_file;
+ int mX;
+ int mY;
+ unsigned int mWidth;
+ unsigned int mHeight;
+ Visual *mVisual;
+ Colormap mColormap;
+ unsigned int mDepth;
+ bool bShutting;
std::map<std::string, std::string> _options;
+ SDL_Thread *mThread;
+ GLXContext mContext;
+ Window mWindow;
+ int _streamfd;
+ NPBool _glInitialized;
+
+ // This data is shared amongst all instantiations of this class
+ static NPBool _plugInitialized;
+// static XtAppContext _xContext;
+// static int _instantiations;
};
// end of __PLUGIN_H__
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ./ChangeLog plugin/Makefile.am plugin/pla...,
Rob Savoye <=