Mercurial > mplayer.hg
annotate libvo/vo_xmga.c @ 10944:e2be5ab1d6e3
typo
author | diego |
---|---|
date | Fri, 26 Sep 2003 12:38:55 +0000 |
parents | 07870312c054 |
children | c2bff70784d5 |
rev | line source |
---|---|
100 | 1 |
2 //#define SHOW_TIME | |
1 | 3 |
4 /* | |
7680 | 5 * vo_xmga.c |
1 | 6 * |
7 * Copyright (C) Zoltan Ponekker - Jan 2001 | |
8 * | |
9 */ | |
10 | |
11 #include <stdio.h> | |
12 #include <stdlib.h> | |
13 #include <string.h> | |
14 | |
15 #include "config.h" | |
6296 | 16 |
1 | 17 #include "video_out.h" |
18 #include "video_out_internal.h" | |
19 | |
20 | |
21 #include <sys/ioctl.h> | |
22 #include <unistd.h> | |
23 #include <fcntl.h> | |
24 #include <sys/mman.h> | |
25 | |
26 #include "drivers/mga_vid.h" | |
27 | |
28 #include <X11/Xlib.h> | |
29 #include <X11/Xutil.h> | |
30 #include <errno.h> | |
31 | |
4017 | 32 #ifdef HAVE_XINERAMA |
33 #include <X11/extensions/Xinerama.h> | |
34 #endif | |
35 | |
31 | 36 #include "x11_common.h" |
616 | 37 #include "sub.h" |
2057 | 38 #include "aspect.h" |
31 | 39 |
182 | 40 #ifdef SHOW_TIME |
9380 | 41 #include "../osdep/timer.h" |
100 | 42 static unsigned int timer=0; |
43 static unsigned int timerd=0; | |
44 #endif | |
45 | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
46 #ifdef HAVE_NEW_GUI |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
47 #include "../Gui/interface.h" |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
48 #endif |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
49 |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8017
diff
changeset
|
50 static vo_info_t info = |
1 | 51 { |
7680 | 52 "Matrox G200/G4x0/G550 overlay in X11 window (using /dev/mga_vid)", |
1 | 53 "xmga", |
54 "Zoltan Ponekker <pontscho@makacs.poliod.hu>", | |
55 "" | |
56 }; | |
57 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8017
diff
changeset
|
58 LIBVO_EXTERN( xmga ) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8017
diff
changeset
|
59 |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8017
diff
changeset
|
60 |
1 | 61 static XGCValues wGCV; |
62 | |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7124
diff
changeset
|
63 static uint32_t mDepth; |
1 | 64 static XWindowAttributes attribs; |
65 static uint32_t fgColor; | |
66 | |
67 static uint32_t mvHeight; | |
68 static uint32_t mvWidth; | |
69 | |
70 static Window mRoot; | |
71 | |
72 static XSetWindowAttributes xWAttribs; | |
73 | |
6311
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
6307
diff
changeset
|
74 static int inited=0; |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
6307
diff
changeset
|
75 |
4981 | 76 #define VO_XMGA |
1 | 77 #include "mga_common.c" |
4981 | 78 #undef VO_XMGA |
1 | 79 |
80 static void mDrawColorKey( void ) | |
81 { | |
4795 | 82 XSetBackground( mDisplay,vo_gc,0 ); |
83 XClearWindow( mDisplay,vo_window ); | |
84 XSetForeground( mDisplay,vo_gc,fgColor ); | |
4981 | 85 XFillRectangle( mDisplay,vo_window,vo_gc,drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight) ); |
1 | 86 XFlush( mDisplay ); |
87 } | |
88 | |
31 | 89 static void check_events(void) |
1 | 90 { |
4303 | 91 int e=vo_x11_check_events(mDisplay); |
92 if ( !(e&VO_EVENT_RESIZE) && !(e&VO_EVENT_EXPOSE) ) return; | |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
93 set_window(); |
6043 | 94 mDrawColorKey(); |
6296 | 95 if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) ) mp_msg(MSGT_VO,MSGL_WARN,"Error in mga_vid_config ioctl (wrong mga_vid.o version?)" ); |
1 | 96 } |
97 | |
31 | 98 static void flip_page(void){ |
182 | 99 #ifdef SHOW_TIME |
100 | 100 unsigned int t; |
101 t=GetTimer(); | |
6296 | 102 mp_msg(MSGT_VO,MSGL_STATUS," [timer: %08X diff: %6d dd: %6d ] \n",t,t-timer,(t-timer)-timerd); |
100 | 103 timerd=t-timer; |
104 timer=t; | |
182 | 105 #endif |
100 | 106 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1210
diff
changeset
|
107 vo_mga_flip_page(); |
31 | 108 } |
1 | 109 |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
6953
diff
changeset
|
110 static uint32_t config( uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
1 | 111 { |
112 char * mTitle=(title == NULL) ? "XMGA render" : title; | |
113 XVisualInfo vinfo; | |
114 unsigned long xswamask; | |
115 | |
7679 | 116 if(mga_init(width,height,format)) return -1; // ioctl errors? |
1 | 117 |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
118 aspect_save_orig(width,height); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
119 aspect_save_prescale(d_width,d_height); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
120 aspect_save_screenres(vo_screenwidth,vo_screenheight); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
121 |
1 | 122 mvWidth=width; mvHeight=height; |
123 | |
6307 | 124 vo_panscan_x=vo_panscan_y=vo_panscan_amount=0; |
125 | |
7679 | 126 vo_dx=( vo_screenwidth - d_width ) / 2; |
127 vo_dy=( vo_screenheight - d_height ) / 2; | |
10729 | 128 geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth, vo_screenheight); |
4981 | 129 vo_dwidth=d_width; vo_dheight=d_height; |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
130 vo_mouse_autohide=1; |
1 | 131 |
132 switch ( vo_depthonscreen ) | |
133 { | |
134 case 32: | |
135 case 24: fgColor=0x00ff00ffL; break; | |
136 case 16: fgColor=0xf81fL; break; | |
137 case 15: fgColor=0x7c1fL; break; | |
6296 | 138 default: mp_msg(MSGT_VO,MSGL_ERR,"Sorry, this (%d) color depth not supported.\n",vo_depthonscreen ); return -1; |
1 | 139 } |
140 | |
5158 | 141 inited=1; |
142 | |
10729 | 143 aspect(&d_width,&d_height,A_NOZOOM); |
5985 | 144 |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1637
diff
changeset
|
145 #ifdef HAVE_NEW_GUI |
5985 | 146 if(use_gui) |
147 guiGetEvent( guiSetShVideo,0 ); // the GUI will set up / resize the window | |
148 else | |
149 #endif | |
723 | 150 { |
6043 | 151 if ( flags&1 ) aspect(&dwidth,&dheight,A_ZOOM); |
723 | 152 |
6043 | 153 XGetWindowAttributes( mDisplay,mRootWin,&attribs ); |
723 | 154 mDepth=attribs.depth; |
155 if ( mDepth != 15 && mDepth != 16 && mDepth != 24 && mDepth != 32 ) mDepth=24; | |
156 XMatchVisualInfo( mDisplay,mScreen,mDepth,TrueColor,&vinfo ); | |
6043 | 157 xWAttribs.colormap=XCreateColormap( mDisplay,mRootWin,vinfo.visual,AllocNone ); |
723 | 158 xWAttribs.background_pixel=0; |
159 xWAttribs.border_pixel=0; | |
6043 | 160 xWAttribs.event_mask=StructureNotifyMask | ExposureMask | KeyPressMask | |
161 ((WinID==0)?0:(ButtonPressMask | ButtonReleaseMask | PointerMotionMask | PropertyChangeMask)); | |
723 | 162 xswamask=CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; |
1 | 163 |
3847 | 164 if ( WinID>=0 ){ |
6043 | 165 |
166 vo_window = WinID ? ((Window)WinID) : mRootWin; | |
167 if ( WinID ) | |
168 { | |
169 XUnmapWindow( mDisplay,vo_window ); | |
170 XChangeWindowAttributes( mDisplay,vo_window,xswamask,&xWAttribs); | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6755
diff
changeset
|
171 vo_x11_selectinput_witherr( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask ); |
6043 | 172 } else XSelectInput( mDisplay,vo_window,ExposureMask ); |
173 | |
7679 | 174 } else { |
175 | |
7777 | 176 if ( vo_window == None ) |
177 { | |
178 vo_window=XCreateWindow( mDisplay,mRootWin, | |
6043 | 179 vo_dx,vo_dy, |
180 vo_dwidth,vo_dheight, | |
181 xWAttribs.border_pixel, | |
182 mDepth, | |
183 InputOutput, | |
184 vinfo.visual,xswamask,&xWAttribs ); | |
185 | |
7777 | 186 vo_x11_classhint( mDisplay,vo_window,"xmga" ); |
187 vo_hidecursor(mDisplay,vo_window); | |
188 vo_x11_sizehint( vo_dx,vo_dy,vo_dwidth,vo_dheight,0 ); | |
723 | 189 |
7777 | 190 XStoreName( mDisplay,vo_window,mTitle ); |
191 XMapWindow( mDisplay,vo_window ); | |
6043 | 192 |
7777 | 193 if ( flags&1 ) vo_x11_fullscreen(); |
5999 | 194 |
3990 | 195 #ifdef HAVE_XINERAMA |
7777 | 196 vo_x11_xinerama_move(mDisplay,vo_window); |
3990 | 197 #endif |
7777 | 198 } else if ( !(flags&1) ) XMoveResizeWindow( mDisplay,vo_window,vo_dx,vo_dy,vo_dwidth,vo_dheight ); |
6043 | 199 } |
7679 | 200 |
7777 | 201 if ( vo_gc != None ) XFreeGC( mDisplay,vo_gc ); |
6043 | 202 vo_gc=XCreateGC( mDisplay,vo_window,GCForeground,&wGCV ); |
7679 | 203 |
204 } // !GUI | |
1 | 205 |
6043 | 206 if ( ( flags&1 )&&( !WinID ) ) { vo_dx=0; vo_dy=0; vo_dwidth=vo_screenwidth; vo_dheight=vo_screenheight; vo_fs=1; } |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
207 |
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
208 panscan_calc(); |
7679 | 209 |
210 mga_vid_config.colkey_on=1; | |
211 mga_vid_config.colkey_red=255; | |
212 mga_vid_config.colkey_green=0; | |
213 mga_vid_config.colkey_blue=255; | |
214 | |
215 set_window(); // set up mga_vid_config.dest_width etc | |
1 | 216 |
6755 | 217 saver_off(mDisplay); |
218 | |
219 XFlush( mDisplay ); | |
220 XSync( mDisplay,False ); | |
7777 | 221 |
222 ioctl(f,MGA_VID_ON,0); | |
6755 | 223 |
7679 | 224 return 0; |
1 | 225 } |
226 | |
7679 | 227 static void uninit(void){ |
228 mp_msg(MSGT_VO,MSGL_V,"vo: uninit!\n"); | |
229 mga_uninit(); | |
230 if(!inited) return; // no window? | |
5158 | 231 inited=0; |
4316 | 232 saver_on(mDisplay); |
7679 | 233 vo_x11_uninit(); // destroy the window |
1 | 234 } |
4352 | 235 |