MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / AUTO_STATIC_ARRAY

Function AUTO_STATIC_ARRAY

engine/PoseidonGL33/TextureGL33_Init.cpp:279–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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.
309Poseidon::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}

Callers

nothing calls this directly

Calls 15

LoadHeadersNVFunction · 0.85
DecodePAABufferFunction · 0.85
ClassifyAlphaFunction · 0.85
ClassifyTextureAlphaFunction · 0.85
saturateMaxFunction · 0.85
MipmapSizeGL33Function · 0.85
ErrorMessageFunction · 0.85
Tex2DFunction · 0.85
ActiveUnitFunction · 0.85
OnTexDeletedFunction · 0.85
restMethod · 0.80
ASetNMipmapsMethod · 0.80

Tested by

no test coverage detected