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_agg.cpp ...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog backend/render_handler_agg.cpp ...
Date: Tue, 29 Apr 2008 11:29:06 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/04/29 11:29:05

Modified files:
        .              : ChangeLog 
        backend        : render_handler_agg.cpp render_handler_cairo.cpp 
                         render_handler_ogl.cpp 
        server         : DynamicShape.cpp DynamicShape.h 
                         FreetypeGlyphsProvider.cpp 
                         generic_character.cpp shape.h 
                         sprite_instance.cpp sprite_instance.h 
                         styles.cpp styles.h 
        server/parser  : character_def.h shape_character_def.cpp 
                         shape_character_def.h 
        testsuite/actionscript.all: MovieClip.as 

Log message:
                * backend/render_handler_agg.cpp, 
backend/render_handler_cairo.cpp,
                  backend/render_handler_ogl.cpp:
                  Update calls to fetch line_style strokes, implement 
noScale="none"
                  in AGG and log_unimpl in all renderers about unsupported 
values
                  of it.
                * server/parser/character_def.h,
                  server/parser/shape_character_def.{h,cpp},
                  server/generic_character.cpp:
                  Have point_test_local take an additional matrix argument
                  to deal with non-scaled strokes.
                * server/DynamicShape.{cpp,h}: have lineTo and curveTo take
                  an swf version argument, as influence of strokes on boundaries
                  are version-dependent.
                * server/FreetypeGlyphProvider.cpp: use SWF6 semantic for the 
glyph
                  shapes.
                * server/shape.{h,cpp} (expandBounds): take an swf version 
argument, as
                  influence of strokes on boundaries are version-dependent.
                * server/styles.{cpp,h}: add vertical and horizontal stroke
                  scaling flag support.
                * server/sprite_instance.{cpp,h}: Add support for noScale
                  parameter of lineStyle in SWF8.
                * testsuite/actionscript.all/MovieClip.as: success in bounds
                  checking of strokes in SWF8.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6441&r2=1.6442
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_agg.cpp?cvsroot=gnash&r1=1.136&r2=1.137
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_cairo.cpp?cvsroot=gnash&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_ogl.cpp?cvsroot=gnash&r1=1.110&r2=1.111
http://cvs.savannah.gnu.org/viewcvs/gnash/server/DynamicShape.cpp?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/server/DynamicShape.h?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/FreetypeGlyphsProvider.cpp?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/server/generic_character.cpp?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/server/shape.h?cvsroot=gnash&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.522&r2=1.523
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.187&r2=1.188
http://cvs.savannah.gnu.org/viewcvs/gnash/server/styles.cpp?cvsroot=gnash&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/gnash/server/styles.h?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/character_def.h?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/shape_character_def.cpp?cvsroot=gnash&r1=1.69&r2=1.70
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/shape_character_def.h?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/MovieClip.as?cvsroot=gnash&r1=1.129&r2=1.130

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6441
retrieving revision 1.6442
diff -u -b -r1.6441 -r1.6442
--- ChangeLog   29 Apr 2008 10:23:48 -0000      1.6441
+++ ChangeLog   29 Apr 2008 11:29:01 -0000      1.6442
@@ -1,3 +1,29 @@
+2008-04-29 Sandro Santilli <address@hidden>
+
+       * backend/render_handler_agg.cpp, backend/render_handler_cairo.cpp,
+         backend/render_handler_ogl.cpp: 
+         Update calls to fetch line_style strokes, implement noScale="none"
+         in AGG and log_unimpl in all renderers about unsupported values
+         of it.
+       * server/parser/character_def.h,
+         server/parser/shape_character_def.{h,cpp},
+         server/generic_character.cpp:
+         Have point_test_local take an additional matrix argument
+         to deal with non-scaled strokes.
+       * server/DynamicShape.{cpp,h}: have lineTo and curveTo take
+         an swf version argument, as influence of strokes on boundaries
+         are version-dependent.
+       * server/FreetypeGlyphProvider.cpp: use SWF6 semantic for the glyph
+         shapes.
+       * server/shape.{h,cpp} (expandBounds): take an swf version argument, as
+         influence of strokes on boundaries are version-dependent.
+       * server/styles.{cpp,h}: add vertical and horizontal stroke
+         scaling flag support.
+       * server/sprite_instance.{cpp,h}: Add support for noScale
+         parameter of lineStyle in SWF8.
+       * testsuite/actionscript.all/MovieClip.as: success in bounds
+         checking of strokes in SWF8.
+
 2008-04-29 Benjamin Wolsey <address@hidden>
 
        * server/asobj/Global.cpp: tidy up, register ASnative functions,

