Remove GrCaps::SupportedRead::fSwizzle and supporting code
Add weird color types that handle the swizzling.
Change-Id: Ie37a00eb877fe5e519f7498bf749e02a2f1dc204
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230135
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h
index fd08219..85be494 100644
--- a/include/private/GrTypesPriv.h
+++ b/include/private/GrTypesPriv.h
@@ -1150,6 +1150,14 @@
kRGBA_F16_Clamped,
kRGBA_F32,
+ // Unusual formats that come up after reading back in cases where we are reassigning the meaning
+ // of a texture format's channels to use for a particular color format but have to read back the
+ // data to a full RGBA quadruple. (e.g. using a R8 texture format as A8 color type but the API
+ // only supports reading to RGBA8.) None of these have SkColorType equivalents.
+ kAlpha_8xxx,
+ kAlpha_F32xxx,
+ kGray_8xxx,
+
kR_16, // Not in SkColorType
kRG_1616, // Not in SkColorType
@@ -1180,6 +1188,9 @@
case GrColorType::kRGBA_F16: return kRGBA_F16_SkColorType;
case GrColorType::kRGBA_F16_Clamped: return kRGBA_F16Norm_SkColorType;
case GrColorType::kRGBA_F32: return kRGBA_F32_SkColorType;
+ case GrColorType::kAlpha_8xxx: return kUnknown_SkColorType;
+ case GrColorType::kAlpha_F32xxx: return kUnknown_SkColorType;
+ case GrColorType::kGray_8xxx: return kUnknown_SkColorType;
case GrColorType::kR_16: return kUnknown_SkColorType;
case GrColorType::kRG_1616: return kUnknown_SkColorType;
// Experimental (for Y416 and mutant P016/P010)
@@ -1232,6 +1243,9 @@
case GrColorType::kRGBA_F16: return kRGBA_SkColorTypeComponentFlags;
case GrColorType::kRGBA_F16_Clamped: return kRGBA_SkColorTypeComponentFlags;
case GrColorType::kRGBA_F32: return kRGBA_SkColorTypeComponentFlags;
+ case GrColorType::kAlpha_8xxx: return kAlpha_SkColorTypeComponentFlag;
+ case GrColorType::kAlpha_F32xxx: return kAlpha_SkColorTypeComponentFlag;
+ case GrColorType::kGray_8xxx: return kGray_SkColorTypeComponentFlag;
case GrColorType::kR_16: return kRed_SkColorTypeComponentFlag;
case GrColorType::kRG_1616: return kRed_SkColorTypeComponentFlag |
kGreen_SkColorTypeComponentFlag;
@@ -1364,6 +1378,12 @@
return GrColorTypeDesc::MakeRGBA(16, GrColorTypeEncoding::kFloat);
case GrColorType::kRGBA_F32:
return GrColorTypeDesc::MakeRGBA(32, GrColorTypeEncoding::kFloat);
+ case GrColorType::kAlpha_8xxx:
+ return GrColorTypeDesc::MakeAlpha(8, GrColorTypeEncoding::kUnorm);
+ case GrColorType::kAlpha_F32xxx:
+ return GrColorTypeDesc::MakeAlpha(32, GrColorTypeEncoding::kFloat);
+ case GrColorType::kGray_8xxx:
+ return GrColorTypeDesc::MakeGray(8, GrColorTypeEncoding::kUnorm);
case GrColorType::kR_16:
return GrColorTypeDesc::MakeR(16, GrColorTypeEncoding::kUnorm);
case GrColorType::kRG_1616:
@@ -1421,6 +1441,9 @@
case GrColorType::kRGBA_F16: return 8;
case GrColorType::kRGBA_F16_Clamped: return 8;
case GrColorType::kRGBA_F32: return 16;
+ case GrColorType::kAlpha_8xxx: return 4;
+ case GrColorType::kAlpha_F32xxx: return 16;
+ case GrColorType::kGray_8xxx: return 4;
case GrColorType::kR_16: return 2;
case GrColorType::kRG_1616: return 4;
// Experimental (for Y416 and mutant P016/P010)
@@ -1518,6 +1541,9 @@
case GrColorType::kAlpha_F16: return kAlpha_half_GrPixelConfig;
case GrColorType::kRGBA_F16: return kRGBA_half_GrPixelConfig;
case GrColorType::kRGBA_F16_Clamped: return kRGBA_half_Clamped_GrPixelConfig;
+ case GrColorType::kAlpha_8xxx: return kUnknown_GrPixelConfig;
+ case GrColorType::kAlpha_F32xxx: return kUnknown_GrPixelConfig;
+ case GrColorType::kGray_8xxx: return kUnknown_GrPixelConfig;
case GrColorType::kR_16: return kR_16_GrPixelConfig;
case GrColorType::kRG_1616: return kRG_1616_GrPixelConfig;
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index 32714b8..a66b391 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -361,11 +361,13 @@
if (GrColorType::kRGB_888x == read.fColorType) {
read.fOffsetAlignmentForTransferBuffer = 0;
}
- // It's very convenient to access 1 byte-per-channel 32 bitvRGB/RGBA color types as uint32_t.
+ // It's very convenient to access 1 byte-per-channel 32 bit color types as uint32_t on the CPU.
// Make those aligned reads out of the buffer even if the underlying API doesn't require it.
auto componentFlags = GrColorTypeComponentFlags(read.fColorType);
if ((componentFlags == kRGBA_SkColorTypeComponentFlags ||
- componentFlags == kRGB_SkColorTypeComponentFlags) &&
+ componentFlags == kRGB_SkColorTypeComponentFlags ||
+ componentFlags == kAlpha_SkColorTypeComponentFlag ||
+ componentFlags == kGray_SkColorTypeComponentFlag) &&
GrColorTypeBytesPerPixel(read.fColorType) == 4) {
switch (read.fOffsetAlignmentForTransferBuffer & 0b11) {
// offset alignment already a multiple of 4
diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h
index 61df9db..19a993e 100644
--- a/src/gpu/GrCaps.h
+++ b/src/gpu/GrCaps.h
@@ -237,7 +237,6 @@
GrColorType srcColorType) const = 0;
struct SupportedRead {
- GrSwizzle fSwizzle;
GrColorType fColorType;
// If the read is occurring using GrGpu::transferPixelsFrom then this provides the
// minimum alignment of the offset into the transfer buffer.
diff --git a/src/gpu/GrDataUtils.cpp b/src/gpu/GrDataUtils.cpp
index a36a271..45d2ff8 100644
--- a/src/gpu/GrDataUtils.cpp
+++ b/src/gpu/GrDataUtils.cpp
@@ -390,6 +390,15 @@
case GrColorType::kRGBA_F32: *load = SkRasterPipeline::load_f32;
*isNormalized = false;
break;
+ case GrColorType::kAlpha_8xxx: *load = SkRasterPipeline::load_8888;
+ swizzle = GrSwizzle("000r");
+ break;
+ case GrColorType::kAlpha_F32xxx: *load = SkRasterPipeline::load_f32;
+ swizzle = GrSwizzle("000r");
+ break;
+ case GrColorType::kGray_8xxx: *load = SkRasterPipeline::load_8888;
+ swizzle = GrSwizzle("rrr1");
+ break;
case GrColorType::kR_16: *load = SkRasterPipeline::load_a16;
swizzle = GrSwizzle("a001");
break;
@@ -440,6 +449,12 @@
case GrColorType::kRGBA_F32: *store = SkRasterPipeline::store_f32;
*isNormalized = false;
break;
+ case GrColorType::kAlpha_8xxx: *store = SkRasterPipeline::store_8888;
+ swizzle = GrSwizzle("a000");
+ break;
+ case GrColorType::kAlpha_F32xxx: *store = SkRasterPipeline::store_f32;
+ swizzle = GrSwizzle("a000");
+ break;
case GrColorType::kR_16: swizzle = GrSwizzle("000r");
*store = SkRasterPipeline::store_a16;
break;
@@ -451,6 +466,7 @@
break;
case GrColorType::kGray_8: // not currently supported as output
+ case GrColorType::kGray_8xxx: // not currently supported as output
case GrColorType::kUnknown:
SK_ABORT("unexpected CT");
}
@@ -466,7 +482,7 @@
bool GrConvertPixels(const GrPixelInfo& dstInfo, void* dst, size_t dstRB,
const GrPixelInfo& srcInfo, const void* src, size_t srcRB,
- bool flipY, GrSwizzle swizzle) {
+ bool flipY) {
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
if (!srcInfo.isValid() || !dstInfo.isValid()) {
return false;
@@ -497,7 +513,6 @@
bool srcIsSRGB;
auto loadSwizzle = get_load_and_get_swizzle(srcInfo.colorType(), &load, &srcIsNormalized,
&srcIsSRGB);
- loadSwizzle = GrSwizzle::Concat(loadSwizzle, swizzle);
SkRasterPipeline::StockStage store;
bool dstIsNormalized;
@@ -583,7 +598,6 @@
return true;
}
-
GrColorType SkColorTypeAndFormatToGrColorType(const GrCaps* caps,
SkColorType skCT,
const GrBackendFormat& format) {
diff --git a/src/gpu/GrDataUtils.h b/src/gpu/GrDataUtils.h
index 5417ac9..c72feb7 100644
--- a/src/gpu/GrDataUtils.h
+++ b/src/gpu/GrDataUtils.h
@@ -107,6 +107,6 @@
// Swizzle param is applied after loading and before converting from srcInfo to dstInfo.
bool GrConvertPixels(const GrPixelInfo& dstInfo, void* dst, size_t dstRB,
const GrPixelInfo& srcInfo, const void* src, size_t srcRB,
- bool flipY = false, GrSwizzle swizzle = GrSwizzle{});
+ bool flipY = false);
#endif
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index 15dad7a..630fea3 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -180,8 +180,7 @@
bool makeTight = !caps->readPixelsRowBytesSupport() && tightRowBytes != rowBytes;
bool convert = unpremul || premul || needColorConversion || flip || makeTight ||
- (dstInfo.colorType() != supportedRead.fColorType) ||
- supportedRead.fSwizzle != GrSwizzle::RGBA();
+ (dstInfo.colorType() != supportedRead.fColorType);
std::unique_ptr<char[]> tmpPixels;
GrPixelInfo tmpInfo;
@@ -209,8 +208,7 @@
}
if (convert) {
- return GrConvertPixels(dstInfo, dst, rowBytes, tmpInfo, readDst, readRB, flip,
- supportedRead.fSwizzle);
+ return GrConvertPixels(dstInfo, dst, rowBytes, tmpInfo, readDst, readRB, flip);
}
return true;
}
@@ -629,14 +627,14 @@
PixelTransferResult result;
result.fTransferBuffer = std::move(buffer);
auto at = this->colorSpaceInfo().alphaType();
- if (supportedRead.fColorType != dstCT || supportedRead.fSwizzle != GrSwizzle("rgba") || flip) {
+ if (supportedRead.fColorType != dstCT || flip) {
result.fPixelConverter = [w = rect.width(), h = rect.height(), dstCT, supportedRead, at](
void* dst, const void* src) {
GrPixelInfo srcInfo(supportedRead.fColorType, at, nullptr, w, h);
GrPixelInfo dstInfo(dstCT, at, nullptr, w, h);
GrConvertPixels(dstInfo, dst, dstInfo.minRowBytes(),
srcInfo, src, srcInfo.minRowBytes(),
- /* flipY = */ false, supportedRead.fSwizzle);
+ /* flipY = */ false);
};
}
return result;
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 09a93a2..668448b 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -308,6 +308,9 @@
case GrColorType::kRGBA_F16:
case GrColorType::kRGBA_F16_Clamped:
case GrColorType::kAlpha_8:
+ case GrColorType::kAlpha_8xxx:
+ case GrColorType::kAlpha_F32xxx:
+ case GrColorType::kGray_8xxx:
return -1;
}
SkUNREACHABLE;
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 529e5a4..20320be 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -1590,14 +1590,13 @@
ioFormat.fExternalReadFormat = 0;
}
- // Format: R8, Surface: kAlpha_8, Data: kRGBA_8888
+ // Format: R8, Surface: kAlpha_8, Data: kAlpha_8xxx
{
auto& ioFormat = ctInfo.fExternalIOFormats[ioIdx++];
- ioFormat.fColorType = GrColorType::kRGBA_8888;
+ ioFormat.fColorType = GrColorType::kAlpha_8xxx;
ioFormat.fExternalType = GR_GL_UNSIGNED_BYTE;
ioFormat.fExternalTexImageFormat = 0;
ioFormat.fExternalReadFormat = GR_GL_RGBA;
- ioFormat.fReadSwizzle = GrSwizzle("000r");
}
}
@@ -1622,14 +1621,13 @@
ioFormat.fExternalReadFormat = 0;
}
- // Format: R8, Surface: kGray_8, Data: kRGBA_8888
+ // Format: R8, Surface: kGray_8, Data: kGray_8xxx
{
auto& ioFormat = ctInfo.fExternalIOFormats[ioIdx++];
- ioFormat.fColorType = GrColorType::kRGBA_8888;
+ ioFormat.fColorType = GrColorType::kGray_8xxx;
ioFormat.fExternalType = GR_GL_UNSIGNED_BYTE;
ioFormat.fExternalTexImageFormat = 0;
ioFormat.fExternalReadFormat = GR_GL_RGBA;
- ioFormat.fReadSwizzle = GrSwizzle("rrr1");
}
}
}
@@ -1704,7 +1702,6 @@
ioFormat.fExternalType = GR_GL_UNSIGNED_BYTE;
ioFormat.fExternalTexImageFormat = 0;
ioFormat.fExternalReadFormat = GR_GL_RGBA;
- ioFormat.fReadSwizzle = GrSwizzle("000a");
}
}
}
@@ -2103,14 +2100,13 @@
ioFormat.fExternalReadFormat = 0;
}
- // Format: R16F, Surface: kAlpha_F16, Data: kRGBA_F32
+ // Format: R16F, Surface: kAlpha_F16, Data: kAlpha_F32xxx
{
auto& ioFormat = ctInfo.fExternalIOFormats[ioIdx++];
- ioFormat.fColorType = GrColorType::kRGBA_F32;
+ ioFormat.fColorType = GrColorType::kAlpha_F32xxx;
ioFormat.fExternalType = GR_GL_FLOAT;
ioFormat.fExternalTexImageFormat = 0;
ioFormat.fExternalReadFormat = GR_GL_RGBA;
- ioFormat.fReadSwizzle = GrSwizzle("000r");
}
}
}
@@ -3688,12 +3684,12 @@
// this as makes sense to increase performance and correctness.
GrGLFormat srcFormat = GrGLBackendFormatToGLFormat(srcBackendFormat);
if (srcFormat == GrGLFormat::kUnknown) {
- return {GrSwizzle{}, GrColorType::kUnknown, 0};
+ return {GrColorType::kUnknown, 0};
}
// We first try to find a supported read pixels GrColorType that matches the requested
// dstColorType. If that doesn't exists we will use any valid read pixels GrColorType.
- GrCaps::SupportedRead fallbackRead = {GrSwizzle{}, GrColorType::kUnknown, 0};
+ GrCaps::SupportedRead fallbackRead = {GrColorType::kUnknown, 0};
const auto& formatInfo = this->getFormatInfo(srcFormat);
bool foundSrcCT = false;
for (int i = 0; !foundSrcCT && i < formatInfo.fColorTypeInfoCount; ++i) {
@@ -3706,13 +3702,12 @@
GrGLenum transferOffsetAlignment =
offset_alignment_for_transfer_buffer(ioInfo.fExternalType);
if (ioInfo.fColorType == dstColorType) {
- return {ioInfo.fReadSwizzle, dstColorType, transferOffsetAlignment};
+ return {dstColorType, transferOffsetAlignment};
}
// Currently we just pick the first supported format that we find as our
// fallback.
if (fallbackRead.fColorType == GrColorType::kUnknown) {
- fallbackRead = {ioInfo.fReadSwizzle, ioInfo.fColorType,
- transferOffsetAlignment};
+ fallbackRead = {ioInfo.fColorType, transferOffsetAlignment};
}
}
}
@@ -4001,6 +3996,12 @@
return kRG_half_GrPixelConfig;
}
break;
+
+ // These have no equivalent config:
+ case GrColorType::kAlpha_8xxx:
+ case GrColorType::kAlpha_F32xxx:
+ case GrColorType::kGray_8xxx:
+ break;
}
SkDebugf("Unknown pixel config 0x%x\n", format);
@@ -4074,7 +4075,7 @@
bool GrGLCaps::canClearTextureOnCreation() const { return fClearTextureSupport; }
#ifdef SK_DEBUG
-static bool format_color_type_valid_pair(GrGLenum format, GrColorType colorType) {
+static constexpr bool format_color_type_valid_pair(GrGLenum format, GrColorType colorType) {
switch (colorType) {
case GrColorType::kUnknown:
return false;
@@ -4119,9 +4120,13 @@
case GrColorType::kRG_F16:
return GR_GL_RG16F == format;
+ // These have no equivalent config:
+ case GrColorType::kAlpha_8xxx:
+ case GrColorType::kAlpha_F32xxx:
+ case GrColorType::kGray_8xxx:
+ return false;
}
- SK_ABORT("Unknown color type");
- return false;
+ SkUNREACHABLE;
}
#endif
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 57bd50e..64be61a 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -611,10 +611,6 @@
GrGLenum fExternalType = 0;
GrGLenum fExternalTexImageFormat = 0;
GrGLenum fExternalReadFormat = 0;
-
- // This is the swizzle to apply to the data after it is read back using the
- // fExternalReadFormat so that the data is in the form expected by fColorType.
- GrSwizzle fReadSwizzle = GrSwizzle::RGBA();
};
GrGLenum externalFormat(GrColorType externalColorType, ExternalFormatUsage usage) const {
diff --git a/src/gpu/mock/GrMockCaps.h b/src/gpu/mock/GrMockCaps.h
index 3f4e5a0..23a47a4 100644
--- a/src/gpu/mock/GrMockCaps.h
+++ b/src/gpu/mock/GrMockCaps.h
@@ -184,7 +184,7 @@
SupportedRead onSupportedReadPixelsColorType(GrColorType srcColorType, const GrBackendFormat&,
GrColorType) const override {
- return SupportedRead{GrSwizzle::RGBA(), srcColorType, 1};
+ return SupportedRead{srcColorType, 1};
}
static const int kMaxSampleCnt = 16;
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index 56ad7e8..1b7e30d 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -599,7 +599,7 @@
}
// A near clone of format_color_type_valid_pair
-GrPixelConfig validate_sized_format(GrMTLPixelFormat grFormat, GrColorType ct) {
+static constexpr GrPixelConfig validate_sized_format(GrMTLPixelFormat grFormat, GrColorType ct) {
MTLPixelFormat format = static_cast<MTLPixelFormat>(grFormat);
switch (ct) {
case GrColorType::kUnknown:
@@ -615,7 +615,6 @@
case GrColorType::kBGR_565:
case GrColorType::kABGR_4444:
return kUnknown_GrPixelConfig;
- break;
#else
case GrColorType::kBGR_565:
if (MTLPixelFormatB5G6R5Unorm == format) {
@@ -703,9 +702,12 @@
return kRG_half_GrPixelConfig;
}
break;
+ case GrColorType::kAlpha_8xxx:
+ case GrColorType::kAlpha_F32xxx:
+ case GrColorType::kGray_8xxx:
+ return kUnknown_GrPixelConfig;
}
-
- return kUnknown_GrPixelConfig;
+ SkUNREACHABLE;
}
bool GrMtlCaps::onAreColorTypeAndFormatCompatible(GrColorType ct,
@@ -782,7 +784,7 @@
}
#ifdef SK_DEBUG
-static bool format_color_type_valid_pair(MTLPixelFormat format, GrColorType colorType) {
+static constexpr bool format_color_type_valid_pair(MTLPixelFormat format, GrColorType colorType) {
switch (colorType) {
case GrColorType::kUnknown:
return false;
@@ -837,9 +839,12 @@
return MTLPixelFormatRGBA16Unorm == format;
case GrColorType::kRG_F16:
return MTLPixelFormatRG16Float == format;
+ case GrColorType::kAlpha_8xxx:
+ case GrColorType::kAlpha_F32xxx:
+ case GrColorType::kGray_8xxx:
+ return false;
}
- SK_ABORT("Unknown color type");
- return false;
+ SkUNREACHABLE;
}
#endif
@@ -902,7 +907,7 @@
GrColorType dstColorType) const {
const GrMTLPixelFormat* grMtlFormat = srcBackendFormat.getMtlFormat();
if (!grMtlFormat) {
- return {GrSwizzle(), GrColorType::kUnknown, 0};
+ return {GrColorType::kUnknown, 0};
}
GrColorType readCT = GrColorType::kUnknown;
@@ -974,6 +979,6 @@
}
// Metal requires the destination offset for copyFromTexture to be a multiple of the textures
// pixels size.
- return {GrSwizzle::RGBA(), readCT, GrColorTypeBytesPerPixel(readCT)};
+ return {readCT, GrColorTypeBytesPerPixel(readCT)};
}
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 563fb65..259a5ad 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -1065,6 +1065,11 @@
return kRG_half_GrPixelConfig;
}
break;
+ // These have no equivalent:
+ case GrColorType::kAlpha_8xxx:
+ case GrColorType::kAlpha_F32xxx:
+ case GrColorType::kGray_8xxx:
+ break;
}
return kUnknown_GrPixelConfig;
@@ -1142,7 +1147,7 @@
bool GrVkCaps::canClearTextureOnCreation() const { return true; }
#ifdef SK_DEBUG
-static bool format_color_type_valid_pair(VkFormat vkFormat, GrColorType colorType) {
+static constexpr bool format_color_type_valid_pair(VkFormat vkFormat, GrColorType colorType) {
switch (colorType) {
case GrColorType::kUnknown:
return false;
@@ -1187,9 +1192,12 @@
return VK_FORMAT_R16G16B16A16_UNORM == vkFormat;
case GrColorType::kRG_F16:
return VK_FORMAT_R16G16_SFLOAT == vkFormat;
+ case GrColorType::kAlpha_8xxx:
+ case GrColorType::kAlpha_F32xxx:
+ case GrColorType::kGray_8xxx:
+ return false;
}
- SK_ABORT("Unknown color type");
- return false;
+ SkUNREACHABLE;
}
#endif
@@ -1240,7 +1248,7 @@
GrColorType dstColorType) const {
const VkFormat* vkFormat = srcBackendFormat.getVkFormat();
if (!vkFormat) {
- return {GrSwizzle(), GrColorType::kUnknown, 0};
+ return {GrColorType::kUnknown, 0};
}
// The VkBufferImageCopy bufferOffset field must be both a multiple of 4 and of a single texel.
@@ -1248,53 +1256,53 @@
switch (*vkFormat) {
case VK_FORMAT_R8G8B8A8_UNORM:
- return {GrSwizzle::RGBA(), GrColorType::kRGBA_8888, offsetAlignment};
+ return {GrColorType::kRGBA_8888, offsetAlignment};
case VK_FORMAT_R8_UNORM:
if (srcColorType == GrColorType::kAlpha_8) {
- return {GrSwizzle::RGBA(), GrColorType::kAlpha_8, offsetAlignment};
+ return {GrColorType::kAlpha_8, offsetAlignment};
} else if (srcColorType == GrColorType::kGray_8) {
- return {GrSwizzle::RGBA(), GrColorType::kGray_8, offsetAlignment};
+ return {GrColorType::kGray_8, offsetAlignment};
} else {
- return {GrSwizzle(), GrColorType::kUnknown, 0};
+ return {GrColorType::kUnknown, 0};
}
case VK_FORMAT_B8G8R8A8_UNORM:
- return {GrSwizzle::RGBA(), GrColorType::kBGRA_8888, offsetAlignment};
+ return {GrColorType::kBGRA_8888, offsetAlignment};
case VK_FORMAT_R5G6B5_UNORM_PACK16:
- return {GrSwizzle::RGBA(), GrColorType::kBGR_565, offsetAlignment};
+ return {GrColorType::kBGR_565, offsetAlignment};
case VK_FORMAT_R16G16B16A16_SFLOAT:
if (srcColorType == GrColorType::kRGBA_F16) {
- return {GrSwizzle::RGBA(), GrColorType::kRGBA_F16, offsetAlignment};
+ return {GrColorType::kRGBA_F16, offsetAlignment};
} else if (srcColorType == GrColorType::kRGBA_F16_Clamped) {
- return {GrSwizzle::RGBA(), GrColorType::kRGBA_F16_Clamped, offsetAlignment};
+ return {GrColorType::kRGBA_F16_Clamped, offsetAlignment};
} else {
- return {GrSwizzle(), GrColorType::kUnknown, 0};
+ return {GrColorType::kUnknown, 0};
}
case VK_FORMAT_R16_SFLOAT:
- return {GrSwizzle::RGBA(), GrColorType::kAlpha_F16, offsetAlignment};
+ return {GrColorType::kAlpha_F16, offsetAlignment};
case VK_FORMAT_R8G8B8_UNORM:
- return {GrSwizzle::RGBA(), GrColorType::kRGB_888x, offsetAlignment};
+ return {GrColorType::kRGB_888x, offsetAlignment};
case VK_FORMAT_R8G8_UNORM:
- return {GrSwizzle::RGBA(), GrColorType::kRG_88, offsetAlignment};
+ return {GrColorType::kRG_88, offsetAlignment};
case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
- return {GrSwizzle::RGBA(), GrColorType::kRGBA_1010102, offsetAlignment};
+ return {GrColorType::kRGBA_1010102, offsetAlignment};
case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
- return {GrSwizzle::RGBA(), GrColorType::kABGR_4444, offsetAlignment};
+ return {GrColorType::kABGR_4444, offsetAlignment};
case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
- return {GrSwizzle::RGBA(), GrColorType::kABGR_4444, offsetAlignment};
+ return {GrColorType::kABGR_4444, offsetAlignment};
case VK_FORMAT_R32G32B32A32_SFLOAT:
- return {GrSwizzle::RGBA(), GrColorType::kRGBA_F32, offsetAlignment};
+ return {GrColorType::kRGBA_F32, offsetAlignment};
case VK_FORMAT_R8G8B8A8_SRGB:
- return {GrSwizzle::RGBA(), GrColorType::kRGBA_8888_SRGB, offsetAlignment};
+ return {GrColorType::kRGBA_8888_SRGB, offsetAlignment};
case VK_FORMAT_R16_UNORM:
- return {GrSwizzle::RGBA(), GrColorType::kR_16, offsetAlignment};
+ return {GrColorType::kR_16, offsetAlignment};
case VK_FORMAT_R16G16_UNORM:
- return {GrSwizzle::RGBA(), GrColorType::kRG_1616, offsetAlignment};
+ return {GrColorType::kRG_1616, offsetAlignment};
// Experimental (for Y416 and mutant P016/P010)
case VK_FORMAT_R16G16B16A16_UNORM:
- return {GrSwizzle::RGBA(), GrColorType::kRGBA_16161616, offsetAlignment};
+ return {GrColorType::kRGBA_16161616, offsetAlignment};
case VK_FORMAT_R16G16_SFLOAT:
- return {GrSwizzle::RGBA(), GrColorType::kRG_F16, offsetAlignment};
+ return {GrColorType::kRG_F16, offsetAlignment};
default:
- return {GrSwizzle(), GrColorType::kUnknown, 0};
+ return {GrColorType::kUnknown, 0};
}
}
diff --git a/tests/GrTestingBackendTextureUploadTest.cpp b/tests/GrTestingBackendTextureUploadTest.cpp
index cf0ac31..c331381 100644
--- a/tests/GrTestingBackendTextureUploadTest.cpp
+++ b/tests/GrTestingBackendTextureUploadTest.cpp
@@ -58,7 +58,7 @@
// skbug.com/9165
auto supportedRead =
caps->supportedReadPixelsColorType(grCT, backendTex.getBackendFormat(), grCT);
- if (supportedRead.fColorType != grCT || supportedRead.fSwizzle != GrSwizzle("rgba")) {
+ if (supportedRead.fColorType != grCT) {
return;
}
diff --git a/tests/TransferPixelsTest.cpp b/tests/TransferPixelsTest.cpp
index d4c4aab..1b459d2 100644
--- a/tests/TransferPixelsTest.cpp
+++ b/tests/TransferPixelsTest.cpp
@@ -78,7 +78,7 @@
GrCaps::SupportedRead supportedRead = caps->supportedReadPixelsColorType(
srcCT, texture->backendFormat(), dstColorType);
std::fill_n(tolerances, 4, 0);
- if (supportedRead.fColorType != dstColorType || supportedRead.fSwizzle != GrSwizzle("rgba")) {
+ if (supportedRead.fColorType != dstColorType) {
size_t tmpRowBytes = GrColorTypeBytesPerPixel(supportedRead.fColorType) * w;
std::unique_ptr<char[]> tmpPixels(new char[tmpRowBytes * h]);
if (!gpu->readPixels(texture, 0, 0, w, h,
@@ -88,8 +88,8 @@
GrPixelInfo tmpInfo(supportedRead.fColorType, kUnpremul_SkAlphaType, nullptr, w, h);
GrPixelInfo dstInfo(dstColorType, kUnpremul_SkAlphaType, nullptr, w, h);
determine_tolerances(tmpInfo.colorType(), dstInfo.colorType(), tolerances);
- return GrConvertPixels(dstInfo, dst, rowBytes, tmpInfo, tmpPixels.get(), tmpRowBytes, false,
- supportedRead.fSwizzle);
+ return GrConvertPixels(dstInfo, dst, rowBytes, tmpInfo, tmpPixels.get(), tmpRowBytes,
+ false);
}
return gpu->readPixels(texture, 0, 0, w, h, supportedRead.fColorType, dst, rowBytes);
}
@@ -364,11 +364,6 @@
GrPixelInfo transferInfo(allowedRead.fColorType, kUnpremul_SkAlphaType, nullptr, kTextureWidth,
kTextureHeight);
- // Caps may indicate that we should swizzle this data before we compare it.
- if (allowedRead.fSwizzle != GrSwizzle("rgba")) {
- GrConvertPixels(transferInfo, transferData.get(), fullBufferRowBytes, transferInfo,
- transferData.get(), fullBufferRowBytes, false, allowedRead.fSwizzle);
- }
float tol[4];
determine_tolerances(allowedRead.fColorType, colorType, tol);
@@ -410,11 +405,6 @@
buffer->unmap();
transferInfo = transferInfo.makeWH(kPartialWidth, kPartialHeight);
- if (allowedRead.fSwizzle != GrSwizzle("rgba")) {
- GrConvertPixels(transferInfo, transferData.get(), partialBufferRowBytes, transferInfo,
- transferData.get(), partialBufferRowBytes, false, allowedRead.fSwizzle);
- }
-
const char* textureDataStart =
textureData.get() + textureDataRowBytes * kPartialTop + textureDataBpp * kPartialLeft;
textureDataInfo = textureDataInfo.makeWH(kPartialWidth, kPartialHeight);