Groundwork for nonlinear blending mode in Ganesh

Changing a bit of plumbing so we have what we need for one-off color
conversion, and fixing the logic in some of our surface validation.

Plenty more to come, want to submit this stuff in manageable chunks.

BUG=skia:6242

Change-Id: Iac9954c7cc490cc99663db4b9cdf5d6388fc39c7
Reviewed-on: https://skia-review.googlesource.com/9389
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 9fe813f..85d896a 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -10,6 +10,7 @@
 #include "GrContextPriv.h"
 #include "GrResourceProvider.h"
 #include "SkCanvas.h"
+#include "SkColorSpace_Base.h"
 #include "SkGpuDevice.h"
 #include "SkImage_Base.h"
 #include "SkImage_Gpu.h"
@@ -177,13 +178,15 @@
             return !colorSpace || colorSpace->gammaIsLinear();
         case kSRGBA_8888_GrPixelConfig:
         case kSBGRA_8888_GrPixelConfig:
-            return context->caps()->srgbSupport() && colorSpace && colorSpace->gammaCloseToSRGB();
+            return context->caps()->srgbSupport() && colorSpace && colorSpace->gammaCloseToSRGB() &&
+                   !as_CSB(colorSpace)->nonLinearBlending();
         case kRGBA_8888_GrPixelConfig:
         case kBGRA_8888_GrPixelConfig:
             // If we don't have sRGB support, we may get here with a color space. It still needs
             // to be sRGB-like (so that the application will work correctly on sRGB devices.)
             return !colorSpace ||
-                (!context->caps()->srgbSupport() && colorSpace->gammaCloseToSRGB());
+                (colorSpace->gammaCloseToSRGB() && (!context->caps()->srgbSupport() ||
+                                                    !as_CSB(colorSpace)->nonLinearBlending()));
         default:
             return !colorSpace;
     }