]> git.vomp.tv Git - vompclient.git/blob - windowsosd.h
Convert PlayerRadioRec to std::thread
[vompclient.git] / windowsosd.h
1 /*
2         Copyright 2004-2005 Marten Richter
3
4         This file is part of VOMP.
5
6         VOMP is free software; you can redistribute it and/or modify
7         it under the terms of the GNU General Public License as published by
8         the Free Software Foundation; either version 2 of the License, or
9         (at your option) any later version.
10
11         VOMP is distributed in the hope that it will be useful,
12         but WITHOUT ANY WARRANTY; without even the implied warranty of
13         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14         GNU General Public License for more details.
15
16         You should have received a copy of the GNU General Public License
17         along with VOMP; if not, write to the Free Software
18         Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #ifndef WINDOWSOSD_H
22 #define WINDOWSOSD_H
23
24 #include <mutex>
25 #include <winsock2.h>
26 #include <d3d9.h>
27 #include <Dxva2api.h>
28 #include "threadwin.h"
29
30 #define  BACKBUFFER_WIDTH 1920
31 #define  BACKBUFFER_HEIGHT 1080
32
33 class DsAllocator;
34
35 struct OSDVERTEX
36 {
37         FLOAT x, y, z, rhw;
38         DWORD c;
39         FLOAT u, v;
40 };
41
42 #define D3DFVF_OSDVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE| D3DFVF_TEX1)
43
44
45 // This class defines all necessary interfaces
46 // for windows osd to communicate with other windows base classes
47
48 class WindowsOsd : public ThreadWin {
49 public:
50         WindowsOsd();
51         virtual ~WindowsOsd();
52
53         bool IsEvrSupported() { return evrsupported; };
54         void setExternalDriving(DsAllocator* dsall, DWORD width, DWORD height);
55
56
57         DWORD getFilterType(){ return filter_type; };
58         void setFilterType(D3DTEXTUREFILTERTYPE type) { filter_type = type; };
59
60         LPDIRECT3DDEVICE9 getD3dDev();
61         LPDIRECT3D9 getD3d();
62         IDirect3DDeviceManager9 * getD3dMan() { return d3ddevman; };
63         DWORD getFilterCaps();
64         HWND getWindow() { return window; };
65         void setWindow(HWND twnd) { window = twnd; };
66
67         // This function is called  in order to get Screen updates
68         void Render();
69         void RenderDS(LPDIRECT3DSURFACE9 present);
70         void Blank();
71         void BeginPainting();
72         void EndPainting();
73
74         virtual bool isInitialized()=0;
75
76         void threadMethod();
77
78         enum EVR_state {
79                 EVR_pres_off = 0,
80                 EVR_pres_started,
81                 EVR_pres_pause
82         };
83
84         void SetEVRStatus(EVR_state new_state){ evrstate = new_state; };
85 protected:
86
87         int createDirect3D9Objects();
88         void shutdownDirect3D9Objects();
89         void startRenderLoop();
90         void stopRenderLoop();
91         void InternalRendering(LPDIRECT3DSURFACE9 present);
92         bool DoLost();
93         virtual void lostDestroyObjects()=0;
94         virtual void lostRecreateObjects()=0;
95
96         virtual void getTextureCoordinates(FLOAT*, FLOAT*)=0;
97
98         virtual void updateOsd() {};
99
100         void LockDevice();
101         void UnlockDevice();
102         
103         virtual LPDIRECT3DTEXTURE9 getNextOsdTexture()=0;
104
105         LPDIRECT3DVERTEXBUFFER9 InitVertexBuffer(DWORD width, DWORD height);
106         LPDIRECT3DVERTEXBUFFER9 InitBackgroundVertexBuffer(DWORD width, DWORD height);
107         
108
109         bool evrsupported;
110         EVR_state evrstate;
111         D3DTEXTUREFILTERTYPE filter_type;
112 #ifdef WINDOWS_LEGACY
113         LPDIRECT3D9 d3d;
114         LPDIRECT3DDEVICE9 d3ddevice;
115 #else
116         LPDIRECT3D9EX d3d;
117         LPDIRECT3DDEVICE9EX d3ddevice;
118 #endif
119         LPDIRECT3DSWAPCHAIN9 swappy;
120         LPDIRECT3DSURFACE9 swapsurf;
121         LPDIRECT3DSURFACE9 d3drtsurf;
122
123         UINT dxvatoken;
124         IDirect3DDeviceManager9 *d3ddevman;
125         HANDLE  dxvadevicehandle;
126
127         DsAllocator* dsallocator;
128
129         bool external_driving;
130         std::mutex d3dmutex;
131         HANDLE event;
132         DWORD lastrendertime;
133         DWORD lastosdrendertime;
134         HWND window;
135
136 };
137
138
139
140 #endif