gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash backend/render_handler.h backend/render_h...


From: Udo Giacomozzi
Subject: [Gnash-commit] gnash backend/render_handler.h backend/render_h...
Date: Thu, 12 Oct 2006 18:59:00 +0000

CVSROOT:        /cvsroot/gnash
Module name:    gnash
Changes by:     Udo Giacomozzi <udog>   06/10/12 18:59:00

Modified files:
        backend        : render_handler.h render_handler_agg.cpp 
                         render_handler_tri.cpp render_handler_tri.h 
        gui            : fb.cpp gui.cpp 

Log message:
        Implemented clipping for AGG backend (speed gain)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler.h?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_agg.cpp?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_tri.cpp?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_tri.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/fb.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.21&r2=1.22

Patches:
Index: backend/render_handler.h
===================================================================
RCS file: /cvsroot/gnash/gnash/backend/render_handler.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- backend/render_handler.h    10 Oct 2006 10:23:55 -0000      1.6
+++ backend/render_handler.h    12 Oct 2006 18:59:00 -0000      1.7
@@ -35,7 +35,7 @@
 // 
 //
 
-/* $Id: render_handler.h,v 1.6 2006/10/10 10:23:55 strk Exp $ */
+/* $Id: render_handler.h,v 1.7 2006/10/12 18:59:00 udog Exp $ */
 
 #ifndef RENDER_HANDLER_H
 #define RENDER_HANDLER_H
@@ -208,6 +208,16 @@
        /// Delete the given bitmap info class.
        virtual void    delete_bitmap_info(bitmap_info* bi) = 0;
                
+  /// Sets the update region (called prior to begin_display). It is not 
+  /// required for all renderers. Parameters are world coordinates.
+  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;  
+               
        /// Bracket the displaying of a frame from a movie.
        //
        /// Fill the background color, and set up default

Index: backend/render_handler_agg.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/backend/render_handler_agg.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- backend/render_handler_agg.cpp      11 Oct 2006 22:31:17 -0000      1.18
+++ backend/render_handler_agg.cpp      12 Oct 2006 18:59:00 -0000      1.19
@@ -34,7 +34,7 @@
 // forward this exception.
  
 
-/* $Id: render_handler_agg.cpp,v 1.18 2006/10/11 22:31:17 strk Exp $ */
+/* $Id: render_handler_agg.cpp,v 1.19 2006/10/12 18:59:00 udog Exp $ */
 
 // Original version by Udo Giacomozzi and Hannes Mayr, 
 // INDUNET GmbH (www.indunet.it)
@@ -356,6 +356,11 @@
     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;
+
        agg_init();
   }
 
@@ -396,6 +401,7 @@
          
          // clear the stage using the background color   
          renderer_base rbase(*m_pixf);
+         rbase.clip_box(m_clip_xmin, m_clip_ymin, m_clip_xmax, m_clip_ymax);
     rbase.clear(agg::rgba8(background_color.m_r, background_color.m_g,
        background_color.m_b, background_color.m_a));
 
@@ -459,6 +465,9 @@
        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);       
+
     agg::path_storage path;
     agg::conv_stroke<agg::path_storage> stroke(path);
     stroke.width(1);
@@ -836,6 +845,9 @@
     agg::span_allocator<agg::rgba8> alloc;  // span allocator (?)
     agg_style_handler sh;               // holds fill style definitions
     
+    rasc.clip_box((double)m_clip_xmin, (double)m_clip_ymin, 
+      (double)m_clip_xmax, (double)m_clip_ymax);
+    
     // debug
     int edge_count=0;
     
@@ -922,6 +934,9 @@
       agg::renderer_base<PixelFormat> > ren_sl(rbase); // solid fills
     agg::path_storage agg_path;             // a path in the AGG world
     
+    ras.clip_box((double)m_clip_xmin, (double)m_clip_ymin, 
+      (double)m_clip_xmax, (double)m_clip_ymax);
+
     agg::conv_curve< agg::path_storage > curve(agg_path);    // to render 
curves
     agg::conv_stroke< agg::conv_curve < agg::path_storage > > 
       stroke(curve);  // to get an outline
@@ -991,6 +1006,9 @@
     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);
+      
     agg::path_storage path;
     point pnt, origin;
     
@@ -1249,6 +1267,44 @@
   }    // draw_shape_character_old
 
   
