Improve NVPR stroke accuracy to fix thick strokes

Set the "path stroke error bound" path parameter to 0.02 for all paths.
This means that the stroked path area will be within 98% of the stroke
width in path space.

This should fix many cases where NVPR stroked paths were visibly different to
Skia stroked paths. One such path is in dashcubics gm.

This increases the amount of subdivisions the path object creation will
make for paths that need it. This in turn will increase gpu object space
requirements sligthly. Both of these effects should be unnoticeable.

GL_NV_path_rendering.txt:
"""
    Every path object has a stroke approximation bound parameter
    (PATH_STROKE_BOUND_NV) that is a floating-point value /sab/ clamped
    between 0.0 and 1.0 and set and queried with the PATH_STROKE_BOUND_NV
    path parameter.  Exact determination of samples swept an orthogonal
    centered line segment along cubic Bezier segments and rational
    quadratic Bezier curves (so non-circular partial elliptical arcs) is
    intractable for real-time rendering so an approximation is required;
    /sab/ intuitively bounds the approximation error as a percentage of
    the path object's stroke width.  Specifically, this path parameter
    requests the implementation to stencil any samples within /sweep/
    object space units of the exact sweep of the path's cubic Bezier
    segments or partial elliptical arcs to be sampled by the stroke where

      sweep = ((1-sab)*sw)/2

    where /sw/ is the path object's stroke width.  The initial value
    of /sab/ when a path is created is 0.2.  In practical terms, this
    initial value means the stencil sample positions coverage within 80%
    (100%-20%) of the stroke width of cubic and rational quadratic stroke
    segments should be sampled.
"""

BUG=skia:2049

Review URL: https://codereview.chromium.org/1124423007
This commit is contained in:
kkinnunen 2015-05-18 22:25:47 -07:00 committed by Commit bot
parent d156d36af8
commit 55e4783b51
2 changed files with 2 additions and 0 deletions

View File

@ -838,6 +838,7 @@
#define GR_GL_PATH_END_CAPS 0x9076
#define GR_GL_PATH_JOIN_STYLE 0x9079
#define GR_GL_PATH_MITER_LIMIT 0x907A
#define GR_GL_PATH_STROKE_BOUND 0x9086
// fill modes
#define GR_GL_COUNT_UP 0x9088

View File

@ -178,6 +178,7 @@ void GrGLPath::InitPathObject(GrGLGpu* gpu,
GR_GL_CALL(gpu->glInterface(), PathParameteri(pathID, GR_GL_PATH_JOIN_STYLE, join));
GrGLenum cap = cap_to_gl_cap(stroke.getCap());
GR_GL_CALL(gpu->glInterface(), PathParameteri(pathID, GR_GL_PATH_END_CAPS, cap));
GR_GL_CALL(gpu->glInterface(), PathParameterf(pathID, GR_GL_PATH_STROKE_BOUND, 0.02f));
}
}