| 240 | static TMap<int, RawCacheNode> CacheNodes; |
| 241 | |
| 242 | const uint8_t* GetRawPixels(FTextureID texid) |
| 243 | { |
| 244 | if (!texid.isValid()) return nullptr; |
| 245 | auto gtex = TexMan.GetGameTexture(texid); |
| 246 | auto tex = dynamic_cast<FImageTexture*>(gtex->GetTexture()); |
| 247 | |
| 248 | if (!tex || !tex->GetImage()) return nullptr; |
| 249 | auto img = tex->GetImage(); |
| 250 | auto timg = dynamic_cast<FTileTexture*>(img); |
| 251 | if (!timg || !timg->GetRawData()) |
| 252 | { |
| 253 | auto cache = CacheNodes.CheckKey(texid.GetIndex()); |
| 254 | if (cache) |
| 255 | { |
| 256 | cache->lastUseTime = I_nsTime(); |
| 257 | return cache->data.Data(); |
| 258 | } |
| 259 | RawCacheNode newnode; |
| 260 | newnode.data = img->GetPalettedPixels(0); |
| 261 | newnode.lastUseTime = I_nsTime(); |
| 262 | auto retval =newnode.data.Data(); |
| 263 | CacheNodes.Insert(texid.GetIndex(), std::move(newnode)); |
| 264 | return retval; |
| 265 | } |
| 266 | else |
| 267 | { |
| 268 | return timg->GetRawData(); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | //========================================================================== |
| 273 | // |
no test coverage detected