=== modified file 'gui/sdl.cpp'
--- gui/sdl.cpp	2009-02-25 22:33:03 +0000
+++ gui/sdl.cpp	2009-05-16 04:59:39 +0000
@@ -221,6 +221,12 @@
 {
     _core_trap = false;
 }
+
+void
+SDLGui::setInvalidatedRegions(const InvalidatedRanges& ranges)
+{
+    _glue.setInvalidatedRegions(ranges);
+}
 
 void
 SDLGui::renderBuffer()

=== modified file 'gui/sdl_agg_glue.cpp'
--- gui/sdl_agg_glue.cpp	2009-02-25 22:33:03 +0000
+++ gui/sdl_agg_glue.cpp	2009-05-16 05:11:23 +0000
@@ -145,29 +145,48 @@
     assert(_sdl_surface);
 
     return true;
+}
+
+/// Modified from fb_gui
+void
+SdlAggGlue::setInvalidatedRegions(const InvalidatedRanges& ranges)
+{
+    _agg_renderer->set_invalidated_regions(ranges);
+    _drawbounds.clear();
+
+    for (unsigned int rno=0; rno<ranges.size(); rno++) {
+        geometry::Range2d<int> bounds = Intersection(
+			// twips changed to pixels here
+            _agg_renderer->world_to_pixel(ranges.getRange(rno)),
+            _validbounds);
+
+        // it may happen that a particular range is out of the screen, which
+        // will lead to bounds==null.
+        if (bounds.isNull()) continue;
+        _drawbounds.push_back(bounds);
+    }
 }
 
 void
 SdlAggGlue::render()
-{
-    rect bounds;
-    bounds.set_world();
-    
-    _agg_renderer->set_invalidated_region(bounds);
-
-	// Update the entire screen
-	SDL_BlitSurface(_sdl_surface, 0, _screen, 0);
-	SDL_UpdateRect(_screen, 0, 0, 0, 0);
+{
+    if ( _drawbounds.size() == 0 ) return; // nothing to do..
+
+    for (unsigned int bno=0; bno < _drawbounds.size(); bno++) {
+        geometry::Range2d<int>& bounds = _drawbounds[bno];
+        render(bounds.getMinX(), bounds.getMinY(),
+			bounds.getMaxX(), bounds.getMaxY() );
+    }
 }
 
 void
 SdlAggGlue::render(int minx, int miny, int maxx, int maxy)
 {
-	// Update only the invalidated rectangle
-	SDL_Rect clip = { minx, miny, maxx - minx, maxy - miny };
-	SDL_SetClipRect(_screen, &clip);
-	SDL_BlitSurface(_sdl_surface, 0, _screen, 0);
-	SDL_UpdateRect(_sdl_surface, clip.x, clip.y, clip.w, clip.h);
+	// Update only the invalidated rectangle
+	SDL_Rect clip = { minx, miny, maxx - minx, maxy - miny };
+	SDL_SetClipRect(_screen, &clip);
+	SDL_BlitSurface(_sdl_surface, 0, _screen, 0);
+	SDL_UpdateRect(_screen, clip.x, clip.y, clip.w, clip.h);
 }
 
 } // namespace gnash

=== modified file 'gui/sdl_agg_glue.h'
--- gui/sdl_agg_glue.h	2009-02-25 22:33:03 +0000
+++ gui/sdl_agg_glue.h	2009-05-16 05:19:04 +0000
@@ -30,7 +30,8 @@
     virtual ~SdlAggGlue();
 
     bool init(int argc, char **argv[]);
-    render_handler* createRenderHandler(int depth);
+    render_handler* createRenderHandler(int depth);
+    void setInvalidatedRegions(const InvalidatedRanges& ranges);
     bool prepDrawingArea(int width, int height, boost::uint32_t sdl_flags);
     boost::uint32_t maskFlags(boost::uint32_t sdl_flags);
     void render();
@@ -39,7 +40,10 @@
     SDL_Surface     *_sdl_surface;
     unsigned char   *_offscreenbuf;
     SDL_Surface     *_screen;
