| 2410 | } |
| 2411 | |
| 2412 | void TextureViewer::InitResourcePreview(ResourcePreview *prev, Descriptor res, bool force, |
| 2413 | Following &follow, const QString &bindName, |
| 2414 | const QString &slotName) |
| 2415 | { |
| 2416 | Subresource sub = {0, 0, ~0U}; |
| 2417 | if(res.resource != ResourceId() || force) |
| 2418 | { |
| 2419 | QString fullname = bindName; |
| 2420 | if(!m_Ctx.IsAutogeneratedName(res.resource)) |
| 2421 | { |
| 2422 | if(!fullname.isEmpty()) |
| 2423 | fullname += lit(" = "); |
| 2424 | fullname += m_Ctx.GetResourceName(res.resource); |
| 2425 | } |
| 2426 | if(fullname.isEmpty()) |
| 2427 | fullname = m_Ctx.GetResourceName(res.resource); |
| 2428 | |
| 2429 | prev->setResourceName(fullname); |
| 2430 | |
| 2431 | prev->setProperty("f", QVariant::fromValue(follow)); |
| 2432 | prev->setSlotName(slotName); |
| 2433 | prev->setActive(true); |
| 2434 | prev->setSelected(m_Following == follow); |
| 2435 | |
| 2436 | if(m_Ctx.GetTexture(res.resource)) |
| 2437 | { |
| 2438 | if(res.firstMip >= 0) |
| 2439 | sub.mip = res.firstMip; |
| 2440 | if(res.firstSlice >= 0) |
| 2441 | sub.slice = res.firstSlice; |
| 2442 | } |
| 2443 | else |
| 2444 | { |
| 2445 | res.resource = ResourceId(); |
| 2446 | res.format = ResourceFormat(); |
| 2447 | } |
| 2448 | } |
| 2449 | else if(m_Following == follow) |
| 2450 | { |
| 2451 | prev->setResourceName(tr("Unused")); |
| 2452 | prev->setActive(true); |
| 2453 | prev->setSelected(true); |
| 2454 | |
| 2455 | res.resource = ResourceId(); |
| 2456 | res.format = ResourceFormat(); |
| 2457 | } |
| 2458 | else |
| 2459 | { |
| 2460 | prev->setResourceName(QString()); |
| 2461 | prev->setActive(false); |
| 2462 | prev->setSelected(false); |
| 2463 | |
| 2464 | return; |
| 2465 | } |
| 2466 | |
| 2467 | prev->setProperty("id", QVariant::fromValue(res.resource)); |
| 2468 | prev->setProperty("mip", sub.mip); |
| 2469 | prev->setProperty("slice", sub.slice); |
nothing calls this directly
no test coverage detected