gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, master, updated. 79dc4984cab2b8cfcf66


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. 79dc4984cab2b8cfcf66ecb9022274e9b8c5591b
Date: Wed, 10 Nov 2010 08:49:29 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  79dc4984cab2b8cfcf66ecb9022274e9b8c5591b (commit)
       via  ffddd2065bf73600f38457e37dbbf0597a0f3712 (commit)
       via  144617950afba20518ae505960df80884fe41494 (commit)
       via  280f41ba7aec593fc969a6f87097daca32f047a3 (commit)
       via  5351e5927dae49545c21bfee3a8ac3022f8df018 (commit)
       via  338fcfc318fb0972a1ac215dc199ec694866c8f1 (commit)
       via  dfb05248c357ce6ff706a7eae1d6673f31cd2aad (commit)
       via  63c98bce73af9bf7e0cb996d6fd05a470c66ec1c (commit)
       via  52fdda1f191d9ae396a86af41debd0edee0f20aa (commit)
       via  34a24bfb215dc8b789d3d1569246883580acbe72 (commit)
       via  b83bf13ef8e568ba58df835195b007cc5a22575a (commit)
       via  f171d48c2ad325608204f8743635da2218f0544a (commit)
       via  76495914a880896fdecfc39fc5b9d9e55a184942 (commit)
       via  8f8c89d108d062feb7a4dcd269ce4a87491945d9 (commit)
       via  7e60ef9ae0fa30aafcfa7669a3a655ae8178cab3 (commit)
       via  696fd4ebb8885c052cf2a767afef0a5a258640ed (commit)
      from  958f3eb30a970734104a8b47c5a233afe4381993 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=79dc4984cab2b8cfcf66ecb9022274e9b8c5591b


commit 79dc4984cab2b8cfcf66ecb9022274e9b8c5591b
Merge: ffddd20 958f3eb
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Nov 10 09:49:16 2010 +0100

    Merge branch 'master' of git.sv.gnu.org:/srv/git/gnash


http://git.savannah.gnu.org/cgit//commit/?id=ffddd2065bf73600f38457e37dbbf0597a0f3712


commit ffddd2065bf73600f38457e37dbbf0597a0f3712
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Nov 10 08:12:47 2010 +0100

    Reorganize usage functions, drop silly name() return.

diff --git a/gui/gnash.cpp b/gui/gnash.cpp
index 88840c5..b662ff8 100644
--- a/gui/gnash.cpp
+++ b/gui/gnash.cpp
@@ -47,7 +47,6 @@
 #include "revno.h"
 #include "MediaHandler.h"
 
-using std::cerr;
 using std::endl;
 using std::cout;
 
@@ -67,9 +66,15 @@ namespace {
 namespace {
     namespace po = boost::program_options;
     po::options_description getSupportedOptions(gnash::Player& p);
+
     void setupSoundAndRendering(gnash::Player& p, int i);
     void setupFlashVars(gnash::Player& p, const std::string& param);
     void setupFDs(gnash::Player& p, const std::string& fds);
+
+    void usage_gui_keys(std::ostream& os);
+    void usage(std::ostream& os, const po::options_description& opts);
+    void build_options(std::ostream& os);
+    void version_and_copyright(std::ostream& os);
 }
 
 namespace {
@@ -103,7 +108,7 @@ public:
     }
 
     virtual std::string name() const {
-        return "moo";
+        return std::string();
     }
 
     /// There are no tokens for an accumulator_type
@@ -150,73 +155,6 @@ accumulator_type<T>* accumulator() {
 
 }
 
-static void
-usage_gui_keys(std::ostream& os)
-{
-    os
-    << _("Keys:") << std::endl
-    << std::endl
-    << "  CTRL-Q, CTRL-W           "
-    << _("Quit")
-    << std::endl
-    << "  CTRL-F                   "
-    << _("Toggle fullscreen")
-    << std::endl 
-    << "  CTRL-P                   "
-    << _("Toggle pause") 
-    << std::endl 
-    << "  CTRL-R                   "
-    << _("Restart the movie") 
-    << std::endl 
-    << "  CTRL-O                   "
-    << _("Take a screenshot") 
-    << std::endl 
-    << "  CTRL-L                   "
-    << _("Force immediate redraw") 
-    << std::endl;
-}
-
-static void
-usage(const po::options_description& opts)
-{
-    std::cout << _("Usage: gnash [options] movie_file.swf\n")
-              << _("Plays a SWF (Shockwave Flash) movie\n")
-              << opts << "\n";
-
-    // Add gui keys
-    // TODO: stop printing these in here ?
-    usage_gui_keys(std::cout);
-
-    std::cout << std::endl;
-}
-
-static void
-version_and_copyright()
-{
-    cout << "Gnash " << VERSION << endl
-        << endl
-        << _("Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 "
-                "Free Software Foundation, Inc.\n"
-                "Gnash comes with NO WARRANTY, to the extent permitted "
-                "by law.\nYou may redistribute copies of Gnash under the "
-                "terms of the GNU General\nPublic License.  For more "
-                "information, see the file named COPYING.\n") << endl;
-}
-
-static void
-build_options()
-{
-    cout << _("Build options ") << VERSION << endl
-        << _("   Renderers: ") << RENDERER_CONFIG << endl
-        << _("   Hardware Acceleration: ") << HWACCEL_CONFIG << endl
-        << _("   GUI: ") << GUI_CONFIG << endl
-        << _("   Media handlers: ") << MEDIA_CONFIG << endl
-        
-        << _("   Configured with: ") << CONFIG_CONFIG << endl
-        << _("   CXXFLAGS: ") << CXXFLAGS << endl
-        << _("   Version: ")  << BRANCH_NICK << ":" << BRANCH_REVNO << endl;
-}
-
 int
 main(int argc, char *argv[])
 {
@@ -257,14 +195,14 @@ main(int argc, char *argv[])
     po::notify(vm);
 
     if (vm.count("help")) {
-        version_and_copyright();
-        usage(opts);
+        version_and_copyright(std::cout);
+        usage(std::cout, opts);
         return EXIT_SUCCESS;
     }
 
     if (vm.count("version")) {
-        version_and_copyright();
-        build_options();
+        version_and_copyright(std::cout);
+        build_options(std::cout);
         return EXIT_SUCCESS;
     }
 
@@ -291,7 +229,7 @@ main(int argc, char *argv[])
     // No file name was supplied
     if (infiles.empty()) {
         std::cerr << _("Error: no input file was specified. Exiting.\n");
-        usage(opts);
+        usage(std::cerr, opts);
         return EXIT_FAILURE;
     }
 
@@ -548,11 +486,70 @@ getSupportedOptions(gnash::Player& p)
         _("Quality for screenshot output (not all formats)"))
 
     ("input-file", po::value<std::vector<std::string> >(&infiles),
-        _("Filename pattern for screenshot images"))
+        _("Input files"))
     ;
 
     return desc;
 }
 
+void
+usage_gui_keys(std::ostream& os)
+{
+    os << _("Keys:\n")
+       << "  CTRL-Q, CTRL-W           "
+       << _("Quit\n")
+       << "  CTRL-F                   "
+       << _("Toggle fullscreen\n")
+       << "  CTRL-P                   "
+       << _("Toggle pause\n") 
+       << "  CTRL-R                   "
+       << _("Restart the movie\n") 
+       << "  CTRL-O                   "
+       << _("Take a screenshot\n") 
+       << "  CTRL-L                   "
+       << _("Force immediate redraw\n");
+}
+
+void
+usage(std::ostream& os, const po::options_description& opts)
+{
+    os << _("Usage: gnash [options] movie_file.swf\n")
+       << _("Plays a SWF (Shockwave Flash) movie\n")
+       << opts << "\n";
+
+    // Add gui keys
+    // TODO: stop printing these in here ?
+    usage_gui_keys(os);
+
+    os << std::endl;
+}
+
+void
+version_and_copyright(std::ostream& os)
+{
+    os << "Gnash " << VERSION << "\n\n"
+       << _("Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 "
+            "Free Software Foundation, Inc.\n"
+            "Gnash comes with NO WARRANTY, to the extent permitted "
+            "by law.\nYou may redistribute copies of Gnash under the "
+            "terms of the GNU General\nPublic License.  For more "
+            "information, see the file named COPYING.\n\n");
+}
+
+void
+build_options(std::ostream& os)
+{
+    os << _("Build options ") << VERSION << "\n"
+          << _("   Renderers: ") << RENDERER_CONFIG << "\n"
+          << _("   Hardware Acceleration: ") << HWACCEL_CONFIG << "\n"
+          << _("   GUI: ") << GUI_CONFIG << "\n"
+          << _("   Media handlers: ") << MEDIA_CONFIG << "\n"
+        
+          << _("   Configured with: ") << CONFIG_CONFIG << "\n"
+          << _("   CXXFLAGS: ") << CXXFLAGS << "\n"
+          << _("   Version: ")  << BRANCH_NICK << ":" << BRANCH_REVNO << "\n";
+}
+
+
 } // unnamed namespace
 

http://git.savannah.gnu.org/cgit//commit/?id=144617950afba20518ae505960df80884fe41494


commit 144617950afba20518ae505960df80884fe41494
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Nov 10 07:56:51 2010 +0100

    Fix FPS debugging.

diff --git a/gui/gnash.cpp b/gui/gnash.cpp
index 0ac208e..88840c5 100644
--- a/gui/gnash.cpp
+++ b/gui/gnash.cpp
@@ -516,7 +516,7 @@ getSupportedOptions(gnash::Player& p)
         ).c_str())
 
 #ifdef GNASH_FPS_DEBUG
