Reland "Add sRGB 8888 colortype"
This is a reland of 0f7c10ef5681d5c739bcd8862c58d856fd663a0c
Original change's description:
> Add sRGB 8888 colortype
>
> A color type that linearizes just after loading, and re-encodes to sRGB
> just before storing, mimicking the GPU formats that work the same way.
>
> Notes:
> - No mipmap support
> - No SkPngEncoder support (HashAndEncode's .pngs are ok, though?)
> - Needs better testing
>
> This is a re-creation of reviews.skia.org/392990
>
> Change-Id: I4739c2280211e7176aae98ba0a8476a7fe5efa72
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438219
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
Change-Id: I5b6bb28c4c1faa6c97fcad7552d12c331535714d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441402
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/tools/HashAndEncode.cpp b/tools/HashAndEncode.cpp
index 0f5841b..9e7a8a1 100644
--- a/tools/HashAndEncode.cpp
+++ b/tools/HashAndEncode.cpp
@@ -29,6 +29,7 @@
case kARGB_4444_SkColorType: srcFmt = skcms_PixelFormat_ABGR_4444; break;
case kRGBA_8888_SkColorType: srcFmt = skcms_PixelFormat_RGBA_8888; break;
case kBGRA_8888_SkColorType: srcFmt = skcms_PixelFormat_BGRA_8888; break;
+ case kSRGBA_8888_SkColorType: srcFmt = skcms_PixelFormat_RGBA_8888_sRGB; break;
case kRGBA_1010102_SkColorType: srcFmt = skcms_PixelFormat_RGBA_1010102; break;
case kBGRA_1010102_SkColorType: srcFmt = skcms_PixelFormat_BGRA_1010102; break;
case kGray_8_SkColorType: srcFmt = skcms_PixelFormat_G_8; break;
diff --git a/tools/ToolUtils.cpp b/tools/ToolUtils.cpp
index 1eed400..681ac22 100644
--- a/tools/ToolUtils.cpp
+++ b/tools/ToolUtils.cpp
@@ -55,6 +55,7 @@
case kRGB_565_SkColorType: return "RGB_565";
case kARGB_4444_SkColorType: return "ARGB_4444";
case kRGBA_8888_SkColorType: return "RGBA_8888";
+ case kSRGBA_8888_SkColorType: return "SRGBA_8888";
case kRGB_888x_SkColorType: return "RGB_888x";
case kBGRA_8888_SkColorType: return "BGRA_8888";
case kRGBA_1010102_SkColorType: return "RGBA_1010102";
@@ -83,6 +84,7 @@
case kRGB_565_SkColorType: return "565";
case kARGB_4444_SkColorType: return "4444";
case kRGBA_8888_SkColorType: return "8888";
+ case kSRGBA_8888_SkColorType: return "8888";
case kRGB_888x_SkColorType: return "888";
case kBGRA_8888_SkColorType: return "8888";
case kRGBA_1010102_SkColorType: return "1010102";
diff --git a/tools/flags/CommonFlagsConfig.cpp b/tools/flags/CommonFlagsConfig.cpp
index d3adc4e..d4dfd82 100644
--- a/tools/flags/CommonFlagsConfig.cpp
+++ b/tools/flags/CommonFlagsConfig.cpp
@@ -61,7 +61,9 @@
{ "gles1010102", "gpu", "api=gles,color=1010102" },
{ "glf16", "gpu", "api=gl,color=f16" },
{ "glf16norm", "gpu", "api=gl,color=f16norm" },
+ { "glsrgba", "gpu", "api=gl,color=srgba" },
{ "glesf16", "gpu", "api=gles,color=f16" },
+ { "glessrgba", "gpu", "api=gles,color=srgba" },
{ "glnostencils", "gpu", "api=gl,stencils=false" },
{ "gldft", "gpu", "api=gl,dit=true" },
{ "glesdft", "gpu", "api=gles,dit=true" },
@@ -339,9 +341,9 @@
return false;
}
-static bool parse_option_gpu_color(const SkString& value,
- SkColorType* outColorType,
- SkAlphaType* alphaType) {
+static bool parse_option_gpu_color(const SkString& value,
+ SkColorType* outColorType,
+ SkAlphaType* alphaType) {
// We always use premul unless the color type is 565.
*alphaType = kPremul_SkAlphaType;
@@ -362,6 +364,8 @@
*outColorType = kRGBA_F16_SkColorType;
} else if (value.equals("f16norm")) {
*outColorType = kRGBA_F16Norm_SkColorType;
+ } else if (value.equals("srgba")) {
+ *outColorType = kSRGBA_8888_SkColorType;
} else {
return false;
}
diff --git a/tools/fm/fm.cpp b/tools/fm/fm.cpp
index 9a26f6a..67624eb 100644
--- a/tools/fm/fm.cpp
+++ b/tools/fm/fm.cpp
@@ -520,6 +520,7 @@
{ "f32", kRGBA_F32_SkColorType },
{ "rgba", kRGBA_8888_SkColorType },
{ "bgra", kBGRA_8888_SkColorType },
+ { "srgba", kSRGBA_8888_SkColorType },
{ "16161616", kR16G16B16A16_unorm_SkColorType },
};
const FlagOption<SkAlphaType> kAlphaTypes[] = {