]> git.vomp.tv Git - vompclient.git/blob - osdwinvector.h
Convert all uses of Mutex to std::mutex
[vompclient.git] / osdwinvector.h
1 /*
2     Copyright 2004-2005 Chris Tallon
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, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifndef OSDWINVECTOR_H
21 #define OSDWINVECTOR_H
22
23 #include <stdio.h>
24 #include <d3d10_1.h>
25 #include <d2d1.h>
26 #include <dwrite.h>
27 #include <queue>
28 #include <list>
29 #include <mutex>
30
31 #include "osdvector.h"
32 #include "defines.h"
33 #include "log.h"
34 #include "windowsosd.h"
35
36
37
38
39 class OsdWinVector : public OsdVector, public WindowsOsd
40 {
41   friend class WICPictDecoder;
42   public:
43     OsdWinVector();
44     ~OsdWinVector();
45
46     int init();
47     int shutdown();
48
49         int isInitialized() { return initted; }
50
51         void getScreenSize(int &width, int &height);
52         void getRealScreenSize(int &width, int &height);
53
54         float getFontHeight();
55         float getCharWidth(wchar_t c);
56
57         bool screenShot(void *buffer, int width, int height, bool osd /*include osd*/);
58
59         int getFontNames(const char *** names, const char *** names_keys);
60
61         void setFont(const char * fontname);
62
63         float getPixelAspect() { return aspect_correction; };
64
65 protected:
66         LPDIRECT3DTEXTURE9 getNextOsdTexture();
67         void lostDestroyObjects();
68         void lostRecreateObjects();
69         void updateOsd();
70         void getTextureCoordinates(FLOAT*, FLOAT*);
71
72         /*osd vector implementation*/
73         void destroyImageRef(ImageIndex index);
74         ImageIndex createMonoBitmap(void *base, int width, int height);
75         ImageIndex createImagePalette(int width, int height, const unsigned char *image_data, const unsigned int*palette_data);
76         void createPicture(struct PictureInfo& pict_inf);
77         void destroyStyleRef(VectorHandle index);
78         VectorHandle createStyleRef(const DrawStyle &c);
79         bool getStaticImageData(unsigned int static_id, UCHAR **userdata, ULONG *length);
80
81
82         int  loadFont(bool fontchange);
83
84         std::map<unsigned int, float> font_exp_x;
85         std::vector<char*> fontnames;
86         //vector<char*> fontnames_keys;
87         wchar_t * cur_fontname;
88         bool is_direct_write_initted;
89         IDWriteFactory* dwritefac;
90         IDWriteFont* font;
91         IDWriteFontFace* fontface;
92         float fontheight;
93         float fontzero;
94         float fontaspect_corr;
95
96         struct TTIndex {
97                 unsigned char atlas;
98                 unsigned char position;
99         };
100
101         TTIndex loadTTchar(cTeletextChar c);
102
103         std::map<unsigned int, TTIndex> tt_font_chars;
104         std::vector<ID2D1Bitmap *> tt_atlas;
105         TTIndex ttchar_end;
106         ID2D1SolidColorBrush *ttbrush;
107
108
109         void executeDrawCommand(SVGCommand & command);
110         void drawSetTrans(SurfaceCommands & sc);
111
112         typedef struct {
113                 LPDIRECT3DTEXTURE9 surf9;
114                 IDirect3DQuery9 * query9;
115                 ID3D10Texture2D *surf10;
116                 IDXGISurface * surfdxgi;
117                 ID2D1RenderTarget *rendtarget2D;
118                 ID3D10Query * query10;
119                 HANDLE sharedhandle;
120         } SurfaceInfo;
121
122         std::queue<SurfaceInfo> d2dtod3d;
123         std::queue<SurfaceInfo> d3dtod2d;
124         std::list<SurfaceInfo> allsurfs;
125         SurfaceInfo currentosd_render;
126         SurfaceInfo currentosd_backbuffer;
127         ID2D1RenderTarget * LockOsdDrawing();
128         void UnlockOsdDrawing();
129
130         std::mutex queuemutex;
131
132         void initPaths();
133         void destroyPaths();
134         ID2D1PathGeometry *std_paths[PIPoint + 1];
135
136         ID3D10Device1 * d3ddevice10;
137         ID2D1Factory *d2dfactory;
138         IDXGIDevice * dxgidevice;
139         float aspect_correction;
140         float dpix, dpiy;
141
142         int clip_shift_x;
143         int clip_shift_y;
144
145         int num_clips;
146         
147 };
148
149 #endif