-    ("debug-fps,f", po::value<float>(),
+    ("debug-fps,f", po::value<float>()
         ->notifier(boost::bind(&Player::setFpsPrintTime, &p, _1),
         _("Print FPS every num seconds"))
 #endif 

http://git.savannah.gnu.org/cgit//commit/?id=280f41ba7aec593fc969a6f87097daca32f047a3


commit 280f41ba7aec593fc969a6f87097daca32f047a3
Merge: 5351e59 34a24bf
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Nov 9 18:11:07 2010 +0100

    Merge branch 'jpeg'
    
    Conflicts:
        gui/Makefile.am
        gui/gnash.cpp
        gui/gui.cpp
        gui/gui.h
        librender/Makefile.am

diff --cc gui/Makefile.am
index 208cca0,8403289..dd79c73
--- a/gui/Makefile.am
+++ b/gui/Makefile.am
@@@ -191,17 -204,42 +204,39 @@@ gnash: gnash.i
        cp $< $@
        chmod +x $@
  
+ # These are used to handle input events from a keyboard, mouse, or
+ # touchscreen. These are only used by the Framebuffer GUI, as without
+ # X11, it has no event handling. We do it this way so the optionally
+ # built source files still get included in the source tarball.
+ DEVICES =
+ if ENABLE_INPUT_DEVICES
+ DEVICES += InputDevice.cpp InputDevice.h
+ 
+ # Touchscreen
+ if ENABLE_TSLIB
+ DEVICES += TouchDevice.cpp
+ endif
+ # PS/2 Mouse
+ if ENABLE_MOUSE
+ DEVICES += MouseDevice.cpp
+ endif
+ # Linux input events
+ if ENABLE_INPUT_EVENTS
+ DEVICES += EventDevice.cpp
+ endif
+ endif
+ 
  # Always include the device files in the source tarball
  EXTRA_DIST += \
-       fb/TouchDevice.cpp \
-       fb/MouseDevice.cpp \
-       fb/EventDevice.cpp
+       TouchDevice.cpp \
+       MouseDevice.cpp \
+       EventDevice.cpp
  
  GUI_SRCS = gnash.cpp \
 -      gui.cpp \
 -      gui.h \
 -      Player.cpp \
 -      Player.h \
 -      NullGui.cpp \
 -      NullGui.h \
 +      gui.cpp gui.h \
 +      Player.cpp Player.h \
 +      NullGui.cpp NullGui.h \
-       ScreenShotter.cpp ScreenShotter.h \
+       $(DEVICES) \
        $(NULL)
  
  if BUILD_AQUA_GUI
diff --cc gui/ScreenShotter.cpp
index 4aafcb1,023c972..32a3bb2
--- a/gui/ScreenShotter.cpp
+++ b/gui/ScreenShotter.cpp
@@@ -24,8 -26,11 +26,11 @@@
  #include <boost/algorithm/string/replace.hpp>
  #include <boost/lexical_cast.hpp>
  
- #include "tu_file.h" 
+ #include "log.h"
 -#include "FileTypes.h"
++#include "GnashEnums.h"
  #include "IOChannel.h"
+ #include "Renderer.h"
+ #include "tu_file.h"
  
  namespace gnash {
  
@@@ -38,21 -92,22 +92,29 @@@ ScreenShotter::saveImage(const Renderer
      
      FILE* f = std::fopen(outfile.c_str(), "wb");
      if (f) {
-         boost::shared_ptr<IOChannel> t(makeFileChannel(f, true).release());
-         _renderer->renderToImage(t, GNASH_FILETYPE_PNG);
-     } else {
 -        boost::shared_ptr<IOChannel> t(new tu_file(f, true));
++        boost::shared_ptr<IOChannel> t(makeFileChannel(f, true));
+         r.renderToImage(t, _type, _quality);
+     }
+     else {
          log_error("Failed to open screenshot file \"%s\"!", outfile);
      }
  }
  
  void
- ScreenShotter::screenShot(size_t frameAdvance)
+ ScreenShotter::screenShot(const Renderer& r, size_t frameAdvance)
  {
--    // Save an image if an spontaneous screenshot was requested or the
++    // Save an image if a spontaneous screenshot was requested or the
      // frame is in the list of requested frames.
      if (_immediate || std::binary_search(_frames.begin(), _frames.end(),
                  frameAdvance)) {
-         saveImage(boost::lexical_cast<std::string>(frameAdvance));
++
++        // Check whether we've rendered an image for this frame.
++        if (_done.find(frameAdvance) != _done.end()) {
++            return;
++        }
++        _done.insert(frameAdvance);
++
+         saveImage(r, boost::lexical_cast<std::string>(frameAdvance));
          _immediate = false;
      }
  }
diff --cc gui/ScreenShotter.h
index 9acbe0d,c93cd27..74942f2
--- a/gui/ScreenShotter.h
+++ b/gui/ScreenShotter.h
@@@ -16,14 -16,18 +16,19 @@@
  // along with this program; if not, write to the Free Software
  // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  
- #ifndef GNASH_GUI_SCREENSHOTTER_H
- #define GNASH_GUI_SCREENSHOTTER_H
+ #ifndef GNASH_SCREENSHOT_H
+ #define GNASH_SCREENSHOT_H
  
- #include "Renderer.h" 
- 
- #include <string>
  #include <vector>
+ #include <string>
  #include <boost/shared_ptr.hpp>
++#include <set>
+ 
 -#include "FileTypes.h"
++#include "GnashEnums.h"
+ 
+ namespace gnash {
+     class Renderer;
+ }
  
  namespace gnash {
  
@@@ -90,11 -94,14 +95,16 @@@ private
  
      FrameList _frames;
  
- };
+     const FileType _type;
  
+     const int _quality;
+ 
++    std::set<int> _done;
++
+ };
+  
  } // end of gnash namespace
  
- // end of GNASH_GUI_SCREENSHOTTER_H
  #endif
  
  // Local Variables:
diff --cc gui/gnash.cpp
index 2793602,36dbf4c..0ac208e
--- a/gui/gnash.cpp
+++ b/gui/gnash.cpp
@@@ -305,249 -554,3 +305,254 @@@ main(int argc, char *argv[]
      }
      return EXIT_SUCCESS;
  }
 +
 +namespace {
 +
 +void
 +setupFlashVars(gnash::Player& p, const std::string& param)
 +{
 +    const size_t eq = param.find("=");
 +    if (eq == std::string::npos) {
 +        p.setParam(param, "true");
 +        return;
 +    }
 +    const std::string name = param.substr(0, eq);
 +    const std::string value = param.substr(eq + 1);
 +    p.setParam(name, value);
 +}
 +
 +void
 +setupFDs(gnash::Player& p, const std::string& fds)
 +{
 +    int hostfd = 0, controlfd = 0;
 +    hostfd = std::strtol(fds.substr(0, fds.find(":")).c_str(), NULL, 0);
 +    std::string csub = fds.substr(fds.find(":")+1, fds.size());
 +    controlfd = strtol(csub.c_str(), 0, 0);
 +    gnash::log_debug(_("Host FD #%d, Control FD #%d\n"), 
 +              hostfd, controlfd);
 +
 +    if (hostfd < 0) {
 +        std::cerr << boost::format(_("Invalid host communication "
 +                    "filedescriptor %1%\n")) % hostfd;
 +        std::exit(EXIT_FAILURE);
 +    }
 +    p.setHostFD(hostfd);
 +
 +    if (controlfd < 0) {
 +        std::cerr << boost::format(_("Invalid control communication "
 +                    "filedescriptor %1%\n")) % controlfd;
 +        std::exit(EXIT_FAILURE);
 +    }
 +    p.setControlFD(controlfd);
 +}
 +
 +void
 +setupSoundAndRendering(gnash::Player& p, int i)
 +{
 +    switch (i) {
 +        case 0:
 +            // Disable both
 +            p.setDoRender(false);
 +            p.setDoSound(false);
 +            return;
 +        case 1:
 +            // Enable rendering, disable sound
 +            p.setDoRender(true);
 +            p.setDoSound(false);
 +            return;
 +        case 2:
 +            // Enable sound, disable rendering
 +            p.setDoRender(false);
 +            p.setDoSound(true);
 +            return;
 +        case 3:
 +            // Enable render & sound
 +            p.setDoRender(true);
 +            p.setDoSound(true);
 +            return;
 +        default:
 +            gnash::log_error(_("ERROR: -r must be followed by "
 +                               "0, 1, 2 or 3 "));
 +    }
 +}
 +
 +
 +po::options_description
 +getSupportedOptions(gnash::Player& p)
 +{
 +    using std::string;
 +    using gnash::Player;
 +    using gnash::LogFile;
 +    using gnash::RcInitFile;
 +
 +    std::vector<std::string> handlers;
 +    gnash::media::MediaFactory::instance().listKeys(back_inserter(handlers));
 +
 +    std::vector<std::string> renderers;
 +    boost::split(renderers, RENDERER_CONFIG,
 +        boost::is_any_of(" "), boost::token_compress_on);
 +
 +    po::options_description desc("Options");
 +
 +    desc.add_options()
 +
 +    ("help,h",
 +        _("Print this help and exit"))
 +
 +    ("version,V", 
 +        _("Print version information and exit"))
 +
 +    ("scale,s", po::value<float>()
 +        ->notifier(boost::bind(&Player::setScale, &p,
 +                boost::bind(gnash::clamp<float>, 0.01f, 100.f, _1))),
 +        _("Scale the movie by the specified factor"))
 +
 +    ("delay,d", po::value<int>()
 +        ->notifier(boost::bind(&Player::setDelay, &p, _1)),
 +        _("Number of milliseconds to delay in main loop"))
 +
 +    ("verbose,v", accumulator<int>()
 +        ->notifier(boost::bind(&LogFile::setVerbosity, &dbglogfile, _1)),
 +        _("Produce verbose output"))
 +
 +#if VERBOSE_ACTION
 +    ("verbose-actions,a", po::bool_switch()
 +        ->notifier(boost::bind(&LogFile::setActionDump, &dbglogfile, _1)),
 +        _("Be (very) verbose about action execution"))
 +#endif
 +
 +#if VERBOSE_PARSE
 +    ("verbose-parsing,p", po::bool_switch()
 +        ->notifier(boost::bind(&LogFile::setParserDump, &dbglogfile, _1)),
 +        _("Be (very) verbose about parsing"))
 +#endif
 +
 +    ("audio-dump,A", po::value<string>()
 +        ->notifier(boost::bind(&Player::setAudioDumpfile, &p, _1)),
 +        _("Audio dump file (wave format)"))
 +
 +    ("hwaccel", po::value<string>()
 +        ->default_value("none")
 +        ->notifier(boost::bind(&Player::setHWAccel, &p, _1)),
 +        (string(_("Hardware Video Accelerator to use"))
 +        + string("\nnone|vaapi")). c_str()) 
 +
 +    ("xid,x", po::value<long>()
 +        ->notifier(boost::bind(&Player::setWindowId, &p, _1)),
 +        _("X11 Window ID for display"))
 +
 +    ("writelog,w", po::bool_switch()
 +        ->notifier(boost::bind(&RcInitFile::useWriteLog, &rcfile, _1)),
 +        _("Produce the disk based debug log"))
 +
 +    ("width,j", po::value<int>()
 +        ->notifier(boost::bind(&Player::setWidth, &p, _1)),
 +        _("Set window width"))
 +
 +    ("height,k", po::value<int>()
 +        ->notifier(boost::bind(&Player::setHeight, &p, _1)),
 +        _("Set window height"))
 +
 +    ("x-pos,X", po::value<int>()
 +        ->notifier(boost::bind(&Player::setXPosition, &p, _1)),
 +        _("Set window x position"))
 +
 +    ("y-pos,Y", po::value<int>()
 +        ->notifier(boost::bind(&Player::setYPosition, &p, _1)),
 +        _("Set window y position"))
 +
 +    ("once,1", po::bool_switch()
 +        ->notifier(boost::bind(&Player::setDoLoop, &p,
 +                boost::bind(std::logical_not<bool>(), _1))),
 +        _("Exit when/if movie reaches the last frame"))
 +
 +    ("render-mode,r", po::value<int>()
 +        ->default_value(3)
 +        ->notifier(boost::bind(&setupSoundAndRendering, boost::ref(p), _1)),
 +        (string("0 ")
 +        + string(_("disable rendering and sound")) 
 +        + string("\n1 ")
 +        + string(_("enable rendering, disable sound"))
 +        + string("\n2 ")
 +        + string(_("enable sound, disable rendering"))
 +        + string("\n3 ")
 +        + string(_("enable rendering and sound"))
 +        ).c_str())
 +
 +    ("media,M", po::value<string>()
 +        ->default_value(handlers.front())
 +        ->notifier(boost::bind(&Player::setMedia, &p, _1)),
 +        (string(_("The media handler to use"))
 +         + string("\n") + boost::join(handlers, "|")
 +        ).c_str())
 +
 +    ("renderer,R", po::value<string>()
 +        ->default_value("agg")
 +        ->notifier(boost::bind(&Player::setRenderer, &p, _1)),
 +        (string(_("The renderer to use"))
 +        + string("\n") + boost::join(renderers, "|")
 +        ).c_str())
 +
 +    ("timeout,t", po::value<float>()
 +        ->notifier(boost::bind(&Player::setExitTimeout, &p, _1)),
 +        _("Exit after the specified number of seconds"))
 +
 +    ("real-url,u", po::value<string>(&url),
 +        _("Set \"real\" URL of the movie"))
 +
 +    ("base-url,U", po::value<string>()
 +        ->notifier(boost::bind(&Player::setBaseUrl, &p, _1)),
 +        _("Set \"base\" URL for resolving relative URLs"))
 +
 +    ("param,P", po::value<string>()
 +        ->composing()
 +        ->notifier(boost::bind(&setupFlashVars, boost::ref(p), _1)),
 +        _("Set parameter (e.g. \"FlashVars=A=1&b=2\")"))
 +
 +    ("fd,F", po::value<string>()
 +        ->notifier(boost::bind(&setupFDs, boost::ref(p), _1)),
 +        (string(_("Filedescriptor to use for external communications"))
 +        + string(" <fd>:<fd>")
 +        ).c_str())
 +
 +#ifdef GNASH_FPS_DEBUG
 +    ("debug-fps,f", po::value<float>(),
 +        ->notifier(boost::bind(&Player::setFpsPrintTime, &p, _1),
 +        _("Print FPS every num seconds"))
 +#endif 
 +
 +    ("max-advances", po::value<size_t>()
 +        ->notifier(boost::bind(&Player::setMaxAdvances, &p, _1)),
 +        _("Exit after specified number of frame advances"))
 +
 +    ("fullscreen", po::bool_switch()
 +        ->notifier(boost::bind(&Player::setStartFullscreen, &p, _1)),
 +        _("Start in fullscreen mode"))
 +
 +    // TODO: move to GUIs actually implementing this
 +    ("hide-menubar", po::bool_switch()
 +        ->notifier(boost::bind(&Player::hideMenu, &p, _1)),
 +        _("Start without displaying the menu bar"))
 +
++    // TODO: do this in ScreenShotter class.
 +    ("screenshot", po::value<string>()
 +        ->notifier(boost::bind(&Player::setScreenShots, &p, _1)),
 +        _("List of frames to save as screenshots"))
 +
 +    ("screenshot-file", po::value<string>()
 +        ->notifier(boost::bind(&Player::setScreenShotFile, &p, _1)),
 +        _("Filename pattern for screenshot images"))
 +
++    ("screenshot-quality", po::value<size_t>()
++        ->notifier(boost::bind(&Player::setScreenShotQuality, &p, _1)),
++        _("Quality for screenshot output (not all formats)"))
++
 +    ("input-file", po::value<std::vector<std::string> >(&infiles),
 +        _("Filename pattern for screenshot images"))
 +    ;
 +
 +    return desc;
 +}
 +
 +} // unnamed namespace
 +
diff --cc gui/gui.cpp
index c9148eb,5476462..32fc1a5
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@@ -35,8 -33,10 +33,10 @@@
  #include "movie_root.h"
  #include "VM.h"
  #include "DisplayObject.h"
 -#include "gnash.h"
 +#include "GnashEnums.h"
  #include "RunResources.h"
+ #include "StreamProvider.h"
+ #include "ScreenShotter.h"
  
  #ifdef GNASH_FPS_DEBUG
  #include "ClockTime.h"
@@@ -1342,8 -1330,7 +1330,6 @@@ Gui::callCallback(int fd
  
      f();
  }
--
- 
  // end of namespace
  }
  
diff --cc gui/gui.h
index ba9f15a,825e854..adbabaa
--- a/gui/gui.h
+++ b/gui/gui.h
@@@ -23,13 -23,19 +23,20 @@@
  #include "gnashconfig.h"
  #endif
  
+ #include <boost/intrusive_ptr.hpp>
+ #include <boost/scoped_ptr.hpp>
+ #include <boost/function.hpp>
+ #include <string>
+ #include <map>
+ 
+ #include "SWFRect.h"  // for composition
  #include "snappingrange.h"  // for InvalidatedRanges
 -#include "GnashKey.h" // for gnash::key::code type
 -#include "Renderer.h" // for gnash::key::code type
 +#include "ScreenShotter.h"
 +#include "GnashKey.h"
 +#include "Renderer.h" 
  #include "VirtualClock.h"
  #include "SystemClock.h"
 -#include "gnash.h" // for Quality
 +#include "GnashEnums.h" 
  #include "movie_root.h"
  
  #ifdef USE_SWFTREE
