2 Copyright 2004-2005 Chris Tallon
3 Portions copyright 2004 Jon Gettler
5 This file is part of VOMP.
7 VOMP is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 VOMP is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with VOMP; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include <sys/ioctl.h>
31 // Structures for surface management
36 unsigned long unknown[4];
44 unsigned long unknown;
45 unsigned long win_unknown;
48 unsigned long unknown2;
51 unsigned long unknown3;
52 unsigned long unknown4;
54 unsigned long unknown5;
55 unsigned long unknown6;
59 stbgfx_map_item_t map[3];
60 unsigned long other[2];
65 unsigned long handle; /* surface handle */
69 long unknown; //unsigned long
70 unsigned long depth; /* number of subplanes */
75 stbgfx_display_t display;
78 unsigned char *base[3];
82 // Structures for surface drawing
95 unsigned long dst_handle;
100 unsigned long src_handle;
110 typedef struct bogl_font {
111 char *name; /* Font name. */
112 int height; /* Height in pixels. */
113 unsigned long *content; /* 32-bit right-padded bitmap array. */
114 short *offset; /* 256 offsets into content. */
115 unsigned char *width; /* 256 character widths. */
118 extern osd_font_t font_CaslonRoman_1_25;
119 extern osd_font_t font_helvB24;
120 extern osd_font_t font_helvB18;
124 #define GFX_FB_SFC_ALLOC _IOWR(0xfb,1,int*)
125 #define GFX_FB_SFC_FREE _IOWR(0xfb,2,int)
126 #define GFX_FB_MAP _IOWR(0xfb,3,int*)
127 #define GFX_FB_SFC_UNMAP _IOWR(0xfb,4,int)
128 #define GFX_FB_SET_PAL_1 _IOWR(0xfb,5,int*)
129 #define GFX_FB_SET_PAL_2 _IOW(0xfb,6,int*)
130 #define GFX_FB_OSD_SURFACE _IO(0xfb,7)
131 #define GFX_FB_SFC_SET_SHARE _IOW(0xfb,8,int)
132 #define GFX_FB_OSD_CUR_SETATTR _IOW(0xfb,9,int*)
133 #define GFX_FB_ATTACH _IOW(0xfb,11,int)
134 #define GFX_FB_SFC_DETACH _IOW(0xfb,12,int*)
135 #define GFX_FB_MOVE_DISPLAY _IOWR(0xfb,13,int)
136 #define GFX_FB_SET_DISPLAY _IOW(0xfb,14,int)
137 #define GFX_FB_OSD_CUR_MOVE_1 _IOW(0xfb,15,int*)
138 #define GFX_FB_OSD_CUR_MOVE_2 _IOW(0xfb,16,int)
139 #define GFX_FB_SET_OSD _IOW(0xfb,18,int)
140 #define GFX_FB_SET_DISP_CTRL _IOW(0xfb,21,int*)
141 #define GFX_FB_GET_DISP_CTRL _IOWR(0xfb,22,int*)
142 #define GFX_FB_SET_VIS_DEV_CTL _IOWR(0xfb,23,int*)
143 #define GFX_FB_GET_VIS_DEV_CTL _IOWR(0xfb,24,int*)
144 #define GFX_FB_OSD_BITBLT _IOW(0xfb,51,osd_bitblt_t*)
145 #define GFX_FB_OSD_FILLBLT _IOW(0xfb,53,osd_fillblt_t*)
146 #define GFX_FB_OSD_ADVFILLBLT _IOW(0xfb,54,osd_afillblt_t*)
147 #define GFX_FB_OSD_BLEND _IOW(0xfb,55,int*)
148 #define GFX_FB_OSD_ADVBLEND _IOW(0xfb,56,int*)
149 #define GFX_FB_OSD_RESIZE _IOW(0xfb,58,int*)
150 #define GFX_FB_ENGINE_WAIT _IOW(0xfb,60,int)
151 #define GFX_FB_RESET_ENGINE _IO(0xfb,61)
152 #define GFX_FB_SET_ENGINE_MODE _IOW(0xfb,62,int)
153 #define GFX_FB_GET_ENGINE_MODE _IO(0xfb,63)
154 #define GFX_FB_GET_SFC_INFO _IO(0xfb,64,int*)
155 #define GFX_FB_OSD_SFC_CLIP _IOW(0xfb,65,osd_clip_rec_t*)
156 #define GFX_FB_OSD_COLOURKEY _IOW(0xfb,67,int*)
157 #define GFX_FB_GET_SFC_PSEUDO _IOWR(0xfb,68,int*)
169 Surface(int fd, int id);
172 static Surface* getObject(int id);
174 int create(int height, int width);
176 unsigned long getSurfaceHandle();
178 int fillblt(int x, int y, int width, int height, unsigned int c);
179 void drawPixel(int x, int y, unsigned int c);
180 void drawHorzLine(int x1, int x2, int y, unsigned int c);
181 void drawVertLine(int x, int y1, int y2, unsigned int c);
182 int updateToScreen(int x, int y, int width, int height);
183 int drawText(char* text, int x, int y, int r, int g, int b);
184 int drawTextRJ(char* text, int x, int y, int r, int g, int b);
185 int getCharWidth(char c);
187 void readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b);
188 void yuv2rgb(int y, int u, int v, unsigned char* pr, unsigned char* pg, unsigned char* pb);
189 void screenShot(char* fileName);
191 static void initConversionTables();
193 static void disableBuffer();
194 static void bufferToScreen();
195 static int blt(int fd, unsigned long shandle, int sx, int sy, int width, int height, unsigned long dhandle, int dx, int dy);
197 const static int SCREEN = 1;
198 const static int BUFFER = 2;
201 void c2rgba(unsigned long c, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a)
203 *a = (c & 0xff000000) >> 24;
204 *r = (c & 0x00ff0000) >> 16;
205 *g = (c & 0x0000ff00) >> 8;
206 *b = (c & 0x000000ff);
209 unsigned long rgba(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
211 return (a<<24) | (r<<16) | (g<<8) | b;
216 static Surface* screen;
217 static Surface* buffer;
218 static int disableDoubleBuffering;
222 osd_surface_t surface;
225 void rgb2yuv(unsigned char r, unsigned char g, unsigned char b, unsigned char *y, unsigned char *u, unsigned char *v);
227 static int conv_YB[256];
228 static int conv_YG[256];
229 static int conv_YR[256];
230 static int conv_UB[256];
231 static int conv_UG[256];
232 static int conv_UR[256];
233 static int conv_VB[256];
234 static int conv_VG[256];
235 static int conv_VR[256];
237 static int conv_BY[256];
238 static int conv_GY[256];
239 static int conv_RY[256];
240 static int conv_BU[256];
241 static int conv_GU[256];
242 static int conv_RU[256];
243 static int conv_BV[256];
244 static int conv_GV[256];
245 static int conv_RV[256];