]> git.vomp.tv Git - vompclient.git/blob - src/surface.h
Type change: UCHAR -> u1
[vompclient.git] / src / surface.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 SURFACE_H
21 #define SURFACE_H
22
23 #include "defines.h"
24 #include "colour.h"
25
26 #include "teletextdecodervbiebu.h"
27
28 #ifndef GRADIENT_DRAWING
29 // Font stuff
30
31 // FIXME does anything use this anymore?
32 typedef struct bogl_font
33 {
34   char* name;     /* Font name. */
35   int height;     /* Height in pixels. */
36   int spacing;     /* Vertical spacing in pixels. */
37   unsigned long* content;   /* 32-bit right-padded bitmap array. */
38   short* offset;      /* 256 offsets into content. */
39   unsigned char* width;   /* 256 character widths. */
40 } osd_font_t;
41
42 //extern osd_font_t font_CaslonRoman_1_25;
43 //extern osd_font_t font_helvB24;
44 extern osd_font_t font_helvB18;
45 #endif
46
47 class Bitmap;
48 class DisplayRegion;
49
50 class Surface
51 {
52     // classes that need surface access, their usage is forbidden for vector based
53     friend class WJpegComplex;// implementations of osd
54     friend class VColourTuner;
55
56   public:
57     Surface(int id = 0);
58     virtual ~Surface();
59
60     static Surface* getScreen();
61
62 #ifdef GRADIENT_DRAWING
63     virtual int getFontHeight() = 0;
64     virtual float getCharWidth(wchar_t c) = 0;
65     virtual int drawText(const char* text, int x, int y, const DrawStyle& c) = 0;
66     virtual int drawText(const char* text, int x, int y, int width, const DrawStyle& c) = 0;
67     virtual int drawTextRJ(const char* text, int x, int y, const DrawStyle& c) = 0;
68     virtual int drawTextCentre(const char* text, int x, int y, const DrawStyle& c) = 0;
69 #else
70     //May be move this stuff to a new Basis class surface pixel
71     virtual int getFontHeight();
72     virtual float getCharWidth(wchar_t c);
73     virtual int drawText(const char* text, int x, int y, const DrawStyle& c);
74     virtual int drawText(const char* text, int x, int y, int width, const DrawStyle& c);
75     virtual int drawTextRJ(const char* text, int x, int y, const DrawStyle& c);
76     virtual int drawTextCentre(const char* text, int x, int y, const DrawStyle& c);
77 #endif
78
79     virtual void drawJpeg(const char* /* fileName */, int /* x */, int /* y */, int* /* width */, int* /* height */) {}
80
81     virtual int create(u4 width, u4 height) = 0;
82     virtual void display() = 0;
83
84     virtual int fillblt(int x, int y, int width, int height, const DrawStyle& c) = 0;
85     virtual void drawHorzLine(int x1, int x2, int y, const DrawStyle& c) = 0;
86     virtual void drawVertLine(int x, int y1, int y2, const DrawStyle& c) = 0;
87     virtual void drawBitmap(int x, int y, const Bitmap& bm, const DisplayRegion& region) = 0;
88     virtual void drawPoint(int x, int y, const DrawStyle& c, bool fastdraw = false); // This draws a point, must not be a pixel
89     virtual void drawMonoBitmap(u1* base, int dx, int dy, unsigned int height, unsigned int width, const DrawStyle& nextColour);
90     virtual int updateToScreen(int sx, int sy, int w, int h, int dx, int dy) = 0;
91     virtual void readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b) = 0;
92     virtual bool screenShot(const char* fileName) = 0;
93
94     /* This is for system which need a locking of the drawing surface to speed up drawing */
95     virtual void startFastDraw() {};
96     virtual void endFastDraw() {};
97
98     virtual void drawTTChar(int ox, int oy, int x, int y, cTeletextChar c);
99     static Colour enumTeletextColorToCoulour(enumTeletextColor ttcol);
100
101     // virtual int blt(int fd, unsigned long shandle, int sx, int sy, int width, int height, unsigned long dhandle, int dx, int dy)=0;
102
103     const static int SCREEN = 1;
104     const static int BUFFER = 2;
105
106   protected:
107     static Surface* screen;
108 #ifndef GRADIENT_DRAWING
109     static osd_font_t* font;
110 #endif
111
112     virtual void drawPixel(int x, int y, unsigned int c, bool fastdraw = false) = 0; // deprecated preparation for vector based drawing, only allowed to be called inside implementation
113     virtual void drawPixel(int x, int y, const Colour& c, bool fastdraw = false) = 0; // deprecated preparation for vector based drawing, only allowed to be called inside implementation
114
115   private:
116     void initpol_tables();
117     unsigned int interpol_table_fac1[16][22];
118     unsigned int interpol_table_fac2[16][22];
119     unsigned int interpol_table_fac3[16][22];
120     unsigned int interpol_table_fac4[16][22];
121     int interpol_lowbit[16];
122     int interpol_upbit[16];
123     int interpol_lowline[22];
124     int interpol_upline[22];
125     bool pol_table_inited = false;
126 };
127
128 #endif