Implement the "TODO" in
CairoOutputDev::tilingPatternFill, allowing it to handle tiling patterns where the bounding box dimensions don't match the step sizes. Cairo doesn't seem to support patterns that extend beyond their boundaries, so we need to create a new intermediate surface on which we tile the original pattern graphic so as to create a complete "unit cell" which we can then pass on to cairo as our final pattern.
This allows for much more efficient output when cairo is using a vector backend - rather than having to translate and draw the pattern across the entire tiled region, we can stop after we've finished a unit cell and then repeat that. For example, running the attached patterned PDF (colorgrid.pdf, 1976 bytes) through
pdftocairo -pdf now generates a 2493 byte output PDF versus 176KB with master.
I found the coordinate space transformation a bit tricky (there are several different coordinate spaces and various scale/translation operations to get right) - hopefully it is correct! I have a number of test PDFs I've made to probe different code paths and input scenarios which I'm happy to share as well.