gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog backend/render_handler.h backen...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog backend/render_handler.h backen...
Date: Sat, 02 Dec 2006 21:03:50 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/12/02 21:03:50

Modified files:
        .              : ChangeLog 
        backend        : render_handler.h render_handler_agg.cpp 
                         render_handler_tri.cpp render_handler_tri.h 
        gui            : fb.cpp fbsup.h gtk.cpp gtksup.h gui.cpp gui.h 

Log message:
                * backend/render_handler.h, backend/render_handler_agg.cpp
                  backend/render_handler_tri.cpp, backend/render_handler_tri.h
                  gui/gtk.cpp, gui/gtksup.h, gui/gui.cpp, gui/gui.h, 
gui/fbsup.h,
                  gui/fb.cpp:
                  Use Range2d<int> rather then 4 integers for clip bounds,
                  keep trac of *valid* range for pixel values, add some 
questions
                  as comments in the code. Please forgive me if this will break
                  something but we're in a stage we'll have to break things
                  for making them better ...

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1845&r2=1.1846
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler.h?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_agg.cpp?cvsroot=gnash&r1=1.48&r2=1.49
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_tri.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_tri.h?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/fb.cpp?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/fbsup.h?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtk.cpp?cvsroot=gnash&r1=1.49&r2=1.50
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtksup.h?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.51&r2=1.52
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.h?cvsroot=gnash&r1=1.38&r2=1.39

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1845
retrieving revision 1.1846
diff -u -b -r1.1845 -r1.1846
--- ChangeLog   2 Dec 2006 20:51:19 -0000       1.1845
+++ ChangeLog   2 Dec 2006 21:03:50 -0000       1.1846
@@ -1,5 +1,17 @@
 2006-12-02 Sandro Santilli <address@hidden>
 
+       * backend/render_handler.h, backend/render_handler_agg.cpp
+         backend/render_handler_tri.cpp, backend/render_handler_tri.h
+         gui/gtk.cpp, gui/gtksup.h, gui/gui.cpp, gui/gui.h, gui/fbsup.h,
+         gui/fb.cpp:
+         Use Range2d<int> rather then 4 integers for clip bounds,
+         keep trac of *valid* range for pixel values, add some questions
+         as comments in the code. Please forgive me if this will break
+         something but we're in a stage we'll have to break things
+         for making them better ...
+
+2006-12-02 Sandro Santilli <address@hidden>
+
        * server/rect.h: added is_world() and get_world() methods.
 
 2006-12-01 Sandro Santilli <address@hidden>

Index: backend/render_handler.h
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- backend/render_handler.h    1 Dec 2006 15:52:17 -0000       1.23
+++ backend/render_handler.h    2 Dec 2006 21:03:50 -0000       1.24
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: render_handler.h,v 1.23 2006/12/01 15:52:17 strk Exp $ */
+/* $Id: render_handler.h,v 1.24 2006/12/02 21:03:50 strk Exp $ */
 
 #ifndef RENDER_HANDLER_H
 #define RENDER_HANDLER_H
@@ -259,13 +259,12 @@
        ///
        /// For more info see page \ref region_update.
        ///
