From 2b2042e1c2d3729ac895ad5d9ea6bc34db19fa24 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sat, 20 Aug 2016 13:05:53 +0100 Subject: [PATCH] gsdx: Allow screenshot compression level to be changed At higher resolutions it takes too much time to save a screenshot at the maximum compression level. So let's allow the user to set the compression level. This re-uses the png_compression_level setting. The default compression level is 1 for speed, but if the user wishes to increase the compression level (without using an external tool) and doesn't mind if the screenshot takes more time to save then they can increase the compression level up to a maximum of 9 (which can take quite a while). Fixes #1527. --- plugins/GSdx/GSRenderer.cpp | 2 +- plugins/GSdx/GSRendererHW.cpp | 4 ++-- plugins/GSdx/GSTexture.h | 2 +- plugins/GSdx/GSTexture11.cpp | 4 ++-- plugins/GSdx/GSTexture11.h | 2 +- plugins/GSdx/GSTexture9.cpp | 4 ++-- plugins/GSdx/GSTexture9.h | 2 +- plugins/GSdx/GSTextureNull.h | 2 +- plugins/GSdx/GSTextureOGL.cpp | 4 ++-- plugins/GSdx/GSTextureOGL.h | 2 +- plugins/GSdx/GSTextureSW.cpp | 4 ++-- plugins/GSdx/GSTextureSW.h | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/plugins/GSdx/GSRenderer.cpp b/plugins/GSdx/GSRenderer.cpp index 4f000fb30a..f3f07aaf67 100644 --- a/plugins/GSdx/GSRenderer.cpp +++ b/plugins/GSdx/GSRenderer.cpp @@ -489,7 +489,7 @@ void GSRenderer::VSync(int field) if(GSTexture* t = m_dev->GetCurrent()) { - t->Save(m_snapshot + ".bmp", true); + t->Save(m_snapshot + ".bmp"); } m_snapshot.clear(); diff --git a/plugins/GSdx/GSRendererHW.cpp b/plugins/GSdx/GSRendererHW.cpp index 80374834a5..dec9e02f08 100644 --- a/plugins/GSdx/GSRendererHW.cpp +++ b/plugins/GSdx/GSRendererHW.cpp @@ -551,13 +551,13 @@ void GSRendererHW::Draw() (int)context->CLAMP.MINU, (int)context->CLAMP.MAXU, (int)context->CLAMP.MINV, (int)context->CLAMP.MAXV); - tex->m_texture->Save(m_dump_root+s, false, true); + tex->m_texture->Save(m_dump_root+s, true); if(tex->m_palette) { s = format("%05d_f%lld_tpx_%05x_%d.dds", s_n, frame, context->TEX0.CBP, context->TEX0.CPSM); - tex->m_palette->Save(m_dump_root+s, false, true); + tex->m_palette->Save(m_dump_root+s, true); } } diff --git a/plugins/GSdx/GSTexture.h b/plugins/GSdx/GSTexture.h index 296a5a3873..bfe411aa7e 100644 --- a/plugins/GSdx/GSTexture.h +++ b/plugins/GSdx/GSTexture.h @@ -46,7 +46,7 @@ public: virtual bool Update(const GSVector4i& r, const void* data, int pitch) = 0; virtual bool Map(GSMap& m, const GSVector4i* r = NULL) = 0; virtual void Unmap() = 0; - virtual bool Save(const string& fn, bool user_image = false, bool dds = false) = 0; + virtual bool Save(const string& fn, bool dds = false) = 0; virtual uint32 GetID() { return 0; } GSVector2 GetScale() const {return m_scale;} diff --git a/plugins/GSdx/GSTexture11.cpp b/plugins/GSdx/GSTexture11.cpp index 59e10fb151..5fee53cfda 100644 --- a/plugins/GSdx/GSTexture11.cpp +++ b/plugins/GSdx/GSTexture11.cpp @@ -93,7 +93,7 @@ void GSTexture11::Unmap() } } -bool GSTexture11::Save(const string& fn, bool user_image, bool dds) +bool GSTexture11::Save(const string& fn, bool dds) { CComPtr res; D3D11_TEXTURE2D_DESC desc; @@ -179,7 +179,7 @@ bool GSTexture11::Save(const string& fn, bool user_image, bool dds) return false; } - int compression = user_image ? Z_BEST_COMPRESSION : theApp.GetConfigI("png_compression_level"); + int compression = theApp.GetConfigI("png_compression_level"); bool success = GSPng::Save(format, fn, static_cast(sm.pData), desc.Width, desc.Height, sm.RowPitch, compression); m_ctx->Unmap(res, 0); diff --git a/plugins/GSdx/GSTexture11.h b/plugins/GSdx/GSTexture11.h index 8b9640e069..89b84e1dc0 100644 --- a/plugins/GSdx/GSTexture11.h +++ b/plugins/GSdx/GSTexture11.h @@ -40,7 +40,7 @@ public: bool Update(const GSVector4i& r, const void* data, int pitch); bool Map(GSMap& m, const GSVector4i* r); void Unmap(); - bool Save(const string& fn, bool user_image = false, bool dds = false); + bool Save(const string& fn, bool dds = false); operator ID3D11Texture2D*(); operator ID3D11ShaderResourceView*(); diff --git a/plugins/GSdx/GSTexture9.cpp b/plugins/GSdx/GSTexture9.cpp index ae413d7ce6..976567bdcd 100644 --- a/plugins/GSdx/GSTexture9.cpp +++ b/plugins/GSdx/GSTexture9.cpp @@ -142,7 +142,7 @@ void GSTexture9::Unmap() } } -bool GSTexture9::Save(const string& fn, bool user_image, bool dds) +bool GSTexture9::Save(const string& fn, bool dds) { bool rb_swapped = true; CComPtr surface; @@ -201,7 +201,7 @@ bool GSTexture9::Save(const string& fn, bool user_image, bool dds) return false; } - int compression = user_image ? Z_BEST_COMPRESSION : theApp.GetConfigI("png_compression_level"); + int compression = theApp.GetConfigI("png_compression_level"); bool success = GSPng::Save(format, fn, static_cast(slr.pBits), desc.Width, desc.Height, slr.Pitch, compression, rb_swapped); surface->UnlockRect(); diff --git a/plugins/GSdx/GSTexture9.h b/plugins/GSdx/GSTexture9.h index 347734fd50..dcf67cdf96 100644 --- a/plugins/GSdx/GSTexture9.h +++ b/plugins/GSdx/GSTexture9.h @@ -38,7 +38,7 @@ public: bool Update(const GSVector4i& r, const void* data, int pitch); bool Map(GSMap& m, const GSVector4i* r); void Unmap(); - bool Save(const string& fn, bool user_image = false, bool dds = false); + bool Save(const string& fn, bool dds = false); operator IDirect3DSurface9*(); operator IDirect3DTexture9*(); diff --git a/plugins/GSdx/GSTextureNull.h b/plugins/GSdx/GSTextureNull.h index 5d443b24e7..0a18d53fb4 100644 --- a/plugins/GSdx/GSTextureNull.h +++ b/plugins/GSdx/GSTextureNull.h @@ -37,5 +37,5 @@ public: bool Update(const GSVector4i& r, const void* data, int pitch) {return true;} bool Map(GSMap& m, const GSVector4i* r) {return false;} void Unmap() {} - bool Save(const string& fn, bool user_image = false, bool dds = false) { return false; } + bool Save(const string& fn, bool dds = false) {return false;} }; diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 5904690aeb..56256149a3 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -443,7 +443,7 @@ void GSTextureOGL::Unmap() } } -bool GSTextureOGL::Save(const string& fn, bool user_image, bool dds) +bool GSTextureOGL::Save(const string& fn, bool dds) { // Collect the texture data uint32 pitch = 4 * m_size.x; @@ -492,7 +492,7 @@ bool GSTextureOGL::Save(const string& fn, bool user_image, bool dds) glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); } - int compression = user_image ? Z_BEST_COMPRESSION : theApp.GetConfigI("png_compression_level"); + int compression = theApp.GetConfigI("png_compression_level"); return GSPng::Save(fmt, fn, image.get(), m_size.x, m_size.y, pitch, compression); } diff --git a/plugins/GSdx/GSTextureOGL.h b/plugins/GSdx/GSTextureOGL.h index cba8601f64..8a2aadc678 100644 --- a/plugins/GSdx/GSTextureOGL.h +++ b/plugins/GSdx/GSTextureOGL.h @@ -68,7 +68,7 @@ class GSTextureOGL final : public GSTexture bool Update(const GSVector4i& r, const void* data, int pitch) final; bool Map(GSMap& m, const GSVector4i* r = NULL) final; void Unmap() final; - bool Save(const string& fn, bool user_image = false, bool dds = false) final; + bool Save(const string& fn, bool dds = false) final; bool IsBackbuffer() { return (m_type == GSTexture::Backbuffer); } bool IsDss() { return (m_type == GSTexture::DepthStencil); } diff --git a/plugins/GSdx/GSTextureSW.cpp b/plugins/GSdx/GSTextureSW.cpp index 6e02f59da6..29d5d25e9b 100644 --- a/plugins/GSdx/GSTextureSW.cpp +++ b/plugins/GSdx/GSTextureSW.cpp @@ -85,7 +85,7 @@ void GSTextureSW::Unmap() m_mapped.clear(std::memory_order_release); } -bool GSTextureSW::Save(const string& fn, bool user_image, bool dds) +bool GSTextureSW::Save(const string& fn, bool dds) { if(dds) return false; // not implemented @@ -94,6 +94,6 @@ bool GSTextureSW::Save(const string& fn, bool user_image, bool dds) #else GSPng::Format fmt = GSPng::RGB_PNG; #endif - int compression = user_image ? Z_BEST_COMPRESSION : theApp.GetConfigI("png_compression_level"); + int compression = theApp.GetConfigI("png_compression_level"); return GSPng::Save(fmt, fn, static_cast(m_data), m_size.x, m_size.y, m_pitch, compression); } diff --git a/plugins/GSdx/GSTextureSW.h b/plugins/GSdx/GSTextureSW.h index 52154ee297..8cba020ff5 100644 --- a/plugins/GSdx/GSTextureSW.h +++ b/plugins/GSdx/GSTextureSW.h @@ -38,5 +38,5 @@ public: bool Update(const GSVector4i& r, const void* data, int pitch); bool Map(GSMap& m, const GSVector4i* r); void Unmap(); - bool Save(const string& fn, bool user_image = false, bool dds = false); + bool Save(const string& fn, bool dds = false); };