1#ifndef MYTHRENDER_D3D9_H
2#define MYTHRENDER_D3D9_H
5#if QT_VERSION >= QT_VERSION_CHECK(6,5,0)
6#include <QtSystemDetection>
10#include "libmythbase/mythconfig.h"
19#if defined (Q_OS_WINDOWS)
36 bool IsValid(
void)
const {
return m_valid; }
37 QSize
GetSize(
void)
const {
return m_size; }
38 int GetDataSize(
void)
const {
return m_size.width() * m_size.height() * 4; }
39 bool SetAsRenderTarget(
void);
40 bool UpdateImage(IDirect3DSurface9 *surface);
42 bool UpdateVertices(
const QRect &dvr,
const QRect &vr,
int alpha = 255,
45 uint8_t* GetBuffer(
bool &hardware_conv,
uint &pitch);
46 void ReleaseBuffer(
void);
53 IDirect3DVertexBuffer9 *m_vertexbuffer {
nullptr};
54 IDirect3DTexture9 *m_texture {
nullptr};
55 IDirect3DSurface9 *m_surface {
nullptr};
64 IDirect3DDevice9* Acquire(
void);
73 m_dest(QRect(QPoint(0,0),QSize(0,0))),
99 static void* ResolveAddress(
const char* lib,
const char* proc);
103 bool Create(QSize size, HWND window);
104 bool Test(
bool &reset);
106 bool ClearBuffer(
void);
109 void CopyFrame(
void* surface,
D3D9Image *img);
110 bool StretchRect(IDirect3DTexture9 *texture, IDirect3DSurface9 *surface,
111 bool known_surface =
true);
112 bool DrawTexturedQuad(IDirect3DVertexBuffer9 *vertexbuffer);
113 void DrawRect(
const QRect &rect,
const QColor &color,
int alpha);
114 bool Present(HWND win);
115 bool HardwareYUVConversion(
void);
116 QRect GetRect(IDirect3DVertexBuffer9 *vertexbuffer);
117 bool SetRenderTarget(IDirect3DTexture9 *texture);
119 IDirect3DTexture9* CreateTexture(
const QSize &size);
120 void DeleteTexture(IDirect3DTexture9* texture);
122 IDirect3DVertexBuffer9* CreateVertexBuffer(IDirect3DTexture9* texture =
nullptr);
123 bool UpdateVertexBuffer(IDirect3DVertexBuffer9* vertexbuffer,
124 const QRect &dvr,
const QRect &vr,
125 int alpha = 255,
bool video =
false);
126 void DeleteVertexBuffer(IDirect3DVertexBuffer9* vertexbuffer);
128 IDirect3DSurface9* CreateSurface(
const QSize &size,
bool video =
false);
129 bool UpdateSurface(IDirect3DSurface9* surface,
131 void DeleteSurface(IDirect3DSurface9* surface);
132 uint8_t* GetBuffer(IDirect3DSurface9* surface,
uint &pitch);
133 void ReleaseBuffer(IDirect3DSurface9* surface);
137 bool SetTexture(IDirect3DDevice9* dev,
138 IDirect3DTexture9 *texture,
140 void DeleteTextures(
void);
141 void DeleteVertexBuffers(
void);
142 void DeleteSurfaces(
void);
143 void Init2DState(
void);
144 void EnableBlending(IDirect3DDevice9* dev,
bool enable);
145 void MultiTexturing(IDirect3DDevice9* dev,
bool enable,
146 IDirect3DTexture9 *texture =
nullptr);
147 void SetTextureVertices(IDirect3DDevice9* dev,
bool enable);
154 IDirect3D9 *m_d3d {
nullptr};
155 IDirect3DDevice9 *m_rootD3DDevice {
nullptr};
156 D3DFORMAT m_adaptor_fmt {D3DFMT_UNKNOWN};
157 D3DFORMAT m_videosurface_fmt {D3DFMT_UNKNOWN};
158 D3DFORMAT m_surface_fmt {D3DFMT_UNKNOWN};
159 D3DFORMAT m_texture_fmt {D3DFMT_UNKNOWN};
160 IDirect3DVertexBuffer9 *m_rect_vertexbuffer {
nullptr};
161 IDirect3DSurface9 *m_default_surface {
nullptr};
162 IDirect3DSurface9 *m_current_surface {
nullptr};
166 bool m_multi_texturing {
true};
167 bool m_texture_vertices {
true};
170 IDirect3DDevice9* AcquireDevice(
void);
171 void ReleaseDevice(
void);
175 void CreateDeviceManager(
void);
176 void DestroyDeviceManager(
void);
180 HANDLE m_deviceHandle {
nullptr};
int GetDataSize(void) const
QSize GetSize(void) const
D3D9Locker(MythRenderD3D9 *render)
MythD3DSurface(QSize size=QSize(0, 0), D3DFORMAT fmt=D3DFMT_UNKNOWN)
IDirect3DTexture9 * m_texture
MythD3DVertexBuffer(IDirect3DTexture9 *tex=nullptr)
QMap< IDirect3DSurface9 *, MythD3DSurface > m_surfaces
QMap< IDirect3DTexture9 *, QSize > m_textures
QMap< IDirect3DVertexBuffer9 *, MythD3DVertexBuffer > m_vertexbuffers
IDirect3DDeviceManager9 * GetDeviceManager(void)
void * IDirect3DDeviceManager9