clamp to 0 in repeat and mirror image tilers

If we were doing this math with real numbers or even just doubles, these
clamps wouldn't be necessary.  But we're favoring speed over accuracy
here when we emulate fmod() and some of those inaccuracies end up with
values outside the [0,tile) range, negative!

To keep the spirit of fast over 100% accurate, I've just added a safety
clamp to 0.  The case in the unit test now returns 0 where it should
really return something like 7 or 8, but at least we won't try to read
_way_ outside the image buffer.

BUG=chromium:749260

Change-Id: Ifc5cfe69798beccbb2a16547510158576e06eb3a
Reviewed-on: https://skia-review.googlesource.com/29580
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
4 files changed