gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash/backend render_handler_agg_style.h


From: Udo Giacomozzi
Subject: [Gnash-commit] gnash/backend render_handler_agg_style.h
Date: Fri, 27 Oct 2006 15:09:30 +0000

CVSROOT:        /cvsroot/gnash
Module name:    gnash
Changes by:     Udo Giacomozzi <udog>   06/10/27 15:09:30

Modified files:
        backend        : render_handler_agg_style.h 

Log message:
        Fixed radial gradients (quick hack)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_agg_style.h?cvsroot=gnash&r1=1.3&r2=1.4

Patches:
Index: render_handler_agg_style.h
===================================================================
RCS file: /cvsroot/gnash/gnash/backend/render_handler_agg_style.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- render_handler_agg_style.h  26 Oct 2006 16:34:02 -0000      1.3
+++ render_handler_agg_style.h  27 Oct 2006 15:09:30 -0000      1.4
@@ -90,10 +90,10 @@
 class image_accessor_clip_transp : public agg::image_accessor_clip<PixelFormat>
 {
 public:
-  image_accessor_clip_transp(const PixelFormat& pixf) : 
-    agg::image_accessor_clip<PixelFormat>::image_accessor_clip(pixf, 
-      agg::rgba8(255, 0, 0, 0))
+  image_accessor_clip_transp(const PixelFormat& pixf)  
   {
+    agg::image_accessor_clip<PixelFormat>::image_accessor_clip(pixf, 
+      agg::rgba8_pre(255, 0, 0, 0).premultiply());
   }
 };
 
@@ -107,6 +107,22 @@
 #define image_accessor_clip_transp agg::image_accessor_clone
 
 
+/// Quick hack to make radial gradients work properly. For some strange reason
+/// the xform matrix leads to incorrect results even if it is the same for
+/// linear gradients (which work). This implementation is sub-optimal because
+/// it adds two addition operations for each pixel(?), so this needs to be
+/// solved in another way (ie. calculate correct matrix)   
+class my_gradient_radial
+{
+  public:
+  static AGG_INLINE int calculate(int x, int y, int d)
+  {
+    x-=512; 
+    y-=512; 
+    return int(sqrt(x*x + y*y));
+  }
+};
+
 /// AGG bitmap fill style. There are quite a few combinations possible and so
 /// the class types are defined outside. The bitmap can be tiled or clipped.
 /// It can have any transformation matrix and color transform. Any pixel format
@@ -587,7 +603,8 @@
       typedef agg::rgba8 color_type;            
       typedef agg::span_allocator<color_type> span_allocator_type;
       typedef agg::span_interpolator_linear<agg::trans_affine> 
interpolator_type;
-      typedef agg::gradient_radial gradient_func_type;
+      //typedef agg::gradient_radial gradient_func_type;
+      typedef my_gradient_radial gradient_func_type;
       typedef gradient_func_type gradient_adaptor_type;
       typedef agg::gradient_lut<agg::color_interpolator<agg::rgba8>, 256> 
color_func_type;
       typedef agg::span_gradient<color_type,
@@ -599,7 +616,7 @@
         interpolator_type, gradient_func_type, gradient_adaptor_type, 
         color_func_type, sg_type> st_type;
       
-      st_type* st = new st_type(fs, mat, cx, 64);       
+      st_type* st = new st_type(fs, mat, cx, 64/2);  // div 2 because of 
my_gradient_radial     
         
       // NOTE: The value 64 is based on the bitmap texture used by other
       // Gnash renderers which is normally 64x64 pixels for linear gradients.  
     




reply via email to

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