]> git.vomp.tv Git - vompclient.git/blob - windowsosd.h
Rewrite timers class using std::thread/mutex/cond/chrono
[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 <winsock2.h>
25 #include <d3d9.h>
26 #include <Dxva2api.h>
27 #include "threadwin.h"
28
29 #define  BACKBUFFER_WIDTH 1920
30 #define  BACKBUFFER_HEIGHT 1080
31
32 class DsAllocator;
33
34 struct OSDVERTEX
35 {
36         FLOAT x, y, z, rhw;
37         DWORD c;
38         FLOAT u, v;
39 };
40
41 #define D3DFVF_OSDVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE| D3DFVF_TEX1)
42
43
44 // This class defines all necessary interfaces
45 // for windows osd to communicate with other windows base classes
46
47 class WindowsOsd : public ThreadWin {
48 public:
49         WindowsOsd();
50         virtual ~WindowsOsd();
51
52         bool IsEvrSupported() { return evrsupported; };
53         void setExternalDriving(DsAllocator* dsall, DWORD width, DWORD height);
54
55
56         DWORD getFilterType(){ return filter_type; };
57         void setFilterType(D3DTEXTUREFILTERTYPE type) { filter_type = type; };
58
59         LPDIRECT3DDEVICE9 getD3dDev();
60         LPDIRECT3D9 getD3d();
61         IDirect3DDeviceManager9 * getD3dMan() { return d3ddevman; };
62         DWORD getFilterCaps();
63         HWND getWindow() { return window; };
64         void setWindow(HWND twnd) { window = twnd; };
65
66         // This function is called  in order to get Screen updates
67         void Render();
68         void RenderDS(LPDIRECT3DSURFACE9 present);
69         void Blank();
70         void BeginPainting();
71         void EndPainting();
72
73         virtual int isInitialized()=0;
74
75         void threadMethod();
76
77         enum EVR_state {
78                 EVR_pres_off = 0,
79                 EVR_pres_started,
80                 EVR_pres_pause
81         };
82
83         void SetEVRStatus(EVR_state new_state){ evrstate = new_state; };
84 protected:
85
86         int createDirect3D9Objects();
87         void shutdownDirect3D9Objects();
88         void startRenderLoop();
89         void stopRenderLoop();
90         void InternalRendering(LPDIRECT3DSURFACE9 present);
91         bool DoLost();
92         virtual void lostDestroyObjects()=0;
93         virtual void lostRecreateObjects()=0;
94
95         virtual void getTextureCoordinates(FLOAT*, FLOAT*)=0;
96
97         virtual void updateOsd() {};
98
99         void LockDevice();
100         void UnlockDevice();
101         
102         virtual LPDIRECT3DTEXTURE9 getNextOsdTexture()=0;
103
104         LPDIRECT3DVERTEXBUFFER9 InitVertexBuffer(DWORD width, DWORD height);
105         LPDIRECT3DVERTEXBUFFER9 InitBackgroundVertexBuffer(DWORD width, DWORD height);
106         
107
108         bool evrsupported;
109         EVR_state evrstate;
110         D3DTEXTUREFILTERTYPE filter_type;
111 #ifdef WINDOWS_LEGACY
112         LPDIRECT3D9 d3d;
113         LPDIRECT3DDEVICE9 d3ddevice;
114 #else
115         LPDIRECT3D9EX d3d;
116         LPDIRECT3DDEVICE9EX d3ddevice;
117 #endif
118         LPDIRECT3DSWAPCHAIN9 swappy;
119         LPDIRECT3DSURFACE9 swapsurf;
120         LPDIRECT3DSURFACE9 d3drtsurf;
121
122         UINT dxvatoken;
123         IDirect3DDeviceManager9 *d3ddevman;
124         HANDLE  dxvadevicehandle;
125
126         DsAllocator* dsallocator;
127
128         bool external_driving;
129         HANDLE d3dmutex;
130         HANDLE event;
131         DWORD lastrendertime;
132         DWORD lastosdrendertime;
133         HWND window;
134
135 };
136
137
138
139 #endif