« Return to Thread: Problems with outline rasterizer

Re: Problems with outline rasterizer

by jbarbara :: Rate this Message:

Reply to Author | View in Thread

Thanks!

This fix just fixed an outline text issue I was having where all lowercase i's and l's outline didn't not appear.  Must have been optimized away!

I had only just started digging into the code when I saw this post thought I would give it a try!

Joe

Jim Barry-2 wrote:
Hi Folks,

I noticed that the outline rasterizer fails to draw empty (or nearly-empty) rectangles. For example, consider a rectangle with vertices ABCD and zero height. The sequence of events goes like this:

1) Add vertex A to path. Vertex list is now "A".

2) Add vertex B to path. Vertex list is now "AB".

3) Add vertex C to path - A and B are coincident so vertex B is removed. Vertex list is now "AC".

4) Add vertex D to path. Vertex list is now "ACD".

5) Process path_cmd_end_poly:
 - rasterizer_outline_aa<>::render closes the path
 - vertex_sequence<>::close sees that C and D are coincident and removes vertex C
 - Vertex list is now "AD"
 - rasterizer_outline_aa<>::render no-ops because vertex count < 3

I propose changing the logic in rasterizer_outline_aa<>::render from this:

  if(close_polygon)
  {
    if(m_src_vertices.size() >= 3)
    {
       // ...
    }
  }
  else
  // ...

to this:

  if(close_polygon && (m_src_vertices.size() >= 3))
  {
    // ...
  }
  else
  // ...

Now the zero-height rectangle will be drawn as a line. Does this seem like a reasonable fix, or might it cause other problems?

Also, the outline rasterizer will "optimize" away rectangles with single-pixel width/height, because it considers points at a distance of 1.5 times the subpixel scale or closer to be coincident. Presumably Maxim had a reason for choosing this threshold, but I propose changing line_aa_vertex::operator() from this:

  bool operator () (const line_aa_vertex& val)
  {
    float_type dx = val.x - x;
    float_type dy = val.y - y;
    return (len = uround(sqrt(dx * dx + dy * dy))) >
      (line_subpixel_scale + line_subpixel_scale / 2);
  }

to this:

  bool operator () (const line_aa_vertex& val)
  {
    float_type dx = val.x - x;
    float_type dy = val.y - y;
    return (len = uround(sqrt(dx * dx + dy * dy))) >= line_subpixel_scale;
  }

Comments?

- Jim

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

 « Return to Thread: Problems with outline rasterizer