Index: backend/render_handler_agg.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_agg.cpp,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -b -r1.136 -r1.137
--- backend/render_handler_agg.cpp      23 Apr 2008 17:47:49 -0000      1.136
+++ backend/render_handler_agg.cpp      29 Apr 2008 11:29:02 -0000      1.137
@@ -1299,11 +1299,20 @@
        
       const line_style& lstyle = line_styles[this_path_gnash.m_line-1];
           
-      int width = lstyle.get_width();
-      if (width==1)
-        this_stroke->width(1);
+      int thickness = lstyle.getThickness();
+      if (!thickness) this_stroke->width(1); // hairline
+      else if ( (!lstyle.scaleThicknessVertically()) && 
(!lstyle.scaleThicknessHorizontally()) )
+      {
+        this_stroke->width(TWIPS_TO_PIXELS(thickness));
+      }
       else
-        this_stroke->width(width*stroke_scale);
+      {
+        if ( (!lstyle.scaleThicknessVertically()) || 
(!lstyle.scaleThicknessHorizontally()) )
+        {
+           LOG_ONCE( log_unimpl(_("Unidirectionally scaled strokes in AGG 
renderer (we'll scale by the scalable one)")) );
+        }
+        this_stroke->width(thickness*stroke_scale);
+      }
        
       this_stroke->attach(curve);
       this_stroke->line_cap(agg::round_cap);
@@ -1752,11 +1761,20 @@
         
         const line_style& lstyle = line_styles[this_path_gnash.m_line-1];
           
-        int width = lstyle.get_width();
-        if (width==1)
-          stroke.width(1);
+        int thickness = lstyle.getThickness();
+        if (!thickness) stroke.width(1); // hairline
+        else if ( (!lstyle.scaleThicknessVertically()) && 
(!lstyle.scaleThicknessHorizontally()) )
+        {
+          stroke.width(TWIPS_TO_PIXELS(thickness));
+        }
         else
-          stroke.width(std::max(1.0f, width*stroke_scale));
+        {
+          if ( (!lstyle.scaleThicknessVertically()) || 
(!lstyle.scaleThicknessHorizontally()) )
+          {
+             LOG_ONCE( log_unimpl(_("Unidirectionally scaled strokes in AGG 
renderer (we'll scale by the scalable one)")) );
+          }
+          stroke.width(std::max(1.0f, thickness*stroke_scale));
+        }
           
         stroke.line_cap(agg::round_cap);        
         stroke.line_join(agg::round_join); 

Index: backend/render_handler_cairo.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_cairo.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- backend/render_handler_cairo.cpp    14 Mar 2008 06:16:40 -0000      1.40
+++ backend/render_handler_cairo.cpp    29 Apr 2008 11:29:02 -0000      1.41
@@ -543,13 +543,21 @@
   
   void apply_line_style(const line_style& style, const cxform& cx)
   {
-    float width = style.get_width();
+    float width = style.getThickness();
 
     if ( width == 0.0 ) {
       // TODO: test this!
       cairo_set_line_width(_cr, 1.0); // expected: 1 pixel
     } else {
-      cairo_set_line_width(_cr, width);
+      // TODO: this is correct for !style.scaleThicknessVertically() 
+      //       and !style.scaleThicknessHorizontally().
+      //       If that's not the case, we should scale the thickness
+      //       togheter with the shapes.
+      if ( style.scaleThicknessVertically() || 
style.scaleThicknessHorizontally() )
+      {
+        LOG_ONCE( log_unimpl(_("Scaled strokes in Cairo renderer")) );
+      }
+      cairo_set_line_width(_cr, TWIPS_TO_PIXELS(width));
     }
     
     rgba color = cx.transform(style.get_color());

Index: backend/render_handler_ogl.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_ogl.cpp,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -b -r1.110 -r1.111
--- backend/render_handler_ogl.cpp      23 Apr 2008 14:29:36 -0000      1.110
+++ backend/render_handler_ogl.cpp      29 Apr 2008 11:29:02 -0000      1.111
@@ -1215,11 +1215,26 @@
     
     bool rv = true;
     
-    float width = style.get_width();
+    float width = style.getThickness();
+    float pointSize;
     
-    if (width <= 1.0f) {
+    if (!width)
+    {
       glLineWidth(1.0f);
-    } else {
+      rv = false; // Don't draw rounded lines.
+    }
+    else if ( (!style.scaleThicknessVertically()) && 
(!style.scaleThicknessHorizontally()) )
+    {
+      float pxThickness = TWIPS_TO_PIXELS(width);
+      glLineWidth(pxThickness);
+      glPointSize(pxThickness);
+    }
+    else
+    {
+      if ( (!style.scaleThicknessVertically()) || 
(!style.scaleThicknessHorizontally()) )
+      {
+         LOG_ONCE( log_unimpl(_("Unidirectionally scaled strokes in OGL 
renderer")) );
+      }
       
       float stroke_scale = fabsf(mat.get_x_scale()) + fabsf(mat.get_y_scale());
       stroke_scale /= 2.0f;
@@ -1232,20 +1247,22 @@
       glGetFloatv( GL_LINE_WIDTH_RANGE, width_info);          
       
       if (width > width_info[1]) {
-        log_error("Your OpenGL implementation does not support the line width" 
\
-                  " requested. Lines will be drawn with reduced width.");
+        LOG_ONCE( log_unimpl("Your OpenGL implementation does not support the 
line width" \
+                  " requested. Lines will be drawn with reduced width.") );
+        width = width_info[1];
       }
       
       
       glLineWidth(width);
-      
+      glPointSize(width);
+#if 0
       if (width >= 1.5) {
-        
         glPointSize(width-1);
       } else {
         // Don't draw rounded lines.
         rv = false;
       }
+#endif
       
       
     }

Index: server/DynamicShape.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/DynamicShape.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/DynamicShape.cpp     5 Mar 2008 03:55:58 -0000       1.18
+++ server/DynamicShape.cpp     29 Apr 2008 11:29:02 -0000      1.19
@@ -159,9 +159,9 @@
 }
 
 void
-DynamicShape::lineStyle(boost::uint16_t thickness, const rgba& color)
+DynamicShape::lineStyle(boost::uint16_t thickness, const rgba& color, bool 
vScale, bool hScale)
 {
-       line_style style(thickness, color);
+       line_style style(thickness, color, vScale, hScale);
        _currline = add_line_style(style);
        startNewPath(false); // don't make this the start of a new subshape (to 
verify)
 }
@@ -187,7 +187,7 @@
 }
 
 void
-DynamicShape::lineTo(float x, float y)
+DynamicShape::lineTo(float x, float y, int swfVersion)
 {
        if ( ! _currpath ) startNewPath(true); // first shape is always new (I 
hope this doesn't break anything)
        assert(_currpath);
@@ -195,11 +195,11 @@
        _currpath->drawLineTo(x, y);
 
        // Update bounds 
-       unsigned thickness = _currline ? m_line_styles[_currline-1].get_width() 
: 0;
+       unsigned thickness = _currline ? 
m_line_styles[_currline-1].getThickness() : 0;
        if ( _currpath->size() == 1 ) {
-               _currpath->expandBounds(m_bound, thickness);
+               _currpath->expandBounds(m_bound, thickness, swfVersion);
        } else {
-               m_bound.expand_to_circle(x, y, thickness);
+               m_bound.expand_to_circle(x, y, swfVersion < 8 ? thickness : 
thickness/2.0);
        }
 
        // Update current pen position
@@ -211,7 +211,7 @@
 }
 
 void
-DynamicShape::curveTo(float cx, float cy, float ax, float ay)
+DynamicShape::curveTo(float cx, float cy, float ax, float ay, int swfVersion)
 {
        if ( ! _currpath ) startNewPath(true); // first shape is always new (I 
hope this doesn't break anything)
        assert(_currpath);
@@ -219,12 +219,12 @@
        _currpath->drawCurveTo(cx, cy, ax, ay);
 
        // Update bounds 
-       unsigned thickness = _currline ? m_line_styles[_currline-1].get_width() 
: 0;
+       unsigned thickness = _currline ? 
m_line_styles[_currline-1].getThickness() : 0;
        if ( _currpath->size() == 1 ) {
-               _currpath->expandBounds(m_bound, thickness);
+               _currpath->expandBounds(m_bound, thickness, swfVersion);
        } else {
-               m_bound.expand_to_circle(ax, ay, thickness);
-               m_bound.expand_to_circle(cx, cy, thickness);
+               m_bound.expand_to_circle(ax, ay, swfVersion < 8 ? thickness : 
thickness/2.0);
+               m_bound.expand_to_circle(cx, cy, swfVersion < 8 ? thickness : 
thickness/2.0);
        }
 
        // Update current pen position

Index: server/DynamicShape.h
===================================================================
RCS file: /sources/gnash/gnash/server/DynamicShape.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/DynamicShape.h       27 Mar 2008 10:50:13 -0000      1.12
+++ server/DynamicShape.h       29 Apr 2008 11:29:02 -0000      1.13
@@ -42,12 +42,12 @@
        void moveTo(float x, float y);
 
        /// Draw a straight line from current position to given one
-       void lineTo(float x, float y);
+       void lineTo(float x, float y, int swfVersion);
 
        /// \brief
        /// Draw a curve from current position to given one
        /// using given control points.
-       void curveTo(float cx, float cy, float ax, float ay);
+       void curveTo(float cx, float cy, float ax, float ay, int swfVersion);
 
        /// Start drawing with a solid fill
        void beginFill(const rgba& color);
@@ -62,7 +62,7 @@
        void endFill();
 
        /// Set current line style and start a new path.
-       void lineStyle(boost::uint16_t thickness, const rgba& color);
+       void lineStyle(boost::uint16_t thickness, const rgba& color, bool 
vScale=true, bool hScale=true);
 
        /// Reset line style to no style and start a new path.
        void resetLineStyle();
@@ -106,10 +106,10 @@
        //       would result in a triangle and a stroke, which should fail the 
last hitTest(2,8).
        //
        //
-       bool point_test_local(float x, float y)
+       bool point_test_local(float x, float y, matrix& wm)
        {
                finalize();
-               return shape_character_def::point_test_local(x, y);
+               return shape_character_def::point_test_local(x, y, wm);
        }
 
        /// Add a path, updating _currpath and recomputing bounds
@@ -128,6 +128,10 @@
 
 private:
 
+       /// Movie definition containing the code 
+       /// that created this shape.
+       movie_definition* _mdef;
+
        /// Initialize a new path
        //
        /// Used when changing style or moving the pen

Index: server/FreetypeGlyphsProvider.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/FreetypeGlyphsProvider.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- server/FreetypeGlyphsProvider.cpp   17 Apr 2008 16:24:06 -0000      1.23
+++ server/FreetypeGlyphsProvider.cpp   29 Apr 2008 11:29:02 -0000      1.24
@@ -147,7 +147,8 @@
 #ifdef DEBUG_OUTLINE_DECOMPOSITION 
                log_debug("lineTo: %ld,%ld", to->x, to->y);
 #endif
-               _sh.lineTo(to->x*_scale, -to->y*_scale);
+               static const int swfVersion = 6; // we have no thickness, so 6 
is fine
+               _sh.lineTo(to->x*_scale, -to->y*_scale, swfVersion);
                return 0;
        }
 
@@ -157,7 +158,8 @@
 #ifdef DEBUG_OUTLINE_DECOMPOSITION 
                log_debug("conicTo: %ld,%ld %ld,%ld", ctrl->x, ctrl->y, to->x, 
to->y);
 #endif
-               _sh.curveTo(ctrl->x*_scale, -ctrl->y*_scale, to->x*_scale, 
-to->y*_scale);
+               static const int swfVersion = 6; // we have no thickness, so 6 
is fine
+               _sh.curveTo(ctrl->x*_scale, -ctrl->y*_scale, to->x*_scale, 
-to->y*_scale, swfVersion);
                return 0;
        }
 
@@ -171,7 +173,8 @@
                float x = ctrl1->x + ( (ctrl2->x - ctrl1->x) * 0.5 );
                float y = ctrl1->y + ( (ctrl2->y - ctrl1->y) * 0.5 );
 
-               _sh.curveTo(x*_scale, -y*_scale, to->x*_scale, -to->y*_scale);
+               static const int swfVersion = 6; // we have no thickness, so 6 
is fine
+               _sh.curveTo(x*_scale, -y*_scale, to->x*_scale, -to->y*_scale, 
swfVersion);
                return 0;
        }
 
@@ -457,7 +460,7 @@
 
        FT_Outline_Decompose(outline, &walk, &walker);
 #ifdef DEBUG_OUTLINE_DECOMPOSITION 
-       rect bound; sh->compute_bound(&bound);
+       rect bound; sh->compute_bound(&bound, VM::get().getSWFVersion());
        log_debug("Decomposed glyph for character '%c' has bounds %s", code, 
bound.toString().c_str());
 #endif
 

Index: server/generic_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/generic_character.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- server/generic_character.cpp        5 Mar 2008 03:55:59 -0000       1.14
+++ server/generic_character.cpp        29 Apr 2008 11:29:03 -0000      1.15
@@ -54,7 +54,7 @@
   matrix wm = get_world_matrix();
   point lp(x, y);
   wm.transform_by_inverse(lp);
-  return m_def->point_test_local(lp.x, lp.y);
+  return m_def->point_test_local(lp.x, lp.y, wm);
 }
 
 

Index: server/shape.h
===================================================================
RCS file: /sources/gnash/gnash/server/shape.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- server/shape.h      27 Mar 2008 10:50:15 -0000      1.40
+++ server/shape.h      29 Apr 2008 11:29:03 -0000      1.41
@@ -21,9 +21,10 @@
 
 #include "dsodefs.h"
 #include "styles.h"
+#include "rect.h"
+#include "log.h"
 
 #include <vector> // for path composition
-#include "rect.h"
 #include <boost/bind.hpp>  
 #include <algorithm>
 
@@ -323,10 +324,14 @@
     ///
     /// @param thickness
     ///  The thickess of our lines, half the thickness will
-    ///  be added in all directions
+    ///  be added in all directions in swf8+, all of it will
+    ///  in swf7-
+    ///
+    /// @param swfVersion
+    ///  SWF version to use.
     ///
     void
-    expandBounds(rect& r, unsigned int thickness) const
+    expandBounds(rect& r, unsigned int thickness, int swfVersion) const
     {
       const Path<T>&  p = *this;
 
@@ -338,7 +343,7 @@
         // NOTE: Half of thickness would be enough (and correct) for
         // radius, but that would not match how Flash calculates the
         // bounds using the drawing API.                        
-        unsigned int radius = thickness;
+        unsigned int radius = swfVersion < 8 ? thickness : thickness/2.0;
 
         r.expand_to_circle(ap.x, ap.y, radius);
         for (unsigned int j = 0; j<nedges; j++)
@@ -440,6 +445,8 @@
     bool
     withinSquareDistance(const Point2d<float>& p, float dist) const
     {
+//#define GNASH_DEBUG_PATH_DISTANCE 1
+
       size_t nedges = m_edges.size();
 
       if ( ! nedges ) return false;
@@ -453,10 +460,16 @@
         if ( e.isStraight() )
         {
           float d = Edge<float>::squareDistancePtSeg(p, px, np);
+#ifdef GNASH_DEBUG_PATH_DISTANCES
+         log_debug("squaredDistance %s-%s to %s == %g (asked for %g)", px, np, 
p, d, dist);
+#endif
           if ( d < dist ) return true;
         }
         else
         {
+#ifdef GNASH_DEBUG_PATH_DISTANCES
+         log_debug("edge %d is a curve", i);
+#endif // DEBUG_MOUSE_ENTITY_FINDING
           // It's a curve !
 
           const int_point& A = px;
@@ -485,6 +498,10 @@
             // of the curve 
             float d = Edge<T>::squareDistancePtSeg(p, p0, p1);
 
+#ifdef GNASH_DEBUG_PATH_DISTANCES
+            log_debug("squaredDistance (curve)%s-%s-%s to %s == %g (asked for 
%g)", A, C, B, p, d, dist);
+#endif // DEBUG_MOUSE_ENTITY_FINDING
+
             //float d = edge::squareDistancePtCurve(A, C, B, p, t);
             //log_debug("Factor %26.26g, distance %g (asked %g)", t, sqrt(d), 
sqrt(dist));
             if ( d <= dist ) return true;

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.522
retrieving revision 1.523
diff -u -b -r1.522 -r1.523
--- server/sprite_instance.cpp  28 Apr 2008 13:39:12 -0000      1.522
+++ server/sprite_instance.cpp  29 Apr 2008 11:29:03 -0000      1.523
@@ -1356,6 +1356,8 @@
   }
 
   thickness = 
boost::uint16_t(PIXELS_TO_TWIPS(boost::uint16_t(fclamp(fn.arg(0).to_number(), 
0, 255))));
+  bool scaleThicknessVertically = true;
+  bool scaleThicknessHorizontally = true;
 
   if ( fn.nargs > 1 )
   {
@@ -1382,11 +1384,41 @@
         }
         else
         {
-          log_unimpl(_("pixelHinting arg to MovieClip.lineStyle"));
-          if ( fn.nargs > 4 ) log_unimpl(_("noScale arg to 
MovieClip.lineStyle"));
-          if ( fn.nargs > 5 ) log_unimpl(_("capsStyle arg to 
MovieClip.lineStyle"));
-          if ( fn.nargs > 6 ) log_unimpl(_("jointStyle arg to 
MovieClip.lineStyle"));
-          if ( fn.nargs > 7 ) log_unimpl(_("miterLimit arg to 
MovieClip.lineStyle"));
+          bool pixelHinting = fn.arg(3).to_bool();
+          if ( pixelHinting) LOG_ONCE( log_unimpl(_("pixelHinting in 
MovieClip.lineStyle")) );
+          if ( fn.nargs > 4 )
+          {
+            std::string noScaleString = fn.arg(4).to_string();
+            if ( noScaleString == "none" )
+            {
+              scaleThicknessVertically = scaleThicknessHorizontally = false;
+            }
+            else if ( noScaleString == "vertical" )
+            {
+              scaleThicknessVertically = false;
+              scaleThicknessHorizontally = true;
+            }
+            else if ( noScaleString == "horizontal" )
+            {
+              scaleThicknessVertically = true;
+              scaleThicknessHorizontally = false;
+            }
+            else if ( noScaleString == "normal" )
+            {
+              scaleThicknessVertically = true;
+              scaleThicknessHorizontally = true;
+            }
+            else
+            {
+              IF_VERBOSE_ASCODING_ERRORS(
+              std::stringstream ss; fn.dump_args(ss);
+              log_aserror(_("MovieClip.lineStyle(%s): invalid noScale value 
'%s'"), ss.str(), noScaleString);
+              );
+            }
+          }
+          if ( fn.nargs > 5 ) LOG_ONCE( log_unimpl(_("capsStyle arg to 
MovieClip.lineStyle")) );
+          if ( fn.nargs > 6 ) LOG_ONCE( log_unimpl(_("jointStyle arg to 
MovieClip.lineStyle")) );
+          if ( fn.nargs > 7 ) LOG_ONCE( log_unimpl(_("miterLimit arg to 
MovieClip.lineStyle")) );
           IF_VERBOSE_ASCODING_ERRORS(
           if ( fn.nargs > 8 ) 
           {
@@ -1406,7 +1438,7 @@
 #ifdef DEBUG_DRAWING_API
   log_debug("%s.lineStyle(%d,%d,%d,%d);", sprite->getTarget(), thickness, r, 
g, b);
 #endif
-  sprite->lineStyle(thickness, color);
+  sprite->lineStyle(thickness, color, scaleThicknessVertically, 
scaleThicknessHorizontally);
 
   return as_value();
 }
@@ -2304,7 +2336,7 @@
   character(parent, id),
   m_root(r),
   m_display_list(),
-  _drawable(new DynamicShape),
+  _drawable(new DynamicShape()),
   _drawable_inst(_drawable->create_character_instance(this, 0)),
   //m_goto_frame_action_list(),
   m_play_state(PLAY),

Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -b -r1.187 -r1.188
--- server/sprite_instance.h    27 Apr 2008 18:13:15 -0000      1.187
+++ server/sprite_instance.h    29 Apr 2008 11:29:03 -0000      1.188
@@ -682,9 +682,9 @@
 
        /// @{ Drawing API
        
-       void lineStyle(boost::uint16_t thickness, const rgba& color)
+       void lineStyle(boost::uint16_t thickness, const rgba& color, bool 
vScale=true, bool hScale=true)
        {
-               _drawable->lineStyle(thickness, color);
+               _drawable->lineStyle(thickness, color, vScale, hScale);
        }
 
        void resetLineStyle()
@@ -720,13 +720,13 @@
        void lineTo(float x, float y)
        {
                set_invalidated();
-               _drawable->lineTo(x, y);
+               _drawable->lineTo(x, y, getSWFVersion());
        }
 
        void curveTo(float cx, float cy, float ax, float ay)
        {
                set_invalidated();
-               _drawable->curveTo(cx, cy, ax, ay);
+               _drawable->curveTo(cx, cy, ax, ay, getSWFVersion());
        }
 
        void clear()

Index: server/styles.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/styles.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- server/styles.cpp   28 Apr 2008 13:23:27 -0000      1.38
+++ server/styles.cpp   29 Apr 2008 11:29:04 -0000      1.39
@@ -26,7 +26,9 @@
 line_style::line_style()
     :
     m_width(0),
-    m_color()
+    m_color(),
+    _scaleVertically(true),
+    _scaleHorizontally(true)
 {
 }
 
@@ -55,13 +57,13 @@
        boost::uint8_t caps = in->read_uint(2);
        // 0 -- Round join, 1 -- Bevel join, 2 -- Miter join
        boost::uint8_t joins = in->read_uint(2);
-       bool has_fill = in->read_uint(1);
-       bool no_hscale = in->read_uint(1);
-       bool no_vscale = in->read_uint(1);
-       bool pixel_hinting = in->read_uint(1);
+       bool has_fill = in->read_bit();
+       _scaleHorizontally = ! in->read_bit();
+       _scaleVertically = ! in->read_bit();
+       bool pixel_hinting = in->read_bit();
 
        static_cast<void> (in->read_uint(5));
-       bool no_close = in->read_uint(1);
+       bool no_close = in->read_bit();
        bool end_cap_style = in->read_uint(2); // As caps above.
 
        if (joins == 2)
@@ -107,8 +109,8 @@
        // 0 -- Round join, 1 -- Bevel join, 2 -- Miter join
        boost::uint8_t joins = in->read_uint(2);
        bool has_fill = in->read_bit();
-       bool no_hscale = in->read_bit();
-       bool no_vscale = in->read_bit();
+       _scaleHorizontally = ! in->read_bit();
+       _scaleVertically = ! in->read_bit();
        bool pixel_hinting = in->read_bit();
        static_cast<void> (in->read_uint(5));
        bool no_close = in->read_bit();
@@ -137,8 +139,16 @@
 void
 line_style::set_lerp(const line_style& ls1, const line_style& ls2, float ratio)
 {
-       m_width = (boost::uint16_t)frnd(flerp(ls1.get_width(), ls2.get_width(), 
ratio));
+       m_width = (boost::uint16_t)frnd(flerp(ls1.getThickness(), 
ls2.getThickness(), ratio));
        m_color.set_lerp(ls1.get_color(), ls2.get_color(), ratio);
+       if ( ls1._scaleVertically != ls2._scaleVertically )
+       {
+               LOG_ONCE( log_error("UNTESTED: Dunno how to interpolate line 
styles with different vertical thickness scaling") );
+       }
+       if ( ls1._scaleHorizontally != ls2._scaleHorizontally )
+       {
+               LOG_ONCE( log_error("UNTESTED: Dunno how to interpolate line 
styles with different horizontal thickness scaling") );
+       }
 }
 
 

Index: server/styles.h
===================================================================
RCS file: /sources/gnash/gnash/server/styles.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- server/styles.h     28 Apr 2008 13:23:27 -0000      1.25
+++ server/styles.h     29 Apr 2008 11:29:04 -0000      1.26
@@ -34,10 +34,12 @@
        /// @param color
        ///     Line color
        ///
-       line_style(boost::uint16_t width, const rgba& color)
+       line_style(boost::uint16_t width, const rgba& color, bool 
scaleThicknessVertically, bool scaleThicknessHorizontally)
                :
                m_width(width),
-               m_color(color)
+               m_color(color),
+               _scaleVertically(scaleThicknessVertically),
+               _scaleHorizontally(scaleThicknessHorizontally)
        {
        }
 
@@ -57,7 +59,22 @@
                line_style *pOther);
 
        /// Return thickness of the line, in TWIPS
-       boost::uint16_t get_width() const { return m_width; }
+       boost::uint16_t getThickness() const
+       {
+               return m_width;
+       }
+
+       /// Return true if line thickness should be scaled vertically
+       bool scaleThicknessVertically() const
+       {
+               return _scaleVertically;
+       }
+
+       /// Return true if line thickness should be scaled horizontally
+       bool scaleThicknessHorizontally() const
+       {
+               return _scaleHorizontally;
+       }
 
        /// Return line color and alpha
        const rgba&     get_color() const { return m_color; }
@@ -81,6 +98,8 @@
        
        boost::uint16_t m_width;        // in TWIPS
        rgba    m_color;
+       bool _scaleVertically;
+       bool _scaleHorizontally;
 };
 
 } // namespace gnash

Index: server/parser/character_def.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/character_def.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- server/parser/character_def.h       21 Jan 2008 20:56:00 -0000      1.17
+++ server/parser/character_def.h       29 Apr 2008 11:29:04 -0000      1.18
@@ -30,6 +30,7 @@
 namespace gnash {
        class character;
        class cache_options;
+       class matrix;
        class rect;
 }
 
@@ -71,7 +72,11 @@
        //
        /// Point coordinates are local coords (TWIPS)
        ///
-       virtual bool point_test_local(float /*x*/, float /*y*/)
+       /// @param wm
+       ///     Current world matrix of the instance we want to check.
+       ///     This is needed to properly scale non-scalable strokes.
+       ///
+       virtual bool point_test_local(float /*x*/, float /*y*/, matrix& /*wm*/)
        {
                return false;
        }

Index: server/parser/shape_character_def.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/shape_character_def.cpp,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- server/parser/shape_character_def.cpp       21 Apr 2008 11:27:45 -0000      
1.69
+++ server/parser/shape_character_def.cpp       29 Apr 2008 11:29:04 -0000      
1.70
@@ -573,13 +573,13 @@
         {
             // TODO: performance would be improved by computing
             //       the bounds as edges are parsed.
-            compute_bound(&m_bound);
+            compute_bound(&m_bound, m->get_version());
         }
 #ifdef GNASH_DEBUG_SHAPE_BOUNDS
         else
         {
             rect computedBounds;
-            compute_bound(&computedBounds);
+            compute_bound(&computedBounds, m->get_version());
             if ( computedBounds != m_bounds )
             {
                 log_debug("Shape character read for tag %d contained embedded 
bounds %s, while we computed bounds %s",
@@ -868,9 +868,7 @@
         return count;
     }
 
-    bool  shape_character_def::point_test_local(float x, float y)
-    // Return true if the specified point is on the interior of our shape.
-    // Incoming coords are local coords.
+    bool  shape_character_def::point_test_local(float x, float y, matrix& wm)
     {
 
         //#define DEBUG_POINT_TEST
@@ -913,7 +911,11 @@
 
         if (m_bound.point_test(x, y) == false)
         {
-            // Early out.
+            // TODO: not sure it is safe to early-out
+            //       if line strokes are non-scalable !
+#ifdef DEBUG_POINT_TEST
+            log_debug("Point doesn't hit bounds, early out");
+#endif
             return false;
         }
 
@@ -963,21 +965,30 @@
 
                 line_style& ls = m_line_styles[pth.m_line-1];
 
-                int thickness = ls.get_width();
-                float sqdist;
+                float thickness = ls.getThickness();
 
-                if (thickness == 0)
+                if (! thickness )
                 {
-                    // hairline has always a tolerance of a single twip
-                    sqdist = 1;
+                       thickness = 1; 
                 }
-                else
+               else if ( (!ls.scaleThicknessVertically()) && 
(!ls.scaleThicknessHorizontally()) )
                 {
-                    float dist = thickness/2;
-                    sqdist = dist*dist;
+                       // TODO: pass the matrix to withinSquareDistance 
instead ?
+                       float xScale = wm.get_x_scale();
+                       float yScale = wm.get_y_scale();
+                       //log_debug("xScale: %g, yScale: %g", xScale, yScale);
+
+                       thickness /= std::max(xScale, yScale);
                 }
+               else if ( ls.scaleThicknessVertically() != 
ls.scaleThicknessHorizontally() )
+               {
+                       LOG_ONCE( log_unimpl("Collision detection for 
unidirectionally scaled strokes") );
+               }
+
+               float dist = thickness/2.0;
+               float sqdist = dist*dist;
 
-                //cout << "Thickness of line is " << thickness << " squared is 
" << sqdist << endl;
+                //log_debug("Thickness of line is %g squared is %g", 
thickness, sqdist);
                 if (pth.withinSquareDistance(pt, sqdist))
                     return true;
             }
@@ -1142,9 +1153,9 @@
         return m_bound.width();
     }
 
-    void  shape_character_def::compute_bound(rect* r) const
     // Find the bounds of this shape, and store them in
     // the given rectangle.
+    void  shape_character_def::compute_bound(rect* r, int swfVersion) const
     {
         r->set_null();
 
@@ -1166,10 +1177,10 @@
                 }
                 else
                 {
-                    thickness = m_line_styles[p.m_line-1].get_width();
+                    thickness = m_line_styles[p.m_line-1].getThickness();
                 }
             }
-            p.expandBounds(*r, thickness);
+            p.expandBounds(*r, thickness, swfVersion);
         }
     }
 

Index: server/parser/shape_character_def.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/shape_character_def.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- server/parser/shape_character_def.h 21 Apr 2008 11:27:45 -0000      1.22
+++ server/parser/shape_character_def.h 29 Apr 2008 11:29:05 -0000      1.23
@@ -40,7 +40,13 @@
                virtual ~shape_character_def();
 
                virtual void    display(character* inst);
-               virtual bool point_test_local(float x, float y);
+
+               /// Return true if the specified point is on the interior of 
our shape.
+               //
+               /// Incoming coords are local coords (twips).
+               /// The matrix will be used for lines with non-scalable strokes.
+               ///
+               virtual bool point_test_local(float x, float y, matrix& wm);
 
                float   get_height_local() const;
                float   get_width_local() const;
@@ -81,7 +87,7 @@
                const rect&     get_bound() const { return m_bound; }
 
                /// Compute bounds by looking at the component paths
-               void    compute_bound(rect* r) const;
+               void    compute_bound(rect* r, int swfVersion) const;
 
                const FillStyleVect& get_fill_styles() const { return 
m_fill_styles; }
                const LineStyleVect& get_line_styles() const { return 
m_line_styles; }

Index: testsuite/actionscript.all/MovieClip.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/MovieClip.as,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -b -r1.129 -r1.130
--- testsuite/actionscript.all/MovieClip.as     29 Apr 2008 06:10:02 -0000      
1.129
+++ testsuite/actionscript.all/MovieClip.as     29 Apr 2008 11:29:05 -0000      
1.130
@@ -20,9 +20,9 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: MovieClip.as,v 1.129 2008/04/29 06:10:02 strk Exp $";
+rcsid="$Id: MovieClip.as,v 1.130 2008/04/29 11:29:05 strk Exp $";
 
-rcsid="$Id: MovieClip.as,v 1.129 2008/04/29 06:10:02 strk Exp $";
+rcsid="$Id: MovieClip.as,v 1.130 2008/04/29 11:29:05 strk Exp $";
 #include "check.as"
 
 // To be called at end of test
@@ -1208,10 +1208,13 @@
  check_equals(draw._height, 40);
 #else
  // SWF8 results are more correct (half-thickness added on each side)
- xcheck_equals(draw._width, 20);
- xcheck_equals(draw._height, 30);
+ check_equals(draw._width, 20);
+ check_equals(draw._height, 30);
 #endif
 
+// TODO: check bounds of non-scaled strokes 
+//       relative to a container which is scaled
+
 #endif // OUTPUT_VERSION >= 6
 
 //----------------------------------------------




reply via email to

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