-    render_handler  *_agg_renderer;
+    render_handler  *_agg_renderer;
+    
+    geometry::Range2d<int> _validbounds;
+    std::vector< geometry::Range2d<int> > _drawbounds;
 };
 
 }

=== modified file 'gui/sdl_cairo_glue.cpp'
--- gui/sdl_cairo_glue.cpp	2009-02-25 22:33:03 +0000
+++ gui/sdl_cairo_glue.cpp	2009-05-16 05:17:43 +0000
@@ -57,6 +57,12 @@
     return renderer::cairo::create_handler();
 
 }
+
+/// Not implemented, Fixme
+void
+SdlCairoGlue::setInvalidatedRegions(const InvalidatedRanges& ranges)
+{
+}
 
 
 bool

=== modified file 'gui/sdl_cairo_glue.h'
--- gui/sdl_cairo_glue.h	2009-02-25 22:33:03 +0000
+++ gui/sdl_cairo_glue.h	2009-05-16 05:20:08 +0000
@@ -30,7 +30,8 @@
     virtual ~SdlCairoGlue();
 
     bool init(int argc, char **argv[]);
-    render_handler* createRenderHandler( int depth);
+    render_handler* createRenderHandler( int depth);
+    void setInvalidatedRegions(const InvalidatedRanges& ranges);
     bool prepDrawingArea(int width, int height, boost::uint32_t sdl_flags);
     boost::uint32_t maskFlags(boost::uint32_t sdl_flags);
     void render();

=== modified file 'gui/sdl_glue.h'
--- gui/sdl_glue.h	2009-02-25 22:33:03 +0000
+++ gui/sdl_glue.h	2009-05-16 05:03:29 +0000
@@ -15,7 +15,8 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-#include "gnash.h"
+#include "gnash.h"
+#include "gui.h"
 
 #include <boost/cstdint.hpp> // for boost::?int??_t 
 
@@ -27,7 +28,8 @@
   public:
     virtual ~SdlGlue() { }
     virtual bool init(int argc, char **argv[]) = 0;
-
+
+    virtual void setInvalidatedRegions(const InvalidatedRanges& ranges) = 0;
     virtual bool prepDrawingArea(int width, int height, boost::uint32_t sdl_flags) = 0;
     virtual render_handler* createRenderHandler(int depth) = 0;
     virtual void render() = 0;

=== modified file 'gui/sdl_ogl_glue.cpp'
--- gui/sdl_ogl_glue.cpp	2009-02-25 22:33:03 +0000
+++ gui/sdl_ogl_glue.cpp	2009-05-16 05:17:28 +0000
@@ -77,6 +77,14 @@
 
     return renderer;
 }
+
+
+/// Not implemented, Fixme
+void
+SdlOglGlue::setInvalidatedRegions(const InvalidatedRanges& ranges)
+{
+}
+
 
 bool
 SdlOglGlue::prepDrawingArea(int width, int height, boost::uint32_t sdl_flags)

=== modified file 'gui/sdl_ogl_glue.h'
--- gui/sdl_ogl_glue.h	2009-02-25 22:33:03 +0000
+++ gui/sdl_ogl_glue.h	2009-05-16 05:19:55 +0000
@@ -29,7 +29,8 @@
     virtual ~SdlOglGlue();
 
     bool init(int argc, char ***argv);
-    render_handler* createRenderHandler( int depth);
+    render_handler* createRenderHandler( int depth);
+    void setInvalidatedRegions(const InvalidatedRanges& ranges);
     bool prepDrawingArea(int width, int height, boost::uint32_t sdl_flags);
     void render();
   private:

=== modified file 'gui/sdlsup.h'
--- gui/sdlsup.h	2009-02-25 22:33:03 +0000
+++ gui/sdlsup.h	2009-05-16 05:19:27 +0000
@@ -53,7 +53,8 @@
     virtual bool createWindow(const char *title, int width, int height);
     virtual bool run();
     virtual bool createMenu();
-    virtual bool setupEvents();
+    virtual bool setupEvents();
+    virtual void setInvalidatedRegions(const InvalidatedRanges& ranges);
     virtual void renderBuffer();
     virtual void setInterval(unsigned int interval);
     virtual void disableCoreTrap();

