Increase specificity of GrColorType computed for YUV planes (take 2)
When a single channel texture is used for a YUV channel we will
interpret it as kGray_8. When a single channel texture is used
as an A channel we will interpret it as kAlpha_8.
Change-Id: I0a02b849d214f63369dedf09b78195a293adc78e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/232142
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 49cacb5..2d940f3 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -1410,14 +1410,16 @@
return validate_image_info(*vkFormat, ct, ycbcrInfo->isValid());
}
-GrColorType GrVkCaps::getYUVAColorTypeFromBackendFormat(const GrBackendFormat& format) const {
+GrColorType GrVkCaps::getYUVAColorTypeFromBackendFormat(const GrBackendFormat& format,
+ bool isAlphaChannel) const {
const VkFormat* vkFormat = format.getVkFormat();
if (!vkFormat) {
return GrColorType::kUnknown;
}
switch (*vkFormat) {
- case VK_FORMAT_R8_UNORM: return GrColorType::kAlpha_8;
+ case VK_FORMAT_R8_UNORM: return isAlphaChannel ? GrColorType::kAlpha_8
+ : GrColorType::kGray_8;
case VK_FORMAT_R8G8B8A8_UNORM: return GrColorType::kRGBA_8888;
case VK_FORMAT_R8G8B8_UNORM: return GrColorType::kRGB_888x;
case VK_FORMAT_R8G8_UNORM: return GrColorType::kRG_88;