cairo: Use matrix to determine pattern size

https://bugs.freedesktop.org/show_bug.cgi?id=33364