You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(128) |
Dec
(65) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(48) |
Feb
(132) |
Mar
(95) |
Apr
(47) |
May
(54) |
Jun
(2) |
Jul
(57) |
Aug
(109) |
Sep
(131) |
Oct
(186) |
Nov
(105) |
Dec
(78) |
2007 |
Jan
(125) |
Feb
(105) |
Mar
(52) |
Apr
(104) |
May
(63) |
Jun
(116) |
Jul
(76) |
Aug
|
Sep
(18) |
Oct
(93) |
Nov
(110) |
Dec
(169) |
2008 |
Jan
(90) |
Feb
(64) |
Mar
(41) |
Apr
(23) |
May
(6) |
Jun
(18) |
Jul
(10) |
Aug
(61) |
Sep
(139) |
Oct
(50) |
Nov
(55) |
Dec
(2) |
2009 |
Jan
|
Feb
(1) |
Mar
(62) |
Apr
(22) |
May
(17) |
Jun
(19) |
Jul
(40) |
Aug
(21) |
Sep
|
Oct
(40) |
Nov
(23) |
Dec
|
2010 |
Jan
(14) |
Feb
(40) |
Mar
(9) |
Apr
(11) |
May
(19) |
Jun
(4) |
Jul
(10) |
Aug
(22) |
Sep
(15) |
Oct
|
Nov
(2) |
Dec
|
2011 |
Jan
(13) |
Feb
(10) |
Mar
|
Apr
(13) |
May
|
Jun
|
Jul
(2) |
Aug
(4) |
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
(33) |
May
(20) |
Jun
|
Jul
(8) |
Aug
(7) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
From: Braden M. <br...@us...> - 2006-01-24 15:01:35
|
Update of /cvsroot/openvrml/openvrml/mozilla-plugin/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13582/mozilla-plugin/src Modified Files: openvrml.cpp Log Message: Parse OPENVRML_PLAYER environment variable with g_shell_parse_argv such that arguments can be passed along with the executable name. Index: openvrml.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** openvrml.cpp 23 Jan 2006 04:45:08 -0000 1.25 --- openvrml.cpp 24 Jan 2006 15:01:27 -0000 1.26 *************** *** 1,3 **** ! // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*- // // OpenVRML Mozilla plug-in --- 1,3 ---- ! // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- // // OpenVRML Mozilla plug-in *************** *** 1099,1108 **** } ! const char * exec_path = getenv("OPENVRML_PLAYER"); ! if (!exec_path) { ! exec_path = OPENVRML_LIBEXECDIR_ "/openvrml-player"; } - vector<char> exec_path_vec(exec_path, - exec_path + strlen(exec_path) + 1); string socket_id_arg = --- 1099,1135 ---- } ! // ! // The OPENVRML_PLAYER environment variable overrides the ! // default path to the child process executable. To allow ! // OPENVRML_PLAYER to include arguments (rather than just be a ! // path to an executable), it is parsed wit ! // g_shell_parse_argv. This is particularly useful in case we ! // want to run the child process in a harness like valgrind. ! // ! gint openvrml_player_cmd_argc = 0; ! gchar ** openvrml_player_cmd_argv = 0; ! const gchar * const openvrml_player_cmd = ! g_getenv("OPENVRML_PLAYER"); ! if (!openvrml_player_cmd) { ! openvrml_player_cmd_argc = 1; ! openvrml_player_cmd_argv = ! static_cast<gchar **>(g_malloc(sizeof (gchar *))); ! if (!openvrml_player_cmd_argv) { throw std::bad_alloc(); } ! openvrml_player_cmd_argv[0] = ! OPENVRML_LIBEXECDIR_ "/openvrml-player"; ! } else { ! GError * error = 0; ! gboolean succeeded = ! g_shell_parse_argv(openvrml_player_cmd, ! &openvrml_player_cmd_argc, ! &openvrml_player_cmd_argv, ! &error); ! if (!succeeded) { ! if (error) { ! g_critical(error->message); ! g_error_free(error); ! } ! } } string socket_id_arg = *************** *** 1127,1137 **** write_fd_arg_c_str + write_fd_arg.length() + 1); ! char * argv[] = { ! &exec_path_vec.front(), ! &socket_id_arg_vec.front(), ! &read_fd_arg_vec.front(), ! &write_fd_arg_vec.front(), ! 0 ! }; result = execv(argv[0], argv); --- 1154,1170 ---- write_fd_arg_c_str + write_fd_arg.length() + 1); ! gchar ** const argv = ! static_cast<gchar **>( ! g_malloc( ! sizeof (gchar *) * openvrml_player_cmd_argc + 4)); ! if (!argv) { throw std::bad_alloc(); } ! gint i; ! for (i = 0; i < openvrml_player_cmd_argc; ++i) { ! argv[i] = openvrml_player_cmd_argv[i]; ! } ! argv[i++] = &socket_id_arg_vec.front(); ! argv[i++] = &read_fd_arg_vec.front(); ! argv[i++] = &write_fd_arg_vec.front(); ! argv[i] = 0; result = execv(argv[0], argv); *************** *** 1139,1142 **** --- 1172,1178 ---- g_error("Failed to start openvrml-player"); } + + g_free(argv); + g_strfreev(openvrml_player_cmd_argv); } else if (this->player_pid > 0) { int result = close(this->out_pipe[0]); |
From: Braden M. <br...@us...> - 2006-01-23 04:45:24
|
Update of /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21563/mozilla-plugin/src/openvrml-player Modified Files: Makefile.am gtkglviewer.cpp gtkglviewer.h player.cpp Added Files: flag.cpp flag.h Log Message: Allow the plug-in child process to exit "normally" rather than sending it SIGTERM. Index: gtkglviewer.h =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player/gtkglviewer.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gtkglviewer.h 9 Jan 2006 00:21:09 -0000 1.1 --- gtkglviewer.h 23 Jan 2006 04:45:08 -0000 1.2 *************** *** 26,34 **** --- 26,42 ---- # include <openvrml/gl/viewer.h> + extern "C" gint gtk_gl_viewer_timeout_callback(gpointer ptr); + namespace openvrml_player { + class flag; + class GtkGLViewer : public openvrml::gl::viewer { + friend gint (::gtk_gl_viewer_timeout_callback)(gpointer ptr); + static GdkGLConfig * gl_config; + const flag * quit_; + GtkWidget * drawing_area; guint timer; *************** *** 37,41 **** bool redrawNeeded; ! explicit GtkGLViewer(GtkContainer & container); virtual ~GtkGLViewer() throw (); --- 45,49 ---- bool redrawNeeded; ! explicit GtkGLViewer(GtkContainer & container, flag & quit); virtual ~GtkGLViewer() throw (); --- NEW FILE: flag.h --- // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- // // OpenVRML Mozilla plug-in // Copyright 2006 Braden N. McDaniel // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // # ifndef OPENVRML_PLAYER_FLAG_H # define OPENVRML_PLAYER_FLAG_H # include <boost/thread/mutex.hpp> namespace openvrml_player { class flag : boost::noncopyable { mutable boost::mutex mutex_; bool value_; public: flag(bool init = false); bool value() const; void value(bool val); }; } # endif // ifndef OPENVRML_PLAYER_FLAG_H Index: gtkglviewer.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player/gtkglviewer.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gtkglviewer.cpp 22 Jan 2006 21:35:47 -0000 1.3 --- gtkglviewer.cpp 23 Jan 2006 04:45:08 -0000 1.4 *************** *** 22,25 **** --- 22,26 ---- # include <gdk/gdkx.h> # include "gtkglviewer.h" + # include "flag.h" GdkGLConfig * openvrml_player::GtkGLViewer::gl_config(0); *************** *** 47,54 **** GdkEventMotion * event, gpointer data); - gint gtk_gl_viewer_timeout_callback(const gpointer ptr); } ! openvrml_player::GtkGLViewer::GtkGLViewer(GtkContainer & container): drawing_area(gtk_drawing_area_new()), timer(0), --- 48,56 ---- GdkEventMotion * event, gpointer data); } ! openvrml_player::GtkGLViewer::GtkGLViewer(GtkContainer & container, ! flag & quit): ! quit_(&quit), drawing_area(gtk_drawing_area_new()), timer(0), *************** *** 111,116 **** gtk_container_add(&container, this->drawing_area); - - } --- 113,116 ---- *************** *** 177,181 **** GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(ptr); ! viewer.timer_update(); return false; } --- 177,185 ---- GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(ptr); ! if (!viewer.quit_->value()) { ! viewer.timer_update(); ! } else { ! gtk_main_quit(); ! } return false; } Index: Makefile.am =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player/Makefile.am,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile.am 9 Jan 2006 00:21:09 -0000 1.6 --- Makefile.am 23 Jan 2006 04:45:08 -0000 1.7 *************** *** 18,22 **** plugin_streambuf.h \ browser.h \ ! gtkglviewer.h openvrml_player_SOURCES = \ player.cpp \ --- 18,23 ---- plugin_streambuf.h \ browser.h \ ! gtkglviewer.h \ ! flag.h openvrml_player_SOURCES = \ player.cpp \ *************** *** 24,28 **** plugin_streambuf.cpp \ browser.cpp \ ! gtkglviewer.cpp openvrml_player_LDADD = \ $(top_builddir)/../src/libopenvrml-gl/libopenvrml-gl.la \ --- 25,30 ---- plugin_streambuf.cpp \ browser.cpp \ ! gtkglviewer.cpp \ ! flag.cpp openvrml_player_LDADD = \ $(top_builddir)/../src/libopenvrml-gl/libopenvrml-gl.la \ --- NEW FILE: flag.cpp --- // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- // // OpenVRML Mozilla plug-in // Copyright 2006 Braden N. McDaniel // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // # include "flag.h" openvrml_player::flag::flag(const bool init): value_(init) {} bool openvrml_player::flag::value() const { boost::mutex::scoped_lock lock(this->mutex_); return this->value_; } void openvrml_player::flag::value(const bool val) { boost::mutex::scoped_lock lock(this->mutex_); this->value_ = val; } Index: player.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player/player.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** player.cpp 14 Jan 2006 06:04:56 -0000 1.18 --- player.cpp 23 Jan 2006 04:45:08 -0000 1.19 *************** *** 30,33 **** --- 30,34 ---- # include "command_istream.h" # include "plugin_streambuf.h" + # include "flag.h" using namespace openvrml_player; *************** *** 44,47 **** --- 45,57 ---- // const char initial_stream_uri[] = "x-openvrml-initial:"; + + // + // Used to signal the various threads that we're done. "quit" is + // initiated when the command_istream gets EOF. At that point, the + // command_istream_reader thread sets quit_flag to true. This flag is + // checked by the command_channel_loop thread and the main (rendering) + // thread, signaling them to terminate. + // + flag quit_flag; } *************** *** 78,85 **** static bool got_initial_stream = false; if (!streambuf) { - // - // If the world_url is empty, this is the primordial - // stream. - // if (!got_initial_stream) { g_assert(uninitialized_plugin_streambuf_map_.size() --- 88,91 ---- *************** *** 121,124 **** --- 127,135 ---- } } + + // + // Got EOF from the command stream. Time to shut down. + // + ::quit_flag.value(true); } *************** *** 129,132 **** --- 140,146 ---- } + extern "C" gboolean + openvrml_player_command_channel_loop_quit_event(gpointer data); + namespace { *************** *** 215,218 **** --- 229,238 ---- GIOChannel * request_channel; + struct command_channel_data { + GMainContext * main_context; + GMainLoop * main_loop; + GIOChannel * command_channel; + }; + struct command_channel_loop { command_channel_loop(const gint read_fd, command_istream & command_in): *************** *** 223,233 **** void operator()() const throw () { ! GMainContext * const main_context = g_main_context_new(); ! GMainLoop * const main_loop = g_main_loop_new(main_context, false); ! GIOChannel * const command_channel = ! g_io_channel_unix_new(this->read_fd_); GError * error = 0; GIOStatus status = ! g_io_channel_set_encoding(command_channel, 0, // binary (no encoding) &error); --- 243,253 ---- void operator()() const throw () { ! command_channel_data data; ! data.main_context = g_main_context_new(); ! data.main_loop = g_main_loop_new(data.main_context, false); ! data.command_channel = g_io_channel_unix_new(this->read_fd_); GError * error = 0; GIOStatus status = ! g_io_channel_set_encoding(data.command_channel, 0, // binary (no encoding) &error); *************** *** 241,245 **** GSource * const command_watch = ! g_io_create_watch(command_channel, G_IO_IN); const GDestroyNotify notify = 0; g_source_set_callback( --- 261,266 ---- GSource * const command_watch = ! g_io_create_watch(data.command_channel, ! GIOCondition(G_IO_IN | G_IO_HUP)); const GDestroyNotify notify = 0; g_source_set_callback( *************** *** 248,262 **** static_cast<command_streambuf *>(this->command_in_->rdbuf()), notify); ! guint source_id = g_source_attach(command_watch, main_context); g_return_if_fail(source_id != 0); ! g_main_loop_run(main_loop); g_source_unref(command_watch); ! g_io_channel_shutdown(command_channel, false, 0); ! g_io_channel_unref(command_channel); ! g_main_loop_unref(main_loop); ! g_main_context_unref(main_context); } --- 269,292 ---- static_cast<command_streambuf *>(this->command_in_->rdbuf()), notify); ! guint source_id = g_source_attach(command_watch, ! data.main_context); g_return_if_fail(source_id != 0); ! GSource * const quit = g_idle_source_new(); ! g_source_set_callback( ! quit, ! ::openvrml_player_command_channel_loop_quit_event, ! &data, ! notify); ! source_id = g_source_attach(quit, data.main_context); ! g_return_if_fail(source_id != 0); ! ! g_main_loop_run(data.main_loop); g_source_unref(command_watch); ! g_io_channel_unref(data.command_channel); ! g_main_loop_unref(data.main_loop); ! g_main_context_unref(data.main_context); } *************** *** 310,314 **** : gtk_window_new(GTK_WINDOW_TOPLEVEL); ! GtkGLViewer viewer(*(GTK_CONTAINER(window))); browser b(::request_channel); b.viewer(&viewer); --- 340,344 ---- : gtk_window_new(GTK_WINDOW_TOPLEVEL); ! GtkGLViewer viewer(*(GTK_CONTAINER(window)), ::quit_flag); browser b(::request_channel); b.viewer(&viewer); *************** *** 347,349 **** --- 377,420 ---- viewer.timer_update(); gtk_main(); + + threads.join_all(); + + if (::request_channel) { + GError * error = 0; + const gboolean flush = false; + GIOStatus status = g_io_channel_shutdown(::request_channel, + flush, + &error); + if (status != G_IO_STATUS_NORMAL) { + if (error) { + g_critical(error->message); + g_error_free(error); + } + } + } + g_io_channel_unref(::request_channel); + } + + gboolean openvrml_player_command_channel_loop_quit_event(const gpointer data) + { + command_channel_data & cc_data = + *static_cast<command_channel_data *>(data); + + if (::quit_flag.value()) { + GError * error = 0; + GIOStatus status = g_io_channel_shutdown(cc_data.command_channel, + true, + &error); + if (status != G_IO_STATUS_NORMAL) { + if (error) { + g_critical(error->message); + g_error_free(error); + } + } + + g_main_loop_quit(cc_data.main_loop); + + return false; + } + return true; } |
From: Braden M. <br...@us...> - 2006-01-23 04:45:18
|
Update of /cvsroot/openvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21563 Modified Files: ChangeLog Log Message: Allow the plug-in child process to exit "normally" rather than sending it SIGTERM. Index: ChangeLog =================================================================== RCS file: /cvsroot/openvrml/openvrml/ChangeLog,v retrieving revision 1.1114 retrieving revision 1.1115 diff -C2 -d -r1.1114 -r1.1115 *** ChangeLog 22 Jan 2006 21:35:47 -0000 1.1114 --- ChangeLog 23 Jan 2006 04:45:07 -0000 1.1115 *************** *** 1,4 **** --- 1,48 ---- 2006-01-22 Braden McDaniel <br...@en...> + Allow the plug-in child process to exit "normally" rather than + sending it SIGTERM. + + * mozilla-plugin/src/openvrml.cpp + (PluginInstance::~PluginInstance): Don't send the child + openvrml-player process SIGTERM. Shut down the request_channel + and the write descriptor for the output pipe (corresponding to the + command channel). + * mozilla-plugin/src/openvrml-player/Makefile.am + (noinst_HEADERS): Added flag.h. + (openvrml_player_SOURCES): Added flag.cpp. + * mozilla-plugin/src/openvrml-player/flag.cpp + (openvrml_player::flag::flag(bool)): Construct. + (openvrml_player::flag::value() const): Accessor. + (openvrml_player::flag::value(bool)): Mutator. + * mozilla-plugin/src/openvrml-player/flag.h + (openvrml_player::flag): Added. A bool flag protected by a mutex. + Used to signal the various threads that it's time to quit. + * mozilla-plugin/src/openvrml-player/gtkglviewer.cpp + (openvrml_player::GtkGLViewer::GtkGLViewer(GtkContainer &, + flag&)): Added quit flag parameter. + (gtk_gl_viewer_timeout_callback(gpointer)): Check quit flag. + * mozilla-plugin/src/openvrml-player/gtkglviewer.h + (openvrml_player::GtkGLViewer): Made + gtk_gl_viewer_timeout_callback a friend. Added quit_ member. + (command_channel_data): Struct for passing command_channel_loop + data to the quit_event callback. + (command_channel_loop::operator()() const): Moved main_context, + main_loop, and command_channel to the command_channel_data struct. + Added openvrml_player_command_channel_loop_quit_event as an idle + callback. + (main(int, char *[])): Pass quit_flag to GtkGLViewer constructor. + Join all threads in the thread group before quitting. Shut down + the request_channel. + (openvrml_player_command_channel_loop_quit_event(gpointer)): + "quit" callback for the command_channel_loop--shuts down the + command_channel and calls g_main_loop_quit. + * mozilla-plugin/src/openvrml-player/player.cpp + (openvrml_player::command_istream_reader::operator()() const)): + Set the quit_flag to true if we leave the loop (i.e., we got EOF + from the command stream). + + 2006-01-22 Braden McDaniel <br...@en...> + * mozilla-plugin/src/openvrml-player/gtkglviewer.cpp: Declare timeout callback function 'extern "C"'; callback functions given |
From: Braden M. <br...@us...> - 2006-01-23 04:45:16
|
Update of /cvsroot/openvrml/openvrml/mozilla-plugin/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21563/mozilla-plugin/src Modified Files: openvrml.cpp Log Message: Allow the plug-in child process to exit "normally" rather than sending it SIGTERM. Index: openvrml.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** openvrml.cpp 15 Jul 2005 06:11:45 -0000 1.24 --- openvrml.cpp 23 Jan 2006 04:45:08 -0000 1.25 *************** *** 20,24 **** # include <cerrno> - # include <iostream> # include <list> # include <memory> --- 20,23 ---- *************** *** 265,270 **** void NPP_Shutdown() ! { ! } /** --- 264,268 ---- void NPP_Shutdown() ! {} /** *************** *** 1030,1037 **** { if (this->player_pid) { ! kill(this->player_pid, SIGTERM); int status; int options = 0; ! waitpid(this->player_pid, &status, options); } } --- 1028,1063 ---- { if (this->player_pid) { ! if (this->request_channel) { ! GError * error = 0; ! const gboolean flush = false; ! GIOStatus status = g_io_channel_shutdown(this->request_channel, ! flush, ! &error); ! if (status != G_IO_STATUS_NORMAL) { ! if (error) { ! g_critical(error->message); ! g_error_free(error); ! } ! } ! } ! g_io_channel_unref(this->request_channel); ! ! // ! // The openvrml-player process should detect that this file ! // descriptor has been closed and terminate in response. ! // ! int result = close(this->out_pipe[1]); ! if (result != 0) { ! printerr(strerror(errno)); ! g_error("Failed to close write descriptor for " ! "OpenVRML plug-in's output pipe"); ! } ! int status; int options = 0; ! pid_t pid = waitpid(this->player_pid, &status, options); ! if (pid == -1) { ! printerr(strerror(errno)); ! } } } |
From: Braden M. <br...@us...> - 2006-01-22 21:35:56
|
Update of /cvsroot/openvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5256 Modified Files: ChangeLog Log Message: Declare timeout callback function 'extern "C"'; callback functions given to C APIs should have C linkage. Index: ChangeLog =================================================================== RCS file: /cvsroot/openvrml/openvrml/ChangeLog,v retrieving revision 1.1113 retrieving revision 1.1114 diff -C2 -d -r1.1113 -r1.1114 *** ChangeLog 22 Jan 2006 21:21:15 -0000 1.1113 --- ChangeLog 22 Jan 2006 21:35:47 -0000 1.1114 *************** *** 1,4 **** --- 1,10 ---- 2006-01-22 Braden McDaniel <br...@en...> + * mozilla-plugin/src/openvrml-player/gtkglviewer.cpp: Declare + timeout callback function 'extern "C"'; callback functions given + to C APIs should have C linkage. + + 2006-01-22 Braden McDaniel <br...@en...> + * mozilla-plugin/src/openvrml-player/gtkglviewer.cpp: Disambiguate externally linked functions by prefixing with "gtk_gl_viewer_". |
From: Braden M. <br...@us...> - 2006-01-22 21:35:55
|
Update of /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5256/mozilla-plugin/src/openvrml-player Modified Files: gtkglviewer.cpp Log Message: Declare timeout callback function 'extern "C"'; callback functions given to C APIs should have C linkage. Index: gtkglviewer.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player/gtkglviewer.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gtkglviewer.cpp 22 Jan 2006 21:21:19 -0000 1.2 --- gtkglviewer.cpp 22 Jan 2006 21:35:47 -0000 1.3 *************** *** 47,50 **** --- 47,51 ---- GdkEventMotion * event, gpointer data); + gint gtk_gl_viewer_timeout_callback(const gpointer ptr); } *************** *** 170,183 **** } ! namespace { ! gint timeout_callback(const gpointer ptr) ! { ! assert(ptr); ! using openvrml_player::GtkGLViewer; ! GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(ptr); ! viewer.timer_update(); ! return false; ! } } --- 171,182 ---- } ! gint gtk_gl_viewer_timeout_callback(const gpointer ptr) ! { ! assert(ptr); ! using openvrml_player::GtkGLViewer; ! GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(ptr); ! viewer.timer_update(); ! return false; } *************** *** 185,191 **** { if (!this->timer) { ! this->timer = g_timeout_add(guint(10.0 * (t + 1)), ! GtkFunction(timeout_callback), ! this); } } --- 184,191 ---- { if (!this->timer) { ! this->timer = ! g_timeout_add(guint(10.0 * (t + 1)), ! GtkFunction(gtk_gl_viewer_timeout_callback), ! this); } } |
From: Braden M. <br...@us...> - 2006-01-22 21:21:34
|
Update of /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32633/mozilla-plugin/src/openvrml-player Modified Files: gtkglviewer.cpp Log Message: Disambiguate externally linked functions by prefixing with "gtk_gl_viewer_". Index: gtkglviewer.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player/gtkglviewer.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gtkglviewer.cpp 9 Jan 2006 00:21:09 -0000 1.1 --- gtkglviewer.cpp 22 Jan 2006 21:21:19 -0000 1.2 *************** *** 26,42 **** extern "C" { ! gboolean realize(GtkWidget * widget, GdkEvent * event, gpointer data); ! gboolean expose_event(GtkWidget * widget, GdkEventExpose * event, ! gpointer data); ! gboolean configure_event(GtkWidget * widget, GdkEventConfigure * event, ! gpointer data); ! gboolean key_press_event(GtkWidget * widget, GdkEventKey * event, ! gpointer data); ! gboolean button_press_event(GtkWidget * widget, GdkEventButton * event, ! gpointer data); ! gboolean button_release_event(GtkWidget * widget, GdkEventButton * event, ! gpointer data); ! gboolean motion_notify_event(GtkWidget * widget, GdkEventMotion * event, ! gpointer data); } --- 26,50 ---- extern "C" { ! gboolean gtk_gl_viewer_realize(GtkWidget * widget, ! GdkEvent * event, ! gpointer data); ! gboolean gtk_gl_viewer_expose_event(GtkWidget * widget, ! GdkEventExpose * event, ! gpointer data); ! gboolean gtk_gl_viewer_configure_event(GtkWidget * widget, ! GdkEventConfigure * event, ! gpointer data); ! gboolean gtk_gl_viewer_key_press_event(GtkWidget * widget, ! GdkEventKey * event, ! gpointer data); ! gboolean gtk_gl_viewer_button_press_event(GtkWidget * widget, ! GdkEventButton * event, ! gpointer data); ! gboolean gtk_gl_viewer_button_release_event(GtkWidget * widget, ! GdkEventButton * event, ! gpointer data); ! gboolean gtk_gl_viewer_motion_notify_event(GtkWidget * widget, ! GdkEventMotion * event, ! gpointer data); } *************** *** 78,102 **** g_signal_connect(G_OBJECT((this->drawing_area)), "expose_event", ! G_CALLBACK(expose_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "configure_event", ! G_CALLBACK(configure_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "key_press_event", ! G_CALLBACK(key_press_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "button_press_event", ! G_CALLBACK(button_press_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "button_release_event", ! G_CALLBACK(button_release_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "motion_notify_event", ! G_CALLBACK(motion_notify_event), this); --- 86,110 ---- g_signal_connect(G_OBJECT((this->drawing_area)), "expose_event", ! G_CALLBACK(gtk_gl_viewer_expose_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "configure_event", ! G_CALLBACK(gtk_gl_viewer_configure_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "key_press_event", ! G_CALLBACK(gtk_gl_viewer_key_press_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "button_press_event", ! G_CALLBACK(gtk_gl_viewer_button_press_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "button_release_event", ! G_CALLBACK(gtk_gl_viewer_button_release_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "motion_notify_event", ! G_CALLBACK(gtk_gl_viewer_motion_notify_event), this); *************** *** 189,200 **** } ! gboolean realize(GtkWidget *, GdkEvent *, gpointer) { return true; } ! gboolean expose_event(GtkWidget * const widget, ! GdkEventExpose * const event, ! const gpointer data) { using openvrml_player::GtkGLViewer; --- 197,208 ---- } ! gboolean gtk_gl_viewer_realize(GtkWidget *, GdkEvent *, gpointer) { return true; } ! gboolean gtk_gl_viewer_expose_event(GtkWidget * const widget, ! GdkEventExpose * const event, ! const gpointer data) { using openvrml_player::GtkGLViewer; *************** *** 214,220 **** } ! gboolean configure_event(GtkWidget * const widget, ! GdkEventConfigure *, ! const gpointer data) { GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); --- 222,228 ---- } ! gboolean gtk_gl_viewer_configure_event(GtkWidget * const widget, ! GdkEventConfigure *, ! const gpointer data) { GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); *************** *** 231,237 **** } ! gboolean key_press_event(GtkWidget * const widget, ! GdkEventKey * const event, ! const gpointer data) { using openvrml::gl::viewer; --- 239,245 ---- } ! gboolean gtk_gl_viewer_key_press_event(GtkWidget * const widget, ! GdkEventKey * const event, ! const gpointer data) { using openvrml::gl::viewer; *************** *** 287,293 **** } ! gboolean button_press_event(GtkWidget * const widget, ! GdkEventButton * const event, ! const gpointer data) { using openvrml::gl::viewer; --- 295,301 ---- } ! gboolean gtk_gl_viewer_button_press_event(GtkWidget * const widget, ! GdkEventButton * const event, ! const gpointer data) { using openvrml::gl::viewer; *************** *** 325,331 **** } ! gboolean button_release_event(GtkWidget * const widget, ! GdkEventButton * const event, ! const gpointer data) { using openvrml::gl::viewer; --- 333,339 ---- } ! gboolean gtk_gl_viewer_button_release_event(GtkWidget * const widget, ! GdkEventButton * const event, ! const gpointer data) { using openvrml::gl::viewer; *************** *** 363,369 **** } ! gboolean motion_notify_event(GtkWidget * const widget, ! GdkEventMotion * const event, ! const gpointer data) { using openvrml::gl::viewer; --- 371,377 ---- } ! gboolean gtk_gl_viewer_motion_notify_event(GtkWidget * const widget, ! GdkEventMotion * const event, ! const gpointer data) { using openvrml::gl::viewer; |
From: Braden M. <br...@us...> - 2006-01-22 21:21:34
|
Update of /cvsroot/openvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32633 Modified Files: ChangeLog Log Message: Disambiguate externally linked functions by prefixing with "gtk_gl_viewer_". Index: ChangeLog =================================================================== RCS file: /cvsroot/openvrml/openvrml/ChangeLog,v retrieving revision 1.1112 retrieving revision 1.1113 diff -C2 -d -r1.1112 -r1.1113 *** ChangeLog 22 Jan 2006 07:14:02 -0000 1.1112 --- ChangeLog 22 Jan 2006 21:21:15 -0000 1.1113 *************** *** 1,4 **** --- 1,9 ---- 2006-01-22 Braden McDaniel <br...@en...> + * mozilla-plugin/src/openvrml-player/gtkglviewer.cpp: Disambiguate + externally linked functions by prefixing with "gtk_gl_viewer_". + + 2006-01-22 Braden McDaniel <br...@en...> + * mozilla-plugin/src/openvrml-player/command_istream.cpp: Handle EOF from the command_channel by inserting traits_type::eof() into |
From: Braden M. <br...@us...> - 2006-01-22 07:14:10
|
Update of /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12422/mozilla-plugin/src/openvrml-player Modified Files: command_istream.cpp Log Message: Handle EOF from the command_channel by inserting traits_type::eof() into the stream buffer. Index: command_istream.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player/command_istream.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** command_istream.cpp 9 Jan 2006 00:21:09 -0000 1.1 --- command_istream.cpp 22 Jan 2006 07:14:02 -0000 1.2 *************** *** 48,51 **** --- 48,53 ---- using namespace openvrml_player; + typedef command_istream::traits_type traits_type; + command_streambuf & streambuf = *static_cast<command_streambuf *>(data); *************** *** 66,70 **** return false; } ! if (status == G_IO_STATUS_EOF) { return false; } if (status == G_IO_STATUS_AGAIN) { continue; } g_return_val_if_fail(status == G_IO_STATUS_NORMAL, false); --- 68,75 ---- return false; } ! if (status == G_IO_STATUS_EOF) { ! streambuf.source_buffer_.put(traits_type::eof()); ! return false; ! } if (status == G_IO_STATUS_AGAIN) { continue; } g_return_val_if_fail(status == G_IO_STATUS_NORMAL, false); *************** *** 72,76 **** g_assert(bytes_read == 1); ! streambuf.source_buffer_.put(c); FD_ZERO(&readfds); --- 77,81 ---- g_assert(bytes_read == 1); ! streambuf.source_buffer_.put(traits_type::to_int_type(c)); FD_ZERO(&readfds); |
From: Braden M. <br...@us...> - 2006-01-22 07:14:10
|
Update of /cvsroot/openvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12422 Modified Files: ChangeLog Log Message: Handle EOF from the command_channel by inserting traits_type::eof() into the stream buffer. Index: ChangeLog =================================================================== RCS file: /cvsroot/openvrml/openvrml/ChangeLog,v retrieving revision 1.1111 retrieving revision 1.1112 diff -C2 -d -r1.1111 -r1.1112 *** ChangeLog 21 Jan 2006 20:32:02 -0000 1.1111 --- ChangeLog 22 Jan 2006 07:14:02 -0000 1.1112 *************** *** 1,2 **** --- 1,8 ---- + 2006-01-22 Braden McDaniel <br...@en...> + + * mozilla-plugin/src/openvrml-player/command_istream.cpp: Handle + EOF from the command_channel by inserting traits_type::eof() into + the stream buffer. + 2006-01-21 Braden McDaniel <br...@en...> |
From: Braden M. <br...@us...> - 2006-01-21 20:32:14
|
Update of /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10775/src/libopenvrml/openvrml Modified Files: browser.cpp Log Message: Doc-comment improvements. Index: browser.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/browser.cpp,v retrieving revision 1.122 retrieving revision 1.123 diff -C2 -d -r1.122 -r1.123 *** browser.cpp 14 Jan 2006 06:42:28 -0000 1.122 --- browser.cpp 21 Jan 2006 20:32:03 -0000 1.123 *************** *** 6358,6361 **** --- 6358,6363 ---- * stream. Users of the library must provide an implementation of this class, * to be returned from <code>openvrml::browser::do_get_resource</code>. + * + * @sa openvrml::browser::do_get_resource(const std::string &) */ *************** *** 6920,6923 **** --- 6922,6931 ---- /** + * @example sdl_viewer.cpp + * + * Basic example using openvrml::browser. + */ + + /** * @var openvrml::browser::Vrml97Parser * *************** *** 6926,6929 **** --- 6934,6943 ---- /** + * @var openvrml::browser::X3DVrmlParser + * + * @brief X3D VRML parser generated by ANTLR. + */ + + /** * @internal * *************** *** 7697,7701 **** * resource_istream(&this->buf_) * { ! * this->buf_.open(path.c_str(), ios_base::in); * } * --- 7711,7723 ---- * resource_istream(&this->buf_) * { ! * // ! * // Note that the failbit is set in the constructor if no data ! * // can be read from the stream. This is important. If the ! * // failbit is not set on such a stream, OpenVRML will attempt ! * // to read data from a stream that cannot provide it. ! * // ! * if (!this->buf_.open(path.c_str(), ios_base::in)) { ! * this->setstate(ios_base::failbit); ! * } * } * *************** *** 7705,7708 **** --- 7727,7731 ---- * } * + * private: * virtual const std::string url() const throw () * { *************** *** 7717,7729 **** * // is intended to be portable and stupid). * // * using std::string; * using boost::algorithm::iequals; * string media_type = "application/octet-stream"; ! * const string::size_type dot_pos = this->url_.rfind('.'); ! * if (dot_pos == string::npos ! * || this->url_.size() < dot_pos + 1) { * return media_type; * } ! * const string ext = this->url_.substr(dot_pos + 1); * if (iequals(ext, "wrl")) { * media_type = "model/vrml"; --- 7740,7757 ---- * // is intended to be portable and stupid). * // + * using std::find; * using std::string; * using boost::algorithm::iequals; + * using boost::next; * string media_type = "application/octet-stream"; ! * const string::const_reverse_iterator dot_pos = ! * find(this->url_.rbegin(), this->url_.rend(), '.'); ! * if (dot_pos == this->url_.rend() ! * || next(dot_pos.base()) == this->url_.end()) { * return media_type; * } ! * const string::const_iterator hash_pos = ! * find(next(dot_pos.base()), this->url_.end(), '#'); ! * const string ext(dot_pos.base(), hash_pos); * if (iequals(ext, "wrl")) { * media_type = "model/vrml"; |
From: Braden M. <br...@us...> - 2006-01-21 20:32:13
|
Update of /cvsroot/openvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10775 Modified Files: ChangeLog Log Message: Doc-comment improvements. Index: ChangeLog =================================================================== RCS file: /cvsroot/openvrml/openvrml/ChangeLog,v retrieving revision 1.1110 retrieving revision 1.1111 diff -C2 -d -r1.1110 -r1.1111 *** ChangeLog 14 Jan 2006 06:42:28 -0000 1.1110 --- ChangeLog 21 Jan 2006 20:32:02 -0000 1.1111 *************** *** 1,2 **** --- 1,6 ---- + 2006-01-21 Braden McDaniel <br...@en...> + + * src/libopenvrml/openvrml/browser.cpp: Doc-comment improvements. + 2006-01-14 Braden McDaniel <br...@en...> |
From: Braden M. <br...@us...> - 2006-01-14 06:42:36
|
Update of /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29579/src/libopenvrml/openvrml Modified Files: browser.cpp browser.h Log Message: Added missing OPENVRML_LOCAL. Index: browser.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/browser.cpp,v retrieving revision 1.121 retrieving revision 1.122 diff -C2 -d -r1.121 -r1.122 *** browser.cpp 14 Jan 2006 06:04:56 -0000 1.121 --- browser.cpp 14 Jan 2006 06:42:28 -0000 1.122 *************** *** 8846,8850 **** } ! struct openvrml::scene::load_scene { load_scene(openvrml::scene & scene, --- 8846,8850 ---- } ! struct OPENVRML_LOCAL openvrml::scene::load_scene { load_scene(openvrml::scene & scene, Index: browser.h =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/browser.h,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** browser.h 14 Jan 2006 06:04:56 -0000 1.40 --- browser.h 14 Jan 2006 06:42:28 -0000 1.41 *************** *** 200,204 **** struct vrml_from_url_creator; ! class node_class_map { mutable boost::mutex mutex_; typedef std::map<std::string, boost::shared_ptr<node_class> > --- 200,204 ---- struct vrml_from_url_creator; ! class OPENVRML_LOCAL node_class_map { mutable boost::mutex mutex_; typedef std::map<std::string, boost::shared_ptr<node_class> > |
From: Braden M. <br...@us...> - 2006-01-14 06:42:36
|
Update of /cvsroot/openvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29579 Modified Files: ChangeLog Log Message: Added missing OPENVRML_LOCAL. Index: ChangeLog =================================================================== RCS file: /cvsroot/openvrml/openvrml/ChangeLog,v retrieving revision 1.1109 retrieving revision 1.1110 diff -C2 -d -r1.1109 -r1.1110 *** ChangeLog 14 Jan 2006 06:04:56 -0000 1.1109 --- ChangeLog 14 Jan 2006 06:42:28 -0000 1.1110 *************** *** 1,2 **** --- 1,12 ---- + 2006-01-14 Braden McDaniel <br...@en...> + + Added missing OPENVRML_LOCAL. + + * src/libopenvrml/openvrml/browser.cpp + (openvrml::scene::load_scene): Added OPENVRML_LOCAL to definition. + * src/libopenvrml/openvrml/browser.h + (openvrml::browser::node_class_map): Added OPENVRML_LOCAL to + definition. + 2006-01-13 Braden McDaniel <br...@en...> |
From: Braden M. <br...@us...> - 2006-01-14 06:05:05
|
Update of /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24660/mozilla-plugin/src/openvrml-player Modified Files: browser.cpp player.cpp plugin_streambuf.cpp plugin_streambuf.h Log Message: Allow openvrml::browser and openvrml::scene to be set directly from a resource_istream. Added a thread to openvrml-player specifically to process input from the command channel. This resolves issues with the plug-in deadlocking when the main thread becomes blocked. Index: player.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player/player.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** player.cpp 9 Jan 2006 07:22:16 -0000 1.17 --- player.cpp 14 Jan 2006 06:04:56 -0000 1.18 *************** *** 1,3 **** ! // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*- // // OpenVRML Mozilla plug-in --- 1,3 ---- ! // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- // // OpenVRML Mozilla plug-in *************** *** 36,39 **** --- 36,47 ---- const char application_name[] = "OpenVRML Player"; + + // + // We don't already know what the URI of the initial stream is until we + // start getting that data from the browser. This is a placeholder that + // is used to identify the plugin_streambuf that will be used to receive + // the initial stream data. + // + const char initial_stream_uri[] = "x-openvrml-initial:"; } *************** *** 47,51 **** {} ! void operator()() const { using std::string; --- 55,59 ---- {} ! void operator()() const throw () { using std::string; *************** *** 66,71 **** shared_ptr<plugin_streambuf> streambuf = ! uninitialized_plugin_streambuf_set_.find(url); if (!streambuf) { // --- 74,80 ---- shared_ptr<plugin_streambuf> streambuf = ! uninitialized_plugin_streambuf_map_.find(url); + static bool got_initial_stream = false; if (!streambuf) { // *************** *** 73,82 **** // stream. // ! if (this->browser_->world_url().empty()) { ! g_assert(uninitialized_plugin_streambuf_set_.size() == 1); streambuf = ! uninitialized_plugin_streambuf_set_.front(); ! this->browser_->world_url(url); } else { g_warning("Attempt to create an unrequested " --- 82,91 ---- // stream. // ! if (!got_initial_stream) { ! g_assert(uninitialized_plugin_streambuf_map_.size() == 1); streambuf = ! uninitialized_plugin_streambuf_map_.front(); ! got_initial_stream = true; } else { g_warning("Attempt to create an unrequested " *************** *** 85,95 **** } } ! streambuf->init(type); ! bool succeeded = ::plugin_streambuf_map ! .insert(make_pair(stream_id, streambuf)).second; ! g_assert(succeeded); ! succeeded = ! uninitialized_plugin_streambuf_set_.erase(streambuf); ! g_assert(succeeded); } else if (command == "destroy-stream") { size_t stream_id; --- 94,98 ---- } } ! streambuf->init(stream_id, url, type); } else if (command == "destroy-stream") { size_t stream_id; *************** *** 170,176 **** {} ! void operator()() const { ! class plugin_istream : public std::istream { boost::shared_ptr<plugin_streambuf> streambuf_; --- 173,179 ---- {} ! void operator()() const throw () { ! class plugin_istream : public openvrml::resource_istream { boost::shared_ptr<plugin_streambuf> streambuf_; *************** *** 178,182 **** explicit plugin_istream( const boost::shared_ptr<plugin_streambuf> & streambuf): ! std::istream(streambuf.get()), streambuf_(streambuf) {} --- 181,185 ---- explicit plugin_istream( const boost::shared_ptr<plugin_streambuf> & streambuf): ! openvrml::resource_istream(streambuf.get()), streambuf_(streambuf) {} *************** *** 184,191 **** virtual ~plugin_istream() throw () {} } in(this->streambuf_); ! std::vector<boost::intrusive_ptr<openvrml::node> > nodes = ! this->browser_->create_vrml_from_stream(in); ! this->browser_->replace_world(nodes); } --- 187,209 ---- virtual ~plugin_istream() throw () {} + + private: + virtual const std::string do_url() const throw (std::bad_alloc) + { + return this->streambuf_->url(); + } + + virtual const std::string do_type() const + throw (std::bad_alloc) + { + return this->streambuf_->type(); + } + + virtual bool do_data_available() const throw () + { + return this->streambuf_->data_available(); + } } in(this->streambuf_); ! this->browser_->set_world(in); } *************** *** 195,200 **** }; - GIOChannel * command_channel; GIOChannel * request_channel; } --- 213,268 ---- }; GIOChannel * request_channel; + + struct command_channel_loop { + command_channel_loop(const gint read_fd, command_istream & command_in): + read_fd_(read_fd), + command_in_(&command_in) + {} + + void operator()() const throw () + { + GMainContext * const main_context = g_main_context_new(); + GMainLoop * const main_loop = g_main_loop_new(main_context, false); + GIOChannel * const command_channel = + g_io_channel_unix_new(this->read_fd_); + GError * error = 0; + GIOStatus status = + g_io_channel_set_encoding(command_channel, + 0, // binary (no encoding) + &error); + if (status != G_IO_STATUS_NORMAL) { + if (error) { + g_critical(error->message); + g_error_free(error); + } + exit(EXIT_FAILURE); + } + + GSource * const command_watch = + g_io_create_watch(command_channel, G_IO_IN); + const GDestroyNotify notify = 0; + g_source_set_callback( + command_watch, + reinterpret_cast<GSourceFunc>(::command_data_available), + static_cast<command_streambuf *>(this->command_in_->rdbuf()), + notify); + guint source_id = g_source_attach(command_watch, main_context); + g_return_if_fail(source_id != 0); + + g_main_loop_run(main_loop); + + g_source_unref(command_watch); + g_io_channel_shutdown(command_channel, false, 0); + g_io_channel_unref(command_channel); + + g_main_loop_unref(main_loop); + g_main_context_unref(main_context); + } + + private: + gint read_fd_; + command_istream * command_in_; + }; } *************** *** 234,256 **** command_istream command_in; - if (read_fd) { - ::command_channel = g_io_channel_unix_new(read_fd); - GIOStatus status = g_io_channel_set_encoding(::command_channel, - 0, // binary (no encoding) - &error); - if (status != G_IO_STATUS_NORMAL) { - if (error) { - g_critical(error->message); - g_error_free(error); - } - return EXIT_FAILURE; - } - - g_io_add_watch(::command_channel, - G_IO_IN, - command_data_available, - static_cast<command_streambuf *>(command_in.rdbuf())); - } - if (write_fd) { ::request_channel = g_io_channel_unix_new(write_fd); --- 302,305 ---- *************** *** 269,272 **** --- 318,322 ---- thread_group threads; + scoped_ptr<thread> command_channel_loop_thread; scoped_ptr<thread> initial_stream_reader_thread; if (argc > 1) { *************** *** 274,294 **** b.load_url(uri, parameter); } else { ! shared_ptr<plugin_streambuf> initial_stream(new plugin_streambuf); bool succeeded = ! uninitialized_plugin_streambuf_set_.insert(initial_stream); g_return_val_if_fail(succeeded, EXIT_FAILURE); ! function0<void> f = initial_stream_reader(initial_stream, b); ! initial_stream_reader_thread.reset(threads.create_thread(f)); } - viewer.timer_update(); - function0<void> read_commands = command_istream_reader(command_in, b); scoped_ptr<thread> command_reader_thread( threads.create_thread(read_commands)); gtk_main(); - - g_io_channel_shutdown(::command_channel, false, 0); - g_io_channel_unref(::command_channel); } --- 324,349 ---- b.load_url(uri, parameter); } else { ! function0<void> command_channel_loop_func = ! command_channel_loop(read_fd, command_in); ! command_channel_loop_thread.reset( ! threads.create_thread(command_channel_loop_func)); ! ! shared_ptr<plugin_streambuf> initial_stream( ! new plugin_streambuf(initial_stream_uri)); bool succeeded = ! uninitialized_plugin_streambuf_map_.insert(initial_stream_uri, ! initial_stream); g_return_val_if_fail(succeeded, EXIT_FAILURE); ! function0<void> initial_stream_reader_func = ! initial_stream_reader(initial_stream, b); ! initial_stream_reader_thread.reset( ! threads.create_thread(initial_stream_reader_func)); } function0<void> read_commands = command_istream_reader(command_in, b); scoped_ptr<thread> command_reader_thread( threads.create_thread(read_commands)); + viewer.timer_update(); gtk_main(); } Index: plugin_streambuf.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player/plugin_streambuf.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** plugin_streambuf.cpp 9 Jan 2006 00:21:09 -0000 1.1 --- plugin_streambuf.cpp 14 Jan 2006 06:04:56 -0000 1.2 *************** *** 1,3 **** ! // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*- // // OpenVRML Mozilla plug-in --- 1,3 ---- ! // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*- // // OpenVRML Mozilla plug-in *************** *** 22,28 **** # include "plugin_streambuf.h" ! openvrml_player::plugin_streambuf::plugin_streambuf(const std::string & url): initialized_(false), ! url_(url), c_(traits_type::not_eof(this->c_)), npstream_destroyed_(false) --- 22,29 ---- # include "plugin_streambuf.h" ! openvrml_player::plugin_streambuf:: ! plugin_streambuf(const std::string & requested_url): initialized_(false), ! url_(requested_url), c_(traits_type::not_eof(this->c_)), npstream_destroyed_(false) *************** *** 31,39 **** } ! void openvrml_player::plugin_streambuf::init(const std::string & type) { boost::mutex::scoped_lock lock(this->mutex_); this->type_ = type; this->initialized_ = true; this->streambuf_initialized_.notify_all(); } --- 32,49 ---- } ! void openvrml_player::plugin_streambuf::init(const size_t stream_id, ! const std::string & received_url, ! const std::string & type) { boost::mutex::scoped_lock lock(this->mutex_); + bool succeeded = uninitialized_plugin_streambuf_map_.erase(this->url_); + g_assert(succeeded); + this->url_ = received_url; this->type_ = type; this->initialized_ = true; + const boost::shared_ptr<plugin_streambuf> this_ = shared_from_this(); + succeeded = plugin_streambuf_map.insert(make_pair(stream_id, this_)) + .second; + g_assert(succeeded); this->streambuf_initialized_.notify_all(); } *************** *** 41,48 **** const std::string & openvrml_player::plugin_streambuf::url() const { ! // ! // No need to lock or wait on init here; this->url_ is set in the ! // constructor and cannot be changed. ! // return this->url_; } --- 51,58 ---- const std::string & openvrml_player::plugin_streambuf::url() const { ! boost::mutex::scoped_lock lock(this->mutex_); ! while (!this->initialized_) { ! this->streambuf_initialized_.wait(lock); ! } return this->url_; } *************** *** 81,128 **** ! openvrml_player::uninitialized_plugin_streambuf_set ! openvrml_player::uninitialized_plugin_streambuf_set_; const boost::shared_ptr<openvrml_player::plugin_streambuf> ! openvrml_player::uninitialized_plugin_streambuf_set:: find(const std::string & url) const { boost::mutex::scoped_lock lock(this->mutex_); ! set_t::const_iterator pos = find_if(this->set_.begin(), ! this->set_.end(), ! plugin_streambuf_has_url(url)); ! return pos == this->set_.end() ? boost::shared_ptr<plugin_streambuf>() ! : *pos; } bool ! openvrml_player::uninitialized_plugin_streambuf_set:: ! insert(const boost::shared_ptr<openvrml_player::plugin_streambuf> & streambuf) { boost::mutex::scoped_lock lock(this->mutex_); ! return this->set_.insert(streambuf).second; } bool ! openvrml_player::uninitialized_plugin_streambuf_set:: ! erase(const boost::shared_ptr<openvrml_player::plugin_streambuf> & streambuf) { boost::mutex::scoped_lock lock(this->mutex_); ! return this->set_.erase(streambuf) == 1; } ! size_t openvrml_player::uninitialized_plugin_streambuf_set::size() const { boost::mutex::scoped_lock lock(this->mutex_); ! return this->set_.size(); } const boost::shared_ptr<openvrml_player::plugin_streambuf> ! openvrml_player::uninitialized_plugin_streambuf_set::front() const { boost::mutex::scoped_lock lock(this->mutex_); ! g_assert(!this->set_.empty()); ! return *this->set_.begin(); } --- 91,137 ---- ! openvrml_player::uninitialized_plugin_streambuf_map ! openvrml_player::uninitialized_plugin_streambuf_map_; const boost::shared_ptr<openvrml_player::plugin_streambuf> ! openvrml_player::uninitialized_plugin_streambuf_map:: find(const std::string & url) const { boost::mutex::scoped_lock lock(this->mutex_); ! map_t::const_iterator pos = this->map_.find(url); ! return pos == this->map_.end() ? boost::shared_ptr<plugin_streambuf>() ! : pos->second; } bool ! openvrml_player::uninitialized_plugin_streambuf_map:: ! insert(const std::string & url, ! const boost::shared_ptr<openvrml_player::plugin_streambuf> & streambuf) { boost::mutex::scoped_lock lock(this->mutex_); ! return this->map_.insert(make_pair(url, streambuf)).second; } bool ! openvrml_player::uninitialized_plugin_streambuf_map:: ! erase(const std::string & url) { boost::mutex::scoped_lock lock(this->mutex_); ! return this->map_.erase(url) == 1; } ! size_t openvrml_player::uninitialized_plugin_streambuf_map::size() const { boost::mutex::scoped_lock lock(this->mutex_); ! return this->map_.size(); } const boost::shared_ptr<openvrml_player::plugin_streambuf> ! openvrml_player::uninitialized_plugin_streambuf_map::front() const { boost::mutex::scoped_lock lock(this->mutex_); ! g_assert(!this->map_.empty()); ! return this->map_.begin()->second; } Index: browser.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player/browser.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** browser.cpp 9 Jan 2006 00:21:09 -0000 1.1 --- browser.cpp 14 Jan 2006 06:04:56 -0000 1.2 *************** *** 48,52 **** this->rdbuf(this->streambuf_.get()); bool succeeded = ! uninitialized_plugin_streambuf_set_.insert(this->streambuf_); g_assert(succeeded); --- 48,53 ---- this->rdbuf(this->streambuf_.get()); bool succeeded = ! uninitialized_plugin_streambuf_map_.insert(uri, ! this->streambuf_); g_assert(succeeded); Index: plugin_streambuf.h =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player/plugin_streambuf.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** plugin_streambuf.h 9 Jan 2006 00:21:09 -0000 1.1 --- plugin_streambuf.h 14 Jan 2006 06:04:56 -0000 1.2 *************** *** 26,29 **** --- 26,30 ---- # include <streambuf> # include <boost/shared_ptr.hpp> + # include <boost/enable_shared_from_this.hpp> # include "bounded_buffer.h" *************** *** 32,36 **** class command_istream_reader; ! class plugin_streambuf : public std::streambuf { friend class command_istream_reader; --- 33,40 ---- class command_istream_reader; ! class plugin_streambuf : ! public boost::enable_shared_from_this<plugin_streambuf>, ! public std::streambuf { ! friend class command_istream_reader; *************** *** 38,42 **** bool initialized_; mutable boost::condition streambuf_initialized_; ! const std::string url_; std::string type_; bounded_buffer<int_type, 64> buf_; --- 42,46 ---- bool initialized_; mutable boost::condition streambuf_initialized_; ! std::string url_; std::string type_; bounded_buffer<int_type, 64> buf_; *************** *** 48,53 **** public: ! explicit plugin_streambuf(const std::string & url = ""); ! void init(const std::string & type); const std::string & url() const; const std::string & type() const; --- 52,59 ---- public: ! explicit plugin_streambuf(const std::string & requested_url); ! void init(size_t stream_id, ! const std::string & received_url, ! const std::string & type); const std::string & url() const; const std::string & type() const; *************** *** 56,89 **** }; ! extern class uninitialized_plugin_streambuf_set { mutable boost::mutex mutex_; ! typedef std::set<boost::shared_ptr<plugin_streambuf> > set_t; ! set_t set_; ! ! struct plugin_streambuf_has_url : ! std::unary_function<boost::shared_ptr<plugin_streambuf>, bool> { ! ! explicit plugin_streambuf_has_url(const std::string & url): ! url_(&url) ! {} ! ! bool ! operator()(const boost::shared_ptr<plugin_streambuf> & arg) const ! { ! return arg->url() == *this->url_; ! } ! ! private: ! const std::string * url_; ! }; public: const boost::shared_ptr<plugin_streambuf> find(const std::string & url) const; ! bool insert(const boost::shared_ptr<plugin_streambuf> & streambuf); ! bool erase(const boost::shared_ptr<plugin_streambuf> & streambuf); size_t size() const; const boost::shared_ptr<plugin_streambuf> front() const; ! } uninitialized_plugin_streambuf_set_; --- 62,80 ---- }; ! extern class uninitialized_plugin_streambuf_map { mutable boost::mutex mutex_; ! typedef std::map<std::string, boost::shared_ptr<plugin_streambuf> > ! map_t; ! map_t map_; public: const boost::shared_ptr<plugin_streambuf> find(const std::string & url) const; ! bool insert(const std::string & url, ! const boost::shared_ptr<plugin_streambuf> & streambuf); ! bool erase(const std::string & url); size_t size() const; const boost::shared_ptr<plugin_streambuf> front() const; ! } uninitialized_plugin_streambuf_map_; |
From: Braden M. <br...@us...> - 2006-01-14 06:05:04
|
Update of /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24660/src/libopenvrml/openvrml Modified Files: browser.cpp browser.h Log Message: Allow openvrml::browser and openvrml::scene to be set directly from a resource_istream. Added a thread to openvrml-player specifically to process input from the command channel. This resolves issues with the plug-in deadlocking when the main thread becomes blocked. Index: browser.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/browser.cpp,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -d -r1.120 -r1.121 *** browser.cpp 2 Jan 2006 04:26:16 -0000 1.120 --- browser.cpp 14 Jan 2006 06:04:56 -0000 1.121 *************** *** 7823,7842 **** /** ! * @brief Set the URI for the world. ! * ! * This function does nothing other than change the URI returned by ! * the browser::world_url accessor. It does not result in loading a new world. * ! * @param str a valid URI. * ! * @exception invalid_url if @p str is not a valid URI. ! * @exception std::bad_alloc if memory allocation fails. */ ! void openvrml::browser::world_url(const std::string & str) ! throw (invalid_url, std::bad_alloc) { boost::recursive_mutex::scoped_lock lock(this->mutex_); ! assert(this->scene_); ! this->scene_->url(str); } --- 7823,7911 ---- /** ! * @brief Set the world from a stream. * ! * @param in an input stream. * ! * @exception bad_media_type if @p in.type() is not "model/vrml", ! * "x-world/x-vrml", or "model/x3d+vrml". ! * @excpetion invalid_vrml if @p in has invalid syntax. */ ! void openvrml::browser::set_world(resource_istream & in) { boost::recursive_mutex::scoped_lock lock(this->mutex_); ! ! using std::for_each; ! using std::string; ! ! // ! // Clear out the current scene. ! // ! double now = browser::current_time(); ! if (this->scene_) { this->scene_->shutdown(now); } ! for_each(this->listeners_.begin(), this->listeners_.end(), ! boost::bind2nd(boost::mem_fun(&browser_listener::browser_changed), ! browser_event(*this, browser_event::shutdown))); ! this->scene_.reset(); ! this->active_viewpoint_ = ! node_cast<viewpoint_node *>(this->default_viewpoint_.get()); ! assert(this->viewpoint_list.empty()); ! assert(this->scoped_lights.empty()); ! assert(this->scripts.empty()); ! assert(this->timers.empty()); ! ! // ! // Create the new scene. ! // ! node_class_map new_map; ! this->node_class_map_ = new_map; ! register_node_classes(*this); ! this->scene_.reset(new scene(*this)); ! this->scene_->load(in); ! ! // ! // Initialize. ! // ! now = browser::current_time(); ! this->scene_->initialize(now); ! ! // ! // Get the initial viewpoint_node, if any was specified. ! // ! viewpoint_node * initial_viewpoint = 0; ! const string viewpoint_node_id = uri(this->scene_->url()).fragment(); ! if (!viewpoint_node_id.empty()) { ! if (!this->scene_->nodes().empty()) { ! using boost::intrusive_ptr; ! const intrusive_ptr<node> & n = this->scene_->nodes().front(); ! if (n) { ! node * const vp = n->scope()->find_node(viewpoint_node_id); ! initial_viewpoint = dynamic_cast<viewpoint_node *>(vp); ! } ! } ! } ! ! // ! // Initialize the node_classes. ! // ! this->node_class_map_.init(initial_viewpoint, now); ! ! if (this->active_viewpoint_ ! != node_cast<viewpoint_node *>(this->default_viewpoint_.get())) { ! // XXX ! // XXX Fix openvrml::viewpoint_node so that we don't have to get an ! // XXX event_listener here. ! // XXX ! event_listener & listener = ! this->active_viewpoint_->event_listener("set_bind"); ! dynamic_cast<sfbool_listener &>(listener).process_event(sfbool(true), ! now); ! } ! ! this->modified(true); ! this->new_view = true; // Force resetUserNav ! ! for_each(this->listeners_.begin(), this->listeners_.end(), ! boost::bind2nd(boost::mem_fun(&browser_listener::browser_changed), ! browser_event(*this, browser_event::initialized))); } *************** *** 7864,7867 **** --- 7933,7973 ---- } + struct OPENVRML_LOCAL openvrml::browser::root_scene_loader { + root_scene_loader(browser & b, const std::vector<std::string> & url): + browser_(&b), + url_(&url) + {} + + void operator()() const throw () + try { + boost::recursive_mutex::scoped_lock lock(this->browser_->mutex_); + + using std::endl; + + openvrml::browser & browser = *this->browser_; + + try { + std::auto_ptr<resource_istream> in = + browser.scene_->get_resource(*this->url_); + if (!(*in)) { throw unreachable_url(); } + browser.set_world(*in); + } catch (antlr::ANTLRException & ex) { + browser.err << ex.getMessage() << endl; + } catch (unreachable_url &) { + throw; + } catch (std::exception & ex) { + browser.err << ex.what() << endl; + } catch (...) { + throw unreachable_url(); + } + } catch (unreachable_url & ex) { + this->browser_->err << ex.what() << std::endl; + } + + private: + browser * browser_; + const std::vector<std::string> * url_; + }; + /** * @brief Load a VRML world into the browser. *************** *** 7876,7978 **** throw (std::bad_alloc) { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); ! ! class root_scene : public openvrml::scene { ! public: ! explicit root_scene(openvrml::browser & b): ! scene(b, 0) ! {} ! ! private: ! virtual void scene_loaded() ! { ! boost::recursive_mutex::scoped_lock lock(this->browser().mutex_); ! ! try { ! using std::string; ! ! const double now = browser::current_time(); ! this->initialize(now); ! ! // ! // Get the initial viewpoint_node, if any was specified. ! // ! viewpoint_node * initial_viewpoint = 0; ! const string viewpoint_node_id = uri(this->url()).fragment(); ! if (!viewpoint_node_id.empty()) { ! if (!this->nodes().empty()) { ! const boost::intrusive_ptr<node> & n = this->nodes()[0]; ! if (n) { ! node * const vp = ! n->scope()->find_node(viewpoint_node_id); ! initial_viewpoint = ! dynamic_cast<viewpoint_node *>(vp); ! } ! } ! } ! ! // ! // Initialize the node_classes. ! // ! this->browser().node_class_map_.init(initial_viewpoint, now); ! ! if (this->browser().active_viewpoint_ ! != node_cast<viewpoint_node *>( ! this->browser().default_viewpoint_.get())) { ! event_listener & listener = ! this->browser().active_viewpoint_ ! ->event_listener("set_bind"); ! dynamic_cast<sfbool_listener &>(listener) ! .process_event(sfbool(true), now); ! } ! } catch (std::exception & ex) { ! std::ostream & err = this->browser().err; ! // ! // For some reason the Microsoft compiler (13.10.3077) has a ! // problem with the "normal" operator<< syntax here. ! // ! err.operator<<(ex.what()).operator<<(std::endl); ! } ! this->browser().modified(true); ! this->browser().new_view = true; // Force resetUserNav ! ! using std::for_each; ! ! for_each(this->browser().listeners_.begin(), ! this->browser().listeners_.end(), ! boost::bind2nd( ! boost::mem_fun(&browser_listener::browser_changed), ! browser_event(this->browser(), ! browser_event::initialized))); ! } ! }; ! ! using std::for_each; ! ! const double now = browser::current_time(); ! ! // ! // Clear out the current scene. ! // ! if (this->scene_) { this->scene_->shutdown(now); } ! for_each(this->listeners_.begin(), this->listeners_.end(), ! boost::bind2nd(boost::mem_fun(&browser_listener::browser_changed), ! browser_event(*this, browser_event::shutdown))); ! this->scene_.reset(); ! this->active_viewpoint_ = ! node_cast<viewpoint_node *>(this->default_viewpoint_.get()); ! assert(this->viewpoint_list.empty()); ! assert(this->scoped_lights.empty()); ! assert(this->scripts.empty()); ! assert(this->timers.empty()); ! ! // ! // Create the new scene. ! // ! node_class_map new_map; ! this->node_class_map_ = new_map; ! register_node_classes(*this); ! this->scene_.reset(new root_scene(*this)); ! this->scene_->load(url); } --- 7982,7987 ---- throw (std::bad_alloc) { ! boost::function0<void> f = root_scene_loader(*this, url); ! boost::thread t(f); } *************** *** 8857,8885 **** vector<boost::intrusive_ptr<node> > nodes; try { - using boost::algorithm::iequals; - std::auto_ptr<resource_istream> in = scene.get_resource(url); if (!(*in)) { throw unreachable_url(); } ! scene.url(in->url()); ! if (iequals(in->type(), "model/vrml") ! || iequals(in->type(), "x-world/x-vrml")) { ! scene.profile_ = vrml97_profile_id; ! Vrml97Scanner scanner(*in); ! Vrml97Parser parser(scanner, in->url()); ! parser.vrmlScene(scene, nodes); ! } else if (iequals(in->type(), "model/x3d+vrml")) { ! X3DVrmlScanner scanner(*in); ! X3DVrmlParser parser(scanner, in->url()); ! parser.vrmlScene(scene, nodes); ! } else { ! throw bad_media_type(in->type()); ! } ! } catch (bad_media_type & ex) { ! scene.browser().err << ex.what() << endl; ! } catch (antlr::RecognitionException & ex) { ! throw invalid_vrml(ex.getFilename(), ! ex.getLine(), ! ex.getColumn(), ! ex.getMessage()); } catch (antlr::ANTLRException & ex) { scene.browser().err << ex.getMessage() << endl; --- 8866,8872 ---- vector<boost::intrusive_ptr<node> > nodes; try { std::auto_ptr<resource_istream> in = scene.get_resource(url); if (!(*in)) { throw unreachable_url(); } ! scene.load(*in); } catch (antlr::ANTLRException & ex) { scene.browser().err << ex.getMessage() << endl; *************** *** 8929,8932 **** --- 8916,8958 ---- /** + * @brief Load the scene from a stream. + * + * @param in an input stream. + * + * @exception bad_media_type if @p in.type() is not "model/vrml", + * "x-world/x-vrml", or "model/x3d+vrml". + * @excpetion invalid_vrml if @p in has invalid syntax. + */ + void openvrml::scene::load(resource_istream & in) + { + boost::recursive_mutex::scoped_lock nodes_lock(this->nodes_mutex_); + boost::mutex::scoped_lock url_lock(this->url_mutex_); + + try { + using boost::algorithm::iequals; + + this->url_ = in.url(); + + if (iequals(in.type(), "model/vrml") + || iequals(in.type(), "x-world/x-vrml")) { + Vrml97Scanner scanner(in); + Vrml97Parser parser(scanner, this->url_); + parser.vrmlScene(*this, this->nodes_); + } else if (iequals(in.type(), "model/x3d+vrml")) { + X3DVrmlScanner scanner(in); + X3DVrmlParser parser(scanner, this->url_); + parser.vrmlScene(*this, this->nodes_); + } else { + throw bad_media_type(in.type()); + } + } catch (antlr::RecognitionException & ex) { + throw invalid_vrml(ex.getFilename(), + ex.getLine(), + ex.getColumn(), + ex.getMessage()); + } + } + + /** * @brief Initialize the scene. * *************** *** 8998,9021 **** /** - * @brief Set the URI for the scene. - * - * Generally this function is used in conjunction with the two-argument - * constructor (that does not take an alternative URI list) and the - * scene::nodes mutator function. - * - * @param str a valid URI. - * - * @exception invalid_url if @p str is not a valid URI. - * @exception std::bad_alloc if memory allocation fails. - */ - void openvrml::scene::url(const std::string & str) - throw (invalid_url, std::bad_alloc) - { - boost::mutex::scoped_lock lock(this->url_mutex_); - uri id(str); // Make sure we have a valid URI. - this->url_ = str; - } - - /** * @brief Render the scene. * --- 9024,9027 ---- Index: browser.h =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/browser.h,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** browser.h 2 Jan 2006 04:26:15 -0000 1.39 --- browser.h 14 Jan 2006 06:04:56 -0000 1.40 *************** *** 197,200 **** --- 197,201 ---- friend class X3DVrmlParser; + struct root_scene_loader; struct vrml_from_url_creator; *************** *** 294,299 **** float current_speed(); const std::string world_url() const throw (std::bad_alloc); ! void world_url(const std::string & str) ! throw (invalid_url, std::bad_alloc); void replace_world( const std::vector<boost::intrusive_ptr<node> > & nodes); --- 295,299 ---- float current_speed(); const std::string world_url() const throw (std::bad_alloc); ! void set_world(resource_istream & in); void replace_world( const std::vector<boost::intrusive_ptr<node> > & nodes); *************** *** 377,380 **** --- 377,381 ---- void load(const std::vector<std::string> & url) throw (boost::thread_resource_error, std::bad_alloc); + void load(resource_istream & in); void initialize(double timestamp) throw (std::bad_alloc); const std::vector<boost::intrusive_ptr<node> > & nodes() const *************** *** 383,387 **** throw (std::bad_alloc); const std::string url() const throw (std::bad_alloc); - void url(const std::string & str) throw (invalid_url, std::bad_alloc); void render(openvrml::viewer & viewer, rendering_context context); void load_url(const std::vector<std::string> & url, --- 384,387 ---- |
From: Braden M. <br...@us...> - 2006-01-14 06:05:04
|
Update of /cvsroot/openvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24660 Modified Files: ChangeLog Log Message: Allow openvrml::browser and openvrml::scene to be set directly from a resource_istream. Added a thread to openvrml-player specifically to process input from the command channel. This resolves issues with the plug-in deadlocking when the main thread becomes blocked. Index: ChangeLog =================================================================== RCS file: /cvsroot/openvrml/openvrml/ChangeLog,v retrieving revision 1.1108 retrieving revision 1.1109 diff -C2 -d -r1.1108 -r1.1109 *** ChangeLog 9 Jan 2006 07:22:16 -0000 1.1108 --- ChangeLog 14 Jan 2006 06:04:56 -0000 1.1109 *************** *** 1,2 **** --- 1,91 ---- + 2006-01-13 Braden McDaniel <br...@en...> + + Allow openvrml::browser and openvrml::scene to be set directly + from a resource_istream. Added a thread to openvrml-player + specifically to process input from the command channel. This + resolves issues with the plug-in deadlocking when the main thread + becomes blocked. + + * mozilla-plugin/src/openvrml-player/browser.cpp + (openvrml_player::browser::do_get_resource(const std::string &)): + Changed plugin_resource_istream constructor to use + uninitialized_plugin_streambuf_map_. + * mozilla-plugin/src/openvrml-player/player.cpp + (initial_stream_uri): Identifier for the plugin_streambuf to be + used for the initial stream. + (openvrml_player::command_istream_reader::operator()() const): + Added nothrow exception specification; changed to use + uninitialized_plugin_streambuf_map_; removed call to + openvrml::browser::world_url; changed call to + plugin_streambuf::init to include stream_id and url arguments. + (initial_stream_reader::operator()() const): Added nothrow + exception specification; changed plugin_istream to inherit + openvrml::resource_istream instead of std::istream; call + openvrml::browser::set_world. + (command_channel): Removed; moved to + command_channel_loop::operator(). + (command_channel_loop): Added; thread function object to run a + glib event loop to read input from a GIOChannel. + (main(argc, argv)): Moved logic to initialize the command_channel + GIOChannel to command_channel_loop::operator(); start the + command_channel_loop_thread. + * mozilla-plugin/src/openvrml-player/plugin_streambuf.cpp + (openvrml_player::plugin_streambuf::plugin_streambuf(const + std::string &)): Changed argument name to "requested_url". + (openvrml_player::plugin_streambuf::init(size_t, const std::string + &, const std::string &)): Added stream_id and received_url + arguments; remove the plugin_streambuf from + uninitialized_plugin_streambuf_map_ and add it to + plugin_streambuf_map. + (openvrml_player::plugin_streambuf::url() const): Block until the + plugin_streambuf has been initialized. + (openvrml_player::uninitialized_plugin_streambuf_set_): Removed. + (openvrml_player::uninitialized_plugin_streambuf_map_): Added. + (openvrml_player::uninitialized_plugin_streambuf_set::find(const + std::string &)): Removed. + (openvrml_player::uninitialized_plugin_streambuf_map::find(const + std::string &)): Added. + (openvrml_player::uninitialized_plugin_streambuf_set::insert(const + boost::shared_ptr<openvrml_player::plugin_streambuf> &)): Removed. + (openvrml_player::uninitialized_plugin_streambuf_map::insert(const + std::string &, + boost::shared_ptr<openvrml_player::plugin_streambuf> &)): Added. + (openvrml_player::uninitialized_plugin_streambuf_set::erase(const + boost::shared_ptr<openvrml_player::plugin_streambuf> &)): Removed. + (openvrml_player::uninitialized_plugin_streambuf_map::erase(const + std::string &)): Removed. + (openvrml_player::uninitialized_plugin_streambuf_set::size() + const): Removed. + (openvrml_player::uninitialized_plugin_streambuf_map::size() + const): Removed. + (openvrml_player::uninitialized_plugin_streambuf_set::front() + const): Removed. + (openvrml_player::uninitialized_plugin_streambuf_map::front() + const): Removed. + * mozilla-plugin/src/openvrml-player/plugin_streambuf.h + (openvrml_player::plugin_streambuf): Inherit + boost::enable_shared_from_tis<T>; removed const from url_ member. + (uninitialized_plugin_streambuf_set_): Removed. + (uninitialized_plugin_streambuf_map_): Added. + * src/libopenvrml/openvrml/browser.cpp + (openvrml::browser::world_url(const std::string &)): Removed. + (openvrml::browser::set_world(resource_istream & in)): Added; set + the world from a resource_istream. + (openvrml::browser::root_scene_loader): Added; thread function + object for openvrml::browser::load_url. + (openvrml::browser::load_url(const std::vector<std::string> &, + const std::vector<std::string> &)): Changed to delegate to + openvrml::browser::root_scene_loader. + (openvrml::scene::load_scene): Changed to delegate to + openvrml::scene::load. + (openvrml::scene::load(resource_istream & in)): Added; set the + scene from a resource_istream. + (openvrml::scene::url(const std::string &)): Removed. + * src/libopenvrml/openvrml/browser.h + (openvrml::browser): Added root_scene_loader declaration; removed + world_url mutator; added set_world mutator. + (openvrml::scene): Added load mutator accepting a + resource_istream; removed url mutator. + 2006-01-09 Braden McDaniel <br...@en...> |
From: Braden M. <br...@us...> - 2006-01-09 07:22:27
|
Update of /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12866/mozilla-plugin/src/openvrml-player Modified Files: player.cpp Log Message: Use GOption instead of GNU argp for command line argument parsing. Index: player.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player/player.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** player.cpp 9 Jan 2006 00:21:09 -0000 1.16 --- player.cpp 9 Jan 2006 07:22:16 -0000 1.17 *************** *** 19,24 **** // ! # include <cstdlib> ! # include <boost/lexical_cast.hpp> # include <boost/thread/thread.hpp> # include <unistd.h> --- 19,23 ---- // ! # include <sstream> # include <boost/thread/thread.hpp> # include <unistd.h> *************** *** 26,30 **** # include <boost/numeric/conversion/converter.hpp> # include <gdk/gdkx.h> - # include <argp.h> # include "browser.h" --- 25,28 ---- *************** *** 40,50 **** } - extern "C" { - const char * argp_program_version = "OpenVRML Player " PACKAGE_VERSION; - const char * argp_program_bug_address = PACKAGE_BUGREPORT; - - error_t parse_opt(int key, char * arg, argp_state * state); - } - namespace openvrml_player { --- 38,41 ---- *************** *** 137,178 **** namespace { ! enum option_id { ! gtk_socket_id_id = 128, ! read_fd_id, ! write_fd_id ! }; ! argp_option options[] = { { "gtk-socket-id", - gtk_socket_id_id, - "GTK_SOCKET_ID", 0, "GtkSocket id", ! 0 }, { "read-fd", - read_fd_id, - "READ_FD", 0, "file descriptor for reading commands", ! 0 }, { "write-fd", - write_fd_id, - "WRITE_FD", 0, "file descriptor for writing commands", ! 0 }, ! { 0, 0, 0, 0, 0, 0 } ! }; ! ! struct arguments { ! GdkNativeWindow socket_id; ! int read_fd; ! int write_fd; }; --- 128,163 ---- namespace { ! GdkNativeWindow socket_id; ! gint read_fd, write_fd; ! GOptionEntry options[] = { { "gtk-socket-id", 0, + 0, + G_OPTION_ARG_INT, + &socket_id, "GtkSocket id", ! "GTK_SOCKET_ID" }, { "read-fd", 0, + 0, + G_OPTION_ARG_INT, + &read_fd, "file descriptor for reading commands", ! "READ_FD" }, { "write-fd", 0, + 0, + G_OPTION_ARG_INT, + &write_fd, "file descriptor for writing commands", ! "WRITE_FD" }, ! { 0, 0, 0, G_OPTION_ARG_NONE, 0, 0, 0 } }; *************** *** 231,261 **** gtk_gl_init(&argc, &argv); ! arguments arguments; ! arguments.socket_id = 0; ! arguments.read_fd = 0; ! arguments.write_fd = 0; ! char args_doc[] = "[URI]"; ! char * const doc = 0; ! argp_child * const children = 0; ! char *(*help_filter)(int key, const char * text, void * input) = 0; ! char * argp_domain = 0; ! argp argp = { ! options, ! parse_opt, ! args_doc, ! doc, ! children, ! help_filter, ! argp_domain ! }; ! int uri_arg_index; ! argp_parse(&argp, argc, argv, 0, &uri_arg_index, &arguments); command_istream command_in; ! if (arguments.read_fd) { ! ::command_channel = g_io_channel_unix_new(arguments.read_fd); ! GError * error = 0; GIOStatus status = g_io_channel_set_encoding(::command_channel, 0, // binary (no encoding) --- 216,239 ---- gtk_gl_init(&argc, &argv); ! GError * error = 0; ! GOptionContext * const context = ! g_option_context_new("- render VRML worlds"); ! const gchar * const translation_domain = 0; ! g_option_context_add_main_entries(context, options, translation_domain); ! g_option_context_add_group(context, gtk_get_option_group(true)); ! gboolean succeeded = g_option_context_parse(context, &argc, &argv, &error); ! if (!succeeded) { ! if (error) { ! g_critical(error->message); ! g_error_free(error); ! } ! return EXIT_FAILURE; ! } command_istream command_in; ! if (read_fd) { ! ::command_channel = g_io_channel_unix_new(read_fd); GIOStatus status = g_io_channel_set_encoding(::command_channel, 0, // binary (no encoding) *************** *** 275,284 **** } ! if (arguments.write_fd) { ! ::request_channel = g_io_channel_unix_new(arguments.write_fd); } ! GtkWidget * window = arguments.socket_id ! ? gtk_plug_new(arguments.socket_id) : gtk_window_new(GTK_WINDOW_TOPLEVEL); --- 253,262 ---- } ! if (write_fd) { ! ::request_channel = g_io_channel_unix_new(write_fd); } ! GtkWidget * window = socket_id ! ? gtk_plug_new(socket_id) : gtk_window_new(GTK_WINDOW_TOPLEVEL); *************** *** 292,297 **** scoped_ptr<thread> initial_stream_reader_thread; ! if (uri_arg_index < argc) { ! const vector<string> uri(1, argv[uri_arg_index]), parameter; b.load_url(uri, parameter); } else { --- 270,275 ---- scoped_ptr<thread> initial_stream_reader_thread; ! if (argc > 1) { ! const vector<string> uri(1, argv[1]), parameter; b.load_url(uri, parameter); } else { *************** *** 315,351 **** g_io_channel_unref(::command_channel); } - - error_t parse_opt(int key, char * arg, argp_state * state) - { - using boost::lexical_cast; - using boost::bad_lexical_cast; - - arguments & args = *static_cast<arguments *>(state->input); - - switch (key) { - case gtk_socket_id_id: - try { - args.socket_id = lexical_cast<GdkNativeWindow>(arg); - } catch (bad_lexical_cast &) { - argp_error(state, "GTK_SOCKET_ID must be an integer"); - } - break; - case read_fd_id: - try { - args.read_fd = lexical_cast<int>(arg); - } catch (bad_lexical_cast &) { - argp_error(state, "READ_FD must be an unsigned integer"); - } - break; - case write_fd_id: - try { - args.write_fd = lexical_cast<int>(arg); - } catch (bad_lexical_cast &) { - argp_error(state, "WRITE_FD must be an unsigned integer"); - } - break; - default: - return ARGP_ERR_UNKNOWN; - } - return 0; - } --- 293,294 ---- |
From: Braden M. <br...@us...> - 2006-01-09 07:22:27
|
Update of /cvsroot/openvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12866 Modified Files: ChangeLog Log Message: Use GOption instead of GNU argp for command line argument parsing. Index: ChangeLog =================================================================== RCS file: /cvsroot/openvrml/openvrml/ChangeLog,v retrieving revision 1.1107 retrieving revision 1.1108 diff -C2 -d -r1.1107 -r1.1108 *** ChangeLog 9 Jan 2006 00:21:06 -0000 1.1107 --- ChangeLog 9 Jan 2006 07:22:16 -0000 1.1108 *************** *** 1,2 **** --- 1,19 ---- + 2006-01-09 Braden McDaniel <br...@en...> + + Use GOption instead of GNU argp for command line argument parsing. + + * mozilla-plugin/src/openvrml-player/player.cpp + (argp_program_version): Removed. + (argp_program_bug_address): Removed. + (parse_opt(int, char*, arp_state*)): Removed. + (option_id): Removed enumeration. + (socket_id): Added global variable. + (read_fd): Added global variable. + (write_fd): Added global variable. + (options): Changed from argp_option array to GOptionEntry array. + (arguments): Removed struct. + (main(argc, argv *[])): Parse command line options with GOption + instead of GNU argp. + 2006-01-08 Braden McDaniel <br...@en...> |
From: Braden M. <br...@us...> - 2006-01-09 00:21:18
|
Update of /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8218/mozilla-plugin/src/openvrml-player Modified Files: Makefile.am player.cpp Added Files: bounded_buffer.h browser.cpp browser.h command_istream.cpp command_istream.h gtkglviewer.cpp gtkglviewer.h plugin_streambuf.cpp plugin_streambuf.h Log Message: Factored code in mozilla-plugin/src/openvrml-player/player.cpp into multiple files. --- NEW FILE: plugin_streambuf.h --- // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*- // // OpenVRML Mozilla plug-in // Copyright 2004, 2005, 2006 Braden N. McDaniel // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // # ifndef OPENVRML_PLAYER_PLUGIN_STREAMBUF_H # define OPENVRML_PLAYER_PLUGIN_STREAMBUF_H # include <map> # include <set> # include <streambuf> # include <boost/shared_ptr.hpp> # include "bounded_buffer.h" namespace openvrml_player { class command_istream_reader; class plugin_streambuf : public std::streambuf { friend class command_istream_reader; mutable boost::mutex mutex_; bool initialized_; mutable boost::condition streambuf_initialized_; const std::string url_; std::string type_; bounded_buffer<int_type, 64> buf_; char_type c_; bool npstream_destroyed_; protected: virtual int_type underflow(); public: explicit plugin_streambuf(const std::string & url = ""); void init(const std::string & type); const std::string & url() const; const std::string & type() const; bool data_available() const; void npstream_destroyed(); }; extern class uninitialized_plugin_streambuf_set { mutable boost::mutex mutex_; typedef std::set<boost::shared_ptr<plugin_streambuf> > set_t; set_t set_; struct plugin_streambuf_has_url : std::unary_function<boost::shared_ptr<plugin_streambuf>, bool> { explicit plugin_streambuf_has_url(const std::string & url): url_(&url) {} bool operator()(const boost::shared_ptr<plugin_streambuf> & arg) const { return arg->url() == *this->url_; } private: const std::string * url_; }; public: const boost::shared_ptr<plugin_streambuf> find(const std::string & url) const; bool insert(const boost::shared_ptr<plugin_streambuf> & streambuf); bool erase(const boost::shared_ptr<plugin_streambuf> & streambuf); size_t size() const; const boost::shared_ptr<plugin_streambuf> front() const; } uninitialized_plugin_streambuf_set_; typedef std::map<size_t, boost::shared_ptr<plugin_streambuf> > plugin_streambuf_map_t; extern plugin_streambuf_map_t plugin_streambuf_map; } # endif // ifndef OPENVRML_PLAYER_PLUGIN_STREAMBUF_H --- NEW FILE: gtkglviewer.h --- // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*- // // OpenVRML Mozilla plug-in // Copyright 2004, 2005, 2006 Braden N. McDaniel // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // # ifndef OPENVRML_PLAYER_GTKGLVIEWER_H # define OPENVRML_PLAYER_GTKGLVIEWER_H # include <gtk/gtk.h> # include <gtk/gtkgl.h> # include <openvrml/gl/viewer.h> namespace openvrml_player { class GtkGLViewer : public openvrml::gl::viewer { static GdkGLConfig * gl_config; GtkWidget * drawing_area; guint timer; public: bool redrawNeeded; explicit GtkGLViewer(GtkContainer & container); virtual ~GtkGLViewer() throw (); void timer_update(); protected: // // Implement pure virtual methods from openvrml::gl::viewer. // virtual void post_redraw(); virtual void set_cursor(openvrml::gl::viewer::cursor_style); virtual void swap_buffers(); virtual void set_timer(double); }; } # endif // ifndef OPENVRML_PLAYER_GTKGLVIEWER_H --- NEW FILE: command_istream.h --- // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*- // // OpenVRML Mozilla plug-in // Copyright 2004, 2005, 2006 Braden N. McDaniel // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // # ifndef OPENVRML_PLAYER_COMMAND_ISTREAM_H # define OPENVRML_PLAYER_COMMAND_ISTREAM_H # include <streambuf> # include <glib.h> # include "bounded_buffer.h" extern "C" gboolean command_data_available(GIOChannel * source, GIOCondition condition, gpointer data); namespace openvrml_player { class command_streambuf : boost::noncopyable, public std::streambuf { friend gboolean (::command_data_available)(GIOChannel * source, GIOCondition condition, gpointer data); bounded_buffer<int_type, 64> source_buffer_; char_type c_; protected: virtual int_type underflow(); public: command_streambuf(); }; class command_istream : boost::noncopyable, public std::istream { command_streambuf buf_; public: command_istream(); }; } # endif // ifndef OPENVRML_PLAYER_COMMAND_ISTREAM_H --- NEW FILE: gtkglviewer.cpp --- // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*- // // OpenVRML Mozilla plug-in // Copyright 2004, 2005, 2006 Braden N. McDaniel // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // # include <X11/keysym.h> # include <gdk/gdkx.h> # include "gtkglviewer.h" GdkGLConfig * openvrml_player::GtkGLViewer::gl_config(0); extern "C" { gboolean realize(GtkWidget * widget, GdkEvent * event, gpointer data); gboolean expose_event(GtkWidget * widget, GdkEventExpose * event, gpointer data); gboolean configure_event(GtkWidget * widget, GdkEventConfigure * event, gpointer data); gboolean key_press_event(GtkWidget * widget, GdkEventKey * event, gpointer data); gboolean button_press_event(GtkWidget * widget, GdkEventButton * event, gpointer data); gboolean button_release_event(GtkWidget * widget, GdkEventButton * event, gpointer data); gboolean motion_notify_event(GtkWidget * widget, GdkEventMotion * event, gpointer data); } openvrml_player::GtkGLViewer::GtkGLViewer(GtkContainer & container): drawing_area(gtk_drawing_area_new()), timer(0), redrawNeeded(false) { if (!this->drawing_area) { throw std::bad_alloc(); } if (!GtkGLViewer::gl_config) { static const int attrib_list[] = { // GDK_GL_ALPHA_SIZE, 1, GDK_GL_DOUBLEBUFFER, GDK_GL_DEPTH_SIZE, 1, GDK_GL_RGBA, GDK_GL_RED_SIZE, 1, GDK_GL_ATTRIB_LIST_NONE }; GtkGLViewer::gl_config = gdk_gl_config_new(attrib_list); } static GdkGLContext * const share_list = 0; static const gboolean direct = false; static const int render_type = GDK_GL_RGBA_TYPE; gtk_widget_set_gl_capability(this->drawing_area, GtkGLViewer::gl_config, share_list, direct, render_type); gtk_widget_add_events(this->drawing_area, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_POINTER_MOTION_MASK); g_signal_connect(G_OBJECT((this->drawing_area)), "expose_event", G_CALLBACK(expose_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "configure_event", G_CALLBACK(configure_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "key_press_event", G_CALLBACK(key_press_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "button_press_event", G_CALLBACK(button_press_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "button_release_event", G_CALLBACK(button_release_event), this); g_signal_connect(G_OBJECT(this->drawing_area), "motion_notify_event", G_CALLBACK(motion_notify_event), this); gtk_container_add(&container, this->drawing_area); } openvrml_player::GtkGLViewer::~GtkGLViewer() throw () { if (this->timer) { g_source_remove(timer); } } void openvrml_player::GtkGLViewer::post_redraw() { if (!this->redrawNeeded) { this->redrawNeeded = true; gtk_widget_queue_draw(GTK_WIDGET(this->drawing_area)); } } void openvrml_player::GtkGLViewer::set_cursor(cursor_style style) { GdkCursor * cursor(0); GtkWidget * const widget = GTK_WIDGET(this->drawing_area); switch(style) { case cursor_inherit: XDefineCursor(GDK_WINDOW_XDISPLAY(widget->window), GDK_WINDOW_XWINDOW(widget->window), None); return; case cursor_info: cursor = gdk_cursor_new(GDK_HAND1); break; case cursor_cycle: cursor = gdk_cursor_new(GDK_EXCHANGE); break; case cursor_up_down: cursor = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW); break; case cursor_crosshair: cursor = gdk_cursor_new(GDK_CROSSHAIR); break; default: cursor = gdk_cursor_new(GDK_ARROW); } gdk_window_set_cursor(widget->window, cursor); gdk_cursor_destroy(cursor); } void openvrml_player::GtkGLViewer::swap_buffers() { GtkWidget * const widget = GTK_WIDGET(this->drawing_area); GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); gdk_gl_drawable_swap_buffers(gl_drawable); } namespace { gint timeout_callback(const gpointer ptr) { assert(ptr); using openvrml_player::GtkGLViewer; GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(ptr); viewer.timer_update(); return false; } } void openvrml_player::GtkGLViewer::set_timer(const double t) { if (!this->timer) { this->timer = g_timeout_add(guint(10.0 * (t + 1)), GtkFunction(timeout_callback), this); } } void openvrml_player::GtkGLViewer::timer_update() { this->timer = 0; this->viewer::update(); } gboolean realize(GtkWidget *, GdkEvent *, gpointer) { return true; } gboolean expose_event(GtkWidget * const widget, GdkEventExpose * const event, const gpointer data) { using openvrml_player::GtkGLViewer; GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); g_assert(gl_drawable); GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); g_assert(gl_context); g_assert(data); GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(data); if (event->count == 0 && gdk_gl_drawable_make_current(gl_drawable, gl_context)) { viewer.redraw(); } viewer.redrawNeeded = false; return true; } gboolean configure_event(GtkWidget * const widget, GdkEventConfigure *, const gpointer data) { GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); g_assert(gl_drawable); GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); g_assert(gl_context); if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { g_assert(data); using openvrml_player::GtkGLViewer; GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(data); viewer.resize(widget->allocation.width, widget->allocation.height); } return true; } gboolean key_press_event(GtkWidget * const widget, GdkEventKey * const event, const gpointer data) { using openvrml::gl::viewer; viewer::event_info info; info.event = viewer::event_key_down; switch (event->keyval) { case XK_Home: info.what = viewer::key_home; break; case XK_Left: info.what = viewer::key_left; break; case XK_Up: info.what = viewer::key_up; break; case XK_Right: info.what = viewer::key_right; break; case XK_Down: info.what = viewer::key_down; break; case XK_Page_Up: info.what = viewer::key_page_up; break; case XK_Page_Down: info.what = viewer::key_page_down; break; default: if (event->length <= 0) { return true; } info.what = event->string[0]; } GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); g_assert(gl_drawable); GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); g_assert(gl_context); if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { g_assert(data); using openvrml_player::GtkGLViewer; GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(data); viewer.input(&info); } return true; } gboolean button_press_event(GtkWidget * const widget, GdkEventButton * const event, const gpointer data) { using openvrml::gl::viewer; viewer::event_info info; info.event = viewer::event_mouse_click; switch (event->button) { case Button1: info.what = 0; break; case Button2: info.what = 1; break; case Button3: info.what = 2; break; } info.x = int(event->x); info.y = int(event->y); GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); g_assert(gl_drawable); GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); g_assert(gl_context); if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { g_assert(data); using openvrml_player::GtkGLViewer; GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(data); viewer.input(&info); } return true; } gboolean button_release_event(GtkWidget * const widget, GdkEventButton * const event, const gpointer data) { using openvrml::gl::viewer; viewer::event_info info; info.event = viewer::event_mouse_release; switch (event->button) { case Button1: info.what = 0; break; case Button2: info.what = 1; break; case Button3: info.what = 2; break; } info.x = int(event->x); info.y = int(event->y); GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); g_assert(gl_drawable); GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); g_assert(gl_context); if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { g_assert(data); using openvrml_player::GtkGLViewer; GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(data); viewer.input(&info); } return true; } gboolean motion_notify_event(GtkWidget * const widget, GdkEventMotion * const event, const gpointer data) { using openvrml::gl::viewer; viewer::event_info info; info.event = viewer::event_mouse_drag; info.what = 0; if (event->state & Button1Mask) { info.what = 0; } else if (event->state & Button2Mask) { info.what = 1; } else if (event->state & Button3Mask) { info.what = 2; } else { info.event = viewer::event_mouse_move; } info.x = int(event->x); info.y = int(event->y); GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); g_assert(gl_drawable); GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); g_assert(gl_context); if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { g_assert(data); using openvrml_player::GtkGLViewer; GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(data); viewer.input(&info); } return true; } --- NEW FILE: browser.cpp --- // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*- // // OpenVRML Mozilla plug-in // Copyright 2004, 2005, 2006 Braden N. McDaniel // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // # include <iostream> # include <sstream> # include <glib.h> # include "browser.h" # include "plugin_streambuf.h" openvrml_player::browser::browser(GIOChannel * const request_channel): openvrml::browser(std::cout, std::cerr), request_channel_(request_channel) {} std::auto_ptr<openvrml::resource_istream> openvrml_player::browser::do_get_resource(const std::string & uri) { class plugin_resource_istream : public openvrml::resource_istream { boost::shared_ptr<plugin_streambuf> streambuf_; GIOChannel * request_channel_; public: explicit plugin_resource_istream(const std::string & uri, GIOChannel * const request_channel): openvrml::resource_istream(0), streambuf_(new plugin_streambuf(uri)), request_channel_(request_channel) { using std::ostringstream; this->rdbuf(this->streambuf_.get()); bool succeeded = uninitialized_plugin_streambuf_set_.insert(this->streambuf_); g_assert(succeeded); ostringstream request; request << "get-url " << uri << '\n'; gsize bytes_written; g_io_channel_write_chars(this->request_channel_, request.str().data(), request.str().length(), &bytes_written, 0); g_io_channel_flush(this->request_channel_, 0); } private: virtual const std::string do_url() const throw () { return this->streambuf_->url(); } virtual const std::string do_type() const throw () { return this->streambuf_->type(); } virtual bool do_data_available() const throw () { return this->streambuf_->data_available(); } }; return std::auto_ptr<openvrml::resource_istream>( new plugin_resource_istream(uri, this->request_channel_)); } --- NEW FILE: browser.h --- // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*- // // OpenVRML Mozilla plug-in // Copyright 2004, 2005, 2006 Braden N. McDaniel // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // # ifndef OPENVRML_PLAYER_BROWSER_H # define OPENVRML_PLAYER_BROWSER_H # include <glib.h> # include <openvrml/browser.h> namespace openvrml_player { class browser : public openvrml::browser { GIOChannel * request_channel_; public: explicit browser(GIOChannel * request_channel); private: virtual std::auto_ptr<openvrml::resource_istream> do_get_resource(const std::string & uri); }; } # endif // ifndef OPENVRML_PLAYER_BROWSER_H --- NEW FILE: command_istream.cpp --- // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*- // // OpenVRML Mozilla plug-in // Copyright 2004, 2005, 2006 Braden N. McDaniel // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // # include <cerrno> # include "command_istream.h" openvrml_player::command_streambuf::command_streambuf() { this->setg(&this->c_, &this->c_, &this->c_); } openvrml_player::command_streambuf::int_type openvrml_player::command_streambuf::underflow() { int_type c = this->source_buffer_.get(); if (c == traits_type::eof()) { return traits_type::eof(); } this->c_ = c; this->setg(&this->c_, &this->c_, &this->c_ + 1); return *this->gptr(); } openvrml_player::command_istream::command_istream(): std::istream(&this->buf_) {} gboolean command_data_available(GIOChannel * source, GIOCondition, gpointer data) { using namespace openvrml_player; command_streambuf & streambuf = *static_cast<command_streambuf *>(data); const int fd = g_io_channel_unix_get_fd(source); fd_set readfds; do { gchar c; gsize bytes_read; GError * error = 0; const GIOStatus status = g_io_channel_read_chars(source, &c, 1, &bytes_read, &error); if (status == G_IO_STATUS_ERROR) { if (error) { g_warning(error->message); g_error_free(error); } return false; } if (status == G_IO_STATUS_EOF) { return false; } if (status == G_IO_STATUS_AGAIN) { continue; } g_return_val_if_fail(status == G_IO_STATUS_NORMAL, false); g_assert(bytes_read == 1); streambuf.source_buffer_.put(c); FD_ZERO(&readfds); FD_SET(fd, &readfds); fd_set errorfds; FD_ZERO(&errorfds); FD_SET(fd, &errorfds); timeval timeout = { 0, 0 }; int bits_set = select(fd + 1, &readfds, 0, &errorfds, &timeout); if (FD_ISSET(fd, &errorfds) || bits_set < 0) { g_warning(strerror(errno)); g_return_val_if_reached(false); } } while (FD_ISSET(fd, &readfds)); return true; } Index: player.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/mozilla-plugin/src/openvrml-player/player.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** player.cpp 20 Dec 2005 08:37:44 -0000 1.15 --- player.cpp 9 Jan 2006 00:21:09 -0000 1.16 *************** *** 2,6 **** // // OpenVRML Mozilla plug-in ! // Copyright 2004 Braden N. McDaniel // // This program is free software; you can redistribute it and/or modify --- 2,6 ---- // // OpenVRML Mozilla plug-in ! // Copyright 2004, 2005, 2006 Braden N. McDaniel // // This program is free software; you can redistribute it and/or modify *************** *** 21,37 **** # include <cstdlib> # include <boost/lexical_cast.hpp> - # include <boost/spirit.hpp> - # include <boost/spirit/phoenix.hpp> - # include <boost/thread/condition.hpp> - # include <boost/thread/mutex.hpp> # include <boost/thread/thread.hpp> - # include <openvrml/browser.h> - # include <openvrml/gl/viewer.h> # include <unistd.h> ! # include <argp.h> ! # include <X11/keysym.h> # include <gdk/gdkx.h> ! # include <gtk/gtk.h> ! # include <gtk/gtkgl.h> namespace { --- 21,37 ---- # include <cstdlib> # include <boost/lexical_cast.hpp> # include <boost/thread/thread.hpp> # include <unistd.h> ! // Must include before X11 headers. ! # include <boost/numeric/conversion/converter.hpp> # include <gdk/gdkx.h> ! # include <argp.h> ! ! # include "browser.h" ! # include "gtkglviewer.h" ! # include "command_istream.h" ! # include "plugin_streambuf.h" ! ! using namespace openvrml_player; namespace { *************** *** 45,401 **** error_t parse_opt(int key, char * arg, argp_state * state); - - gboolean realize(GtkWidget * widget, GdkEvent * event, gpointer data); - gboolean expose_event(GtkWidget * widget, GdkEventExpose * event, - gpointer data); - gboolean configure_event(GtkWidget * widget, GdkEventConfigure * event, - gpointer data); - gboolean key_press_event(GtkWidget * widget, GdkEventKey * event, - gpointer data); - gboolean button_press_event(GtkWidget * widget, GdkEventButton * event, - gpointer data); - gboolean button_release_event(GtkWidget * widget, GdkEventButton * event, - gpointer data); - gboolean motion_notify_event(GtkWidget * widget, GdkEventMotion * event, - gpointer data); } ! namespace { ! ! enum option_id { ! gtk_socket_id_id = 128, ! read_fd_id, ! write_fd_id ! }; ! ! argp_option options[] = { ! { ! "gtk-socket-id", ! gtk_socket_id_id, ! "GTK_SOCKET_ID", ! 0, ! "GtkSocket id", ! 0 ! }, ! { ! "read-fd", ! read_fd_id, ! "READ_FD", ! 0, ! "file descriptor for reading commands", ! 0 ! }, ! { ! "write-fd", ! write_fd_id, ! "WRITE_FD", ! 0, ! "file descriptor for writing commands", ! 0 ! }, ! { 0, 0, 0, 0, 0, 0 } ! }; ! ! struct arguments { ! GdkNativeWindow socket_id; ! int read_fd; ! int write_fd; ! }; ! ! class GtkGLViewer : public openvrml::gl::viewer { ! static GdkGLConfig * gl_config; ! ! GtkWidget * drawing_area; ! guint timer; ! ! public: ! bool redrawNeeded; ! ! explicit GtkGLViewer(GtkContainer & container); ! virtual ~GtkGLViewer() throw (); ! ! void timer_update(); ! ! protected: ! // ! // Implement pure virtual methods from openvrml::gl::viewer. ! // ! virtual void post_redraw(); ! virtual void set_cursor(openvrml::gl::viewer::cursor_style); ! virtual void swap_buffers(); ! virtual void set_timer(double); ! }; ! ! ! template <typename T, size_t BufferSize> ! class bounded_buffer { ! mutable boost::mutex mutex_; ! boost::condition buffer_not_full_, buffer_not_empty_; ! ! T buf_[BufferSize]; ! size_t begin_, end_, buffered_; ! ! public: ! bounded_buffer(); ! void put(const T & c); ! const T get(); ! size_t buffered() const; ! }; ! ! template <typename T, size_t BufferSize> ! bounded_buffer<T, BufferSize>::bounded_buffer(): ! begin_(0), ! end_(0), ! buffered_(0) ! {} ! ! template <typename T, size_t BufferSize> ! void bounded_buffer<T, BufferSize>::put(const T & c) ! { ! boost::mutex::scoped_lock lock(this->mutex_); ! while (this->buffered_ == BufferSize) { ! this->buffer_not_full_.wait(lock); ! } ! this->buf_[this->end_] = c; ! this->end_ = (this->end_ + 1) % BufferSize; ! ++this->buffered_; ! this->buffer_not_empty_.notify_one(); ! } ! ! template <typename T, size_t BufferSize> ! const T bounded_buffer<T, BufferSize>::get() ! { ! boost::mutex::scoped_lock lock(this->mutex_); ! while (this->buffered_ == 0) { ! this->buffer_not_empty_.wait(lock); ! } ! T c = this->buf_[this->begin_]; ! this->begin_ = (this->begin_ + 1) % BufferSize; ! --this->buffered_; ! this->buffer_not_full_.notify_one(); ! return c; ! } ! ! template <typename T, size_t BufferSize> ! size_t bounded_buffer<T, BufferSize>::buffered() const ! { ! boost::mutex::scoped_lock lock(this->mutex_); ! return this->buffered_; ! } ! ! ! extern "C" gboolean command_data_available(GIOChannel * source, ! GIOCondition condition, ! gpointer data); ! ! class command_streambuf : boost::noncopyable, public std::streambuf { ! friend gboolean command_data_available(GIOChannel * source, ! GIOCondition condition, ! gpointer data); ! ! bounded_buffer<int_type, 64> source_buffer_; ! char_type c_; ! ! protected: ! virtual int_type underflow(); ! ! public: ! command_streambuf(); ! }; ! ! command_streambuf::command_streambuf() ! { ! this->setg(&this->c_, &this->c_, &this->c_); ! } ! ! command_streambuf::int_type command_streambuf::underflow() ! { ! int_type c = this->source_buffer_.get(); ! if (c == traits_type::eof()) { return traits_type::eof(); } ! this->c_ = c; ! this->setg(&this->c_, &this->c_, &this->c_ + 1); ! return *this->gptr(); ! } ! ! ! class command_istream : boost::noncopyable, public std::istream { ! command_streambuf buf_; ! ! public: ! command_istream(); ! }; ! ! command_istream::command_istream(): ! std::istream(&this->buf_) ! {} ! ! class plugin_streambuf : public std::streambuf { ! friend class command_istream_reader; ! ! mutable boost::mutex mutex_; ! bool initialized_; ! mutable boost::condition streambuf_initialized_; ! const std::string url_; ! std::string type_; ! bounded_buffer<int_type, 64> buf_; ! char_type c_; ! bool npstream_destroyed_; ! ! protected: ! virtual int_type underflow(); ! ! public: ! explicit plugin_streambuf(const std::string & url = ""); ! void init(const std::string & type); ! const std::string & url() const; ! const std::string & type() const; ! bool data_available() const; ! void npstream_destroyed(); ! }; ! ! plugin_streambuf::plugin_streambuf(const std::string & url): ! initialized_(false), ! url_(url), ! c_(traits_type::not_eof(this->c_)), ! npstream_destroyed_(false) ! { ! this->setg(&this->c_, &this->c_, &this->c_); ! } ! ! void plugin_streambuf::init(const std::string & type) ! { ! boost::mutex::scoped_lock lock(this->mutex_); ! this->type_ = type; ! this->initialized_ = true; ! this->streambuf_initialized_.notify_all(); ! } ! ! const std::string & plugin_streambuf::url() const ! { ! // ! // No need to lock or wait on init here; this->url_ is set in the ! // constructor and cannot be changed. ! // ! return this->url_; ! } ! ! const std::string & plugin_streambuf::type() const ! { ! boost::mutex::scoped_lock lock(this->mutex_); ! while (!this->initialized_) { ! this->streambuf_initialized_.wait(lock); ! } ! return this->type_; ! } ! ! bool plugin_streambuf::data_available() const ! { ! return this->buf_.buffered() > 0; ! } ! ! plugin_streambuf::int_type plugin_streambuf::underflow() ! { ! boost::mutex::scoped_lock lock(this->mutex_); ! while (!this->initialized_) { ! this->streambuf_initialized_.wait(lock); ! } ! if (this->c_ == traits_type::eof()) { return traits_type::eof(); } ! this->c_ = this->buf_.get(); ! this->setg(&this->c_, &this->c_, &this->c_ + 1); ! return *this->gptr(); ! } ! ! void plugin_streambuf::npstream_destroyed() ! { ! this->npstream_destroyed_ = true; ! } ! ! ! class browser : public openvrml::browser { ! public: ! browser(); ! ! private: ! virtual std::auto_ptr<openvrml::resource_istream> ! do_get_resource(const std::string & uri); ! }; ! ! class uninitialized_plugin_streambuf_set { ! mutable boost::mutex mutex_; ! typedef std::set<boost::shared_ptr<plugin_streambuf> > set_t; ! set_t set_; ! ! struct plugin_streambuf_has_url : ! std::unary_function<boost::shared_ptr<plugin_streambuf>, bool> { ! ! explicit plugin_streambuf_has_url(const std::string & url): ! url_(&url) ! {} ! ! bool ! operator()(const boost::shared_ptr<plugin_streambuf> & arg) const ! { ! return arg->url() == *this->url_; ! } ! ! private: ! const std::string * url_; ! }; ! ! public: ! const boost::shared_ptr<plugin_streambuf> ! find(const std::string & url) const; ! bool insert(const boost::shared_ptr<plugin_streambuf> & streambuf); ! bool erase(const boost::shared_ptr<plugin_streambuf> & streambuf); ! size_t size() const; ! const boost::shared_ptr<plugin_streambuf> front() const; ! } uninitialized_plugin_streambuf_set_; ! ! const boost::shared_ptr<plugin_streambuf> ! uninitialized_plugin_streambuf_set::find(const std::string & url) const ! { ! boost::mutex::scoped_lock lock(this->mutex_); ! set_t::const_iterator pos = find_if(this->set_.begin(), ! this->set_.end(), ! plugin_streambuf_has_url(url)); ! return pos == this->set_.end() ! ? boost::shared_ptr<plugin_streambuf>() ! : *pos; ! } ! ! bool ! uninitialized_plugin_streambuf_set:: ! insert(const boost::shared_ptr<plugin_streambuf> & streambuf) ! { ! boost::mutex::scoped_lock lock(this->mutex_); ! return this->set_.insert(streambuf).second; ! } ! ! bool ! uninitialized_plugin_streambuf_set:: ! erase(const boost::shared_ptr<plugin_streambuf> & streambuf) ! { ! boost::mutex::scoped_lock lock(this->mutex_); ! return this->set_.erase(streambuf) == 1; ! } ! ! size_t uninitialized_plugin_streambuf_set::size() const ! { ! boost::mutex::scoped_lock lock(this->mutex_); ! return this->set_.size(); ! } ! ! const boost::shared_ptr<plugin_streambuf> ! uninitialized_plugin_streambuf_set::front() const ! { ! boost::mutex::scoped_lock lock(this->mutex_); ! g_assert(!this->set_.empty()); ! return *this->set_.begin(); ! } ! ! typedef std::map<size_t, boost::shared_ptr<plugin_streambuf> > ! plugin_streambuf_map_t; ! ! plugin_streambuf_map_t plugin_streambuf_map; struct command_istream_reader { --- 45,51 ---- error_t parse_opt(int key, char * arg, argp_state * state); } ! namespace openvrml_player { struct command_istream_reader { *************** *** 449,453 **** g_assert(succeeded); succeeded = ! ::uninitialized_plugin_streambuf_set_.erase(streambuf); g_assert(succeeded); } else if (command == "destroy-stream") { --- 99,103 ---- g_assert(succeeded); succeeded = ! uninitialized_plugin_streambuf_set_.erase(streambuf); g_assert(succeeded); } else if (command == "destroy-stream") { *************** *** 483,487 **** --- 133,179 ---- openvrml::browser * browser_; }; + } + namespace { + + enum option_id { + gtk_socket_id_id = 128, + read_fd_id, + write_fd_id + }; + + argp_option options[] = { + { + "gtk-socket-id", + gtk_socket_id_id, + "GTK_SOCKET_ID", + 0, + "GtkSocket id", + 0 + }, + { + "read-fd", + read_fd_id, + "READ_FD", + 0, + "file descriptor for reading commands", + 0 + }, + { + "write-fd", + write_fd_id, + "WRITE_FD", + 0, + "file descriptor for writing commands", + 0 + }, + { 0, 0, 0, 0, 0, 0 } + }; + + struct arguments { + GdkNativeWindow socket_id; + int read_fd; + int write_fd; + }; struct initial_stream_reader { *************** *** 520,524 **** GIOChannel * command_channel; GIOChannel * request_channel; - int request_write_fd; } --- 212,215 ---- *************** *** 533,536 **** --- 224,229 ---- using boost::thread_group; + using namespace openvrml_player; + g_set_application_name(application_name); *************** *** 575,579 **** return EXIT_FAILURE; } ! g_io_add_watch(::command_channel, G_IO_IN, --- 268,272 ---- return EXIT_FAILURE; } ! g_io_add_watch(::command_channel, G_IO_IN, *************** *** 583,587 **** if (arguments.write_fd) { - ::request_write_fd = arguments.write_fd; ::request_channel = g_io_channel_unix_new(arguments.write_fd); } --- 276,279 ---- *************** *** 592,596 **** GtkGLViewer viewer(*(GTK_CONTAINER(window))); ! browser b; b.viewer(&viewer); --- 284,288 ---- GtkGLViewer viewer(*(GTK_CONTAINER(window))); ! browser b(::request_channel); b.viewer(&viewer); *************** *** 658,1111 **** return 0; } - - namespace { - - GdkGLConfig * GtkGLViewer::gl_config(0); - - GtkGLViewer::GtkGLViewer(GtkContainer & container): - drawing_area(gtk_drawing_area_new()), - timer(0), - redrawNeeded(false) - { - if (!this->drawing_area) { throw std::bad_alloc(); } - - if (!GtkGLViewer::gl_config) { - static const int attrib_list[] = { - // GDK_GL_ALPHA_SIZE, 1, - GDK_GL_DOUBLEBUFFER, - GDK_GL_DEPTH_SIZE, 1, - GDK_GL_RGBA, - GDK_GL_RED_SIZE, 1, - GDK_GL_ATTRIB_LIST_NONE - }; - GtkGLViewer::gl_config = gdk_gl_config_new(attrib_list); - } - - static GdkGLContext * const share_list = 0; - static const gboolean direct = false; - static const int render_type = GDK_GL_RGBA_TYPE; - gtk_widget_set_gl_capability(this->drawing_area, - GtkGLViewer::gl_config, - share_list, - direct, - render_type); - - gtk_widget_add_events(this->drawing_area, - GDK_EXPOSURE_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_KEY_PRESS_MASK - | GDK_POINTER_MOTION_MASK); - - g_signal_connect(G_OBJECT((this->drawing_area)), - "expose_event", - G_CALLBACK(expose_event), - this); - g_signal_connect(G_OBJECT(this->drawing_area), - "configure_event", - G_CALLBACK(configure_event), - this); - g_signal_connect(G_OBJECT(this->drawing_area), - "key_press_event", - G_CALLBACK(key_press_event), - this); - g_signal_connect(G_OBJECT(this->drawing_area), - "button_press_event", - G_CALLBACK(button_press_event), - this); - g_signal_connect(G_OBJECT(this->drawing_area), - "button_release_event", - G_CALLBACK(button_release_event), - this); - g_signal_connect(G_OBJECT(this->drawing_area), - "motion_notify_event", - G_CALLBACK(motion_notify_event), - this); - - gtk_container_add(&container, this->drawing_area); - - - } - - GtkGLViewer::~GtkGLViewer() throw () - { - if (this->timer) { g_source_remove(timer); } - } - - void GtkGLViewer::post_redraw() - { - if (!this->redrawNeeded) { - this->redrawNeeded = true; - gtk_widget_queue_draw(GTK_WIDGET(this->drawing_area)); - } - } - - void GtkGLViewer::set_cursor(cursor_style style) - { - GdkCursor * cursor(0); - GtkWidget * const widget = GTK_WIDGET(this->drawing_area); - - switch(style) { - case cursor_inherit: - XDefineCursor(GDK_WINDOW_XDISPLAY(widget->window), - GDK_WINDOW_XWINDOW(widget->window), - None); - return; - - case cursor_info: - cursor = gdk_cursor_new(GDK_HAND1); - break; - - case cursor_cycle: - cursor = gdk_cursor_new(GDK_EXCHANGE); - break; - - case cursor_up_down: - cursor = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW); - break; - - case cursor_crosshair: - cursor = gdk_cursor_new(GDK_CROSSHAIR); - break; - - default: - cursor = gdk_cursor_new(GDK_ARROW); - } - - gdk_window_set_cursor(widget->window, cursor); - gdk_cursor_destroy(cursor); - } - - void GtkGLViewer::swap_buffers() - { - GtkWidget * const widget = GTK_WIDGET(this->drawing_area); - GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); - gdk_gl_drawable_swap_buffers(gl_drawable); - } - - gint timeout_callback(const gpointer ptr) - { - assert(ptr); - GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(ptr); - viewer.timer_update(); - return false; - } - - void GtkGLViewer::set_timer(const double t) - { - if (!this->timer) { - this->timer = g_timeout_add(guint(10.0 * (t + 1)), - GtkFunction(timeout_callback), - this); - } - } - - void GtkGLViewer::timer_update() - { - this->timer = 0; - this->viewer::update(); - } - - browser::browser(): - openvrml::browser(std::cout, std::cerr) - {} - - std::auto_ptr<openvrml::resource_istream> - browser::do_get_resource(const std::string & uri) - { - class plugin_resource_istream : public openvrml::resource_istream { - boost::shared_ptr<plugin_streambuf> streambuf_; - - public: - explicit plugin_resource_istream(const std::string & uri): - openvrml::resource_istream(0), - streambuf_(new plugin_streambuf(uri)) - { - using std::ostringstream; - - this->rdbuf(this->streambuf_.get()); - bool succeeded = - ::uninitialized_plugin_streambuf_set_ - .insert(this->streambuf_); - g_assert(succeeded); - - ostringstream request; - request << "get-url " << uri << '\n'; - gsize bytes_written; - g_io_channel_write_chars(::request_channel, - request.str().data(), - request.str().length(), - &bytes_written, - 0); - g_io_channel_flush(::request_channel, 0); - } - - private: - virtual const std::string do_url() const throw () - { - return this->streambuf_->url(); - } - - virtual const std::string do_type() const throw () - { - return this->streambuf_->type(); - } - - virtual bool do_data_available() const throw () - { - return this->streambuf_->data_available(); - } - }; - return std::auto_ptr<openvrml::resource_istream>( - new plugin_resource_istream(uri)); - } - - gboolean command_data_available(GIOChannel * source, - GIOCondition, - gpointer data) - { - command_streambuf & streambuf = - *static_cast<command_streambuf *>(data); - - const int fd = g_io_channel_unix_get_fd(source); - fd_set readfds; - do { - gchar c; - gsize bytes_read; - GError * error = 0; - const GIOStatus status = - g_io_channel_read_chars(source, &c, 1, &bytes_read, &error); - if (status == G_IO_STATUS_ERROR) { - if (error) { - g_warning(error->message); - g_error_free(error); - } - return false; - } - if (status == G_IO_STATUS_EOF) { return false; } - if (status == G_IO_STATUS_AGAIN) { continue; } - g_return_val_if_fail(status == G_IO_STATUS_NORMAL, false); - - g_assert(bytes_read == 1); - - streambuf.source_buffer_.put(c); - - FD_ZERO(&readfds); - FD_SET(fd, &readfds); - - fd_set errorfds; - FD_ZERO(&errorfds); - FD_SET(fd, &errorfds); - - timeval timeout = { 0, 0 }; - int bits_set = select(fd + 1, &readfds, 0, &errorfds, &timeout); - if (FD_ISSET(fd, &errorfds) || bits_set < 0) { - g_warning(strerror(errno)); - g_return_val_if_reached(false); - } - } while (FD_ISSET(fd, &readfds)); - - return true; - } - } // namespace - - - gboolean realize(GtkWidget *, GdkEvent *, gpointer) - { - return true; - } - - gboolean expose_event(GtkWidget * const widget, - GdkEventExpose * const event, - const gpointer data) - { - GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); - g_assert(gl_drawable); - GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); - g_assert(gl_context); - g_assert(data); - GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(data); - if (event->count == 0 - && gdk_gl_drawable_make_current(gl_drawable, gl_context)) { - viewer.redraw(); - } - viewer.redrawNeeded = false; - return true; - } - - gboolean configure_event(GtkWidget * const widget, - GdkEventConfigure *, - const gpointer data) - { - GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); - g_assert(gl_drawable); - GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); - g_assert(gl_context); - if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { - g_assert(data); - GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(data); - viewer.resize(widget->allocation.width, widget->allocation.height); - } - return true; - } - - gboolean key_press_event(GtkWidget * const widget, - GdkEventKey * const event, - const gpointer data) - { - using openvrml::gl::viewer; - - viewer::event_info info; - info.event = viewer::event_key_down; - - switch (event->keyval) { - case XK_Home: - info.what = viewer::key_home; - break; - - case XK_Left: - info.what = viewer::key_left; - break; - - case XK_Up: - info.what = viewer::key_up; - break; - - case XK_Right: - info.what = viewer::key_right; - break; - - case XK_Down: - info.what = viewer::key_down; - break; - - case XK_Page_Up: - info.what = viewer::key_page_up; - break; - - case XK_Page_Down: - info.what = viewer::key_page_down; - break; - - default: - if (event->length <= 0) { return true; } - info.what = event->string[0]; - } - GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); - g_assert(gl_drawable); - GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); - g_assert(gl_context); - if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { - g_assert(data); - GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(data); - viewer.input(&info); - } - return true; - } - - gboolean button_press_event(GtkWidget * const widget, - GdkEventButton * const event, - const gpointer data) - { - using openvrml::gl::viewer; - - viewer::event_info info; - info.event = viewer::event_mouse_click; - - switch (event->button) { - case Button1: - info.what = 0; - break; - - case Button2: - info.what = 1; - break; - - case Button3: - info.what = 2; - break; - } - - info.x = int(event->x); - info.y = int(event->y); - GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); - g_assert(gl_drawable); - GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); - g_assert(gl_context); - if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { - g_assert(data); - GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(data); - viewer.input(&info); - } - return true; - } - - gboolean button_release_event(GtkWidget * const widget, - GdkEventButton * const event, - const gpointer data) - { - using openvrml::gl::viewer; - - viewer::event_info info; - info.event = viewer::event_mouse_release; - - switch (event->button) { - case Button1: - info.what = 0; - break; - - case Button2: - info.what = 1; - break; - - case Button3: - info.what = 2; - break; - } - - info.x = int(event->x); - info.y = int(event->y); - GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); - g_assert(gl_drawable); - GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); - g_assert(gl_context); - if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { - g_assert(data); - GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(data); - viewer.input(&info); - } - return true; - } - - gboolean motion_notify_event(GtkWidget * const widget, - GdkEventMotion * const event, - const gpointer data) - { - using openvrml::gl::viewer; - - viewer::event_info info; - info.event = viewer::event_mouse_drag; - info.what = 0; - if (event->state & Button1Mask) { - info.what = 0; - } else if (event->state & Button2Mask) { - info.what = 1; - } else if (event->state & Button3Mask) { - info.what = 2; - } else { - info.event = viewer::event_mouse_move; - } - - info.x = int(event->x); - info.y = int(event->y); - GdkGLDrawable * const gl_drawable = gtk_widget_get_gl_drawable(widget); - g_assert(gl_drawable); - GdkGLContext * const gl_context = gtk_widget_get_gl_context(widget); - g_assert(gl_context); - if (gdk_gl_drawable_make_current(gl_drawable, gl_context)) { - g_assert(data); - GtkGLViewer & viewer = *static_cast<GtkGLViewer *>(data); - viewer.input(&info); - } - return true; - } --- 350,351 ---- --- NEW FILE: plugin_streambuf.cpp --- // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*- // // OpenVRML Mozilla plug-in // Copyright 2004, 2005, 2006 Braden N. McDaniel // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // # include <glib.h> # include "plugin_streambuf.h" openvrml_player::plugin_streambuf::plugin_streambuf(const std::string & url): initialized_(false), url_(url), c_(traits_type::not_eof(this->c_)), npstream_destroyed_(false) { this->setg(&this->c_, &this->c_, &this->c_); } void openvrml_player::plugin_streambuf::init(const std::string & type) { boost::mutex::scoped_lock lock(this->mutex_); this->type_ = type; this->initialized_ = true; this->streambuf_initialized_.notify_all(); } const std::string & openvrml_player::plugin_streambuf::url() const { // // No need to lock or wait on init here; this->url_ is set in the // constructor and cannot be changed. // return this->url_; } const std::string & openvrml_player::plugin_streambuf::type() const { boost::mutex::scoped_lock lock(this->mutex_); while (!this->initialized_) { this->streambuf_initialized_.wait(lock); } return this->type_; } bool openvrml_player::plugin_streambuf::data_available() const { return this->buf_.buffered() > 0; } openvrml_player::plugin_streambuf::int_type openvrml_player::plugin_streambuf::underflow() { boost::mutex::scoped_lock lock(this->mutex_); while (!this->initialized_) { this->streambuf_initialized_.wait(lock); } if (this->c_ == traits_type::eof()) { return traits_type::eof(); } this->c_ = this->buf_.get(); this->setg(&this->c_, &this->c_, &this->c_ + 1); return *this->gptr(); } void openvrml_player::plugin_streambuf::npstream_destroyed() { this->npstream_destroyed_ = true; } openvrml_player::uninitialized_plugin_streambuf_set openvrml_player::uninitialized_plugin_streambuf_set_; const boost::shared_ptr<openvrml_player::plugin_streambuf> openvrml_player::uninitialized_plugin_streambuf_set:: find(const std::string & url) const { boost::mutex::scoped_lock lock(this->mutex_); set_t::const_iterator pos = find_if(this->set_.begin(), this->set_.end(), plugin_streambuf_has_url(url)); return pos == this->set_.end() ? boost::shared_ptr<plugin_streambuf>() : *pos; } bool openvrml_player::uninitialized_plugin_streambuf_set:: insert(const boost::shared_ptr<openvrml_player::plugin_streambuf> & streambuf) { boost::mutex::scoped_lock lock(this->mutex_); return this->set_.insert(streambuf).second; } bool openvrml_player::uninitialized_plugin_streambuf_set:: erase(const boost::shared_ptr<openvrml_player::plugin_streambuf> & streambuf) { boost::mutex::scoped_lock lock(this->mutex_); return this->set_.erase(streambuf) == 1; } size_t openvrml_player::uninitialized_plugin_streambuf_set::size() const { boost::mutex::scoped_lock lock(this... [truncated message content] |
From: Braden M. <br...@us...> - 2006-01-09 00:21:18
|
Update of /cvsroot/openvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8218 Modified Files: ChangeLog Log Message: Factored code in mozilla-plugin/src/openvrml-player/player.cpp into multiple files. Index: ChangeLog =================================================================== RCS file: /cvsroot/openvrml/openvrml/ChangeLog,v retrieving revision 1.1106 retrieving revision 1.1107 diff -C2 -d -r1.1106 -r1.1107 *** ChangeLog 7 Jan 2006 23:37:00 -0000 1.1106 --- ChangeLog 9 Jan 2006 00:21:06 -0000 1.1107 *************** *** 1,2 **** --- 1,100 ---- + 2006-01-08 Braden McDaniel <br...@en...> + + Factored code in mozilla-plugin/src/openvrml-player/player.cpp + into multiple files. + + * mozilla-plugin/src/openvrml-player/Makefile.am + (noinst_HEADERS): Added bounded_buffer.h, command_istream.h, + plugin_streambuf.h, browser.h, and gtkglviewer.h. + (openvrml_player_SOURCES): Added command_istream.cpp, + plugin_streambuf.cpp, browser.cpp, and gtkglviewer.cpp. + * mozilla-plugin/src/openvrml-player/bounded_buffer.h + (openvrml_player::bounded_buffer<T, BufferSize>): Moved from + player.cpp. + * mozilla-plugin/src/openvrml-player/browser.cpp + (openvrml_player::browser::browser(GIOChannel *)): Moved from + player.cpp. + (openvrml_player::browser::do_get_resource(const std::string &)): + Moved from player.cpp. + * mozilla-plugin/src/openvrml-player/browser.h + (openvrml_player::browser): Moved from player.cpp. + * mozilla-plugin/src/openvrml-player/command_istream.cpp + (openvrml_player::command_streambuf::command_streambuf()): Moved + from player.cpp. + (openvrml_player::command_streambuf::underflow()): Moved from + player.cpp. + (openvrml_player::command_istream::command_istream()): Moved from + player.cpp. + (command_data_available): Moved from player.cpp. + * mozilla-plugin/src/openvrml-player/command_istream.h + (openvrml_player::command_streambuf): Moved from player.cpp. + (openvrml_player::command_istream): Moved from player.cpp. + * mozilla-plugin/src/openvrml-player/gtkglviewer.cpp + (openvrml_player::GtkGLViewer::gl_config): Moved from player.cpp. + (openvrml_player::GtkGLViewer::GtkGLViewer(GtkContainer &)): Moved + from player.cpp. + (openvrml_player::GtkGLViewer::~GtkGLViewer()): Moved from + player.cpp. + (openvrml_player::GtkGLViewer::post_redraw()): Moved from + player.cpp. + (openvrml_player::GtkGLViewer::set_cursor(cursor_style)): Moved + from player.cpp. + (openvrml_player::GtkGLViewer::swap_buffers()): Moved from + player.cpp. + (timeout_callback): Moved from player.cpp. + (openvrml_player::GtkGLViewer::set_timer(double)): Moved from + player.cpp. + (openvrml_player::GtkGLViewer::timer_update()): Moved from + player.cpp. + (realize): Moved from player.cpp. + (expose_event): Moved from player.cpp. + (configure_event): Moved from player.cpp. + (key_press_event): Moved from player.cpp. + (button_press_event): Moved from player.cpp. + (button_release_event): Moved from player.cpp. + (motion_notify_event): Moved from player.cpp. + * mozilla-plugin/src/openvrml-player/gtkglviewer.h + (openvrml_player::GtkGLViewer): Moved from player.cpp. + * mozilla-plugin/src/openvrml-player/player.cpp + (bounded_buffer<T, BufferSize>): Moved to bounded_buffer.h. + (command_streambuf): Moved to command_istream.h. + (command_istream): Moved to command_istream.h. + (plugin_streambuf): Moved to plugin_streambuf.h. + (browser): Moved to browser.h. + (uninitialized_plugin_streambuf_set): Moved to plugin_streambuf.h. + (uninitialized_plugin_streambuf_set_): Moved to plugin_streambuf.cpp. + (plugin_streambuf_map_t): Moved to plugin_streambuf.h. + (plugin_streambuf_map): Moved to plugin_streambuf.cpp. + * mozilla-plugin/src/openvrml-player/plugin_streambuf.cpp + (openvrml_player::plugin_streambuf::plugin_streambuf(const + std::string &)): Moved from player.cpp. + (openvrml_player::plugin_streambuf::init(const std::string &)): + Moved from player.cpp. + (openvrml_player::plugin_streambuf::url() const): Moved from + player.cpp. + (openvrml_player::plugin_streambuf::type() const): Moved from + player.cpp. + (openvrml_player::plugin_streambuf::data_available() const): Moved + from player.cpp. + (openvrml_player::plugin_streambuf::underflow()): Moved from + player.cpp. + (openvrml_player::plugin_streambuf::npstream_destroyed()): Moved + from player.cpp. + (openvrml_player::uninitialized_plugin_streambuf_set_): Moved from + player.cpp. + (openvrml_player::uninitialized_plugin_streambuf_set::find(const + std::string &) const): Moved from player.cpp. + (openvrml_player::uninitialized_plugin_streambuf_set::insert(const + boost::shared_ptr<openvrml_player::plugin_streambuf> &)): Moved + from player.cpp. + (openvrml_player::uninitialized_plugin_streambuf_set::erase(const + boost::shared_ptr<openvrml_player::plugin_streambuf> &)): Moved + from player.cpp. + (openvrml_player::uninitialized_plugin_streambuf_set::size() + const): Moved from player.cpp. + (openvrml_player::uninitialized_plugin_streambuf_set::front() + const): Moved from player.cpp. + (openvrml_player::plugin_streambuf_map): Moved from player.cpp. + 2006-01-07 Braden McDaniel <br...@en...> |
From: Braden M. <br...@us...> - 2006-01-07 23:37:11
|
Update of /cvsroot/openvrml/openvrml/examples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11458/examples Modified Files: sdl_viewer.cpp Log Message: Fixed file_resource_istream constructor to set failbit if opening the file fails. Index: sdl_viewer.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/examples/sdl_viewer.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** sdl_viewer.cpp 7 Jan 2006 10:20:18 -0000 1.8 --- sdl_viewer.cpp 7 Jan 2006 23:37:01 -0000 1.9 *************** *** 134,138 **** resource_istream(&this->buf_) { ! this->buf_.open(path.c_str(), ios_base::in); } --- 134,140 ---- resource_istream(&this->buf_) { ! if (!this->buf_.open(path.c_str(), ios_base::in)) { ! this->setstate(ios_base::failbit); ! } } |
From: Braden M. <br...@us...> - 2006-01-07 23:37:11
|
Update of /cvsroot/openvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11458 Modified Files: ChangeLog Log Message: Fixed file_resource_istream constructor to set failbit if opening the file fails. Index: ChangeLog =================================================================== RCS file: /cvsroot/openvrml/openvrml/ChangeLog,v retrieving revision 1.1105 retrieving revision 1.1106 diff -C2 -d -r1.1105 -r1.1106 *** ChangeLog 7 Jan 2006 10:20:18 -0000 1.1105 --- ChangeLog 7 Jan 2006 23:37:00 -0000 1.1106 *************** *** 3,6 **** --- 3,13 ---- * examples/sdl_viewer.cpp (browser::do_get_resource(const std::string &)): Fixed + file_resource_istream constructor to set failbit if opening the + file fails. + + 2006-01-07 Braden McDaniel <br...@en...> + + * examples/sdl_viewer.cpp + (browser::do_get_resource(const std::string &)): Fixed file_resource_istream::do_type() to sort of handle fragment identifiers in the URI. |
From: Braden M. <br...@us...> - 2006-01-07 10:20:29
|
Update of /cvsroot/openvrml/openvrml/examples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2197/examples Modified Files: sdl_viewer.cpp Log Message: Fixed file_resource_istream::do_type() to sort of handle fragment identifiers in the URI. Index: sdl_viewer.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/examples/sdl_viewer.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** sdl_viewer.cpp 20 Dec 2005 08:37:43 -0000 1.7 --- sdl_viewer.cpp 7 Jan 2006 10:20:18 -0000 1.8 *************** *** 27,30 **** --- 27,31 ---- # include <fstream> # include <boost/algorithm/string/predicate.hpp> + # include <boost/utility.hpp> # include <SDL.h> # include <openvrml/browser.h> *************** *** 154,166 **** // order to remain simple and portable. // using std::string; using boost::algorithm::iequals; string media_type = "application/octet-stream"; ! const string::size_type dot_pos = this->url_.rfind('.'); ! if (dot_pos == string::npos ! || this->url_.size() < dot_pos + 1) { return media_type; } ! const string ext = this->url_.substr(dot_pos + 1); if (iequals(ext, "wrl")) { media_type = "model/vrml"; --- 155,172 ---- // order to remain simple and portable. // + using std::find; using std::string; using boost::algorithm::iequals; + using boost::next; string media_type = "application/octet-stream"; ! const string::const_reverse_iterator dot_pos = ! find(this->url_.rbegin(), this->url_.rend(), '.'); ! if (dot_pos == this->url_.rend() ! || next(dot_pos.base()) == this->url_.end()) { return media_type; } ! const string::const_iterator hash_pos = ! find(next(dot_pos.base()), this->url_.end(), '#'); ! const string ext(dot_pos.base(), hash_pos); if (iequals(ext, "wrl")) { media_type = "model/vrml"; |
From: Braden M. <br...@us...> - 2006-01-07 10:20:29
|
Update of /cvsroot/openvrml/openvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2197 Modified Files: ChangeLog Log Message: Fixed file_resource_istream::do_type() to sort of handle fragment identifiers in the URI. Index: ChangeLog =================================================================== RCS file: /cvsroot/openvrml/openvrml/ChangeLog,v retrieving revision 1.1104 retrieving revision 1.1105 diff -C2 -d -r1.1104 -r1.1105 *** ChangeLog 2 Jan 2006 04:26:13 -0000 1.1104 --- ChangeLog 7 Jan 2006 10:20:18 -0000 1.1105 *************** *** 1,2 **** --- 1,9 ---- + 2006-01-07 Braden McDaniel <br...@en...> + + * examples/sdl_viewer.cpp + (browser::do_get_resource(const std::string &)): Fixed + file_resource_istream::do_type() to sort of handle fragment + identifiers in the URI. + 2006-01-01 Braden McDaniel <br...@en...> |