@@ -106,6 +106,38 @@ static bool format_has_builtin_alpha(YUVFormat yuvFormat) {
106
106
kY410_YUVFormat == yuvFormat;
107
107
}
108
108
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
+
109
141
// Helper to setup the SkYUVAIndex array correctly
110
142
// Skia allows the client to tack an additional alpha plane onto any of the standard opaque
111
143
// 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 {
1159
1191
return ;
1160
1192
}
1161
1193
1194
+ if (!is_format_natively_supported (context, (YUVFormat) format)) {
1195
+ continue ;
1196
+ }
1197
+
1162
1198
GrBackendTexture yuvaTextures[4 ];
1163
1199
SkPixmap yuvaPixmaps[4 ];
1164
1200
0 commit comments