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: Udo Giacomozzi
Subject: [Gnash-commit] gnash ChangeLog backend/render_handler.h backen...
Date: Wed, 18 Apr 2007 17:04:57 +0000

CVSROOT:        /cvsroot/gnash
Module name:    gnash
Changes by:     Udo Giacomozzi <udog>   07/04/18 17:04:56

Modified files:
        .              : ChangeLog 
        backend        : render_handler.h render_handler_agg.cpp 

Log message:
        renamed getPixel(); implemented getAveragePixel()

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2915&r2=1.2916
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler.h?cvsroot=gnash&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_agg.cpp?cvsroot=gnash&r1=1.71&r2=1.72

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnash/gnash/ChangeLog,v
retrieving revision 1.2915
retrieving revision 1.2916
diff -u -b -r1.2915 -r1.2916
--- ChangeLog   18 Apr 2007 16:18:37 -0000      1.2915
+++ ChangeLog   18 Apr 2007 17:04:56 -0000      1.2916
@@ -1,3 +1,11 @@
+2007-04-18 Udo Giacomozzi <address@hidden>
+
+       * backend/render_handler.h: renamed get_pixel() to getPixel() and
+         changed from void to bool return value
+       * backend/render_handler.h, backend/render_handler_agg.cpp: 
+         implemented getAveragePixel()
+       
+       
 2007-04-18 Sandro Santilli <address@hidden>
 
        * testsuite/MovieTester.h: add click() method.

Index: backend/render_handler.h
===================================================================
RCS file: /cvsroot/gnash/gnash/backend/render_handler.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- backend/render_handler.h    17 Apr 2007 09:00:26 -0000      1.32
+++ backend/render_handler.h    18 Apr 2007 17:04:56 -0000      1.33
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: render_handler.h,v 1.32 2007/04/17 09:00:26 strk Exp $ */
+/* $Id: render_handler.h,v 1.33 2007/04/18 17:04:56 udog Exp $ */
 
 #ifndef RENDER_HANDLER_H
 #define RENDER_HANDLER_H
@@ -490,17 +490,69 @@
     
        /// This function returns the color at any position in the stage. It is 
used
        /// for automatic testing only, it should not be used for anything else!
-       /// world_x and world_y are world coordinates (twips) and the color of 
the
-       /// nearest pixel is returned.
-       virtual void get_pixel(rgba& /*color_return*/, float /*world_x*/, 
-               float /*world_y*/)
+  /// x and y are pixel coordinates (<0 won't make any sense) and the color of 
+  /// the nearest pixel is returned.
+  /// The function returns false when the coordinates are outside the 
+  /// main frame buffer.
+  virtual bool getPixel(rgba& /*color_return*/, int /*x*/, int /*y*/)
        {
 
-               log_msg("get_pixel() not implemented for this renderer");
+    log_msg("getPixel() not implemented for this renderer");
                assert(0);    
+    return false; // avoid compiler warning    
+  }
+  
+  
+  /// Returns the average RGB color for a square block on the stage. The 
+  /// width and height of the block is defined by "radius" and x/y refer
+  /// to the center of the block. radius==1 equals getPixel() and radius==0
+  /// is illegal. For even "radius" values, the center point is not exactly
+  /// defined. 
+  /// The function returns false when at least one pixel of the block was
+  /// outside the main frame buffer. In that case the value in color_return
+  /// is undefined.
+  /// This implementation is provided for simplicity. Renderers should
+  /// implement a specialized version for better performance.
+  virtual bool getAveragePixel(rgba& color_return, int x, int y, 
+    unsigned int radius)
+  {
+  
+    assert(radius>0); 
+  
+    // optimization:
+    if (radius==1)
+      return getPixel(color_return, x, y);
+  
+    unsigned int r=0, g=0, b=0, a=0;
+    
+    x -= radius/2;
+    y -= radius/2;
 
+    int xe = x+radius-1;
+    int ye = y+radius-1;
+
+    rgba pixel;
+    
+    for (int yp=y; yp<ye; yp++)
+    for (int xp=x; xp<xe; xp++)
+    {
+      if (!getPixel(pixel, xp, yp))
+        return false;
+        
+      r += pixel.m_r;      
+      g += pixel.m_g;      
+      b += pixel.m_b;      
+      a += pixel.m_a;      
        }
 
+    int pcount = radius*radius; 
+    color_return.m_r = r / pcount; 
+    color_return.m_g = g / pcount; 
+    color_return.m_b = b / pcount; 
+    color_return.m_a = a / pcount; 
+    
+    return true;
+  }
        /// Sets the x/y scale for the movie  
        virtual void set_scale(float /*xscale*/, float /*yscale*/) {
                // nop

Index: backend/render_handler_agg.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/backend/render_handler_agg.cpp,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -b -r1.71 -r1.72
--- backend/render_handler_agg.cpp      17 Apr 2007 09:20:41 -0000      1.71
+++ backend/render_handler_agg.cpp      18 Apr 2007 17:04:56 -0000      1.72
@@ -16,7 +16,7 @@
 
  
 
-/* $Id: render_handler_agg.cpp,v 1.71 2007/04/17 09:20:41 udog Exp $ */
+/* $Id: render_handler_agg.cpp,v 1.72 2007/04/18 17:04:56 udog Exp $ */
 
 // Original version by Udo Giacomozzi and Hannes Mayr, 
 // INDUNET GmbH (www.indunet.it)
@@ -1876,10 +1876,10 @@
                return false;
   }
 
-  void get_pixel(rgba& color_return, float world_x, float world_y) {
-    int x, y;
+  bool getPixel(rgba& color_return, int x, int y) {
     
-    world_to_pixel(x, y, world_x, world_y);
+    if ((x<0) || (y<0) || (x>=xres) || (y=yres))
+      return false;
 
     agg::rgba8 color = m_pixf->pixel(x, y);    
     
@@ -1888,6 +1888,7 @@
     color_return.m_b = color.b;
     color_return.m_a = color.a;
     
+    return true;
   }
   
   void set_scale(float new_xscale, float new_yscale) {




reply via email to

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