JDK-8170879 : Fix Quad / Cubic BND constants for Marlin (FX)
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-12-07
  • Updated: 2016-12-09
  • Resolved: 2016-12-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Fixed
Related Reports
Relates :  
Description
According to the nonAA quality tests, MarlinFX has larger error for quadratic curves than open pisces (avg 4px vs 2px).

As Marlin starts at count=1 (instead of 4) for quads, the QUAD_DEC_BND threshold has not the same impact as in Pisces.

See the attached (updated) TestNonAARasterization to use a fixed random seed (for better reproducibility)
Comments
And, for the record, I'd much rather have this big improvement in the quad accuracy than the small performance loss we see. Quads are rarely used anyway so cubic performance is probably more sensitive for 99.9% of apps and that remained just as fast as before the fix.
09-12-2016

There are a lot of plans for the curve subdivision that you've mentioned that will have an impact here (you mentioned breaking them down into manageable sizes of no more than XXX pixels at one point) that would impact here and I agree that we should look at that in 10.
09-12-2016

I agree the new approach (norm + thresholds) has an impact on performance but I considered it small compared to the quality improvement. Maybe we could revisit the curve intersection algorithm with scanlines for jdk10 as a follow-up bug ? In particular the current approach generates iteratively curve points with float/double coordinates that forms line segments that are finally accepted or rejected in addLine() (integer coordinates): this may represent a lot of work !
09-12-2016

Just to be clear, I was using a different internal micro-benchmark to test performance on Mac and Windows. I didn't notice that there was a benchmark attached to this bug...
09-12-2016

http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/41a01fa05f6a
09-12-2016

The windows results show that Marlin is still fastest for both quads and cubics. The cubic performance had very little impact from this fix, and while the quad performance took a more measurable hit, it was not a large hit and it is still faster than either variant of Pisces even with these newer equations and constants which make it much more accurate. +1 for the fix.
09-12-2016

The accuracy was improved by a lot by these changes, especially for quads, but also a little for cubics as well. On my Mac, though, the quad performance used to be higher than native pisces and is now a little slower than native pisces but still much faster than java-pisces and the accuracy of the new Marlin tuning parameters puts Marlin as much more accurate for quads than pisces. I'm sure if we used the same metrics in the pisces branches for improved accuracy of quads then Marlin would still be the fastest of the 3. I'm not going to adjust the tuning of the pisces branches since they have been working fine for a number of releases now, but I think it is a good step to move forward with Marlin with these new more accurate parameters and equations. Note that the performance:quality tradeoff of Marlin vs. native pisces is still an excellent ratio with Marlin being a lot more accurate than native pisces but only a little slower. I'll do a quick cross-check on Windows before I commit anything.
08-12-2016

Thanks, we'll take a look soon.
08-12-2016

Web review thread: http://mail.openjdk.java.net/pipermail/openjfx-dev/2016-December/020024.html
08-12-2016

