Revert "Revert "Add integer texture support.""

This reverts commit 9c7edb8311409a141b0dc1d5e480c68c629f1997.

Fixes ASAN errors

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4736

Change-Id: I1b1dae754d357b01da7169c8e7c59d7d8d8a10f6
Reviewed-on: https://skia-review.googlesource.com/4736
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index ff8de9d..71203d6 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -266,11 +266,15 @@
 
     bool applyPremulToSrc = false;
     if (kUnpremul_PixelOpsFlag & pixelOpsFlags) {
-        if (!GrPixelConfigIs8888(srcConfig)) {
+        if (!GrPixelConfigIs8888Unorm(srcConfig)) {
             return false;
         }
         applyPremulToSrc = true;
     }
+    // We don't allow conversion between integer configs and float/fixed configs.
+    if (GrPixelConfigIsSint(surface->config()) != GrPixelConfigIsSint(srcConfig)) {
+        return false;
+    }
 
     GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference;
     // Don't prefer to draw for the conversion (and thereby access a texture from the cache) when
@@ -411,10 +415,14 @@
     }
 
     bool unpremul = SkToBool(kUnpremul_PixelOpsFlag & flags);
-    if (unpremul && !GrPixelConfigIs8888(dstConfig)) {
+    if (unpremul && !GrPixelConfigIs8888Unorm(dstConfig)) {
         // The unpremul flag is only allowed for 8888 configs.
         return false;
     }
+    // We don't allow conversion between integer configs and float/fixed configs.
+    if (GrPixelConfigIsSint(src->config()) != GrPixelConfigIsSint(dstConfig)) {
+        return false;
+    }
 
     GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference;
     // Don't prefer to draw for the conversion (and thereby access a texture from the cache) when
@@ -540,6 +548,11 @@
     ASSERT_OWNED_RESOURCE(src);
     ASSERT_OWNED_RESOURCE(dst);
 
+    // We don't allow conversion between integer configs and float/fixed configs.
+    if (GrPixelConfigIsSint(dst->config()) != GrPixelConfigIsSint(src->config())) {
+        return false;
+    }
+
     if (!dst->asRenderTarget()) {
         SkIRect clippedSrcRect;
         SkIPoint clippedDstPoint;
@@ -683,6 +696,7 @@
         kRGBA_8888_GrPixelConfig,      // kBGRA_8888_GrPixelConfig
         kUnknown_GrPixelConfig,        // kSRGBA_8888_GrPixelConfig
         kSRGBA_8888_GrPixelConfig,     // kSBGRA_8888_GrPixelConfig
+        kUnknown_GrPixelConfig,        // kRGBA_8888_sint_GrPixelConfig
         kUnknown_GrPixelConfig,        // kETC1_GrPixelConfig
         kUnknown_GrPixelConfig,        // kLATC_GrPixelConfig
         kUnknown_GrPixelConfig,        // kR11_EAC_GrPixelConfig
@@ -702,13 +716,14 @@
     GR_STATIC_ASSERT(6  == kBGRA_8888_GrPixelConfig);
     GR_STATIC_ASSERT(7  == kSRGBA_8888_GrPixelConfig);
     GR_STATIC_ASSERT(8  == kSBGRA_8888_GrPixelConfig);
-    GR_STATIC_ASSERT(9  == kETC1_GrPixelConfig);
-    GR_STATIC_ASSERT(10  == kLATC_GrPixelConfig);
-    GR_STATIC_ASSERT(11  == kR11_EAC_GrPixelConfig);
-    GR_STATIC_ASSERT(12 == kASTC_12x12_GrPixelConfig);
-    GR_STATIC_ASSERT(13 == kRGBA_float_GrPixelConfig);
-    GR_STATIC_ASSERT(14 == kAlpha_half_GrPixelConfig);
-    GR_STATIC_ASSERT(15 == kRGBA_half_GrPixelConfig);
+    GR_STATIC_ASSERT(9  == kRGBA_8888_sint_GrPixelConfig);
+    GR_STATIC_ASSERT(10 == kETC1_GrPixelConfig);
+    GR_STATIC_ASSERT(11 == kLATC_GrPixelConfig);
+    GR_STATIC_ASSERT(12 == kR11_EAC_GrPixelConfig);
+    GR_STATIC_ASSERT(13 == kASTC_12x12_GrPixelConfig);
+    GR_STATIC_ASSERT(14 == kRGBA_float_GrPixelConfig);
+    GR_STATIC_ASSERT(15 == kAlpha_half_GrPixelConfig);
+    GR_STATIC_ASSERT(16 == kRGBA_half_GrPixelConfig);
     GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFallback) == kGrPixelConfigCnt);
 }