mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Added a primary surface repository
This commit is contained in:
parent
086b7740d9
commit
c344ec3408
@ -496,14 +496,19 @@ namespace D3dDdi
|
||||
return result;
|
||||
}
|
||||
|
||||
void Adapter::setRepository(LUID luid, CompatWeakPtr<IDirectDraw7> repository)
|
||||
void Adapter::setRepository(LUID luid, CompatWeakPtr<IDirectDraw7> repository, bool isPrimary)
|
||||
{
|
||||
for (auto& adapter : s_adapters)
|
||||
{
|
||||
if (adapter.second.m_luid == luid)
|
||||
{
|
||||
adapter.second.m_repository = repository;
|
||||
SurfaceRepository::get(adapter.second).setRepository(repository);
|
||||
auto& surfaceRepo = SurfaceRepository::get(adapter.second);
|
||||
surfaceRepo.setRepository(repository);
|
||||
if (isPrimary)
|
||||
{
|
||||
surfaceRepo.setAsPrimary();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace D3dDdi
|
||||
|
||||
static void add(const D3DDDIARG_OPENADAPTER& data) { s_adapters.emplace(data.hAdapter, data); }
|
||||
static Adapter& get(HANDLE adapter) { return s_adapters.find(adapter)->second; }
|
||||
static void setRepository(LUID luid, CompatWeakPtr<IDirectDraw7> repository);
|
||||
static void setRepository(LUID luid, CompatWeakPtr<IDirectDraw7> repository, bool isPrimary);
|
||||
|
||||
private:
|
||||
const AdapterInfo& findInfo() const;
|
||||
|
@ -17,6 +17,7 @@
|
||||
namespace
|
||||
{
|
||||
std::map<LUID, D3dDdi::SurfaceRepository> g_repositories;
|
||||
D3dDdi::SurfaceRepository* g_primaryRepository = nullptr;
|
||||
bool g_enableSurfaceCheck = true;
|
||||
|
||||
void initDitherTexture(BYTE* tex, DWORD pitch, DWORD x, DWORD y, DWORD size, DWORD mul, DWORD value)
|
||||
@ -297,6 +298,11 @@ namespace D3dDdi
|
||||
return getSurface(m_paletteTexture, 256, 1, D3DDDIFMT_A8R8G8B8, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY).resource;
|
||||
}
|
||||
|
||||
SurfaceRepository& SurfaceRepository::getPrimary()
|
||||
{
|
||||
return *g_primaryRepository;
|
||||
}
|
||||
|
||||
SurfaceRepository::Surface& SurfaceRepository::getSurface(Surface& surface, DWORD width, DWORD height,
|
||||
D3DDDIFORMAT format, DWORD caps, UINT surfaceCount, DWORD caps2)
|
||||
{
|
||||
@ -386,5 +392,10 @@ namespace D3dDdi
|
||||
}
|
||||
}
|
||||
|
||||
void SurfaceRepository::setAsPrimary()
|
||||
{
|
||||
g_primaryRepository = this;
|
||||
}
|
||||
|
||||
bool SurfaceRepository::s_inCreateSurface = false;
|
||||
}
|
||||
|
@ -53,9 +53,11 @@ namespace D3dDdi
|
||||
D3DDDIFORMAT format, DWORD caps, UINT surfaceCount = 1);
|
||||
const Surface& getTempTexture(DWORD width, DWORD height, D3DDDIFORMAT format);
|
||||
void release(Surface& surface);
|
||||
void setAsPrimary();
|
||||
void setRepository(CompatWeakPtr<IDirectDraw7> dd) { m_dd = dd; }
|
||||
|
||||
static SurfaceRepository& get(const Adapter& adapter);
|
||||
static SurfaceRepository& getPrimary();
|
||||
static bool inCreateSurface() { return s_inCreateSurface; }
|
||||
static void enableSurfaceCheck(bool enable);
|
||||
|
||||
|
@ -284,9 +284,9 @@ namespace DDraw
|
||||
}
|
||||
repo.get()->lpVtbl->SetCooperativeLevel(repo, nullptr, DDSCL_NORMAL);
|
||||
it = repositories.insert({ adapterInfo.luid, repo }).first;
|
||||
D3dDdi::Adapter::setRepository(adapterInfo.luid, it->second, !guid);
|
||||
repo.detach();
|
||||
}
|
||||
D3dDdi::Adapter::setRepository(adapterInfo.luid, it->second);
|
||||
}
|
||||
|
||||
void suppressEmulatedDirectDraw(GUID*& guid)
|
||||
|
@ -97,6 +97,7 @@ namespace DDraw
|
||||
{
|
||||
void installHooks(CompatPtr<IDirectDraw7> dd7)
|
||||
{
|
||||
DDraw::DirectDraw::onCreate(nullptr, *dd7);
|
||||
RealPrimarySurface::init();
|
||||
|
||||
g_origInitialize = dd7.get()->lpVtbl->Initialize;
|
||||
|
Loading…
x
Reference in New Issue
Block a user