@@@ -66,7 -64,7 +65,8 @@@
  
  // Forward declarations
  namespace gnash {
 +    class SWFRect;
+     class ScreenShotter;
      class RunResources;
      class movie_root;
      class movie_definition;
diff --cc libbase/GnashImage.h
index 122bf99,074b7cc..5793562
--- a/libbase/GnashImage.h
+++ b/libbase/GnashImage.h
@@@ -365,11 -366,13 +365,13 @@@ public
  
      /// Write the given image to the given IOChannel in a specified format.
      //
 -    /// @param type     The image format to write in (see libcore/gnash.h)
 +    /// @param type     The image format to write in (see GnashEnums.h)
      /// @param out      The IOChannel to write to.
      /// @param image    The image to write.
-     /// @param quality  The quality of the image output (not used for all
-     ///                 formats)
+     /// @param quality  The quality of the image output, from 0..100. Values
+     ///                 outside this range will be clamped to the minimum or
+     ///                 maxium value. The quality is not used for all
+     ///                 formats.
      DSOEXPORT static void writeImageData(FileType type,
              boost::shared_ptr<gnash::IOChannel> out, const GnashImage& image,
              int quality);
diff --cc librender/Makefile.am
index 54a81b8,ed3517c..40bba03
--- a/librender/Makefile.am
+++ b/librender/Makefile.am
@@@ -51,32 -54,30 +54,24 @@@ AM_CPPFLAGS = -I.. 
  
  GNASH_LIBS = \
        $(top_builddir)/libcore/libgnashcore.la \
-       $(top_builddir)/libbase/libgnashbase.la \
-       $(NULL)
- 
- instdir = $(includedir)/gnash
- 
- inst_HEADERS = \
-       Renderer.h \
-       $(NULL)
+       $(top_builddir)/libbase/libgnashbase.la 
  
  noinst_HEADERS = \
-       agg/Renderer_agg.h \
-       agg/Renderer_agg_bitmap.h \
-       agg/Renderer_agg_style.h \
-       opengl/tu_opengl_includes.h \
-       opengl/Renderer_ogl.h \
-       cairo/Renderer_cairo.h \
-       cairo/PathParser.h
-       $(NULL)
+       Renderer.h \
+       Renderer_agg.h \
+       Renderer_agg_bitmap.h \
+       Renderer_agg_style.h \
+       Renderer_cairo.h \
+       Renderer_ogl.h \
 -      PathParser.h \
 -      ScreenShotter.h \
 -      $(NULL)
++        PathParser.h
  
  pkglib_LTLIBRARIES = libgnashrender.la
  libgnashrender_la_LIBADD = $(LIBVA_LIBS) $(LIBVA_X11_LIBS) $(LIBVA_GLX_LIBS)
 -libgnashrender_la_SOURCES = \
 -      PathParser.cpp \
 -      ScreenShotter.cpp \
 -      $(NULL)
 -
++libgnashrender_la_SOURCES = PathParser.cpp
  libgnashrender_la_LDFLAGS =  -release $(VERSION) 
- libgnashrender_la_SOURCES =
  
  if BUILD_OGL_RENDERER
- libgnashrender_la_SOURCES += opengl/Renderer_ogl.cpp
+ libgnashrender_la_SOURCES += Renderer_ogl.cpp
  libgnashrender_la_LIBADD += $(OPENGL_LIBS)
  endif
  
diff --cc librender/agg/Renderer_agg.cpp
index 6e140ff,665dadc..fc5a234
--- a/librender/agg/Renderer_agg.cpp
+++ b/librender/agg/Renderer_agg.cpp
@@@ -688,9 -702,9 +688,8 @@@ public
      }
  
      virtual void renderToImage(boost::shared_ptr<IOChannel> io,
-             FileType type) const
+             FileType type, int quality) const
      {
--        log_debug("New image: %sx%s", xres, yres);
          image::ImageRGBA im(xres, yres);
          for (int x = 0; x < xres; ++x) {
              for (int y = 0; y < yres; ++y) {

http://git.savannah.gnu.org/cgit//commit/?id=5351e5927dae49545c21bfee3a8ac3022f8df018


commit 5351e5927dae49545c21bfee3a8ac3022f8df018
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Nov 9 16:59:24 2010 +0100

    Make interface more like boost::program_options's.

diff --git a/gui/gnash.cpp b/gui/gnash.cpp
index c483786..2793602 100644
--- a/gui/gnash.cpp
+++ b/gui/gnash.cpp
@@ -76,19 +76,19 @@ namespace {
 
 /// An accumulating option value to handle multiple -v options.
 template<typename T>
-class accumulator : public po::value_semantic {
+class accumulator_type : public po::value_semantic {
 public:
 
-    accumulator() : _interval(1) {}
+    accumulator_type() : _interval(1) {}
 
     /// Set the notifier function.
-    accumulator* notifier(boost::function1<void, const T&> f) {
+    accumulator_type* notifier(boost::function1<void, const T&> f) {
         _notifier = f;
         return this;
     }
 
     /// Set the default value for this option.
-    accumulator* default_value(const T& t) {
+    accumulator_type* default_value(const T& t) {
         _default = t;
         return this;
     }
@@ -97,7 +97,7 @@ public:
     //
     /// Unlike for program_options::value, this specifies a value
     /// to be applied on each occurence of the option.
-    accumulator* implicit_value(const T& t) {
+    accumulator_type* implicit_value(const T& t) {
         _interval = t;
         return this;
     }
@@ -106,7 +106,7 @@ public:
         return "moo";
     }
 
-    /// There are no tokens for an accumulator
+    /// There are no tokens for an accumulator_type
     virtual unsigned min_tokens() const { return 0; }
     virtual unsigned max_tokens() const { return 0; }
 
@@ -135,7 +135,7 @@ public:
         _notifier(boost::any_cast<T>(value_store));
     }
     
-    virtual ~accumulator() {}
+    virtual ~accumulator_type() {}
 
 private:
     boost::function1<void, const T&> _notifier;
@@ -143,6 +143,11 @@ private:
     T _default;
 };
 
+template<typename T>
+accumulator_type<T>* accumulator() {
+    return new accumulator_type<T>();
+}
+
 }
 
 static void
@@ -406,7 +411,7 @@ getSupportedOptions(gnash::Player& p)
         ->notifier(boost::bind(&Player::setDelay, &p, _1)),
         _("Number of milliseconds to delay in main loop"))
 
-    ("verbose,v", (new accumulator<int>())
+    ("verbose,v", accumulator<int>()
         ->notifier(boost::bind(&LogFile::setVerbosity, &dbglogfile, _1)),
         _("Produce verbose output"))
 

http://git.savannah.gnu.org/cgit//commit/?id=338fcfc318fb0972a1ac215dc199ec694866c8f1


commit 338fcfc318fb0972a1ac215dc199ec694866c8f1
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Nov 9 16:51:14 2010 +0100

    Add an accumulator value_semantic to keep options as they were.

diff --git a/gui/gnash.cpp b/gui/gnash.cpp
index 3087d37..c483786 100644
--- a/gui/gnash.cpp
+++ b/gui/gnash.cpp
@@ -31,6 +31,7 @@
 #include <boost/algorithm/string/join.hpp>
 #include <boost/algorithm/string/split.hpp>
 #include <boost/algorithm/string/classification.hpp>
+#include <boost/function.hpp>
 #include <cstdlib>
 #include <utility>
 #include <functional>
@@ -71,6 +72,79 @@ namespace {
     void setupFDs(gnash::Player& p, const std::string& fds);
 }
 
+namespace {
+
+/// An accumulating option value to handle multiple -v options.
+template<typename T>
+class accumulator : public po::value_semantic {
+public:
+
+    accumulator() : _interval(1) {}
+
+    /// Set the notifier function.
+    accumulator* notifier(boost::function1<void, const T&> f) {
+        _notifier = f;
+        return this;
+    }
+
+    /// Set the default value for this option.
+    accumulator* default_value(const T& t) {
+        _default = t;
+        return this;
+    }
+
+    /// Set the implicit value for this option.
+    //
+    /// Unlike for program_options::value, this specifies a value
+    /// to be applied on each occurence of the option.
+    accumulator* implicit_value(const T& t) {
+        _interval = t;
+        return this;
+    }
+
+    virtual std::string name() const {
+        return "moo";
+    }
+
+    /// There are no tokens for an accumulator
+    virtual unsigned min_tokens() const { return 0; }
+    virtual unsigned max_tokens() const { return 0; }
+
+    // Accumulating from different sources is silly.
+    virtual bool is_composing() const {
+        return false;
+    }
+
+    virtual bool is_required() const { return false; }
+    
+    virtual void parse(boost::any& value_store, 
+                       const std::vector<std::string>& new_tokens,
+                       bool /*utf8*/) const
+    {
+        assert(new_tokens.empty());
+        if (value_store.empty()) value_store = T();
+        boost::any_cast<T&>(value_store) += _interval;
+    }
+
+    virtual bool apply_default(boost::any& value_store) const {
+        value_store = _default;
+        return true;
+    }
+                               
+    virtual void notify(const boost::any& value_store) const {
+        _notifier(boost::any_cast<T>(value_store));
+    }
+    
+    virtual ~accumulator() {}
+
+private:
+    boost::function1<void, const T&> _notifier;
+    T _interval;
+    T _default;
+};
+
+}
+
 static void
 usage_gui_keys(std::ostream& os)
 {
@@ -159,11 +233,14 @@ main(int argc, char *argv[])
     po::positional_options_description files;
     files.add("input-file", -1);
 
+    namespace cls = po::command_line_style;
+
     po::variables_map vm;
     try {
         po::store(po::command_line_parser(argc, argv)
                 .options(opts)
                 .positional(files)
+                .style(cls::default_style ^ cls::allow_guessing)
                 .run(), vm);
     }
     catch (const po::error& e) {
@@ -294,6 +371,7 @@ setupSoundAndRendering(gnash::Player& p, int i)
     }
 }
 
+
 po::options_description
 getSupportedOptions(gnash::Player& p)
 {
@@ -328,7 +406,7 @@ getSupportedOptions(gnash::Player& p)
         ->notifier(boost::bind(&Player::setDelay, &p, _1)),
         _("Number of milliseconds to delay in main loop"))
 
-    ("verbose,v", po::value<size_t>()
+    ("verbose,v", (new accumulator<int>())
         ->notifier(boost::bind(&LogFile::setVerbosity, &dbglogfile, _1)),
         _("Produce verbose output"))
 

http://git.savannah.gnu.org/cgit//commit/?id=dfb05248c357ce6ff706a7eae1d6673f31cd2aad


commit dfb05248c357ce6ff706a7eae1d6673f31cd2aad
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Nov 9 13:04:37 2010 +0100

    Use program_options for options; verbosity doesn't work like it used to.

diff --git a/gui/gnash.cpp b/gui/gnash.cpp
index 9ecd314..3087d37 100644
--- a/gui/gnash.cpp
+++ b/gui/gnash.cpp
@@ -32,8 +32,8 @@
 #include <boost/algorithm/string/split.hpp>
 #include <boost/algorithm/string/classification.hpp>
 #include <cstdlib>
-#include <sys/types.h>
-#include <fcntl.h>
+#include <utility>
+#include <functional>
 #ifdef ENABLE_NLS
 # include <clocale>
 #endif
@@ -41,7 +41,6 @@
 #include "Player.h"
 #include "log.h"
 #include "rc.h" // for use of rcfile
-#include "arg_parser.h"
 #include "GnashNumeric.h" // for clamp
 #include "GnashException.h"
 #include "revno.h"
@@ -54,148 +53,24 @@ using std::cout;
 std::vector<std::string> infiles;
 std::string url;
 
+namespace gnash {
+    class Player;
+}
+
 namespace {
     gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
     gnash::RcInitFile& rcfile = gnash::RcInitFile::getDefaultInstance();
 }
 
-static boost::program_options::options_description
-getSupportedOptions()
-{
+// Forward declarations
+namespace {
     namespace po = boost::program_options;
-    using std::string;
-
-    std::vector<std::string> handlers;
-    gnash::media::MediaFactory::instance().listKeys(back_inserter(handlers));
-
-    std::vector<std::string> renderers;
-    boost::split(renderers, RENDERER_CONFIG,
-        boost::is_any_of(" "), boost::token_compress_on);
-
-    po::options_description desc("Options");
-
-    desc.add_options()
-
-    ( "help,h",
-        _("Print this help and exit") )
-
-    ( "version,V", 
-        _("Print version information and exit") )
-
-    ( "scale,s", po::value<float>(),
-        _("Scale the movie by the specified factor") )
-
-    ( "delay,d", po::value<int>(),
-        _("Number of milliseconds to delay in main loop") )
-
-
-    ( "verbose,v",
-        _("Produce verbose output") )
-
-#if VERBOSE_ACTION
-    ( "verbose-actions,a",
-        _("Be (very) verbose about action execution") )
-#endif
-
-#if VERBOSE_PARSE
-    ( "verbose-parsing,p",
-        _("Be (very) verbose about parsing") )
-#endif
-
-    ( "audio-dump,A", po::value<string>(),
-        _("Audio dump file (wave format)") )
-
-    ( "hwaccel", po::value<string>()->default_value("none"),
-        ( string( _("Hardware Video Accelerator to use"))
-        + string( "\nnone|vaapi|omap") ). c_str() ) 
-
-    ( "xid,x", po::value<long>(),
-        _("X11 Window ID for display") )
-
-    ( "writelog,w",
-        _("Produce the disk based debug log") )
-
-    ( "width,j", po::value<int>(),
-        _("Set window width") )
-
-    ( "height,k", po::value<int>(),
-        _("Set window height") )
-
-    ( "x-pos,X", po::value<int>(),
-        _("Set window x position") )
-
-    ( "y-pos,Y", po::value<int>(),
-        _("Set window y position") )
-
-    ( "once,1", 
-        _("Exit when/if movie reaches the last frame") )
-
-    ( "render-mode,r", po::value<int>()->default_value(3),
-        ( string("0 ")
-        + string(_("disable rendering and sound")) 
-        + string("\n1 ")
-        + string(_("enable rendering, disable sound"))
-        + string("\n2 ")
-        + string(_("enable sound, disable rendering"))
-        + string("\n3 ")
-        + string(_("enable rendering and sound"))
-        ).c_str() )
-
-    ( "media,M", po::value<string>()->default_value(handlers.front()),
-        ( string(_("The media handler to use"))
-        + string("\n") + boost::join(handlers, "|")
-        ).c_str() )
-
-    ( "renderer,R", po::value<string>()->default_value("AGG"),
-        ( string(_("The renderer to use"))
-        + string("\n") + boost::join(renderers, "|")
-        ).c_str() )
-
-    ( "timeout,t", po::value<int>(),
-        _("Exit after the specified number of seconds") )
-
-    ( "real-url,u", po::value<string>(),
-        _("Set \"real\" URL of the movie") )
-
-    ( "base-url,U", po::value<string>(),
-        _("Set \"base\" URL for resolving relative URLs") )
-
-    ( "param,P", po::value<string>(),
-        _("Set parameter (e.g. \"FlashVars=A=1&b=2\")") )
-
-    ( "fd,F", po::value<string>(),
-        ( string(_("Filedescriptor to use for external communications"))
-        + string(" <fd>:<fd>")
-        ).c_str() )
-
-#ifdef GNASH_FPS_DEBUG
-    ( "debug-fps,f", po::value<int>(),
-        _("Print FPS every num seconds (float)") )
-#endif // def GNASH_FPS_DEBUG
-
-    ( "max-advances", po::value<int>(),
-        _("Exit after specified number of frame advances") )
-
-    ( "fullscreen",
-        _("Start in fullscreen mode") )
-
-    // TODO: move to GUIs actually implementing this
-    ( "hide-menubar",
-        _("Start without displaying the menu bar") )
-
-    ( "screenshot", po::value<string>(),
-        _("List of frames to save as screenshots") )
-
-    ( "screenshot-file", po::value<string>(),
-        _("Filename pattern for screenshot images") )
-
-    ;
-
-
-    return desc;
+    po::options_description getSupportedOptions(gnash::Player& p);
+    void setupSoundAndRendering(gnash::Player& p, int i);
+    void setupFlashVars(gnash::Player& p, const std::string& param);
+    void setupFDs(gnash::Player& p, const std::string& fds);
 }
 
-
 static void
 usage_gui_keys(std::ostream& os)
 {
@@ -223,25 +98,17 @@ usage_gui_keys(std::ostream& os)
 }
 
 static void
-usage()
+usage(const po::options_description& opts)
 {
-
-    namespace po = boost::program_options;
-    po::options_description opts = getSupportedOptions();
-
-    cout
-
-    << _("Usage: gnash [options] movie_file.swf") << endl
-    << _("Plays a SWF (Shockwave Flash) movie") << endl
-    << opts
-    << endl;
+    std::cout << _("Usage: gnash [options] movie_file.swf\n")
+              << _("Plays a SWF (Shockwave Flash) movie\n")
+              << opts << "\n";
 
     // Add gui keys
     // TODO: stop printing these in here ?
-    usage_gui_keys(cout);
-
-    cout << std::endl;
+    usage_gui_keys(std::cout);
 
+    std::cout << std::endl;
 }
 
 static void
@@ -271,333 +138,12 @@ build_options()
         << _("   Version: ")  << BRANCH_NICK << ":" << BRANCH_REVNO << endl;
 }
 
-static void
-_parseCommandLine(int argc, char* argv[], gnash::Player& player)
-{
-    namespace po = boost::program_options;
-    po::options_description opts = getSupportedOptions();
-
-    po::variables_map vm;
-    po::store(po::parse_command_line(argc, argv, opts), vm);
-    po::notify(vm);
-
-    // TODO: get this done :)
-}
-
-static void
-parseCommandLine(int argc, char* argv[], gnash::Player& player)
-{
-    const Arg_parser::Option opts[] =
-        {
-        { 'h', "help",              Arg_parser::no  },
-        { 'v', "verbose",           Arg_parser::no  },
-        { 'a', 0,                   Arg_parser::no  },
-        { 'p', 0,                   Arg_parser::no  },
-        { 's', "scale",             Arg_parser::yes },
-        { 256, "max-advances",      Arg_parser::yes },
-        { 257, "fullscreen",        Arg_parser::no  },
-        { 258, "hide-menubar",      Arg_parser::no  },                
-        { 'd', "delay",             Arg_parser::yes },
-        { 'x', "xid",               Arg_parser::yes },
-        { 'R', "renderer",          Arg_parser::yes },
-        { 'M', "media",             Arg_parser::yes },
-        { 'r', "render-mode",       Arg_parser::yes },
-        { 't', "timeout",           Arg_parser::yes },        
-        { '1', "once",              Arg_parser::no  },        
-        { 'w', "writelog",          Arg_parser::no  },
-        { 'j', "width",             Arg_parser::yes },
-        { 'k', "height",            Arg_parser::yes },
-        { 'X', "x-position",        Arg_parser::yes },
-        { 'Y', "y-position",        Arg_parser::yes },
-        { 'u', "real-url",          Arg_parser::yes },
-        { 'P', "param",             Arg_parser::yes },
-        { 'U', "base-url",          Arg_parser::yes },  
-        { 'V', "version",           Arg_parser::no  },        
-        { 'f', "debug-fps",         Arg_parser::yes },        
-        { 'F', "fifo",              Arg_parser::yes },
-        { 'A', "dump",              Arg_parser::yes },
-        { 259, "screenshot",        Arg_parser::yes },
-        { 260, "screenshot-file",   Arg_parser::yes },
-        { 261, "hwaccel",           Arg_parser::yes },
-        { 262, "flash-version",     Arg_parser::no },
-        { 'D', 0,                   Arg_parser::yes }, // Handled in dump gui
-        { 'S', 0,                   Arg_parser::yes }, // Handled in dump gui
-        {   0, 0,                   Arg_parser::no  }
-    };
-
-    Arg_parser parser(argc, argv, opts);
-    if (!parser.error().empty()) {
-        cout << parser.error() << endl;
-        exit(EXIT_FAILURE);
-    }
-
-    bool renderflag = false;
-    bool plugin = false;
-    bool widthGiven = false, heightGiven = false;
-    bool xPosGiven = false, yPosGiven = false;
-
-    for (int i = 0; i < parser.arguments(); ++i) {
-        const int code = parser.code(i);
-        try {
-            switch (code) {
-                case 'h':
-                    version_and_copyright();
-                    usage ();
-                    exit(EXIT_SUCCESS);
-                case 'v':
-                    dbglogfile.setVerbosity();
-                    // This happens once per 'v' flag 
-                    gnash::log_debug(_("Verbose output turned on"));
-                    break;
-                case 'V':
-                    version_and_copyright();
-                    build_options();
-                    exit(EXIT_SUCCESS);          
-                case 'w':
-                    rcfile.useWriteLog(true); 
-                    gnash::log_debug(_("Logging to disk enabled"));
-                    break;
-                case 'a':
-#if VERBOSE_ACTION
-                    dbglogfile.setActionDump(true); 
-#else
-                    gnash::log_error(_("No verbose actions; disabled at "
-                                "compile time"));
-#endif
-                    break;
-                case 'p':
-#if VERBOSE_PARSE
-                    dbglogfile.setParserDump(true); 
-#else
-                    gnash::log_error (_("No verbose parsing; disabled at "
-                                "compile time"));
-#endif
-                    break;
-                case 256:
-                    player.setMaxAdvances(parser.argument<unsigned long>(i));
-                    break;
-                case 257:
-                    player.setStartFullscreen(true);
-                    break;
-                case 258:
-                    player.hideMenu(true);
-                    break;
-                case 's':
-                    player.setScale(gnash::clamp<float>(
-                                    parser.argument<float>(i), 0.01f, 100.f));
-                    break;
-                case 'd':
-                    player.setDelay(parser.argument<long>(i));
-                    break;
-                case 'u':
-                    url = parser.argument(i);
-                    gnash::log_debug (_("Setting root URL to %s"), 
url.c_str());
-                    break;
-                case 'U':    
-                    // Set base URL
-                    player.setBaseUrl(parser.argument(i));
-                    gnash::log_debug (_("Setting base URL to %s"),
-                                      parser.argument(i));
-                    break;
-                case 'F':
-                {
-                   const std::string& fds = parser.argument(i);
-                    fds.find(":");
-                    int hostfd = 0, controlfd = 0;
-                    hostfd = strtol(fds.substr(0, fds.find(":")).c_str(), 
NULL, 0);
-                    std::string csub = fds.substr(fds.find(":")+1, fds.size());
-                    controlfd = strtol(csub.c_str(), 0, 0);
-                    gnash::log_debug(_("Host FD #%d, Control FD #%d\n"), 
-                              hostfd, controlfd);
-                    if (hostfd < 0) {
-                        cerr << boost::format(_("Invalid host communication "
-                                               "filedescriptor %d\n"))
-                            % hostfd << endl;
-                        exit(EXIT_FAILURE);
-                    }
-                    player.setHostFD (hostfd);
-
-                    if (controlfd < 0) {
-                        cerr << boost::format(_("Invalid control communication 
"
-                                    "filedescriptor %d\n")) % controlfd << 
endl;
-                        exit(EXIT_FAILURE);
-                    }
-                    player.setControlFD (controlfd);
-                }
-                break;
-                case 'j':
-                    widthGiven = true;
-                    player.setWidth(parser.argument<long>(i));
-                    gnash::log_debug(_("Setting width to %d"),
-                             player.getWidth());
-                    break;
-                case 'k':
-                    heightGiven = true;
-                    player.setHeight(parser.argument<long>(i));
-                    gnash::log_debug(_("Setting height to %d"),
-                             player.getHeight());
-                    break;
-                case 'X':
-                    xPosGiven = true;
-                    player.setXPosition ( parser.argument<int>(i));
-                    gnash::log_debug (_("Setting x position to %d"), 
-                              player.getXPosition());
-                    break;
-                case 'Y':
-                    yPosGiven = true;
-                    player.setYPosition(parser.argument<int>(i));
-                    gnash::log_debug(_("Setting x position to %d"), 
-                              player.getYPosition());
-                    break;
-                case 'x':
-                    plugin = true;
-                    player.setWindowId(parser.argument<long>(i));
-                    break;
-                case '1':
-                    player.setDoLoop(false);
-                    break;
-                    // See if the hardware video decoder was specified
-                 case 261:
-                    switch (parser.argument<char>(i)) {
-                        case 'v':
-                            player.setHWAccel("vaapi");
-                            break;
-                        case 'n':
-                        default:
-                            player.setHWAccel("none");
-                            break;
-                        }
-                    break; 
-                case 262:
-                    cout << rcfile.getFlashVersionString() << endl;
-                    exit(EXIT_SUCCESS);          
-                    break;
-              case 'M':
-                    player.setMedia(parser.argument(i));
-                    break;
-              case 'R':
-                    player.setRenderer(parser.argument(i));
-                    break;
-              case 'r':
-                    renderflag = true;
-                    switch (parser.argument<char>(i)) {
-                        case '0':
-                            // Disable both
-                            player.setDoRender(false);
-                            player.setDoSound(false);
-                            break;
-                        case '1':
-                            // Enable rendering, disable sound
-                            player.setDoRender(true);
-                            player.setDoSound(false);
-                            break;
-                        case '2':
-                            // Enable sound, disable rendering
-                            player.setDoRender(false);
-                            player.setDoSound(true);
-                            break;
-                        case '3':
-                            // Enable render & sound
-                            player.setDoRender(true);
-                            player.setDoSound(true);
-                            break;
-                            // See if a renderer was specified
-                        case 'a':
-                            // Enable AGG as the rendering backend
-                            player.setRenderer("agg");
-                            break;
-                        case 'o':
-                            // Enable OpenGL as the rendering backend
-                            player.setRenderer("opengl");
-                            break;
-                        case 'c':
-                            // Enable Cairo as the rendering backend
-                            player.setRenderer("cairo");
-                            break;
-                        default:
-                            gnash::log_error(_("ERROR: -r must be followed by "
-                                               "0, 1, 2 or 3 "));
-                            break;
-                    }
-                break;
-            case 't':
-                player.setExitTimeout(parser.argument<float>(i));
-                break;
-            case 'f':
-#ifdef GNASH_FPS_DEBUG
-                player.setFpsPrintTime(parser.argument<float>(i));
-#else
-                cout << _("FPS debugging disabled at compile time, -f "
-                          "is invalid") << endl;
-                exit(EXIT_FAILURE);
-#endif 
-                break;
-            case 'P':
-            {
-                const std::string& param = parser.argument(i);
-                const size_t eq = param.find("=");
-                std::string name, value;
-                if (eq == std::string::npos) {
-                    name = param;
-                    value = "true";
-                } else {
-                    name = param.substr(0, eq);
-                    value = param.substr(eq + 1);
-                }
-                player.setParam(name, value);
-                break;
-            }
-            case 'A':
-            {
-                player.setAudioDumpfile(parser.argument(i));
-                break;
-            }
-            case 259:
-                // The player takes care of parsing the list.
-                player.setScreenShots(parser.argument(i));
-                break;
-            case 260:
-                player.setScreenShotFile(parser.argument(i));
-                break;
-            case 0:
-                infiles.push_back(parser.argument(i));
-                break;
-            }
-        }
-        catch (Arg_parser::ArgParserException &e) {
-            cerr << _("Error parsing command line options: ") << e.what() 
-                << endl;
-            cerr << _("This is a Gnash bug.") << endl;
-        }
-    }
-
-    if (!renderflag) {
-        gnash::log_debug (_("No rendering flags specified, using rcfile"));
-        if (plugin) {
-            player.setDoSound(rcfile.usePluginSound());
-        }
-        else {
-            player.setDoSound(rcfile.useSound());
-        }
-    }
-
-    if (plugin && heightGiven && widthGiven && !player.getHeight() &&
-            !player.getWidth()) {
-            // We were given dimensions of 0x0 to render to (probably the 
plugin
-            // is playing an "invisible" movie. Disable video rendering.
-            player.setDoRender(false);
-    }
-
-}
-
 int
 main(int argc, char *argv[])
 {
     
     std::ios::sync_with_stdio(false);
 
-    gnash::Player player;
-
     // Enable native language support, i.e. internationalization
 #ifdef ENABLE_NLS
     std::setlocale (LC_ALL, "");
@@ -605,22 +151,65 @@ main(int argc, char *argv[])
     textdomain (PACKAGE);
 #endif
 
-    try { 
-        parseCommandLine(argc, argv, player);
+    gnash::Player player;
+
+    po::options_description opts = getSupportedOptions(player);
+
+    // Add all positional arguments as input files.
+    po::positional_options_description files;
+    files.add("input-file", -1);
+
+    po::variables_map vm;
+    try {
+        po::store(po::command_line_parser(argc, argv)
+                .options(opts)
+                .positional(files)
+                .run(), vm);
     }
-    catch (const std::exception& ex) {
-        cerr << ex.what() << endl;
+    catch (const po::error& e) {
+        std::cerr << boost::format(_("Error parsing options: %s\n"))
+            % e.what();
         return EXIT_FAILURE;
     }
-    catch (...) {
-        cerr << _("Exception thrown during parseCommandLine") << endl;
-        return EXIT_FAILURE;
+
+    po::notify(vm);
+
+    if (vm.count("help")) {
+        version_and_copyright();
+        usage(opts);
+        return EXIT_SUCCESS;
+    }
+
+    if (vm.count("version")) {
+        version_and_copyright();
+        build_options();
+        return EXIT_SUCCESS;
+    }
+
+    // Do some extra sanity checks on the options.
+    const bool plugin = vm.count("xid");
+
+    if (plugin && vm.count("height") && vm.count("width") &&
+            !player.getHeight() && !player.getWidth()) {
+            // We were given dimensions of 0x0 to render to (probably the 
plugin
+            // is playing an "invisible" movie. Disable video rendering.
+            player.setDoRender(false);
+    }
+
+    if (!vm.count("render-mode")) {
+        std::cerr << "Using rcfile\n";
+        if (plugin) {
+            player.setDoSound(rcfile.usePluginSound());
+        }
+        else {
+            player.setDoSound(rcfile.useSound());
+        }
     }
 
     // No file name was supplied
     if (infiles.empty()) {
-        cerr << _("Error: no input file was specified. Exiting.") << endl;
-        usage();
+        std::cerr << _("Error: no input file was specified. Exiting.\n");
+        usage(opts);
         return EXIT_FAILURE;
     }
 
@@ -634,3 +223,248 @@ main(int argc, char *argv[])
     }
     return EXIT_SUCCESS;
 }
+
+namespace {
+
+void
+setupFlashVars(gnash::Player& p, const std::string& param)
+{
+    const size_t eq = param.find("=");
+    if (eq == std::string::npos) {
+        p.setParam(param, "true");
+        return;
+    }
+    const std::string name = param.substr(0, eq);
+    const std::string value = param.substr(eq + 1);
+    p.setParam(name, value);
+}
+
+void
+setupFDs(gnash::Player& p, const std::string& fds)
+{
+    int hostfd = 0, controlfd = 0;
+    hostfd = std::strtol(fds.substr(0, fds.find(":")).c_str(), NULL, 0);
+    std::string csub = fds.substr(fds.find(":")+1, fds.size());
+    controlfd = strtol(csub.c_str(), 0, 0);
+    gnash::log_debug(_("Host FD #%d, Control FD #%d\n"), 
+              hostfd, controlfd);
+
+    if (hostfd < 0) {
+        std::cerr << boost::format(_("Invalid host communication "
+                    "filedescriptor %1%\n")) % hostfd;
+        std::exit(EXIT_FAILURE);
+    }
+    p.setHostFD(hostfd);
+
+    if (controlfd < 0) {
+        std::cerr << boost::format(_("Invalid control communication "
+                    "filedescriptor %1%\n")) % controlfd;
+        std::exit(EXIT_FAILURE);
+    }
+    p.setControlFD(controlfd);
+}
+
+void
+setupSoundAndRendering(gnash::Player& p, int i)
+{
+    switch (i) {
+        case 0:
+            // Disable both
+            p.setDoRender(false);
+            p.setDoSound(false);
+            return;
+        case 1:
+            // Enable rendering, disable sound
+            p.setDoRender(true);
+            p.setDoSound(false);
+            return;
+        case 2:
+            // Enable sound, disable rendering
+            p.setDoRender(false);
+            p.setDoSound(true);
+            return;
+        case 3:
+            // Enable render & sound
+            p.setDoRender(true);
+            p.setDoSound(true);
+            return;
+        default:
+            gnash::log_error(_("ERROR: -r must be followed by "
+                               "0, 1, 2 or 3 "));
+    }
+}
+
+po::options_description
+getSupportedOptions(gnash::Player& p)
+{
+    using std::string;
+    using gnash::Player;
+    using gnash::LogFile;
+    using gnash::RcInitFile;
+
+    std::vector<std::string> handlers;
+    gnash::media::MediaFactory::instance().listKeys(back_inserter(handlers));
+
+    std::vector<std::string> renderers;
+    boost::split(renderers, RENDERER_CONFIG,
+        boost::is_any_of(" "), boost::token_compress_on);
+
+    po::options_description desc("Options");
+
+    desc.add_options()
+
+    ("help,h",
+        _("Print this help and exit"))
+
+    ("version,V", 
+        _("Print version information and exit"))
+
+    ("scale,s", po::value<float>()
+        ->notifier(boost::bind(&Player::setScale, &p,
+                boost::bind(gnash::clamp<float>, 0.01f, 100.f, _1))),
+        _("Scale the movie by the specified factor"))
+
+    ("delay,d", po::value<int>()
+        ->notifier(boost::bind(&Player::setDelay, &p, _1)),
+        _("Number of milliseconds to delay in main loop"))
+
+    ("verbose,v", po::value<size_t>()
+        ->notifier(boost::bind(&LogFile::setVerbosity, &dbglogfile, _1)),
+        _("Produce verbose output"))
+
+#if VERBOSE_ACTION
+    ("verbose-actions,a", po::bool_switch()
+        ->notifier(boost::bind(&LogFile::setActionDump, &dbglogfile, _1)),
+        _("Be (very) verbose about action execution"))
+#endif
+
+#if VERBOSE_PARSE
+    ("verbose-parsing,p", po::bool_switch()
+        ->notifier(boost::bind(&LogFile::setParserDump, &dbglogfile, _1)),
+        _("Be (very) verbose about parsing"))
+#endif
+
+    ("audio-dump,A", po::value<string>()
+        ->notifier(boost::bind(&Player::setAudioDumpfile, &p, _1)),
+        _("Audio dump file (wave format)"))
+
+    ("hwaccel", po::value<string>()
+        ->default_value("none")
+        ->notifier(boost::bind(&Player::setHWAccel, &p, _1)),
+        (string(_("Hardware Video Accelerator to use"))
+        + string("\nnone|vaapi")). c_str()) 
+
+    ("xid,x", po::value<long>()
+        ->notifier(boost::bind(&Player::setWindowId, &p, _1)),
+        _("X11 Window ID for display"))
+
+    ("writelog,w", po::bool_switch()
+        ->notifier(boost::bind(&RcInitFile::useWriteLog, &rcfile, _1)),
+        _("Produce the disk based debug log"))
+
+    ("width,j", po::value<int>()
+        ->notifier(boost::bind(&Player::setWidth, &p, _1)),
+        _("Set window width"))
+
+    ("height,k", po::value<int>()
+        ->notifier(boost::bind(&Player::setHeight, &p, _1)),
+        _("Set window height"))
+
+    ("x-pos,X", po::value<int>()
+        ->notifier(boost::bind(&Player::setXPosition, &p, _1)),
+        _("Set window x position"))
+
+    ("y-pos,Y", po::value<int>()
+        ->notifier(boost::bind(&Player::setYPosition, &p, _1)),
+        _("Set window y position"))
+
+    ("once,1", po::bool_switch()
+        ->notifier(boost::bind(&Player::setDoLoop, &p,
+                boost::bind(std::logical_not<bool>(), _1))),
+        _("Exit when/if movie reaches the last frame"))
+
+    ("render-mode,r", po::value<int>()
+        ->default_value(3)
+        ->notifier(boost::bind(&setupSoundAndRendering, boost::ref(p), _1)),
+        (string("0 ")
+        + string(_("disable rendering and sound")) 
+        + string("\n1 ")
+        + string(_("enable rendering, disable sound"))
+        + string("\n2 ")
+        + string(_("enable sound, disable rendering"))
+        + string("\n3 ")
+        + string(_("enable rendering and sound"))
+        ).c_str())
+
+    ("media,M", po::value<string>()
+        ->default_value(handlers.front())
+        ->notifier(boost::bind(&Player::setMedia, &p, _1)),
+        (string(_("The media handler to use"))
+         + string("\n") + boost::join(handlers, "|")
+        ).c_str())
+
+    ("renderer,R", po::value<string>()
+        ->default_value("agg")
+        ->notifier(boost::bind(&Player::setRenderer, &p, _1)),
+        (string(_("The renderer to use"))
+        + string("\n") + boost::join(renderers, "|")
+        ).c_str())
+
+    ("timeout,t", po::value<float>()
+        ->notifier(boost::bind(&Player::setExitTimeout, &p, _1)),
+        _("Exit after the specified number of seconds"))
+
+    ("real-url,u", po::value<string>(&url),
+        _("Set \"real\" URL of the movie"))
+
+    ("base-url,U", po::value<string>()
+        ->notifier(boost::bind(&Player::setBaseUrl, &p, _1)),
+        _("Set \"base\" URL for resolving relative URLs"))
+
+    ("param,P", po::value<string>()
+        ->composing()
+        ->notifier(boost::bind(&setupFlashVars, boost::ref(p), _1)),
+        _("Set parameter (e.g. \"FlashVars=A=1&b=2\")"))
+
+    ("fd,F", po::value<string>()
+        ->notifier(boost::bind(&setupFDs, boost::ref(p), _1)),
+        (string(_("Filedescriptor to use for external communications"))
+        + string(" <fd>:<fd>")
+        ).c_str())
+
+#ifdef GNASH_FPS_DEBUG
+    ("debug-fps,f", po::value<float>(),
+        ->notifier(boost::bind(&Player::setFpsPrintTime, &p, _1),
+        _("Print FPS every num seconds"))
+#endif 
+
+    ("max-advances", po::value<size_t>()
+        ->notifier(boost::bind(&Player::setMaxAdvances, &p, _1)),
+        _("Exit after specified number of frame advances"))
+
+    ("fullscreen", po::bool_switch()
+        ->notifier(boost::bind(&Player::setStartFullscreen, &p, _1)),
+        _("Start in fullscreen mode"))
+
+    // TODO: move to GUIs actually implementing this
+    ("hide-menubar", po::bool_switch()
+        ->notifier(boost::bind(&Player::hideMenu, &p, _1)),
+        _("Start without displaying the menu bar"))
+
+    ("screenshot", po::value<string>()
+        ->notifier(boost::bind(&Player::setScreenShots, &p, _1)),
+        _("List of frames to save as screenshots"))
+
+    ("screenshot-file", po::value<string>()
+        ->notifier(boost::bind(&Player::setScreenShotFile, &p, _1)),
+        _("Filename pattern for screenshot images"))
+
+    ("input-file", po::value<std::vector<std::string> >(&infiles),
+        _("Filename pattern for screenshot images"))
+    ;
+
+    return desc;
+}
+
+} // unnamed namespace
+

http://git.savannah.gnu.org/cgit//commit/?id=63c98bce73af9bf7e0cb996d6fd05a470c66ec1c


commit 63c98bce73af9bf7e0cb996d6fd05a470c66ec1c
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Nov 9 10:42:45 2010 +0100

    Const correct.

diff --git a/gui/Player.h b/gui/Player.h
index 089f749..f195b3d 100644
--- a/gui/Player.h
+++ b/gui/Player.h
@@ -133,7 +133,7 @@ public:
         return oldtimeout;
     }
     
-    void setParam(std::string& name, std::string& value) {
+    void setParam(const std::string& name, const std::string& value) {
         _params[name] = value;
     }
     

http://git.savannah.gnu.org/cgit//commit/?id=52fdda1f191d9ae396a86af41debd0edee0f20aa


commit 52fdda1f191d9ae396a86af41debd0edee0f20aa
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Nov 9 08:24:46 2010 +0100

    Use program_options interface for default values.

diff --git a/gui/gnash.cpp b/gui/gnash.cpp
index 848faf3..9ecd314 100644
--- a/gui/gnash.cpp
+++ b/gui/gnash.cpp
@@ -55,8 +55,8 @@ std::vector<std::string> infiles;
 std::string url;
 
 namespace {
-gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
-gnash::RcInitFile& rcfile = gnash::RcInitFile::getDefaultInstance();
+    gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+    gnash::RcInitFile& rcfile = gnash::RcInitFile::getDefaultInstance();
 }
 
 static boost::program_options::options_description
@@ -105,9 +105,9 @@ getSupportedOptions()
     ( "audio-dump,A", po::value<string>(),
         _("Audio dump file (wave format)") )
 
-    ( "hwaccel", po::value<string>(),
+    ( "hwaccel", po::value<string>()->default_value("none"),
         ( string( _("Hardware Video Accelerator to use"))
-        + string( "\nnone|vaapi|omap (default: none)") ). c_str() ) 
+        + string( "\nnone|vaapi|omap") ). c_str() ) 
 
     ( "xid,x", po::value<long>(),
         _("X11 Window ID for display") )
@@ -130,7 +130,7 @@ getSupportedOptions()
     ( "once,1", 
         _("Exit when/if movie reaches the last frame") )
 
-    ( "render-mode,r", po::value<int>(),
+    ( "render-mode,r", po::value<int>()->default_value(3),
         ( string("0 ")
         + string(_("disable rendering and sound")) 
         + string("\n1 ")
@@ -138,19 +138,17 @@ getSupportedOptions()
         + string("\n2 ")
         + string(_("enable sound, disable rendering"))
         + string("\n3 ")
-        + string(_("enable rendering and sound (default)"))
+        + string(_("enable rendering and sound"))
         ).c_str() )
 
-    ( "media,M", po::value<string>(),
+    ( "media,M", po::value<string>()->default_value(handlers.front()),
         ( string(_("The media handler to use"))
         + string("\n") + boost::join(handlers, "|")
-        + string(" (default: ") + handlers.front() + string(")")
         ).c_str() )
 
-    ( "renderer,R", po::value<string>(),
+    ( "renderer,R", po::value<string>()->default_value("AGG"),
         ( string(_("The renderer to use"))
         + string("\n") + boost::join(renderers, "|")
-        + string(" (default: AGG)")
         ).c_str() )
 
     ( "timeout,t", po::value<int>(),

http://git.savannah.gnu.org/cgit//commit/?id=34a24bfb215dc8b789d3d1569246883580acbe72


commit 34a24bfb215dc8b789d3d1569246883580acbe72
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Oct 14 13:33:15 2010 +0200

    Make the interface more transparent

diff --git a/gui/Player.cpp b/gui/Player.cpp
index 7f288ff..17eb078 100644
--- a/gui/Player.cpp
+++ b/gui/Player.cpp
@@ -48,6 +48,7 @@
 #include "VM.h"
 #include "SystemClock.h"
 #include "ExternalInterface.h"
+#include "ScreenShotter.h"
 
 #include "GnashSystemIOHeaders.h" // for write() 
 #include "log.h"
@@ -533,8 +534,12 @@ Player::run(int argc, char* argv[], const std::string& 
infile,
                 url.path().substr(p + 1);
             _screenshotFile = "screenshot-" + name + "-%f";
         }
-
-        _gui->requestScreenShots(v, last, _screenshotFile, _screenshotQuality);
+        if (!last && v.empty()) return;
+        
+        std::auto_ptr<ScreenShotter> ss(new ScreenShotter(_screenshotFile, 
_screenshotQuality));
+        if (last) ss->lastFrame();
+        ss->setFrames(v);
+        _gui->setScreenShotter(ss);
     }
 
     _gui->run();
diff --git a/gui/gui.cpp b/gui/gui.cpp
index 3f836c7..5476462 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -1012,6 +1012,12 @@ Gui::advanceMovie()
 }
 
 void
+Gui::setScreenShotter(std::auto_ptr<ScreenShotter> ss)
+{
+    _screenShotter.reset(ss.release());
+}
+
+void
 Gui::takeScreenShot()
 {
     if (!_screenShotter.get()) {
@@ -1029,22 +1035,6 @@ Gui::takeScreenShot()
 }
 
 void
-Gui::requestScreenShots(const ScreenShotter::FrameList& l, bool last,
-        const std::string& filename, int quality)
-{
-    // Nothing to do if there is no renderer or if no frames should be
-    // saved.
-    if (!_renderer.get() || (l.empty() && !last)) {
-        return;
-    }
-
-    _screenShotter.reset(new ScreenShotter(filename, quality));
-    if (last) _screenShotter->lastFrame();
-    _screenShotter->setFrames(l);
-
-}
-
-void
 Gui::setCursor(gnash_cursor_type /*newcursor*/)
 {
     /* do nothing */
diff --git a/gui/gui.h b/gui/gui.h
index c2466d8..825e854 100644
--- a/gui/gui.h
+++ b/gui/gui.h
@@ -37,7 +37,6 @@
 #include "SystemClock.h"
 #include "gnash.h" // for Quality
 #include "movie_root.h"
-#include "ScreenShotter.h"
 
 #ifdef USE_SWFTREE
 #include "tree.hh" // for tree
@@ -65,6 +64,7 @@
 
 // Forward declarations
 namespace gnash {
+    class ScreenShotter;
     class RunResources;
     class movie_root;
     class movie_definition;
@@ -122,13 +122,7 @@ public:
     /// Set the time in milliseconds after which the programme should exit.
     virtual void setTimeout(unsigned int timeout) = 0;
 
-    /// Request a list of screenshots
-    //
-    /// @param l        A list of frames to render to an image file
-    /// @param last     Whether to render the last frame before exist
-    /// @param filename The filename pattern to save images as.
-    void requestScreenShots(const ScreenShotter::FrameList& l, bool last,
-            const std::string& filename, int quality);
+    void setScreenShotter(std::auto_ptr<ScreenShotter> ss);
 
     /** \brief
      * Create and display our window.

http://git.savannah.gnu.org/cgit//commit/?id=b83bf13ef8e568ba58df835195b007cc5a22575a


commit b83bf13ef8e568ba58df835195b007cc5a22575a
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Oct 14 13:15:10 2010 +0200

    Don't store renderer in ScreenShotter.

diff --git a/gui/gui.cpp b/gui/gui.cpp
index 262737a..3f836c7 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -197,11 +197,9 @@ Gui::unsetFullscreen()
 void
 Gui::quit()
 {
-    log_debug(__PRETTY_FUNCTION__);
-
     // Take a screenshot of the last frame if required.
-    if (_screenShotter.get()) {
-        _screenShotter->last();
+    if (_screenShotter.get() && _renderer.get()) {
+        _screenShotter->last(*_renderer);
     }
     
     quitUI();
@@ -960,7 +958,7 @@ Gui::advanceMovie()
 #ifdef GNASH_FPS_DEBUG
     // will be a no-op if fps_timer_interval is zero
     if (advanced) {
-       fpsCounterTick();
+        fpsCounterTick();
     }
 #endif
     
@@ -996,8 +994,8 @@ Gui::advanceMovie()
                }
        }
 
-    if (_screenShotter.get()) {
-        _screenShotter->screenShot(_advances);
+    if (_screenShotter.get() && _renderer.get()) {
+        _screenShotter->screenShot(*_renderer, _advances);
     }
 
     // Only increment advances and check for exit condition when we've
@@ -1024,8 +1022,7 @@ Gui::takeScreenShot()
         const std::string& name = (p == std::string::npos) ? url.path() :
             url.path().substr(p + 1);
         const std::string& filename = "screenshot-" + name + "-%f";
-        _screenShotter.reset(new ScreenShotter(_renderer, filename,
-                    GNASH_FILETYPE_PNG));
+        _screenShotter.reset(new ScreenShotter(filename, GNASH_FILETYPE_PNG));
     }
     assert (_screenShotter.get());
     _screenShotter->now();
@@ -1041,7 +1038,7 @@ Gui::requestScreenShots(const ScreenShotter::FrameList& 
l, bool last,
         return;
     }
 
-    _screenShotter.reset(new ScreenShotter(_renderer, filename, quality));
+    _screenShotter.reset(new ScreenShotter(filename, quality));
     if (last) _screenShotter->lastFrame();
     _screenShotter->setFrames(l);
 
diff --git a/librender/ScreenShotter.cpp b/librender/ScreenShotter.cpp
index 6260651..023c972 100644
--- a/librender/ScreenShotter.cpp
+++ b/librender/ScreenShotter.cpp
@@ -58,10 +58,8 @@ typeFromFileName(const std::string& filename)
     return GNASH_FILETYPE_PNG;
 }
 
-ScreenShotter::ScreenShotter(boost::shared_ptr<Renderer> r,
-        const std::string& fileName, int quality)
+ScreenShotter::ScreenShotter(const std::string& fileName, int quality)
     :
-    _renderer(r),
     _immediate(false),
     _fileName(fileName),
     _last(false),
@@ -70,10 +68,9 @@ ScreenShotter::ScreenShotter(boost::shared_ptr<Renderer> r,
 {
 }
 
-ScreenShotter::ScreenShotter(boost::shared_ptr<Renderer> r,
-        const std::string& fileName, FileType type, int quality)
+ScreenShotter::ScreenShotter(const std::string& fileName, FileType type,
+        int quality)
     :
-    _renderer(r),
     _immediate(false),
     _fileName(fileName),
     _last(false),
@@ -87,7 +84,7 @@ ScreenShotter::~ScreenShotter()
 }
 
 void
-ScreenShotter::saveImage(const std::string& id) const
+ScreenShotter::saveImage(const Renderer& r, const std::string& id) const
 {
     // Replace all "%f" in the filename with the frameAdvance.
     std::string outfile(_fileName);
@@ -96,29 +93,30 @@ ScreenShotter::saveImage(const std::string& id) const
     FILE* f = std::fopen(outfile.c_str(), "wb");
     if (f) {
         boost::shared_ptr<IOChannel> t(new tu_file(f, true));
-        _renderer->renderToImage(t, _type, _quality);
-    } else {
+        r.renderToImage(t, _type, _quality);
+    }
+    else {
         log_error("Failed to open screenshot file \"%s\"!", outfile);
     }
 }
 
 void
-ScreenShotter::screenShot(size_t frameAdvance)
+ScreenShotter::screenShot(const Renderer& r, size_t frameAdvance)
 {
     // Save an image if an spontaneous screenshot was requested or the
     // frame is in the list of requested frames.
     if (_immediate || std::binary_search(_frames.begin(), _frames.end(),
                 frameAdvance)) {
-        saveImage(boost::lexical_cast<std::string>(frameAdvance));
+        saveImage(r, boost::lexical_cast<std::string>(frameAdvance));
         _immediate = false;
     }
 }
 
 void
-ScreenShotter::last() const
+ScreenShotter::last(const Renderer& r) const
 {
     if (_last) {
-        saveImage("last");
+        saveImage(r, "last");
     }
 }
 
diff --git a/librender/ScreenShotter.h b/librender/ScreenShotter.h
index 2939ca3..c93cd27 100644
--- a/librender/ScreenShotter.h
+++ b/librender/ScreenShotter.h
@@ -39,12 +39,10 @@ public:
     typedef std::vector<size_t> FrameList;
 
     /// Create a ScreenShotter with output type selected from filename
-    ScreenShotter(boost::shared_ptr<Renderer> r, const std::string& fileName,
-            int quality = 100);
+    ScreenShotter(const std::string& fileName, int quality = 100);
     
     /// Create a ScreenShotter, specifying the output type.
-    ScreenShotter(boost::shared_ptr<Renderer> r, const std::string& fileName,
-            FileType f, int quality = 100);
+    ScreenShotter(const std::string& fileName, FileType f, int quality = 100);
 
     ~ScreenShotter();
 
@@ -60,11 +58,13 @@ public:
 
     /// Called on the last frame before exit.
     //
+    /// @param r                The renderer to use to render the image.
+    //
     /// Which frame is last depends on the execution path of the SWF, whether
     /// the SWF loops, whether a timeout was requested or a maximum number of
     /// advances set. Those conditions are not knowable in advance, so
     /// the last frame is a special case.
-    void last() const;
+    void last(const Renderer& r) const;
 
     /// Takes a screenshot if required.
     //
@@ -72,7 +72,8 @@ public:
     //
     /// @param frameAdvance     used to check whether a screenshot is required
     ///                         as well as to construct the filename.
-    void screenShot(size_t frameAdvance);
+    /// @param r                The renderer to use to render the image.
+    void screenShot(const Renderer& r, size_t frameAdvance);
 
     /// Request a list of frames to be rendered to image files.
     void setFrames(const FrameList& frames);
@@ -80,9 +81,7 @@ public:
 private:
 
     /// Take the screenshot.
-    void saveImage(const std::string& filename) const;
-
-    boost::shared_ptr<Renderer> _renderer;
+    void saveImage(const Renderer& r, const std::string& filename) const;
 
     /// If true, the next call to screenshot will take a screenshot
     bool _immediate;

http://git.savannah.gnu.org/cgit//commit/?id=f171d48c2ad325608204f8743635da2218f0544a


commit f171d48c2ad325608204f8743635da2218f0544a
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Oct 14 11:06:17 2010 +0200

    Move screenshot class to librender.

diff --git a/gui/Makefile.am b/gui/Makefile.am
index dd79c73..8403289 100644
--- a/gui/Makefile.am
+++ b/gui/Makefile.am
@@ -233,9 +233,12 @@ EXTRA_DIST += \
        EventDevice.cpp
 
 GUI_SRCS = gnash.cpp \
-       gui.cpp gui.h \
-       Player.cpp Player.h \
-       NullGui.cpp NullGui.h \
+       gui.cpp \
+       gui.h \
+       Player.cpp \
+       Player.h \
+       NullGui.cpp \
+       NullGui.h \
        $(DEVICES) \
        $(NULL)
 
diff --git a/gui/gnash.cpp b/gui/gnash.cpp
index f6d87e9..36dbf4c 100644
--- a/gui/gnash.cpp
+++ b/gui/gnash.cpp
@@ -46,6 +46,7 @@
 #include "GnashException.h"
 #include "revno.h"
 #include "MediaHandler.h"
+#include "ScreenShotter.h"
 
 #ifdef HAVE_FFMPEG_AVCODEC_H
 extern "C" {
diff --git a/gui/gui.cpp b/gui/gui.cpp
index 2db9ca4..262737a 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -25,11 +25,7 @@
 #include "gui.h"
 
 #include <vector>
-#include <cstdio>
-#include <cstring>
 #include <algorithm> 
-#include <boost/algorithm/string/replace.hpp>
-#include <boost/lexical_cast.hpp>
 
 #include "MovieClip.h"
 #include "Renderer.h"
@@ -37,10 +33,10 @@
 #include "movie_root.h"
 #include "VM.h"
 #include "DisplayObject.h"
-#include "tu_file.h"
 #include "gnash.h"
 #include "RunResources.h"
 #include "StreamProvider.h"
+#include "ScreenShotter.h"
 
 #ifdef GNASH_FPS_DEBUG
 #include "ClockTime.h"
@@ -1017,27 +1013,6 @@ Gui::advanceMovie()
        return true;
 }
 
-FileType
-typeFromFileName(const std::string& filename)
-{
-    struct { const char* ext; FileType type; } matches[] =
-        {
-            { ".png",   GNASH_FILETYPE_PNG },
-            { ".jpg",   GNASH_FILETYPE_JPEG },
-            { ".jpeg",   GNASH_FILETYPE_JPEG }
-        };
-    
-    for (size_t i = 0; i < 3; ++i) {
-        const char* ext = matches[i].ext;
-        const std::string::size_type pos = filename.rfind(ext);
-        if (pos != std::string::npos &&
-                pos + std::strlen(ext) == filename.size()) {
-            return matches[i].type;
-        }
-    }
-    return GNASH_FILETYPE_PNG;
-}
-
 void
 Gui::takeScreenShot()
 {
@@ -1049,7 +1024,8 @@ Gui::takeScreenShot()
         const std::string& name = (p == std::string::npos) ? url.path() :
             url.path().substr(p + 1);
         const std::string& filename = "screenshot-" + name + "-%f";
-        _screenShotter.reset(new ScreenShotter(_renderer, filename));
+        _screenShotter.reset(new ScreenShotter(_renderer, filename,
+                    GNASH_FILETYPE_PNG));
     }
     assert (_screenShotter.get());
     _screenShotter->now();
@@ -1368,49 +1344,6 @@ Gui::callCallback(int fd)
     f();
 }
 
-void
-ScreenShotter::saveImage(const std::string& id) const
-{
-    // Replace all "%f" in the filename with the frameAdvance.
-    std::string outfile(_fileName);
-    boost::replace_all(outfile, "%f", id);
-    
-    FILE* f = std::fopen(outfile.c_str(), "wb");
-    if (f) {
-        boost::shared_ptr<IOChannel> t(new tu_file(f, true));
-        _renderer->renderToImage(t, _type, _quality);
-    } else {
-        log_error("Failed to open screenshot file \"%s\"!", outfile);
-    }
-}
-
-void
-ScreenShotter::screenShot(size_t frameAdvance)
-{
-    // Save an image if an spontaneous screenshot was requested or the
-    // frame is in the list of requested frames.
-    if (_immediate || std::binary_search(_frames.begin(), _frames.end(),
-                frameAdvance)) {
-        saveImage(boost::lexical_cast<std::string>(frameAdvance));
-        _immediate = false;
-    }
-}
-
-void
-ScreenShotter::last() const
-{
-    if (_last) {
-       saveImage("last");
-    }
-}
-
-void
-ScreenShotter::setFrames(const FrameList& frames)
-{
-    _frames = frames;
-    std::sort(_frames.begin(), _frames.end());
-}
-
 // end of namespace
 }
 
diff --git a/gui/gui.h b/gui/gui.h
index 0acee1f..c2466d8 100644
--- a/gui/gui.h
+++ b/gui/gui.h
@@ -23,6 +23,12 @@
 #include "gnashconfig.h"
 #endif
 
+#include <boost/intrusive_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
+#include <boost/function.hpp>
+#include <string>
+#include <map>
+
 #include "SWFRect.h"  // for composition
 #include "snappingrange.h"  // for InvalidatedRanges
 #include "GnashKey.h" // for gnash::key::code type
@@ -31,19 +37,12 @@
 #include "SystemClock.h"
 #include "gnash.h" // for Quality
 #include "movie_root.h"
+#include "ScreenShotter.h"
 
 #ifdef USE_SWFTREE
 #include "tree.hh" // for tree
 #endif
 
-#include <boost/intrusive_ptr.hpp>
-#include <boost/scoped_ptr.hpp>
-#include <boost/function.hpp>
-#include <vector>
-#include <cstdlib> 
-#include <string>
-#include <map>
-
 // Define this to enable fps debugging without touching
 // gnashconfig.h
 //#define GNASH_FPS_DEBUG
@@ -65,8 +64,7 @@
 #define ENABLE_KEYBOARD_MOUSE_MOVEMENTS 1
 
 // Forward declarations
-namespace gnash
-{
+namespace gnash {
     class RunResources;
     class movie_root;
     class movie_definition;
@@ -81,81 +79,6 @@ enum gnash_cursor_type {
   CURSOR_INPUT
 };
 
-FileType typeFromFileName(const std::string& fileName);
-
-/// Handles screen dumps.
-class ScreenShotter
-{
-public:
-
-    typedef std::vector<size_t> FrameList;
-
-    /// Create a ScreenShotter with renderer and output name.
-    ScreenShotter(boost::shared_ptr<Renderer> r, const std::string& fileName,
-            int quality = 100)
-        :
-        _renderer(r),
-        _immediate(false),
-        _fileName(fileName),
-        _last(false),
-        _type(typeFromFileName(fileName)),
-        _quality(quality)
-    {
-    }
-
-    /// Take a screenshot at the next possible moment.
-    void now() {
-        _immediate = true;
-    }
-
-    /// Take a screenshot when the last frame is reached.
-    void lastFrame() {
-        _last = true;
-    }
-
-    /// Called on the last frame before exit.
-    //
-    /// Which frame is last depends on the execution path of the SWF, whether
-    /// the SWF loops, whether a timeout was requested or a maximum number of
-    /// advances set. Those conditions are not knowable in advance, so
-    /// the last frame is a special case.
-    void last() const;
-
-    /// Takes a screenshot if required.
-    //
-    /// Called on each advance.
-    //
-    /// @param frameAdvance     used to check whether a screenshot is required
-    ///                         as well as to construct the filename.
-    void screenShot(size_t frameAdvance);
-
-    /// Request a list of frames to be rendered to image files.
-    void setFrames(const FrameList& frames);
-
-private:
-
-    /// Take the screenshot.
-    void saveImage(const std::string& filename) const;
-
-    boost::shared_ptr<Renderer> _renderer;
-
-    /// If true, the next call to screenshot will take a screenshot
-    bool _immediate;
-
-    /// Name used to generate output file.
-    const std::string _fileName;
-
-    /// Whether to take a screenshot on the last frame.
-    bool _last;
-
-    FrameList _frames;
-
-    const FileType _type;
-
-    const int _quality;
-
-};
-
 /// Parent class from which all GUI implementations will depend.
 class Gui {
 
diff --git a/librender/Makefile.am b/librender/Makefile.am
index 40bba03..ed3517c 100644
--- a/librender/Makefile.am
+++ b/librender/Makefile.am
@@ -63,11 +63,17 @@ noinst_HEADERS = \
        Renderer_agg_style.h \
        Renderer_cairo.h \
        Renderer_ogl.h \
-        PathParser.h
+       PathParser.h \
+       ScreenShotter.h \
+       $(NULL)
 
 pkglib_LTLIBRARIES = libgnashrender.la
 libgnashrender_la_LIBADD = $(LIBVA_LIBS) $(LIBVA_X11_LIBS) $(LIBVA_GLX_LIBS)
-libgnashrender_la_SOURCES = PathParser.cpp
+libgnashrender_la_SOURCES = \
+       PathParser.cpp \
+       ScreenShotter.cpp \
+       $(NULL)
+
 libgnashrender_la_LDFLAGS =  -release $(VERSION) 
 
 if BUILD_OGL_RENDERER
diff --git a/librender/ScreenShotter.cpp b/librender/ScreenShotter.cpp
new file mode 100644
index 0000000..6260651
--- /dev/null
+++ b/librender/ScreenShotter.cpp
@@ -0,0 +1,137 @@
+// 
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+//   Foundation, Inc
+// 
+// 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 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+#include "ScreenShotter.h"
+
+#include <vector>
+#include <string>
+#include <cstring>
+#include <algorithm>
+#include <cstdio>
+#include <boost/algorithm/string/replace.hpp>
+#include <boost/lexical_cast.hpp>
+
+#include "log.h"
+#include "FileTypes.h"
+#include "IOChannel.h"
+#include "Renderer.h"
+#include "tu_file.h"
+
+namespace gnash {
+
+/// Guess an appropriate file type from the filename.
+//
+/// If none can be guessed, we use png.
+FileType
+typeFromFileName(const std::string& filename)
+{
+    struct { const char* ext; FileType type; } matches[] =
+        {
+            { ".png", GNASH_FILETYPE_PNG },
+            { ".jpg", GNASH_FILETYPE_JPEG },
+            { ".jpeg", GNASH_FILETYPE_JPEG }
+        };
+    
+    for (size_t i = 0; i < 3; ++i) {
+        const char* ext = matches[i].ext;
+        const std::string::size_type pos = filename.rfind(ext);
+        if (pos != std::string::npos &&
+                pos + std::strlen(ext) == filename.size()) {
+            return matches[i].type;
+        }
+    }
+    return GNASH_FILETYPE_PNG;
+}
+
+ScreenShotter::ScreenShotter(boost::shared_ptr<Renderer> r,
+        const std::string& fileName, int quality)
+    :
+    _renderer(r),
+    _immediate(false),
+    _fileName(fileName),
+    _last(false),
+    _type(typeFromFileName(fileName)),
+    _quality(quality)
+{
+}
+
+ScreenShotter::ScreenShotter(boost::shared_ptr<Renderer> r,
+        const std::string& fileName, FileType type, int quality)
+    :
+    _renderer(r),
+    _immediate(false),
+    _fileName(fileName),
+    _last(false),
+    _type(type),
+    _quality(quality)
+{
+}
+
+ScreenShotter::~ScreenShotter()
+{
+}
+
+void
+ScreenShotter::saveImage(const std::string& id) const
+{
+    // Replace all "%f" in the filename with the frameAdvance.
+    std::string outfile(_fileName);
+    boost::replace_all(outfile, "%f", id);
+    
+    FILE* f = std::fopen(outfile.c_str(), "wb");
+    if (f) {
+        boost::shared_ptr<IOChannel> t(new tu_file(f, true));
+        _renderer->renderToImage(t, _type, _quality);
+    } else {
+        log_error("Failed to open screenshot file \"%s\"!", outfile);
+    }
+}
+
+void
+ScreenShotter::screenShot(size_t frameAdvance)
+{
+    // Save an image if an spontaneous screenshot was requested or the
+    // frame is in the list of requested frames.
+    if (_immediate || std::binary_search(_frames.begin(), _frames.end(),
+                frameAdvance)) {
+        saveImage(boost::lexical_cast<std::string>(frameAdvance));
+        _immediate = false;
+    }
+}
+
+void
+ScreenShotter::last() const
+{
+    if (_last) {
+        saveImage("last");
+    }
+}
+
+void
+ScreenShotter::setFrames(const FrameList& frames)
+{
+    _frames = frames;
+    std::sort(_frames.begin(), _frames.end());
+}
+
+}
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: nil
+// End:
diff --git a/librender/ScreenShotter.h b/librender/ScreenShotter.h
new file mode 100644
index 0000000..2939ca3
--- /dev/null
+++ b/librender/ScreenShotter.h
@@ -0,0 +1,111 @@
+// 
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+//   Foundation, Inc
+// 
+// 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 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+#ifndef GNASH_SCREENSHOT_H
+#define GNASH_SCREENSHOT_H
+
+#include <vector>
+#include <string>
+#include <boost/shared_ptr.hpp>
+
+#include "FileTypes.h"
+
+namespace gnash {
+    class Renderer;
+}
+
+namespace gnash {
+
+/// Handles screen dumps.
+class ScreenShotter
+{
+public:
+
+    typedef std::vector<size_t> FrameList;
+
+    /// Create a ScreenShotter with output type selected from filename
+    ScreenShotter(boost::shared_ptr<Renderer> r, const std::string& fileName,
+            int quality = 100);
+    
+    /// Create a ScreenShotter, specifying the output type.
+    ScreenShotter(boost::shared_ptr<Renderer> r, const std::string& fileName,
+            FileType f, int quality = 100);
+
+    ~ScreenShotter();
+
+    /// Take a screenshot at the next possible moment.
+    void now() {
+        _immediate = true;
+    }
+
+    /// Take a screenshot when the last frame is reached.
+    void lastFrame() {
+        _last = true;
+    }
+
+    /// Called on the last frame before exit.
+    //
+    /// Which frame is last depends on the execution path of the SWF, whether
+    /// the SWF loops, whether a timeout was requested or a maximum number of
+    /// advances set. Those conditions are not knowable in advance, so
+    /// the last frame is a special case.
+    void last() const;
+
+    /// Takes a screenshot if required.
+    //
+    /// Called on each advance.
+    //
+    /// @param frameAdvance     used to check whether a screenshot is required
+    ///                         as well as to construct the filename.
+    void screenShot(size_t frameAdvance);
+
+    /// Request a list of frames to be rendered to image files.
+    void setFrames(const FrameList& frames);
+
+private:
+
+    /// Take the screenshot.
+    void saveImage(const std::string& filename) const;
+
+    boost::shared_ptr<Renderer> _renderer;
+
+    /// If true, the next call to screenshot will take a screenshot
+    bool _immediate;
+
+    /// Name used to generate output file.
+    const std::string _fileName;
+
+    /// Whether to take a screenshot on the last frame.
+    bool _last;
+
+    FrameList _frames;
+
+    const FileType _type;
+
+    const int _quality;
+
+};
+ 
+} // end of gnash namespace
+
+#endif
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: nil
+// End:

http://git.savannah.gnu.org/cgit//commit/?id=76495914a880896fdecfc39fc5b9d9e55a184942


commit 76495914a880896fdecfc39fc5b9d9e55a184942
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Oct 14 10:06:57 2010 +0200

    Document.

diff --git a/libbase/GnashImage.cpp b/libbase/GnashImage.cpp
index 2d33fec..32c8e67 100644
--- a/libbase/GnashImage.cpp
+++ b/libbase/GnashImage.cpp
@@ -37,6 +37,7 @@
 #include "GnashImageJpeg.h"
 #include "IOChannel.h"
 #include "log.h"
+#include "GnashNumeric.h"
 
 namespace gnash {
 namespace image {
@@ -160,7 +161,9 @@ Output::writeImageData(FileType type,
     
     const size_t width = image.width();
     const size_t height = image.height();
-            
+    
+    quality = clamp<int>(quality, 0, 100);    
+
     std::auto_ptr<Output> outChannel;
 
     switch (type) {
diff --git a/libbase/GnashImage.h b/libbase/GnashImage.h
index 6b19c60..074b7cc 100644
--- a/libbase/GnashImage.h
+++ b/libbase/GnashImage.h
@@ -369,8 +369,10 @@ public:
     /// @param type     The image format to write in (see libcore/gnash.h)
     /// @param out      The IOChannel to write to.
     /// @param image    The image to write.
-    /// @param quality  The quality of the image output (not used for all
-    ///                 formats)
+    /// @param quality  The quality of the image output, from 0..100. Values
+    ///                 outside this range will be clamped to the minimum or
+    ///                 maxium value. The quality is not used for all
+    ///                 formats.
     DSOEXPORT static void writeImageData(FileType type,
             boost::shared_ptr<gnash::IOChannel> out, const GnashImage& image,
             int quality);

http://git.savannah.gnu.org/cgit//commit/?id=8f8c89d108d062feb7a4dcd269ce4a87491945d9


commit 8f8c89d108d062feb7a4dcd269ce4a87491945d9
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Oct 14 10:01:57 2010 +0200

    Reuse existing function.

diff --git a/libbase/GnashImageJpeg.cpp b/libbase/GnashImageJpeg.cpp
index 5c49025..771326e 100644
--- a/libbase/GnashImageJpeg.cpp
+++ b/libbase/GnashImageJpeg.cpp
@@ -602,19 +602,18 @@ JpegOutput::writeImageRGB(const unsigned char* rgbData)
 void
 JpegOutput::writeImageRGBA(const unsigned char* rgbaData)
 {
-    boost::scoped_array<unsigned char> data(new unsigned char[_width * 3]);
+    const size_t components = 3;
+    const size_t size = _width * _height;
 
-    for (size_t y = 0; y < _height; ++y) {
-        for (size_t x = 0; x < _width; ++x) {
-            data[x * 3] = rgbaData[y * _width * 4 + x * 4];
-            data[x * 3 + 1] = rgbaData[y * _width * 4 + x * 4 + 1];
-            data[x * 3 + 2] = rgbaData[y * _width * 4 + x * 4 + 2];
-        }
+    boost::scoped_array<unsigned char> data(
+            new unsigned char[size * components]);
 
-        unsigned char* ypos = data.get();
-        // JPEG needs non-const data.
-        jpeg_write_scanlines(&m_cinfo, &ypos, 1);
+    for (size_t pixel = 0; pixel < size; ++pixel) {
+        data[pixel * 3] = rgbaData[pixel * 4];
+        data[pixel * 3 + 1] = rgbaData[pixel * 4 + 1];
+        data[pixel * 3 + 2] = rgbaData[pixel * 4 + 2];
     }
+    writeImageRGB(data.get());
 }
 
 std::auto_ptr<Output>

http://git.savannah.gnu.org/cgit//commit/?id=7e60ef9ae0fa30aafcfa7669a3a655ae8178cab3


commit 7e60ef9ae0fa30aafcfa7669a3a655ae8178cab3
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Oct 14 09:57:52 2010 +0200

    Implement JPEG screenshot output.

diff --git a/gui/Player.cpp b/gui/Player.cpp
index d8539ec..7f288ff 100644
--- a/gui/Player.cpp
+++ b/gui/Player.cpp
@@ -105,7 +105,8 @@ Player::Player()
     _hostfd(-1),
     _controlfd(-1),
     _startFullscreen(false),
-    _hideMenu(false)
+    _hideMenu(false),
+    _screenshotQuality(100)
 {
 }
 
@@ -533,7 +534,7 @@ Player::run(int argc, char* argv[], const std::string& 
infile,
             _screenshotFile = "screenshot-" + name + "-%f";
         }
 
-        _gui->requestScreenShots(v, last, _screenshotFile);
+        _gui->requestScreenShots(v, last, _screenshotFile, _screenshotQuality);
     }
 
     _gui->run();
diff --git a/gui/Player.h b/gui/Player.h
index 5489da3..e0b3d8d 100644
--- a/gui/Player.h
+++ b/gui/Player.h
@@ -197,6 +197,13 @@ public:
         _screenshotFile = file;
     }
 
+    /// Set the quality for screenshot output.
+    //
+    /// A %f in the filename will be replaced with the frame number.
+    void setScreenShotQuality(int quality) {
+        _screenshotQuality = quality;
+    }
+
 private:
 
     /// Whether to ue HW video decoding support, no value means disabled.
@@ -369,6 +376,11 @@ private:
     //
     /// If empty, a default is used.
     std::string _screenshotFile;
+    
+    /// The filename to save screenshots to.
+    //
+    /// By default 100.
+    int _screenshotQuality;
 
     /// The identifier for the media handler.
     //
diff --git a/gui/gnash.cpp b/gui/gnash.cpp
index 134cee9..f6d87e9 100644
--- a/gui/gnash.cpp
+++ b/gui/gnash.cpp
@@ -222,6 +222,7 @@ parseCommandLine(int argc, char* argv[], gnash::Player& 
player)
         { 'A', "dump",              Arg_parser::yes },
         { 259, "screenshot",        Arg_parser::yes },
         { 260, "screenshot-file",   Arg_parser::yes },
+        { 263, "screenshot-quality",Arg_parser::yes },
         { 261, "hwaccel",           Arg_parser::yes },
         { 262, "flash-version",     Arg_parser::no },
         { 'D', 0,                   Arg_parser::yes }, // Handled in dump gui
@@ -474,6 +475,9 @@ parseCommandLine(int argc, char* argv[], gnash::Player& 
player)
             case 260:
                 player.setScreenShotFile(parser.argument(i));
                 break;
+            case 263:
+                player.setScreenShotQuality(parser.argument<int>(i));
+                break;
             case 0:
                 infiles.push_back(parser.argument(i));
                 break;
diff --git a/gui/gui.cpp b/gui/gui.cpp
index bdfd0cf..2db9ca4 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -1017,6 +1017,27 @@ Gui::advanceMovie()
        return true;
 }
 
+FileType
+typeFromFileName(const std::string& filename)
+{
+    struct { const char* ext; FileType type; } matches[] =
+        {
+            { ".png",   GNASH_FILETYPE_PNG },
+            { ".jpg",   GNASH_FILETYPE_JPEG },
+            { ".jpeg",   GNASH_FILETYPE_JPEG }
+        };
+    
+    for (size_t i = 0; i < 3; ++i) {
+        const char* ext = matches[i].ext;
+        const std::string::size_type pos = filename.rfind(ext);
+        if (pos != std::string::npos &&
+                pos + std::strlen(ext) == filename.size()) {
+            return matches[i].type;
+        }
+    }
+    return GNASH_FILETYPE_PNG;
+}
+
 void
 Gui::takeScreenShot()
 {
@@ -1036,15 +1057,15 @@ Gui::takeScreenShot()
 
 void
 Gui::requestScreenShots(const ScreenShotter::FrameList& l, bool last,
-        const std::string& filename)
+        const std::string& filename, int quality)
 {
     // Nothing to do if there is no renderer or if no frames should be
     // saved.
     if (!_renderer.get() || (l.empty() && !last)) {
-       return;
+        return;
     }
 
-    _screenShotter.reset(new ScreenShotter(_renderer, filename));
+    _screenShotter.reset(new ScreenShotter(_renderer, filename, quality));
     if (last) _screenShotter->lastFrame();
     _screenShotter->setFrames(l);
 
@@ -1357,7 +1378,7 @@ ScreenShotter::saveImage(const std::string& id) const
     FILE* f = std::fopen(outfile.c_str(), "wb");
     if (f) {
         boost::shared_ptr<IOChannel> t(new tu_file(f, true));
-        _renderer->renderToImage(t, GNASH_FILETYPE_PNG);
+        _renderer->renderToImage(t, _type, _quality);
     } else {
         log_error("Failed to open screenshot file \"%s\"!", outfile);
     }
diff --git a/gui/gui.h b/gui/gui.h
index 690715b..0acee1f 100644
--- a/gui/gui.h
+++ b/gui/gui.h
@@ -81,6 +81,7 @@ enum gnash_cursor_type {
   CURSOR_INPUT
 };
 
+FileType typeFromFileName(const std::string& fileName);
 
 /// Handles screen dumps.
 class ScreenShotter
@@ -90,13 +91,17 @@ public:
     typedef std::vector<size_t> FrameList;
 
     /// Create a ScreenShotter with renderer and output name.
-    ScreenShotter(boost::shared_ptr<Renderer> r, const std::string& fileName)
+    ScreenShotter(boost::shared_ptr<Renderer> r, const std::string& fileName,
+            int quality = 100)
         :
         _renderer(r),
         _immediate(false),
         _fileName(fileName),
-        _last(false)
-    {}
+        _last(false),
+        _type(typeFromFileName(fileName)),
+        _quality(quality)
+    {
+    }
 
     /// Take a screenshot at the next possible moment.
     void now() {
@@ -145,6 +150,10 @@ private:
 
     FrameList _frames;
 
+    const FileType _type;
+
+    const int _quality;
+
 };
 
 /// Parent class from which all GUI implementations will depend.
@@ -196,7 +205,7 @@ public:
     /// @param last     Whether to render the last frame before exist
     /// @param filename The filename pattern to save images as.
     void requestScreenShots(const ScreenShotter::FrameList& l, bool last,
-            const std::string& filename);
+            const std::string& filename, int quality);
 
     /** \brief
      * Create and display our window.
diff --git a/librender/Renderer.h b/librender/Renderer.h
index b8e55e4..2511777 100644
--- a/librender/Renderer.h
+++ b/librender/Renderer.h
@@ -321,7 +321,7 @@ public:
     ///                 Note that not all FileTypes are images: rendering
     ///                 to an FLV will not work.
     virtual void renderToImage(boost::shared_ptr<IOChannel> /*io*/,
-        FileType /*type*/) const {
+        FileType /*type*/, int /*quality*/) const {
 
         log_debug(_("Rendering to image not implemented for this "
             "renderer"));
diff --git a/librender/Renderer_agg.cpp b/librender/Renderer_agg.cpp
index 32b99cd..665dadc 100644
--- a/librender/Renderer_agg.cpp
+++ b/librender/Renderer_agg.cpp
@@ -702,7 +702,7 @@ public:
     }
 
     virtual void renderToImage(boost::shared_ptr<IOChannel> io,
-            FileType type) const
+            FileType type, int quality) const
     {
         log_debug("New image: %sx%s", xres, yres);
         image::ImageRGBA im(xres, yres);
@@ -713,7 +713,7 @@ public:
             }
         }
         
-        image::Output::writeImageData(type, io, im, 100);
+        image::Output::writeImageData(type, io, im, quality);
     }
 
     template<typename SourceFormat, typename Matrix>

http://git.savannah.gnu.org/cgit//commit/?id=696fd4ebb8885c052cf2a767afef0a5a258640ed


commit 696fd4ebb8885c052cf2a767afef0a5a258640ed
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Oct 14 09:57:21 2010 +0200

    Allow writing RGBA images to JPEG, ignoring alpha.

diff --git a/libbase/GnashImageJpeg.cpp b/libbase/GnashImageJpeg.cpp
index b89534b..5c49025 100644
--- a/libbase/GnashImageJpeg.cpp
+++ b/libbase/GnashImageJpeg.cpp
@@ -599,6 +599,23 @@ JpegOutput::writeImageRGB(const unsigned char* rgbData)
     }
 }
 
+void
+JpegOutput::writeImageRGBA(const unsigned char* rgbaData)
+{
+    boost::scoped_array<unsigned char> data(new unsigned char[_width * 3]);
+
+    for (size_t y = 0; y < _height; ++y) {
+        for (size_t x = 0; x < _width; ++x) {
+            data[x * 3] = rgbaData[y * _width * 4 + x * 4];
+            data[x * 3 + 1] = rgbaData[y * _width * 4 + x * 4 + 1];
+            data[x * 3 + 2] = rgbaData[y * _width * 4 + x * 4 + 2];
+        }
+
+        unsigned char* ypos = data.get();
+        // JPEG needs non-const data.
+        jpeg_write_scanlines(&m_cinfo, &ypos, 1);
+    }
+}
 
 std::auto_ptr<Output>
 JpegOutput::create(boost::shared_ptr<IOChannel> o, size_t width, size_t height,
diff --git a/libbase/GnashImageJpeg.h b/libbase/GnashImageJpeg.h
index e5e3e8a..8417b27 100644
--- a/libbase/GnashImageJpeg.h
+++ b/libbase/GnashImageJpeg.h
@@ -181,7 +181,14 @@ public:
     /// Write RGB image data using the parameters supplied at construction.
     //
     /// @param rgbData  The raw RGB image data to write as a JPEG.
-    void writeImageRGB(const unsigned char* rgbData);
+    virtual void writeImageRGB(const unsigned char* rgbData);
+
+    /// Write RGBA image data using the parameters supplied at construction.
+    //
+    /// Note: transparency is ignored because JPEG doesn't support it!
+    //
+    /// @param rgbaData  The raw RGBA image data to write as a JPEG.
+    virtual void writeImageRGBA(const unsigned char* rgbaData);
 
     /// Create a JpegOutput, transferring ownership to the caller.
     //

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

Summary of changes:
 gui/Makefile.am                |  100 +++--
 gui/Player.cpp                 |   12 +-
 gui/Player.h                   |   14 +-
 gui/ScreenShotter.cpp          |   93 ++++-
 gui/ScreenShotter.h            |   50 ++-
 gui/gnash.cpp                  |  939 ++++++++++++++++++----------------------
 gui/gui.cpp                    |   42 +--
 gui/gui.h                      |   24 +-
 libbase/GnashImage.cpp         |    5 +-
 libbase/GnashImage.h           |    6 +-
 libbase/GnashImageJpeg.cpp     |   16 +
 libbase/GnashImageJpeg.h       |    9 +-
 librender/Makefile.am          |   36 +-
 librender/Renderer.h           |    2 +-
 librender/agg/Renderer_agg.cpp |    5 +-
 15 files changed, 703 insertions(+), 650 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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