| 277 | PacLevelMem mip = _mipmaps[level]; |
| 278 | |
| 279 | AUTO_STATIC_ARRAY(char, mem, 256 * 256 * 2); |
| 280 | mem.Realloc(mip._pitch * mip._h); |
| 281 | mem.Resize(mip._pitch * mip._h); |
| 282 | |
| 283 | _src->GetMipmapData(mem.Data(), mip, level); |
| 284 | |
| 285 | if (_interpolate) |
| 286 | { |
| 287 | AUTO_STATIC_ARRAY(char, imem, 256 * 256 * 2); |
| 288 | PacLevelMem& imip = _interpolate->_mipmaps[level]; |
| 289 | imem.Realloc(imip._pitch * imip._h); |
| 290 | imem.Resize(imip._pitch * imip._h); |
| 291 | _interpolate->_src->GetMipmapData(imem.Data(), imip, level); |
| 292 | icol = imip.GetPixel(imem.Data(), u, v); |
| 293 | } |
| 294 | Color col = mip.GetPixel(mem.Data(), u, v); |
| 295 | if (_interpolate) |
| 296 | { |
| 297 | col = col * (1 - _iFactor) + icol * _iFactor; |
| 298 | } |
| 299 | return col; |
| 300 | } |
| 301 | |
| 302 | // Decode the top (full-resolution) mip once and classify its alpha channel. |
| 303 | // Reads the texture's bytes through the VFS (so it works for PBO-packed textures) and |
| 304 | // decodes via the shared DecodePAABuffer, which handles every PAA/PAC pixel format |
| 305 | // (DXT1/3/5, ARGB8888/4444/1555, AI88, P8) — unlike PacLevelMem::GetPixelInt, which |
| 306 | // only covers a subset and would Fail per texel on the rest. Top mip on purpose: a |
| 307 | // smaller mip blurs a cutout's crisp 0/255 holes into false partial-alpha, which would |
| 308 | // mis-route a pole/fence to the blend pass. |
| 309 | Poseidon::AlphaStats::Kind TextureGL33::ScanTopMipAlphaClass() |
| 310 | { |
| 311 | LoadHeadersNV(); |
| 312 | if (!_src) |
| 313 | return Poseidon::AlphaStats::Opaque; |
| 314 | |
| 315 | QIFStream in; |
| 316 | GFileServer->Open(in, Name()); |
| 317 | const int size = in.fail() ? 0 : in.rest(); |
| 318 | if (size <= 0) |
| 319 | return Poseidon::AlphaStats::Opaque; |
| 320 | |
| 321 | AUTO_STATIC_ARRAY(char, fileData, 256 * 1024); |
| 322 | fileData.Realloc(size); |
| 323 | fileData.Resize(size); |
| 324 | in.read(fileData.Data(), size); |
| 325 | |
| 326 | const char* name = Name(); |
| 327 | const size_t len = name ? strlen(name) : 0; |
| 328 | const bool isPaa = len >= 4 && (name[len - 1] == 'a' || name[len - 1] == 'A'); // .paa vs .pac |
| 329 | |
| 330 | const Poseidon::DecodedImage img = Poseidon::DecodePAABuffer(fileData.Data(), static_cast<size_t>(size), isPaa); |
| 331 | if (!img.valid()) |
| 332 | return Poseidon::AlphaStats::Opaque; |
| 333 | |
| 334 | return Poseidon::ClassifyAlpha(img.rgba.data(), static_cast<size_t>(img.width) * static_cast<size_t>(img.height)) |
| 335 | .kind; |
| 336 | } |
nothing calls this directly
no test coverage detected