1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Added GdiStretchBltMode setting

See issue #330.
This commit is contained in:
narzoul 2024-06-23 22:12:28 +02:00
parent 0b974e2dd7
commit 767c8d28ee
6 changed files with 54 additions and 0 deletions

View File

@ -22,6 +22,7 @@
#include <Config/Settings/ForceD3D9On12.h>
#include <Config/Settings/FpsLimiter.h>
#include <Config/Settings/FullscreenMode.h>
#include <Config/Settings/GdiStretchBltMode.h>
#include <Config/Settings/LogLevel.h>
#include <Config/Settings/PalettizedTextures.h>
#include <Config/Settings/RemoveBorders.h>
@ -78,6 +79,7 @@ namespace Config
Settings::ForceD3D9On12 forceD3D9On12;
Settings::FpsLimiter fpsLimiter;
Settings::FullscreenMode fullscreenMode;
Settings::GdiStretchBltMode gdiStretchBltMode;
Settings::LogLevel logLevel;
Settings::PalettizedTextures palettizedTextures;
Settings::RemoveBorders removeBorders;

View File

@ -0,0 +1,25 @@
#pragma once
#include <Config/MappedSetting.h>
namespace Config
{
namespace Settings
{
class GdiStretchBltMode : public MappedSetting<UINT>
{
public:
static const UINT APP = 0;
GdiStretchBltMode() : MappedSetting("GdiStretchBltMode", "app", {
{"app", APP},
{"coloroncolor", COLORONCOLOR},
{"halftone", HALFTONE}
})
{
}
};
}
extern Settings::GdiStretchBltMode gdiStretchBltMode;
}

View File

@ -188,6 +188,7 @@
<ClInclude Include="Config\Settings\ForceD3D9On12.h" />
<ClInclude Include="Config\Settings\FpsLimiter.h" />
<ClInclude Include="Config\Settings\FullscreenMode.h" />
<ClInclude Include="Config\Settings\GdiStretchBltMode.h" />
<ClInclude Include="Config\Settings\LogLevel.h" />
<ClInclude Include="Config\Settings\PalettizedTextures.h" />
<ClInclude Include="Config\Settings\RemoveBorders.h" />

View File

@ -720,6 +720,9 @@
<ClInclude Include="Config\Settings\VertexFixup.h">
<Filter>Header Files\Config\Settings</Filter>
</ClInclude>
<ClInclude Include="Config\Settings\GdiStretchBltMode.h">
<Filter>Header Files\Config\Settings</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Gdi\Gdi.cpp">

View File

@ -1,5 +1,6 @@
#include <Common/Hook.h>
#include <Common/Log.h>
#include <Config/Settings/GdiStretchBltMode.h>
#include <Gdi/CompatDc.h>
#include <Gdi/Dc.h>
#include <Gdi/DcFunctions.h>
@ -342,6 +343,24 @@ namespace
Compat::hookFunction<origFunc>(moduleName, funcName, &compatGdiTextDcFunc<origFunc>);
}
int WINAPI setStretchBltMode(HDC hdc, int mode)
{
LOG_FUNC("SetStretchBltMode", hdc, mode);
if (COLORONCOLOR == mode && HALFTONE == Config::gdiStretchBltMode.get())
{
POINT org = {};
GetBrushOrgEx(hdc, &org);
auto result = CALL_ORIG_FUNC(SetStretchBltMode)(hdc, HALFTONE);
SetBrushOrgEx(hdc, org.x, org.y, nullptr);
return LOG_RESULT(result);
}
if (HALFTONE == mode && COLORONCOLOR == Config::gdiStretchBltMode.get())
{
mode = COLORONCOLOR;
}
return LOG_RESULT(CALL_ORIG_FUNC(SetStretchBltMode)(hdc, mode));
}
HWND WINAPI windowFromDc(HDC dc)
{
return CALL_ORIG_FUNC(WindowFromDC)(Gdi::Dc::getOrigDc(dc));
@ -394,6 +413,7 @@ namespace Gdi
// Device context functions
HOOK_GDI_DC_FUNCTION(gdi32, DrawEscape);
HOOK_FUNCTION(gdi32, SetStretchBltMode, setStretchBltMode);
HOOK_FUNCTION(user32, WindowFromDC, windowFromDc);
// Filled shape functions

View File

@ -15,6 +15,7 @@
#include <Config/Settings/DisplayFilter.h>
#include <Config/Settings/FontAntialiasing.h>
#include <Config/Settings/FpsLimiter.h>
#include <Config/Settings/GdiStretchBltMode.h>
#include <Config/Settings/RenderColorDepth.h>
#include <Config/Settings/ResolutionScale.h>
#include <Config/Settings/ResolutionScaleFilter.h>
@ -28,6 +29,7 @@
#include <Config/Settings/VertexFixup.h>
#include <Config/Settings/VSync.h>
#include <D3dDdi/Device.h>
#include <Gdi/Gdi.h>
#include <Gdi/GuiThread.h>
#include <Input/Input.h>
#include <Overlay/ConfigWindow.h>
@ -57,6 +59,7 @@ namespace
{ &Config::displayFilter },
{ &Config::fontAntialiasing },
{ &Config::fpsLimiter },
{ &Config::gdiStretchBltMode, []() { Gdi::redraw(nullptr); } },
{ &Config::renderColorDepth, &D3dDdi::Device::updateAllConfig },
{ &Config::resolutionScale, &D3dDdi::Device::updateAllConfig },
{ &Config::resolutionScaleFilter },