First webrev: http://cr.openjdk.java.net/~lbourges/marlinFX/marlinFX-8170879.0/ This simple fix changes MarlinFX renderers: - use QUAD_DEC_BND=0.5 pixel - cleaned up comments about both CUBIC / QUAD BND that are really related to 2nd derivative (so expressed subpixels) - modified the subdivision condition to use the manhattan norm |ddx| + |ddy| instead of max( |ddx| , |ddy| ) to improve the average bad pixels from 2.1 to 1.6 (30% better) Quality tests after the fix: cubic: bad paths (59294/100000 == 59,29%, 94335 bad pixels (avg = 1,59), 3966 warnings (avg = 0,07) quad: bad paths (62916/100000 == 62,92%, 103818 bad pixels (avg = 1,65), 6514 warnings (avg = 0,10) I also fixed the RasterPerf test that did not really tested the nonAA performance as the antialiasing argument was hard-coded to true. Here are the latest results still showing that MarlinFX is still the fastest rasterizer (the fix caused only 3% slowdown on quads) 1656771 10x10 Rectangle native non-AA rasterizations took 2838.21ms, 583737.989789339 ops/sec 167656 100x100 Rectangle native non-AA rasterizations took 2988.26ms, 56104.89047137799 ops/sec 24657 300x300 Rectangle native non-AA rasterizations took 2999.07ms, 8221.548680090827 ops/sec 1095638 10x10 Ellipse native non-AA rasterizations took 2921.11ms, 375075.91292351193 ops/sec 141453 100x100 Ellipse native non-AA rasterizations took 2993.52ms, 47253.06662390764 ops/sec 23322 300x300 Ellipse native non-AA rasterizations took 2990.53ms, 7798.6176363387085 ops/sec 104167 100x100 Cubics native non-AA rasterizations took 2993.09ms, 34802.49508033504 ops/sec 179098 100x100 Quads native non-AA rasterizations took 2990.27ms, 59893.588204409636 ops/sec 697353 10x10 Rectangle native AA rasterizations took 2970.08ms, 234792.66551742714 ops/sec 69040 100x100 Rectangle native AA rasterizations took 2996.82ms, 23037.75335188633 ops/sec 15150 300x300 Rectangle native AA rasterizations took 3000.23ms, 5049.6128630138355 ops/sec 427194 10x10 Ellipse native AA rasterizations took 2984.12ms, 143155.77121563477 ops/sec 52642 100x100 Ellipse native AA rasterizations took 3000.88ms, 17542.187624963342 ops/sec 14141 300x300 Ellipse native AA rasterizations took 2999.32ms, 4714.735340010402 ops/sec 32264 100x100 Cubics native AA rasterizations took 3004.43ms, 10738.80902533925 ops/sec 65598 100x100 Quads native AA rasterizations took 2996.14ms, 21894.170499375865 ops/sec 2270203 10x10 Rectangle Java non-AA rasterizations took 2643.8ms, 858689.3864891444 ops/sec 130620 100x100 Rectangle Java non-AA rasterizations took 2933.28ms, 44530.355097365406 ops/sec 18158 300x300 Rectangle Java non-AA rasterizations took 2999.77ms, 6053.130740023402 ops/sec 1302146 10x10 Ellipse Java non-AA rasterizations took 2832.42ms, 459729.1362156742 ops/sec 115743 100x100 Ellipse Java non-AA rasterizations took 2980.09ms, 38838.759903224396 ops/sec 17448 300x300 Ellipse Java non-AA rasterizations took 3000.02ms, 5815.961226925154 ops/sec 90130 100x100 Cubics Java non-AA rasterizations took 2947.1ms, 30582.606630246682 ops/sec 153626 100x100 Quads Java non-AA rasterizations took 2981.04ms, 51534.36384617449 ops/sec 577864 10x10 Rectangle Java AA rasterizations took 2886.25ms, 200212.7327847553 ops/sec 49513 100x100 Rectangle Java AA rasterizations took 2997.83ms, 16516.280109279047 ops/sec 10649 300x300 Rectangle Java AA rasterizations took 2999.48ms, 3550.282048888474 ops/sec 396414 10x10 Ellipse Java AA rasterizations took 2984.77ms, 132812.2434894481 ops/sec 40773 100x100 Ellipse Java AA rasterizations took 2999.61ms, 13592.767059717762 ops/sec 10132 300x300 Ellipse Java AA rasterizations took 2999.64ms, 3377.7386619727704 ops/sec 28466 100x100 Cubics Java AA rasterizations took 3080.16ms, 9241.727702457016 ops/sec 48989 100x100 Quads Java AA rasterizations took 2900.38ms, 16890.545376812694 ops/sec 2837061 10x10 Rectangle Marlin non-AA rasterizations took 2773.42ms, 1022946.7588753236 ops/sec 217841 100x100 Rectangle Marlin non-AA rasterizations took 2560.12ms, 85090.15202412388 ops/sec 48999 300x300 Rectangle Marlin non-AA rasterizations took 2966.98ms, 16514.772597051546 ops/sec 1165498 10x10 Ellipse Marlin non-AA rasterizations took 2259.69ms, 515777.82793215 ops/sec 145263 100x100 Ellipse Marlin non-AA rasterizations took 2450.31ms, 59283.51922817929 ops/sec 31591 300x300 Ellipse Marlin non-AA rasterizations took 2868.11ms, 11014.57057086374 ops/sec 93796 100x100 Cubics Marlin non-AA rasterizations took 2760.0ms, 33984.057971014496 ops/sec 182128 100x100 Quads Marlin non-AA rasterizations took 2978.02ms, 61157.413314887075 ops/sec 803422 10x10 Rectangle Marlin AA rasterizations took 2411.52ms, 333159.9986730361 ops/sec 64034 100x100 Rectangle Marlin AA rasterizations took 2449.72ms, 26139.31388077005 ops/sec 20347 300x300 Rectangle Marlin AA rasterizations took 2996.04ms, 6791.297846490701 ops/sec 560302 10x10 Ellipse Marlin AA rasterizations took 2462.22ms, 227559.68191307035 ops/sec 52090 100x100 Ellipse Marlin AA rasterizations took 2436.22ms, 21381.484430798533 ops/sec 17032 300x300 Ellipse Marlin AA rasterizations took 2918.12ms, 5836.634545529314 ops/sec 39960 100x100 Cubics Marlin AA rasterizations took 2516.15ms, 15881.406116487491 ops/sec 53866 100x100 Quads Marlin AA rasterizations took 2426.0ms, 22203.627370156635 ops/sec
07-12-2016