+  void world_to_pixel(int *x, int *y, const float world_x, const float 
world_y) 
+  {
+    *x = (int) (world_x * scale);
+    *y = (int) (world_y * scale);
+  }
+  
+  
+  virtual void set_invalidated_region(const rect bounds) {
+  
+    if (bounds.m_x_max - bounds.m_x_min > 1e10f) {
+    
+      // 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;
+      
+    } else {
+    
+      world_to_pixel(&m_clip_xmin, &m_clip_ymin, bounds.m_x_min, 
bounds.m_y_min);
+      world_to_pixel(&m_clip_xmax, &m_clip_ymax, bounds.m_x_max, 
bounds.m_y_max);
+      
+      // add 2 pixels (GUI does that too)
+      m_clip_xmin -= 2;
+      m_clip_ymin -= 2;
+      m_clip_xmax += 2;
+      m_clip_ymax += 2;
+  
+      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;
+      
+     }    
+  
+  }
+  
 private:  // private methods  
 
   /// Returns the cache manager instance of the given character definition.
@@ -1268,6 +1324,12 @@
   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;
+  
 };     // end class render_handler_agg
 
 

Index: backend/render_handler_tri.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/backend/render_handler_tri.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- backend/render_handler_tri.cpp      9 Oct 2006 07:50:18 -0000       1.5
+++ backend/render_handler_tri.cpp      12 Oct 2006 18:59:00 -0000      1.6
@@ -35,7 +35,7 @@
 // 
 //
 
-/* $Id: render_handler_tri.cpp,v 1.5 2006/10/09 07:50:18 strk Exp $ */
+/* $Id: render_handler_tri.cpp,v 1.6 2006/10/12 18:59:00 udog Exp $ */
 
 #include "render_handler_tri.h"
 
@@ -357,5 +357,10 @@
 } // get_cache_of
  
 
+void triangulating_render_handler::world_to_pixel(int *x, int *y, const float 
world_x, const float world_y) 
+{
+  assert(0); // not implemented (and currently not required for tri. renderers)
+}
+
 
 } // namespace gnash

Index: backend/render_handler_tri.h
===================================================================
RCS file: /cvsroot/gnash/gnash/backend/render_handler_tri.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- backend/render_handler_tri.h        9 Oct 2006 07:50:18 -0000       1.4
+++ backend/render_handler_tri.h        12 Oct 2006 18:59:00 -0000      1.5
@@ -35,7 +35,7 @@
 // 
 //
 
-/* $Id: render_handler_tri.h,v 1.4 2006/10/09 07:50:18 strk Exp $ */
+/* $Id: render_handler_tri.h,v 1.5 2006/10/12 18:59:00 udog Exp $ */
 
 #ifndef GNASH_RENDER_HANDLER_TRI_H
 #define GNASH_RENDER_HANDLER_TRI_H
@@ -139,6 +139,9 @@
   /// handler activates glyph textures by default.
   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);  
     
   // --- helper methods 
--------------------------------------------------------
   // These methods are called by draw_shape_character() and normally don't need

Index: gui/fb.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/gui/fb.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- gui/fb.cpp  12 Oct 2006 17:46:10 -0000      1.11
+++ gui/fb.cpp  12 Oct 2006 18:59:00 -0000      1.12
@@ -404,6 +404,16 @@
   // forward to renderer
   _renderer->set_invalidated_region(bounds);
   
+  if (bounds.m_x_max - bounds.m_x_min > 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.m_x_min, 
bounds.m_y_min);
   _renderer->world_to_pixel(&m_draw_maxx, &m_draw_maxy, bounds.m_x_max, 
bounds.m_y_max);
@@ -414,6 +424,8 @@
   m_draw_maxx = valid_x(m_draw_maxx+2);
   m_draw_maxy = valid_y(m_draw_maxy+2);
 
+  }
+
 #endif
   
 }

Index: gui/gui.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- gui/gui.cpp 12 Oct 2006 16:37:25 -0000      1.21
+++ gui/gui.cpp 12 Oct 2006 18:59:00 -0000      1.22
@@ -250,7 +250,7 @@
     // show frame on screen
        gui->renderBuffer();
        
-  };
+  }
   
   _last_invalidated_bounds = changed_bounds;
   




reply via email to

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