Use int when possible to calculate atlas indices in shaders.

On certain iOS devices half has a mantissa of only 10 bits, which is not
enough to perform the floating point trickery to get the lower bits
out of the "texture coordinates". Instead we use int if available, and
float if not available.

Also re-enables multitexturing for iOS and adds a sample which
stresses the issue, and a version of fontcache that tests multitexturing.

Bug: skia:7285
Change-Id: Ia541b6a418c1860c941071750ceb26459eb846ea
Reviewed-on: https://skia-review.googlesource.com/99800
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index f6c66db..d106023 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -277,20 +277,12 @@
             new GrDrawingManager(this, prcOptions, atlasTextContextOptions, &fSingleOwner));
 
     GrDrawOpAtlas::AllowMultitexturing allowMultitexturing;
-    switch (options.fAllowMultipleGlyphCacheTextures) {
-        case GrContextOptions::Enable::kDefault:
-#ifdef SK_BUILD_FOR_IOS
-            allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kNo;
-#else
-            allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kYes;
-#endif
-            break;
-        case GrContextOptions::Enable::kNo:
-            allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kNo;
-            break;
-        case GrContextOptions::Enable::kYes:
-            allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kYes;
-            break;
+    if (GrContextOptions::Enable::kNo == options.fAllowMultipleGlyphCacheTextures ||
+        // multitexturing supported only if range can represent the index + texcoords fully
+        !(fCaps->shaderCaps()->floatIs32Bits() || fCaps->shaderCaps()->integerSupport())) {
+        allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kNo;
+    } else {
+        allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kYes;
     }
     fAtlasGlyphCache = new GrAtlasGlyphCache(this, options.fGlyphCacheTextureMaximumBytes,
                                              allowMultitexturing);