When uploading pixmaps to textures it is important that we account for how the original pixmaps' channels are swizzled into the texture during upload. This will compute a swizzle for each texture based on the original color types and the views' swizzles. The views must all have the same origin or the result will be an invalid GrYUVATextureProxies.
77 if (n == 0) {
78 *this = {};
80 return;
81 }
82 fMipmapped = skgpu::Mipmapped::kYes;
83 for (int i = 0; i < n; ++i) {
87 if (!views[i] || views[i].origin() != views[0].origin()) {
88 *this = {};
90 return;
91 }
92 if (views[i].
proxy()->asTextureProxy()->
mipmapped() == skgpu::Mipmapped::kNo) {
93 fMipmapped = skgpu::Mipmapped::kNo;
94 }
95 }
96
98 if (fYUVALocations[0].fPlane < 0) {
99 *this = {};
101 return;
102 }
103
104
106 int plane = fYUVALocations[i].fPlane;
107 if (plane >= 0) {
108 int chanAsIdx = static_cast<int>(fYUVALocations[i].fChannel);
109 switch (views[plane].swizzle()[chanAsIdx]) {
114
115 default:
116 SkDEBUGFAILF(
"Unexpected swizzle value: %c", views[i].swizzle()[chanAsIdx]);
117 *this = {};
119 return;
120 }
121 }
122 }
123 for (int i = 0; i < n; ++i) {
125 }
126 fTextureOrigin = views[0].
origin();
128}
static constexpr uint32_t GrColorTypeChannelFlags(GrColorType ct)
static int num_channels(const GrBackendFormat &format)
#define SkDEBUGFAILF(fmt,...)
sk_sp< GrSurfaceProxy > detachProxy()
GrSurfaceOrigin origin() const
GrSurfaceProxy * proxy(int i) const
static constexpr int kYUVAChannelCount