-       virtual void set_invalidated_region(const rect /*bounds*/) {    
+       virtual void set_invalidated_region(const rect& /*bounds*/) {    
                // implementation is optional    
        }
        
   /// Converts world coordinates to pixel coordinates
-  virtual void world_to_pixel(int *x, int *y, const float world_x, 
-    const float world_y) = 0;  
+  virtual geometry::Range2d<int> world_to_pixel(const rect& worldbounds) = 0;
                
        /// Bracket the displaying of a frame from a movie.
        //
@@ -384,7 +383,7 @@
   ///
   /// See also gnash::renderer::bounds_in_clipping_area
   ///
-  virtual bool bounds_in_clipping_area(const rect& bounds) {
+  virtual bool bounds_in_clipping_area(const rect& /*bounds*/) {
     return true;
   }
 

Index: backend/render_handler_agg.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_agg.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- backend/render_handler_agg.cpp      1 Dec 2006 16:43:56 -0000       1.48
+++ backend/render_handler_agg.cpp      2 Dec 2006 21:03:50 -0000       1.49
@@ -16,7 +16,7 @@
 
  
 
-/* $Id: render_handler_agg.cpp,v 1.48 2006/12/01 16:43:56 strk Exp $ */
+/* $Id: render_handler_agg.cpp,v 1.49 2006/12/02 21:03:50 strk Exp $ */
 
 // Original version by Udo Giacomozzi and Hannes Mayr, 
 // INDUNET GmbH (www.indunet.it)
@@ -275,18 +275,24 @@
     delete [] m_buffer;
   }
   
-  void clear(unsigned int left, unsigned int top, unsigned int width, 
-    unsigned int height) {
-    
-         if (!width) return;
+  void clear(geometry::Range2d<int> region)
+  {
+         if (region.isNull()) return;
          
-         unsigned int y;
-         const unsigned int max_y = top+height; // to be exact, it's one off 
the max.
          const agg::gray8 black(0);
                  
-    for (y=top; y<max_y; y++) 
+         // TODO: what to do in this case ?
+         assert (! region.isWorld() );
+         
+         unsigned int left=region.getMinX();
+         unsigned int width=region.width();
+         // to be exact, it's one off the max. (?)
+         const unsigned int max_y = region.getMaxY();
+          for (unsigned int y=region.getMinY(); y<max_y; y++) 
+         {
       m_pixf.copy_hline(left, y, width, black);
   }
+  }
   
   renderer_base& get_rbase() {
     return m_rbase;
@@ -487,10 +493,7 @@
     m_pixf = new PixelFormat(m_rbuf);
     //m_rbase = new renderer_base(*m_pixf);  --> does not work!!??
     
-    m_clip_xmin = 0;
-    m_clip_ymin = 0;
-    m_clip_xmax = xres-1;
-    m_clip_ymax = yres-1;
+    _clipbounds.setTo(0, 0, xres-1, yres-1);
         
     log_msg("initialized AGG buffer <%p>, %d bytes, %dx%d, rowsize is %d 
bytes", 
       mem, size, x, y, row_size);
@@ -518,10 +521,9 @@
          assert(m_pixf != NULL);
 
          // clear the stage using the background color    
-    clear_framebuffer(m_clip_xmin, m_clip_ymin, 
-      m_clip_xmax-m_clip_xmin+1, m_clip_ymax-m_clip_ymin+1, 
-      agg::rgba8(background_color.m_r, background_color.m_g, 
-      background_color.m_b, background_color.m_a));
+    clear_framebuffer(_clipbounds, agg::rgba8(background_color.m_r,
+               background_color.m_g, background_color.m_b,
+               background_color.m_a));
          
     // calculate final pixel scale
     /*double scaleX, scaleY;
@@ -538,24 +540,32 @@
        /// still correct, but slower. 
   /// This function clears only a certain portion of the screen, while /not/ 
   /// being notably slower for a fullscreen clear. 
-       void clear_framebuffer(int left, int top, int width, int height, 
agg::rgba8 color) {
-    
-         if (width<1) {
-           log_msg("warning: clear_framebuffer() called with width=%d", width);
+       void clear_framebuffer(geometry::Range2d<int> region,
+                   agg::rgba8 color)
+       {
+           unsigned int width = region.width();
+           if (width < 1)
+           {
+               log_warning("clear_framebuffer() called with width=%d",
+                       width);
       return;
     }
     
-         if (height<1) {
-           log_msg("warning: clear_framebuffer() called with height=%d", 
height);
+           if (region.height() < 1)
+           {
+               log_warning("clear_framebuffer() called with height=%d",
+                       region.height());
       return;
     }
          
-         unsigned int y;
-         const unsigned int max_y = top+height; // to be exact, it's one off 
the max.
-                 
-    for (y=top; y<max_y; y++) 
+           // to be exact, it's one off the max. (?)
+           unsigned int left=region.getMinX();
+           for (unsigned int y=region.getMinY(), maxy=region.getMaxY();
+                   y<maxy; ++y) 
+           {
       m_pixf->copy_hline(left, y, width, color);
   }
+  }
 
   bool allow_glyph_textures() {
     // We want to render all glyphs in place 
@@ -622,8 +632,11 @@
        agg::renderer_scanline_aa_solid<
        agg::renderer_base<PixelFormat> > ren_sl(rbase);
        
-    ras.clip_box((double)m_clip_xmin, (double)m_clip_ymin, 
-      (double)m_clip_xmax, (double)m_clip_ymax);       
+       ras.clip_box(
+               (double)_clipbounds.getMinX(),
+               (double)_clipbounds.getMinY(),
+               (double)_clipbounds.getMaxX(),
+               (double)_clipbounds.getMaxY());         
 
     agg::path_storage path;
     agg::conv_stroke<agg::path_storage> stroke(path);
@@ -674,12 +687,7 @@
     
     agg_alpha_mask* new_mask = new agg_alpha_mask(xres, yres);
     
-    // TODO: implement a testInvariant() function for these
-    assert(m_clip_xmin <= m_clip_xmax);
-    assert(m_clip_ymin <= m_clip_ymax);
-
-    new_mask->clear(m_clip_xmin, m_clip_ymin, 
-      m_clip_xmax-m_clip_xmin+1, m_clip_ymax-m_clip_ymin+1); 
+    new_mask->clear(_clipbounds);
     
     m_alpha_mask.push_back(new_mask);
     
@@ -903,12 +911,15 @@
     agg::span_allocator<agg::rgba8> alloc;  // span allocator (?)
     agg_style_handler sh;               // holds fill style definitions
     
-    // TODO: implement a testInvariant() function for these
-    assert(m_clip_xmin <= m_clip_xmax);
-    assert(m_clip_ymin <= m_clip_ymax);
-
-    rasc.clip_box((double)m_clip_xmin, (double)m_clip_ymin, 
-      (double)m_clip_xmax, (double)m_clip_ymax);
+        // TODO: what do do if _clipbox.isNull() or _clipbox.isWorld() ?
+       //       currently an assertion will fail when get{Min,Max}{X,Y}
+       //       are called below
+
+       rasc.clip_box(
+               (double)_clipbounds.getMinX(),
+               (double)_clipbounds.getMinY(),
+               (double)_clipbounds.getMaxX(),
+               (double)_clipbounds.getMaxY());         
     
     // debug
     int edge_count=0;
@@ -1221,12 +1232,15 @@
       agg::renderer_base<PixelFormat> > ren_sl(rbase); // solid fills
     agg::path_storage agg_path;             // a path in the AGG world
 
-    // TODO: implement a testInvariant() function for these
-    assert(m_clip_xmin <= m_clip_xmax);
-    assert(m_clip_ymin <= m_clip_ymax);
-
-    ras.clip_box((double)m_clip_xmin, (double)m_clip_ymin, 
-      (double)m_clip_xmax, (double)m_clip_ymax);
+        // TODO: what do do if _clipbox.isNull() or _clipbox.isWorld() ?
+       //       currently an assertion will fail when get{Min,Max}{X,Y}
+       //       are called below
+
+       ras.clip_box(
+               (double)_clipbounds.getMinX(),
+               (double)_clipbounds.getMinY(),
+               (double)_clipbounds.getMaxX(),
+               (double)_clipbounds.getMaxY());         
 
     agg::conv_curve< agg::path_storage > curve(agg_path);    // to render 
curves
     agg::conv_stroke< agg::conv_curve < agg::path_storage > > 
@@ -1308,12 +1322,15 @@
     agg::renderer_scanline_aa_solid<
       agg::renderer_base<PixelFormat> > ren_sl(rbase);
 
-    // TODO: implement a testInvariant() function for these
-    assert(m_clip_xmin <= m_clip_xmax);
-    assert(m_clip_ymin <= m_clip_ymax);
-
-    ras.clip_box((double)m_clip_xmin, (double)m_clip_ymin, 
-      (double)m_clip_xmax, (double)m_clip_ymax);
+        // TODO: what do do if _clipbox.isNull() or _clipbox.isWorld() ?
+       //       currently an assertion will fail when get{Min,Max}{X,Y}
+       //       are called below
+
+       ras.clip_box(
+               (double)_clipbounds.getMinX(),
+               (double)_clipbounds.getMinY(),
+               (double)_clipbounds.getMaxX(),
+               (double)_clipbounds.getMaxY());         
       
     agg::path_storage path;
     point pnt, origin;
@@ -1357,84 +1374,64 @@
   }
                       
   
-  void world_to_pixel(int *x, int *y, const float world_x, const float 
world_y) 
+  inline void world_to_pixel(int& x, int& y,
+         float world_x, float world_y)
   {
-    *x = (int) (world_x * xscale);
-    *y = (int) (world_y * yscale);
+        // negative pixels seems ok here... we don't 
+       // clip to valid range, use world_to_pixel(rect&)
+       // and Intersect() against valid range instead.
+       x = (world_x * xscale);
+       y = (world_y * yscale);
   }
   
+  geometry::Range2d<int> world_to_pixel(const rect& wb)
+  {
+      using namespace gnash::geometry;
   
-  virtual void set_invalidated_region(const rect bounds) {
+    if ( wb.is_null() ) return Range2d<int>(nullRange);
+    if ( wb.is_world() ) return Range2d<int>(worldRange);
   
-    // we really support such big numbers ?
-    // better reduce the limit check, to make sure...
-    if (bounds.width() > 1e9f) {
+    int xmin, ymin, xmax, ymax;
     
-      // Region is entire rendering buffer. Don't convert to integer as 
-      // this will overflow.
-      m_clip_xmin = 0;
-      m_clip_ymin = 0;
-      m_clip_xmax = xres-1;
-      m_clip_ymax = yres-1;
+    world_to_pixel(xmin, ymin, wb.get_x_min(), wb.get_y_min());
+    world_to_pixel(xmax, ymax, wb.get_x_max(), wb.get_y_max());
       
-    } else {
-    
-      world_to_pixel(&m_clip_xmin, &m_clip_ymin, bounds.get_x_min(), 
bounds.get_y_min());
-      world_to_pixel(&m_clip_xmax, &m_clip_ymax, bounds.get_x_max(), 
bounds.get_y_max());
+    return Range2d<int>(xmin, ymin, xmax, ymax);
+  }
       
-      // add 2 pixels (GUI does that too)
-      m_clip_xmin -= 2;
-      m_clip_ymin -= 2;
-      m_clip_xmax += 2;
-      m_clip_ymax += 2;
   
-#if 1 // temporary and overkill solution to bug #18416, and an example
-      // of Range2d<> class use
+  virtual void set_invalidated_region(const rect& bounds) {
 
       using gnash::geometry::Range2d;
 
-      Range2d<int> clipbounds(m_clip_xmin, m_clip_ymin, m_clip_xmax, 
m_clip_ymax);
-      Range2d<int> visiblerect(0, 0, xres-1, yres-1);
-      Range2d<int> actualbounds = Intersection(clipbounds, visiblerect);
+      Range2d<int> pixbounds = world_to_pixel(bounds);
 
-      m_clip_xmin = actualbounds.getMinX();
-      m_clip_xmax = actualbounds.getMaxX();
-      m_clip_ymin = actualbounds.getMinY();
-      m_clip_ymax = actualbounds.getMaxY();
-
-#else // bogus implementation (can make min > max)
-
-      if (m_clip_xmin < 0) m_clip_xmin=0;    
-      if (m_clip_xmin < 0) m_clip_xmin=0;    
-      if (m_clip_ymin < 0) m_clip_ymin=0;    
-      if (m_clip_xmax > xres-1) m_clip_xmax = xres-1;    
-      if (m_clip_ymax > yres-1) m_clip_ymax = yres-1;
+      // TODO: add 2 pixels (GUI does that too)
+      //m_clip_xmin -= 2;
+      //m_clip_ymin -= 2;
+      //m_clip_xmax += 2;
+      //m_clip_ymax += 2;
 
-#endif
-      
-     }    
+      // TODO: cache 'visiblerect' and maintain in sync with
+      //       xres/yres.
+      Range2d<int> visiblerect(0, 0, xres-1, yres-1);
+      _clipbounds = Intersection(pixbounds, visiblerect);
   
   }
   
   virtual bool bounds_in_clipping_area(const rect& bounds) {    
     int bxmin, bxmax, bymin, bymax;
     
-    if (bounds.is_null()) return false;
-    
-    world_to_pixel(&bxmin, &bymin, bounds.get_x_min(), bounds.get_y_min()); 
-    world_to_pixel(&bxmax, &bymax, bounds.get_x_max(), bounds.get_y_max());
+       using gnash::geometry::Range2d;
     
-    return
-      (bxmin <= m_clip_xmax) &&
-      (bxmin <= m_clip_xmax) &&
-      (bymax >= m_clip_ymin) && 
-      (bymax >= m_clip_ymin); 
+       Range2d<int> pixbounds = world_to_pixel(bounds);
+       return Intersect(pixbounds, _clipbounds);
   }
 
   void get_pixel(rgba& color_return, float world_x, float world_y) {
     int x, y;
     
-    world_to_pixel(&x, &y, world_x, world_y);
+    world_to_pixel(x, y, world_x, world_y);
 
     agg::rgba8 color = m_pixf->pixel(x, y);    
     
@@ -1469,11 +1466,8 @@
   agg::rendering_buffer m_rbuf;  
   PixelFormat *m_pixf;
   
-  // clipping rectangle
-  int m_clip_xmin;
-  int m_clip_ymin;
-  int m_clip_xmax;
-  int m_clip_ymax;
+  /// clipping rectangle
+  geometry::Range2d<int> _clipbounds;
   
   // this flag is set while a mask is drawn
   bool m_drawing_mask; 

Index: backend/render_handler_tri.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_tri.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- backend/render_handler_tri.cpp      11 Nov 2006 22:44:53 -0000      1.9
+++ backend/render_handler_tri.cpp      2 Dec 2006 21:03:50 -0000       1.10
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: render_handler_tri.cpp,v 1.9 2006/11/11 22:44:53 strk Exp $ */
+/* $Id: render_handler_tri.cpp,v 1.10 2006/12/02 21:03:50 strk Exp $ */
 
 #include "render_handler_tri.h"
 
@@ -339,8 +339,8 @@
 } // get_cache_of
  
 
-void triangulating_render_handler::world_to_pixel(int* /*x*/, int* /*y*/, 
-  const float /*world_x*/, const float /*world_y*/) 
+geometry::Range2d<int>
+triangulating_render_handler::world_to_pixel(const rect& worldbounds)
 {
   assert(0); // not implemented (and currently not required for tri. renderers)
 }

Index: backend/render_handler_tri.h
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_tri.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- backend/render_handler_tri.h        29 Oct 2006 18:34:17 -0000      1.7
+++ backend/render_handler_tri.h        2 Dec 2006 21:03:50 -0000       1.8
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: render_handler_tri.h,v 1.7 2006/10/29 18:34:17 rsavoye Exp $ */
+/* $Id: render_handler_tri.h,v 1.8 2006/12/02 21:03:50 strk Exp $ */
 
 #ifndef GNASH_RENDER_HANDLER_TRI_H
 #define GNASH_RENDER_HANDLER_TRI_H
@@ -125,8 +125,7 @@
   bool allow_glyph_textures() { return true; }
 
   /// Translates world coordinates to pixel coordinates
-  void world_to_pixel(int *x, int *y, const float world_x, 
-    const float world_y);  
+  geometry::Range2d<int> world_to_pixel(const rect& worldbounds);
     
   // --- helper methods 
--------------------------------------------------------
   // These methods are called by draw_shape_character() and normally don't need

Index: gui/fb.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/fb.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- gui/fb.cpp  29 Oct 2006 18:34:10 -0000      1.18
+++ gui/fb.cpp  2 Dec 2006 21:03:50 -0000       1.19
@@ -322,9 +322,6 @@
 {
 #ifdef DOUBLE_BUFFER
 
-  assert(m_draw_minx <= m_draw_maxx);
-  assert(m_draw_miny <= m_draw_maxy);
-  
   // Size of a pixel in bytes
   // NOTE: +7 to support 15 bpp
   const unsigned int pixel_size = (var_screeninfo.bits_per_pixel+7)/8;
@@ -334,13 +331,14 @@
     var_screeninfo.xres * pixel_size;
     
   // Size, in bytes, of a row that has to be copied
-  const unsigned int row_size =
-    (m_draw_maxx-m_draw_minx+1) * pixel_size;
+  const unsigned int row_size = _drawbounds.width() * pixel_size;
     
   // copy each row
-  for (int y=m_draw_miny; y<=m_draw_maxy; y++) {
+  const int minx = _drawbounds.getMinX();
+  const int maxy = _drawbounds.getMaxY();
+  for (int y=_drawbounds.getMinY(); y<maxy; ++y) {
   
-    const unsigned int pixel_index = y * scanline_size + 
m_draw_minx*pixel_size;
+    const unsigned int pixel_index = y * scanline_size + minx*pixel_size;
     
     memcpy(&fbmem[pixel_index], &buffer[pixel_index], row_size);
     
@@ -405,27 +403,14 @@
   // forward to renderer
   _renderer->set_invalidated_region(bounds);
   
-  if (bounds.width() > 1e10f) {
-    // Region is entire screen. Don't convert to integer as this will overflow.
-    
-    m_draw_minx=0;
-    m_draw_miny=0;
-    m_draw_maxx=m_stage_width-1;
-    m_draw_maxy=m_stage_height-1;
-    
-  } else {
-
-    // remember for renderBuffer()
-    _renderer->world_to_pixel(&m_draw_minx, &m_draw_miny, bounds.get_x_min(), 
bounds.get_y_min());
-    _renderer->world_to_pixel(&m_draw_maxx, &m_draw_maxy, bounds.get_x_max(), 
bounds.get_y_max());
-  
-    // add two pixels because of anti-aliasing...
-    m_draw_minx = valid_x(m_draw_minx-2);
-    m_draw_miny = valid_y(m_draw_miny-2);
-    m_draw_maxx = valid_x(m_draw_maxx+2);
-    m_draw_maxy = valid_y(m_draw_maxy+2);
+       // update _drawbounds, which are the bounds that need to
+       // be rerendered (??)
+       //
+       _drawbounds = Intersection(
+                       _renderer->world_to_pixel(bounds),
+                       _validbounds);
     
-  }
+       // TODO: add two pixels because of anti-aliasing...
 
 #endif
   

Index: gui/fbsup.h
===================================================================
RCS file: /sources/gnash/gnash/gui/fbsup.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- gui/fbsup.h 29 Oct 2006 18:34:10 -0000      1.10
+++ gui/fbsup.h 2 Dec 2006 21:03:50 -0000       1.11
@@ -66,10 +66,8 @@
 #ifdef DOUBLE_BUFFER
                unsigned char *buffer; // offscreen buffer
 #endif         
-    int m_draw_minx;
-    int m_draw_miny;
-    int m_draw_maxx;
-    int m_draw_maxy;
+
+    geometry::Range2d<int> _drawbounds;
     
     int m_stage_width;
     int m_stage_height;

Index: gui/gtk.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gtk.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- gui/gtk.cpp 11 Nov 2006 15:25:27 -0000      1.49
+++ gui/gtk.cpp 2 Dec 2006 21:03:50 -0000       1.50
@@ -52,7 +52,9 @@
 }
 
 GtkGui::GtkGui(unsigned long xid, float scale, bool loop, unsigned int depth)
- : Gui(xid, scale, loop, depth)
+       :
+       Gui(xid, scale, loop, depth),
+       _drawbounds(0, 0, 0, 0)
 {
 }
 
@@ -193,10 +195,17 @@
 GtkGui::createWindow(int width, int height)
 {
     GNASH_REPORT_FUNCTION;
+
+       assert(_width>0);
+       assert(_height>0);
+
     _width = width;
     _height = height;
     
-               glue.setRenderHandlerSize(width, height);
+       _validbounds.setTo(0, 0, _width-1, _height-1);
+       _drawbounds = _validbounds;
+    
+       glue.setRenderHandlerSize(_width, _height);
 
     return true;
 }
@@ -204,7 +213,8 @@
 void
 GtkGui::renderBuffer()
 {
-               glue.render(m_draw_minx, m_draw_miny, m_draw_maxx, m_draw_maxy);
+       glue.render(_drawbounds.getMinX(), _drawbounds.getMinY(),
+               _drawbounds.getMaxX(), _drawbounds.getMaxY());
 }
 
 int
@@ -220,38 +230,26 @@
 {
 #ifdef RENDERER_AGG
   // forward to renderer
+       //
+       // Why? Why have the region been invalidated ??
+       // Was the renderer offscreen buffer also invalidated
+       // (need to rerender)?
+       // Was only the 'onscreen' buffer be invalidated (no need to rerender,
+       // just to blit) ??
+       //
+       // To be safe just assume this 'invalidated' region is actually
+       // the offscree buffer, for safety, but we need to clarify this.
+       //
   _renderer->set_invalidated_region(bounds);
 
-  if ( bounds.width() > 1e10f ) {
-    // Region is entire screen. Don't convert to integer as this will overflow.
-
-    m_draw_minx=0;
-    m_draw_miny=0;
-    m_draw_maxx=_width-1;
-    m_draw_maxy=_height-1;
-
-  } else {
-
-    // remember for renderBuffer()
-    _renderer->world_to_pixel(&m_draw_minx, &m_draw_miny, bounds.get_x_min(), 
bounds.get_y_min());
-    _renderer->world_to_pixel(&m_draw_maxx, &m_draw_maxy, bounds.get_x_max(), 
bounds.get_y_max());
-
-    // add two pixels because of anti-aliasing...
-    m_draw_minx = valid_coord(m_draw_minx-2, _width);
-    m_draw_miny = valid_coord(m_draw_miny-2, _height);
-    m_draw_maxx = valid_coord(m_draw_maxx+2, _width);
-    m_draw_maxy = valid_coord(m_draw_maxy+2, _height);
-
-       }
+       // update _drawbounds, which are the bounds that need to
+       // be rerendered (??)
+       //
+       _drawbounds = Intersection(
+                       _renderer->world_to_pixel(bounds),
+                       _validbounds);
        
-       /*
-       log_msg("GtkGui::set_invalidated_region pixel: x1:%i, y1:%i, x2:%i, 
y2:%i\n", \
-               m_draw_minx,
-               m_draw_miny, \
-               m_draw_maxx, \
-               m_draw_maxy \
-       );
-       */
+       // TODO: add two pixels because of anti-aliasing...
 #endif
 }
 
@@ -562,7 +560,7 @@
        // Set an invalidate region that contains the entire screen for sure
        // TODO: be more conservative in setting draw_bounds
        //       (look at the GdkEventExpose)
-       rect draw_bounds(-1e10f, -1e10f, +1e10f, +1e10f);
+       rect draw_bounds; draw_bounds.set_world();
 
        gui->set_invalidated_region(draw_bounds);
 

Index: gui/gtksup.h
===================================================================
RCS file: /sources/gnash/gnash/gui/gtksup.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- gui/gtksup.h        2 Nov 2006 14:00:13 -0000       1.29
+++ gui/gtksup.h        2 Dec 2006 21:03:50 -0000       1.30
@@ -126,10 +126,8 @@
     GdkPixbuf  *_window_icon_pixbuf;
     GtkWidget   *_drawing_area;    
     GtkMenu     *_popup_menu;
-    int                                m_draw_minx;
-    int                                m_draw_miny;
-    int                                m_draw_maxx;
-    int                                m_draw_maxy;
+
+    geometry::Range2d<int> _drawbounds;
 
        int valid_coord(int coord, int max);
 #ifdef RENDERER_CAIRO

Index: gui/gui.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- gui/gui.cpp 24 Nov 2006 17:50:47 -0000      1.51
+++ gui/gui.cpp 2 Dec 2006 21:03:50 -0000       1.52
@@ -49,8 +49,8 @@
 Gui::Gui() :
     _loop(true),
     _xid(0),
-    _width(0),
-    _height(0),
+    _width(1),
+    _height(1),
     _xscale(1.0f),
     _yscale(1.0f),
     _depth(16),
@@ -61,11 +61,12 @@
 //    GNASH_REPORT_FUNCTION;
 }
 
-Gui::Gui(unsigned long xid, float scale, bool loop, unsigned int depth) :
+Gui::Gui(unsigned long xid, float scale, bool loop, unsigned int depth)
+       :
     _loop(loop),
     _xid(xid),
-    _width(0),
-    _height(0),
+    _width(1),
+    _height(1),
     _xscale(scale),
     _yscale(scale),
     _depth(depth),
@@ -92,7 +93,12 @@
 Gui::resize_view(int width, int height)
 {
 //    GNASH_REPORT_FUNCTION;
-       if (VM::isInitialized()) {
+
+       assert(width>0);
+       assert(height>0);
+
+       if ( VM::isInitialized() )
+       {
 
                sprite_instance* m_sp = VM::get().getRoot();
 
@@ -116,7 +122,9 @@
                
                _renderer->set_scale(_xscale, _yscale);
 
-       } else {
+       }
+       else
+       {
                log_warning("Resize request received while there's still"
                        " no movie loaded, can't correctly set movie scale");
        }
@@ -127,6 +135,7 @@
        // set new size ?
        _width = width;
        _height = height;
+       _validbounds.setTo(0, 0, _width-1, _height-1);
        //log_msg("new size (in twips) is: %dx%d", _width*20, _height*20); 
 
 }

Index: gui/gui.h
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- gui/gui.h   21 Nov 2006 00:25:46 -0000      1.38
+++ gui/gui.h   2 Dec 2006 21:03:50 -0000       1.39
@@ -121,8 +121,14 @@
     virtual void set_invalidated_region(const rect& /*bounds*/) {      
       // does not need to be implemented (optional feature),
       // but still needs to be available.
+      //
       // Why "rect" (floats)? Because the gui does not really
       // know about the scale the renderer currently uses... 
+      //
+      // <strk> but it does not about the "semantic" of the TWIPS
+      //        coordinate space, which is integer values...
+      //        The question really is: why floats for TWIPS ?
+      //        (guess this goes deep in the core/server libs)
     } 
 
     /// Asks the GUI handler if the next frame should be redrawn completely. 
@@ -195,10 +201,19 @@
     bool            _loop;
     /// The X Window ID to attach to. If zero, we create a new window.
     unsigned long   _xid;
+
+    // should it be unsigned ints ? (probably!)
+    // This would be 0,0,_width,_height, so maybe
+    // we should not duplicate the info with those
+    // explicit values too..
+    geometry::Range2d<int> _validbounds;
+
     /// Desired window width.
     int             _width;
+
     /// Desired window height.
     int             _height;
+
     /// The window width scale.
     float           _xscale;
     /// The window height scale.




reply via email to

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