Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f47717a

Browse files
rphilliSkia Commit-Bot
authored andcommitted
Alter wacky_yuv_formats GM to skip rows if the required backing GPU format(s) aren't supported
Change-Id: I066345d57f11e0937fc760ebdba6ad308a5f948b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/242821 Reviewed-by: Brian Osman <[email protected]> Commit-Queue: Robert Phillips <[email protected]>
1 parent a5d96bc commit f47717a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

gm/wacky_yuv_formats.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,38 @@ static bool format_has_builtin_alpha(YUVFormat yuvFormat) {
106106
kY410_YUVFormat == yuvFormat;
107107
}
108108

109+
static bool is_colorType_texturable(const GrCaps* caps, GrColorType ct) {
110+
GrBackendFormat format = caps->getDefaultBackendFormat(ct, GrRenderable::kNo);
111+
if (!format.isValid()) {
112+
return false;
113+
}
114+
115+
return caps->isFormatTexturable(format);
116+
}
117+
118+
static bool is_format_natively_supported(GrContext* context, YUVFormat yuvFormat) {
119+
120+
const GrCaps* caps = context->priv().caps();
121+
122+
switch (yuvFormat) {
123+
case kP016_YUVFormat: // fall through
124+
case kP010_YUVFormat: return is_colorType_texturable(caps, GrColorType::kAlpha_16) &&
125+
is_colorType_texturable(caps, GrColorType::kRG_1616);
126+
case kP016F_YUVFormat: return is_colorType_texturable(caps, GrColorType::kAlpha_F16) &&
127+
is_colorType_texturable(caps, GrColorType::kRG_F16);
128+
case kY416_YUVFormat: return is_colorType_texturable(caps, GrColorType::kRGBA_16161616);
129+
case kAYUV_YUVFormat: return is_colorType_texturable(caps, GrColorType::kRGBA_8888);
130+
case kY410_YUVFormat: return is_colorType_texturable(caps, GrColorType::kRGBA_1010102);
131+
case kNV12_YUVFormat: // fall through
132+
case kNV21_YUVFormat: return is_colorType_texturable(caps, GrColorType::kGray_8) &&
133+
is_colorType_texturable(caps, GrColorType::kRG_88);
134+
case kI420_YUVFormat: // fall through
135+
case kYV12_YUVFormat: return is_colorType_texturable(caps, GrColorType::kGray_8);
136+
}
137+
138+
SkUNREACHABLE;
139+
}
140+
109141
// Helper to setup the SkYUVAIndex array correctly
110142
// Skia allows the client to tack an additional alpha plane onto any of the standard opaque
111143
// formats (via the addExtraAlpha) flag. In this case it is assumed to be a stand-alone single-
@@ -1159,6 +1191,10 @@ class WackyYUVFormatsGM : public GM {
11591191
return;
11601192
}
11611193

1194+
if (!is_format_natively_supported(context, (YUVFormat) format)) {
1195+
continue;
1196+
}
1197+
11621198
GrBackendTexture yuvaTextures[4];
11631199
SkPixmap yuvaPixmaps[4];
11641200

0 commit comments

Comments
 (0)