1 #ifndef MYTHRENDER_D3D9_H
2 #define MYTHRENDER_D3D9_H
20 using IDirect3DDeviceManager9 =
void*;
31 bool IsValid(
void)
const {
return m_valid; }
32 QSize
GetSize(
void)
const {
return m_size; }
33 int GetDataSize(
void)
const {
return m_size.width() * m_size.height() * 4; }
34 bool SetAsRenderTarget(
void);
35 bool UpdateImage(IDirect3DSurface9 *surface);
37 bool UpdateVertices(
const QRect &dvr,
const QRect &vr,
int alpha = 255,
40 uint8_t* GetBuffer(
bool &hardware_conv,
uint &pitch);
41 void ReleaseBuffer(
void);
48 IDirect3DVertexBuffer9 *m_vertexbuffer {
nullptr};
49 IDirect3DTexture9 *m_texture {
nullptr};
50 IDirect3DSurface9 *m_surface {
nullptr};
59 IDirect3DDevice9* Acquire(
void);
68 m_dest(QRect(QPoint(0,0),QSize(0,0))),
94 static void* ResolveAddress(
const char* lib,
const char* proc);
98 bool Create(QSize size, HWND window);
99 bool Test(
bool &reset);
101 bool ClearBuffer(
void);
104 void CopyFrame(
void* surface,
D3D9Image *img);
105 bool StretchRect(IDirect3DTexture9 *texture, IDirect3DSurface9 *surface,
106 bool known_surface =
true);
107 bool DrawTexturedQuad(IDirect3DVertexBuffer9 *vertexbuffer);
108 void DrawRect(
const QRect &rect,
const QColor &color,
int alpha);
109 bool Present(HWND win);
110 bool HardwareYUVConversion(
void);
111 QRect GetRect(IDirect3DVertexBuffer9 *vertexbuffer);
112 bool SetRenderTarget(IDirect3DTexture9 *texture);
114 IDirect3DTexture9* CreateTexture(
const QSize &size);
115 void DeleteTexture(IDirect3DTexture9* texture);
117 IDirect3DVertexBuffer9* CreateVertexBuffer(IDirect3DTexture9* texture =
nullptr);
118 bool UpdateVertexBuffer(IDirect3DVertexBuffer9* vertexbuffer,
119 const QRect &dvr,
const QRect &vr,
120 int alpha = 255,
bool video =
false);
121 void DeleteVertexBuffer(IDirect3DVertexBuffer9* vertexbuffer);
123 IDirect3DSurface9* CreateSurface(
const QSize &size,
bool video =
false);
124 bool UpdateSurface(IDirect3DSurface9* surface,
126 void DeleteSurface(IDirect3DSurface9* surface);
127 uint8_t* GetBuffer(IDirect3DSurface9* surface,
uint &pitch);
128 void ReleaseBuffer(IDirect3DSurface9* surface);
132 bool SetTexture(IDirect3DDevice9* dev,
133 IDirect3DTexture9 *texture,
135 void DeleteTextures(
void);
136 void DeleteVertexBuffers(
void);
137 void DeleteSurfaces(
void);
138 void Init2DState(
void);
139 void EnableBlending(IDirect3DDevice9* dev,
bool enable);
140 void MultiTexturing(IDirect3DDevice9* dev,
bool enable,
141 IDirect3DTexture9 *texture =
nullptr);
142 void SetTextureVertices(IDirect3DDevice9* dev,
bool enable);
149 IDirect3D9 *m_d3d {
nullptr};
150 IDirect3DDevice9 *m_rootD3DDevice {
nullptr};
151 D3DFORMAT m_adaptor_fmt {D3DFMT_UNKNOWN};
152 D3DFORMAT m_videosurface_fmt {D3DFMT_UNKNOWN};
153 D3DFORMAT m_surface_fmt {D3DFMT_UNKNOWN};
154 D3DFORMAT m_texture_fmt {D3DFMT_UNKNOWN};
155 IDirect3DVertexBuffer9 *m_rect_vertexbuffer {
nullptr};
156 IDirect3DSurface9 *m_default_surface {
nullptr};
157 IDirect3DSurface9 *m_current_surface {
nullptr};
161 bool m_multi_texturing {
true};
162 bool m_texture_vertices {
true};
165 IDirect3DDevice9* AcquireDevice(
void);
166 void ReleaseDevice(
void);
170 void CreateDeviceManager(
void);
171 void DestroyDeviceManager(
void);
174 IDirect3DDeviceManager9 *m_deviceManager {
nullptr};
175 HANDLE m_deviceHandle {
nullptr};
179 #endif // MYTHRENDER_D3D9_H