ImageData can track whether they're meant to be loaded into a Texture with a non-sRGB format when gamma correct rendering is enabled.

Fixes #1556.

* Add ImageData/CompressedImageData:setLinear and ImageData/CompressedImageData:isLinear.
  The flag is used as a hint when loading a texture from the data to determine if the format should not be treated as sRGB-encoded. The 'linear' flag in newImage overrides this.

* love.graphics.readbackTexture automatically sets the linear flag on ImageData it returns when the texture's format is linear.
  This allows an ImageData generated via readback to be fed back into a new Texture and the format will match the original Canvas.

* Also clean up some image decoding code.
This commit is contained in:
Sasha Szpakowski
2023-10-14 20:48:21 -03:00
parent bd55100d56
commit 8c13943f64
26 changed files with 149 additions and 105 deletions
+2 -8
View File
@@ -364,11 +364,8 @@ PixelFormat getSRGBPixelFormat(PixelFormat format)
case PIXELFORMAT_ASTC_10x10_UNORM: return PIXELFORMAT_ASTC_10x10_sRGB;
case PIXELFORMAT_ASTC_12x10_UNORM: return PIXELFORMAT_ASTC_12x10_sRGB;
case PIXELFORMAT_ASTC_12x12_UNORM: return PIXELFORMAT_ASTC_12x12_sRGB;
default:
break;
default: return format;
}
return format;
}
PixelFormat getLinearPixelFormat(PixelFormat format)
@@ -398,11 +395,8 @@ PixelFormat getLinearPixelFormat(PixelFormat format)
case PIXELFORMAT_ASTC_10x10_sRGB: return PIXELFORMAT_ASTC_10x10_UNORM;
case PIXELFORMAT_ASTC_12x10_sRGB: return PIXELFORMAT_ASTC_12x10_UNORM;
case PIXELFORMAT_ASTC_12x12_sRGB: return PIXELFORMAT_ASTC_12x12_UNORM;
default:
break;
default: return format;
}
return format;
}
size_t getPixelFormatBlockSize(PixelFormat format)