Refactor XShmImagePool to fit 4K and 8K frames more easily

XShmImagePool did not handle cases where the shared memory segment size
was limited. It put 2x frames (for double-buffering) into one segment,
and reserved 1.5x space in case the window is resized larger.

On modern Linux kernels (versions >= 3.16), the segment size is limited
to 256MB. But a single 8K frame is 127MB. So 127*2*1.5 = 380MB exceeds
this limit and will fallback to software rendering. Additionally, on
kernels older than 3.16 (~5.5% of users), the size is limited to 32MB,
which is just barely enough to fit a single 4K frame.

To address these issues, 2 changes are made:
* Each frame is put in a separate segment.
* The 1.5x margin is only added if it won't exceed the max segment size.

Also includes couple of bugfixes.

BUG=991633,1007278
R=rjkroege

Change-Id: I924f350b2ae8edeee3723d3cd9f1b3688d9e8f85
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1829655
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702514}
4 files changed