mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-25 01:00:01 +00:00
Account for scaleFactor when saving clipped PNG.
This commit is contained in:
parent
7a4af06cee
commit
e1fd6b6f21
@ -95,7 +95,7 @@ bool TextureReplacer::LoadIni() {
|
||||
if (ini.GetKeys("hashes", hashNames)) {
|
||||
auto hashes = ini.GetOrCreateSection("hashes");
|
||||
// Format: hashname = filename.png
|
||||
for (std::string hashName : hashNames) {
|
||||
for (const std::string &hashName : hashNames) {
|
||||
hashes->Get(hashName.c_str(), &aliases_[hashName], "");
|
||||
}
|
||||
}
|
||||
@ -104,7 +104,7 @@ bool TextureReplacer::LoadIni() {
|
||||
if (ini.GetKeys("hashranges", hashrangeKeys)) {
|
||||
auto hashranges = ini.GetOrCreateSection("hashranges");
|
||||
// Format: addr,w,h = newW,newH
|
||||
for (std::string key : hashrangeKeys) {
|
||||
for (const std::string &key : hashrangeKeys) {
|
||||
std::string value;
|
||||
if (hashranges->Get(key.c_str(), &value, "")) {
|
||||
ParseHashRange(key, value);
|
||||
@ -277,7 +277,7 @@ static bool WriteTextureToPNG(png_imagep image, const std::string &filename, int
|
||||
}
|
||||
#endif
|
||||
|
||||
void TextureReplacer::NotifyTextureDecoded(u64 cachekey, u32 hash, u32 addr, const void *data, int pitch, int level, int w, int h, ReplacedTextureFormat fmt) {
|
||||
void TextureReplacer::NotifyTextureDecoded(u64 cachekey, u32 hash, u32 addr, const void *data, int pitch, int level, int w, int h, int scaleFactor, ReplacedTextureFormat fmt) {
|
||||
_assert_msg_(G3D, enabled_, "Replacement not enabled");
|
||||
if (!g_Config.bSaveNewTextures) {
|
||||
// Ignore.
|
||||
@ -308,7 +308,12 @@ void TextureReplacer::NotifyTextureDecoded(u64 cachekey, u32 hash, u32 addr, con
|
||||
}
|
||||
|
||||
// Only save the hashed portion of the PNG.
|
||||
LookupHashRange(addr, w, h);
|
||||
int lookupW = w / scaleFactor;
|
||||
int lookupH = h / scaleFactor;
|
||||
if (LookupHashRange(addr, lookupW, lookupH)) {
|
||||
w = lookupW * scaleFactor;
|
||||
h = lookupH * scaleFactor;
|
||||
}
|
||||
|
||||
#ifdef USING_QT_UI
|
||||
ERROR_LOG(G3D, "Replacement texture saving not implemented for Qt");
|
||||
|
@ -133,7 +133,7 @@ public:
|
||||
|
||||
ReplacedTexture &FindReplacement(u64 cachekey, u32 hash, int w, int h);
|
||||
|
||||
void NotifyTextureDecoded(u64 cachekey, u32 hash, u32 addr, const void *data, int pitch, int level, int w, int h, ReplacedTextureFormat fmt);
|
||||
void NotifyTextureDecoded(u64 cachekey, u32 hash, u32 addr, const void *data, int pitch, int level, int w, int h, int scaleFactor, ReplacedTextureFormat fmt);
|
||||
|
||||
protected:
|
||||
bool LoadIni();
|
||||
|
@ -1674,7 +1674,7 @@ void TextureCacheDX9::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &re
|
||||
|
||||
if (replacer.Enabled()) {
|
||||
int bpp = dstFmt == D3DFMT_A8R8G8B8 ? 4 : 2;
|
||||
replacer.NotifyTextureDecoded(entry.CacheKey(), entry.fullhash, entry.addr, pixelData, w * bpp, level, w, h, FromD3D9Format(dstFmt));
|
||||
replacer.NotifyTextureDecoded(entry.CacheKey(), entry.fullhash, entry.addr, pixelData, w * bpp, level, w, h, scaleFactor, FromD3D9Format(dstFmt));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1813,7 +1813,7 @@ void TextureCache::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &repla
|
||||
|
||||
if (replacer.Enabled()) {
|
||||
int bpp = dstFmt == GL_UNSIGNED_BYTE ? 4 : 2;
|
||||
replacer.NotifyTextureDecoded(entry.CacheKey(), entry.fullhash,entry.addr, pixelData, (useUnpack ? bufw : w) * bpp, level, w, h, FromGLESFormat(dstFmt, useBGRA));
|
||||
replacer.NotifyTextureDecoded(entry.CacheKey(), entry.fullhash,entry.addr, pixelData, (useUnpack ? bufw : w) * bpp, level, w, h, scaleFactor, FromGLESFormat(dstFmt, useBGRA));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1348,7 +1348,7 @@ void TextureCacheVulkan::SetTexture(VulkanPushBuffer *uploadBuffer) {
|
||||
} else {
|
||||
LoadTextureLevel(*entry, (uint8_t *)data, stride, i, scaleFactor, dstFmt);
|
||||
if (replacer.Enabled()) {
|
||||
replacer.NotifyTextureDecoded(cachekey, entry->fullhash, texaddr, data, stride, i, mipWidth, mipHeight, FromVulkanFormat(actualFmt));
|
||||
replacer.NotifyTextureDecoded(cachekey, entry->fullhash, texaddr, data, stride, i, mipWidth, mipHeight, scaleFactor, FromVulkanFormat(actualFmt));
|
||||
}
|
||||
}
|
||||
entry->vkTex->texture_->UploadMip(i, mipWidth, mipHeight, texBuf, bufferOffset, stride / bpp);
|
||||
|
Loading…
Reference in New Issue
Block a user