Fixes drawImage for thumbs
Limit the size of canvases to 5MP (iOS restriction)
Cache pages at the start of drawing, not the end.
Fix mishandling of incomplete, inverted masks.
Merge pull request #4932 from nnethercote/cache-pages-earlier

Cache pages at the start of drawing, not the end.
Merge pull request #4924 from yurydelendik/fixthumb

Fixes drawImage for thumbs
Merge pull request #4933 from nnethercote/fix-4926-masking

Fix mishandling of incomplete, inverted masks.
Merge pull request #4834 from dferer/canvas-max-size

Limit the size of canvases to 5MP (iOS restriction)