Various fixes for linear blending and gradients

With linear blending turned off some textures were still
created as sRGB textures instead of linear textures.
Multi-stop gradients were not behaving properly on devices
with no support for float textures.
Gradients are now always interpolated in linear space
even if linear blending is off.
New functions to always force sRGB->linear->sRGB conversions.

Test: Manual testing
Bug: 29940137
Change-Id: Ie2f84ee2a65fd85570e88af813e841e0e625df6c
diff --git a/libs/hwui/FloatColor.h b/libs/hwui/FloatColor.h
index 6d19b7c..9df7338 100644
--- a/libs/hwui/FloatColor.h
+++ b/libs/hwui/FloatColor.h
@@ -28,8 +28,20 @@
 struct FloatColor {
     // "color" is a gamma-encoded sRGB color
     // After calling this method, the color is stored as a pre-multiplied linear color
+    // if linear blending is enabled. Otherwise, the color is stored as a pre-multiplied
+    // gamma-encoded sRGB color
     void set(uint32_t color) {
         a = ((color >> 24) & 0xff) / 255.0f;
+        r = a * EOCF(((color >> 16) & 0xff) / 255.0f);
+        g = a * EOCF(((color >>  8) & 0xff) / 255.0f);
+        b = a * EOCF(((color      ) & 0xff) / 255.0f);
+    }
+
+    // "color" is a gamma-encoded sRGB color
+    // After calling this method, the color is stored as a pre-multiplied linear color
+    // if linear blending is enabled.
+    void setSRGB(uint32_t color) {
+        a = ((color >> 24) & 0xff) / 255.0f;
         r = a * EOCF_sRGB(((color >> 16) & 0xff) / 255.0f);
         g = a * EOCF_sRGB(((color >>  8) & 0xff) / 255.0f);
         b = a * EOCF_sRGB(((color      ) & 0xff) / 255.0f);