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/Extensions.cpp b/libs/hwui/Extensions.cpp
index 4dc7536..1d67579 100644
--- a/libs/hwui/Extensions.cpp
+++ b/libs/hwui/Extensions.cpp
@@ -45,13 +45,18 @@
mHas1BitStencil = extensions.has("GL_OES_stencil1");
mHas4BitStencil = extensions.has("GL_OES_stencil4");
mHasUnpackSubImage = extensions.has("GL_EXT_unpack_subimage");
- mHasSRGB = extensions.has("GL_EXT_sRGB");
+
+#ifdef ANDROID_ENABLE_LINEAR_BLENDING
+ mHasSRGB = mVersionMajor >= 3 || extensions.has("GL_EXT_sRGB");
mHasSRGBWriteControl = extensions.has("GL_EXT_sRGB_write_control");
- // If linear blending is enabled, the device must have ES3.0 and GL_EXT_sRGB_write_control
-#ifdef ANDROID_ENABLE_LINEAR_BLENDING
- assert(mVersionMajor >= 3 || mHasSRGB);
- assert(mHasSRGBWriteControl);
+ // If linear blending is enabled, the device must have (ES3.0 or EXT_sRGB)
+ // and EXT_sRGB_write_control
+ LOG_ALWAYS_FATAL_IF(!mHasSRGB, "Linear blending requires ES 3.0 or EXT_sRGB");
+ LOG_ALWAYS_FATAL_IF(!mHasSRGBWriteControl, "Linear blending requires EXT_sRGB_write_control");
+#else
+ mHasSRGB = false;
+ mHasSRGBWriteControl = false;
#endif
const char* version = (const char*) glGetString(GL_VERSION);