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

49 lines
1.3 KiB
C++

#pragma once
#define CINTERFACE
#include <memory>
#include <ddraw.h>
#include "Common/CompatRef.h"
namespace DDraw
{
template <typename TSurface>
class SurfaceImpl;
class Surface
{
public:
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, LPVOID*);
virtual ULONG STDMETHODCALLTYPE AddRef();
virtual ULONG STDMETHODCALLTYPE Release();
virtual ~Surface();
template <typename TDirectDraw, typename TSurface, typename TSurfaceDesc>
static HRESULT create(CompatRef<TDirectDraw> dd, TSurfaceDesc desc, TSurface*& surface);
template <typename TSurface>
static SurfaceImpl<TSurface>* getImpl(CompatRef<TSurface> dds);
template <typename TSurface>
SurfaceImpl<TSurface>* getImpl() const;
protected:
static void attach(CompatRef<IDirectDrawSurface7> dds, std::unique_ptr<Surface>& privateData);
std::unique_ptr<SurfaceImpl<IDirectDrawSurface>> m_impl;
std::unique_ptr<SurfaceImpl<IDirectDrawSurface2>> m_impl2;
std::unique_ptr<SurfaceImpl<IDirectDrawSurface3>> m_impl3;
std::unique_ptr<SurfaceImpl<IDirectDrawSurface4>> m_impl4;
std::unique_ptr<SurfaceImpl<IDirectDrawSurface7>> m_impl7;
private:
static HRESULT WINAPI attachToLinkedSurfaces(
IDirectDrawSurface7* surface, DDSURFACEDESC2* desc, void* rootSurface);
virtual void createImpl();
};
}