Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11yuv.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | 51038e80ae59 |
children | 11775724e3fe |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1306
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1306
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1306
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1306
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1306
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1306
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1306
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
182
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 /* This is the XFree86 Xv extension implementation of YUV video overlays */ | |
25 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
26 #if SDL_VIDEO_DRIVER_X11_XV |
0 | 27 |
28 #include <X11/Xlib.h> | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
29 #ifndef NO_SHARED_MEMORY |
0 | 30 #include <sys/ipc.h> |
31 #include <sys/shm.h> | |
32 #include <X11/extensions/XShm.h> | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
33 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
34 #include "../Xext/extensions/Xvlib.h" |
0 | 35 |
36 #include "SDL_x11yuv_c.h" | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
37 #include "../SDL_yuvfuncs.h" |
0 | 38 |
39 #define XFREE86_REFRESH_HACK | |
40 #ifdef XFREE86_REFRESH_HACK | |
41 #include "SDL_x11image_c.h" | |
42 #endif | |
43 | |
44 /* Workaround when pitch != width */ | |
45 #define PITCH_WORKAROUND | |
46 | |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
47 /* Fix for the NVidia GeForce 2 - use the last available adaptor */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
48 /*#define USE_LAST_ADAPTOR *//* Apparently the NVidia drivers are fixed */ |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
49 |
0 | 50 /* The functions used to manipulate software video overlays */ |
51 static struct private_yuvhwfuncs x11_yuvfuncs = { | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
52 X11_LockYUVOverlay, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
53 X11_UnlockYUVOverlay, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
54 X11_DisplayYUVOverlay, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
55 X11_FreeYUVOverlay |
0 | 56 }; |
57 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
58 struct private_yuvhwdata |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
59 { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
60 int port; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
61 #ifndef NO_SHARED_MEMORY |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
62 int yuv_use_mitshm; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
63 XShmSegmentInfo yuvshm; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
64 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
65 SDL_NAME (XvImage) * image; |
0 | 66 }; |
67 | |
68 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
69 static int (*X_handler) (Display *, XErrorEvent *) = NULL; |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
70 |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
71 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
72 /* Shared memory error handler routine */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
73 static int shm_error; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
74 static int |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
75 shm_errhandler (Display * d, XErrorEvent * e) |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
76 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
77 if (e->error_code == BadAccess) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
78 shm_error = True; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
79 return (0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
80 } else |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
81 return (X_handler (d, e)); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
82 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
83 #endif /* !NO_SHARED_MEMORY */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
84 |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
85 static int xv_error; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
86 static int |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
87 xv_errhandler (Display * d, XErrorEvent * e) |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
88 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
89 if (e->error_code == BadMatch) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
90 xv_error = True; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
91 return (0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
92 } else |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
93 return (X_handler (d, e)); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
94 } |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
95 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
96 SDL_Overlay * |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
97 X11_CreateYUVOverlay (_THIS, int width, int height, Uint32 format, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
98 SDL_Surface * display) |
0 | 99 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
100 SDL_Overlay *overlay; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
101 struct private_yuvhwdata *hwdata; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
102 int xv_port; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
103 unsigned int i, j, k; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
104 unsigned int adaptors; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
105 SDL_NAME (XvAdaptorInfo) * ainfo; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
106 int bpp; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
107 #ifndef NO_SHARED_MEMORY |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
108 XShmSegmentInfo *yuvshm; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
109 #endif |
0 | 110 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
111 /* Look for the XVideo extension with a valid port for this format */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
112 xv_port = -1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
113 if ((Success == |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
114 SDL_NAME (XvQueryExtension) (GFX_Display, &j, &j, &j, &j, &j)) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
115 && (Success == |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
116 SDL_NAME (XvQueryAdaptors) (GFX_Display, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
117 RootWindow (GFX_Display, SDL_Screen), |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
118 &adaptors, &ainfo))) { |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
119 #ifdef USE_LAST_ADAPTOR |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
120 for (i = 0; i < adaptors; ++i) |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
121 #else |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
122 for (i = 0; (i < adaptors) && (xv_port == -1); ++i) |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
123 #endif /* USE_LAST_ADAPTOR */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
124 { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
125 /* Check to see if the visual can be used */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
126 if (BUGGY_XFREE86 (<=, 4001)) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
127 int visual_ok = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
128 for (j = 0; j < ainfo[i].num_formats; ++j) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
129 if (ainfo[i].formats[j].visual_id == SDL_Visual->visualid) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
130 visual_ok = 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
131 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
132 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
133 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
134 if (!visual_ok) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
135 continue; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
136 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
137 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
138 if ((ainfo[i].type & XvInputMask) && |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
139 (ainfo[i].type & XvImageMask)) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
140 int num_formats; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
141 SDL_NAME (XvImageFormatValues) * formats; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
142 formats = SDL_NAME (XvListImageFormats) (GFX_Display, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
143 ainfo[i]. |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
144 base_id, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
145 &num_formats); |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
146 #ifdef USE_LAST_ADAPTOR |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
147 for (j = 0; j < num_formats; ++j) |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
148 #else |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
149 for (j = 0; (j < num_formats) && (xv_port == -1); ++j) |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
150 #endif /* USE_LAST_ADAPTOR */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
151 { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
152 if ((Uint32) formats[j].id == format) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
153 for (k = 0; k < ainfo[i].num_ports; ++k) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
154 if (Success == SDL_NAME (XvGrabPort) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
155 (GFX_Display, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
156 ainfo[i].base_id + k, CurrentTime)) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
157 xv_port = ainfo[i].base_id + k; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
158 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
159 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
160 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
161 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
162 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
163 if (formats) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
164 XFree (formats); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
165 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
166 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
167 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
168 SDL_NAME (XvFreeAdaptorInfo) (ainfo); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
169 } |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
170 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
171 /* Precalculate the bpp for the pitch workaround below */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
172 switch (format) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
173 /* Add any other cases we need to support... */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
174 case SDL_YUY2_OVERLAY: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
175 case SDL_UYVY_OVERLAY: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
176 case SDL_YVYU_OVERLAY: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
177 bpp = 2; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
178 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
179 default: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
180 bpp = 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
181 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
182 } |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
183 |
434
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
184 #if 0 |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
185 /* |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
186 * !!! FIXME: |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
187 * "Here are some diffs for X11 and yuv. Note that the last part 2nd |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
188 * diff should probably be a new call to XvQueryAdaptorFree with ainfo |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
189 * and the number of adaptors, instead of the loop through like I did." |
434
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
190 * |
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
191 * ACHTUNG: This is broken! It looks like XvFreeAdaptorInfo does this |
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
192 * for you, so we end up with a double-free. I need to look at this |
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
193 * more closely... --ryan. |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
194 */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
195 for (i = 0; i < adaptors; ++i) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
196 if (ainfo[i].name != NULL) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
197 Xfree (ainfo[i].name); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
198 if (ainfo[i].formats != NULL) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
199 Xfree (ainfo[i].formats); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
200 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
201 Xfree (ainfo); |
434
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
202 #endif |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
203 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
204 if (xv_port == -1) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
205 SDL_SetError ("No available video ports for requested format"); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
206 return (NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
207 } |
0 | 208 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
209 /* Enable auto-painting of the overlay colorkey */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
210 { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
211 static const char *attr[] = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
212 { "XV_AUTOPAINT_COLORKEY", "XV_AUTOPAINT_COLOURKEY" }; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
213 unsigned int i; |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
214 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
215 SDL_NAME (XvSelectPortNotify) (GFX_Display, xv_port, True); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
216 X_handler = XSetErrorHandler (xv_errhandler); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
217 for (i = 0; i < sizeof (attr) / (sizeof attr[0]); ++i) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
218 Atom a; |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
219 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
220 xv_error = False; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
221 a = XInternAtom (GFX_Display, attr[i], True); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
222 if (a != None) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
223 SDL_NAME (XvSetPortAttribute) (GFX_Display, xv_port, a, 1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
224 XSync (GFX_Display, True); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
225 if (!xv_error) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
226 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
227 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
228 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
229 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
230 XSetErrorHandler (X_handler); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
231 SDL_NAME (XvSelectPortNotify) (GFX_Display, xv_port, False); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
232 } |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
233 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
234 /* Create the overlay structure */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
235 overlay = (SDL_Overlay *) SDL_malloc (sizeof *overlay); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
236 if (overlay == NULL) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
237 SDL_NAME (XvUngrabPort) (GFX_Display, xv_port, CurrentTime); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
238 SDL_OutOfMemory (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
239 return (NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
240 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
241 SDL_memset (overlay, 0, (sizeof *overlay)); |
0 | 242 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
243 /* Fill in the basic members */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
244 overlay->format = format; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
245 overlay->w = width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
246 overlay->h = height; |
0 | 247 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
248 /* Set up the YUV surface function structure */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
249 overlay->hwfuncs = &x11_yuvfuncs; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
250 overlay->hw_overlay = 1; |
0 | 251 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
252 /* Create the pixel data and lookup tables */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
253 hwdata = (struct private_yuvhwdata *) SDL_malloc (sizeof *hwdata); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
254 overlay->hwdata = hwdata; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
255 if (hwdata == NULL) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
256 SDL_NAME (XvUngrabPort) (GFX_Display, xv_port, CurrentTime); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
257 SDL_OutOfMemory (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
258 SDL_FreeYUVOverlay (overlay); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
259 return (NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
260 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
261 hwdata->port = xv_port; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
262 #ifndef NO_SHARED_MEMORY |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
263 yuvshm = &hwdata->yuvshm; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
264 SDL_memset (yuvshm, 0, sizeof (*yuvshm)); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
265 hwdata->image = SDL_NAME (XvShmCreateImage) (GFX_Display, xv_port, format, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
266 0, width, height, yuvshm); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
267 #ifdef PITCH_WORKAROUND |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
268 if (hwdata->image != NULL && hwdata->image->pitches[0] != (width * bpp)) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
269 /* Ajust overlay width according to pitch */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
270 XFree (hwdata->image); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
271 width = hwdata->image->pitches[0] / bpp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
272 hwdata->image = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
273 SDL_NAME (XvShmCreateImage) (GFX_Display, xv_port, format, 0, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
274 width, height, yuvshm); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
275 } |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
276 #endif /* PITCH_WORKAROUND */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
277 hwdata->yuv_use_mitshm = (hwdata->image != NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
278 if (hwdata->yuv_use_mitshm) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
279 yuvshm->shmid = shmget (IPC_PRIVATE, hwdata->image->data_size, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
280 IPC_CREAT | 0777); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
281 if (yuvshm->shmid >= 0) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
282 yuvshm->shmaddr = (char *) shmat (yuvshm->shmid, 0, 0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
283 yuvshm->readOnly = False; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
284 if (yuvshm->shmaddr != (char *) -1) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
285 shm_error = False; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
286 X_handler = XSetErrorHandler (shm_errhandler); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
287 XShmAttach (GFX_Display, yuvshm); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
288 XSync (GFX_Display, True); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
289 XSetErrorHandler (X_handler); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
290 if (shm_error) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
291 shmdt (yuvshm->shmaddr); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
292 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
293 shm_error = True; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
294 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
295 shmctl (yuvshm->shmid, IPC_RMID, NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
296 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
297 shm_error = True; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
298 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
299 if (shm_error) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
300 XFree (hwdata->image); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
301 hwdata->yuv_use_mitshm = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
302 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
303 hwdata->image->data = yuvshm->shmaddr; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
304 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
305 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
306 if (!hwdata->yuv_use_mitshm) |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
307 #endif /* NO_SHARED_MEMORY */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
308 { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
309 hwdata->image = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
310 SDL_NAME (XvCreateImage) (GFX_Display, xv_port, format, 0, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
311 width, height); |
0 | 312 |
313 #ifdef PITCH_WORKAROUND | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
314 if (hwdata->image != NULL |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
315 && hwdata->image->pitches[0] != (width * bpp)) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
316 /* Ajust overlay width according to pitch */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
317 XFree (hwdata->image); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
318 width = hwdata->image->pitches[0] / bpp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
319 hwdata->image = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
320 SDL_NAME (XvCreateImage) (GFX_Display, xv_port, format, 0, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
321 width, height); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
322 } |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
323 #endif /* PITCH_WORKAROUND */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
324 if (hwdata->image == NULL) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
325 SDL_SetError ("Couldn't create XVideo image"); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
326 SDL_FreeYUVOverlay (overlay); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
327 return (NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
328 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
329 hwdata->image->data = SDL_malloc (hwdata->image->data_size); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
330 if (hwdata->image->data == NULL) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
331 SDL_OutOfMemory (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
332 SDL_FreeYUVOverlay (overlay); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
333 return (NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
334 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
335 } |
0 | 336 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
337 /* Find the pitch and offset values for the overlay */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
338 overlay->planes = hwdata->image->num_planes; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
339 overlay->pitches = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
340 (Uint16 *) SDL_malloc (overlay->planes * sizeof (Uint16)); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
341 overlay->pixels = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
342 (Uint8 **) SDL_malloc (overlay->planes * sizeof (Uint8 *)); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
343 if (!overlay->pitches || !overlay->pixels) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
344 SDL_OutOfMemory (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
345 SDL_FreeYUVOverlay (overlay); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
346 return (NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
347 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
348 for (i = 0; i < overlay->planes; ++i) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
349 overlay->pitches[i] = hwdata->image->pitches[i]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
350 overlay->pixels[i] = (Uint8 *) hwdata->image->data + |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
351 hwdata->image->offsets[i]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
352 } |
0 | 353 |
354 #ifdef XFREE86_REFRESH_HACK | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
355 /* Work around an XFree86 X server bug (?) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
356 We can't perform normal updates in windows that have video |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
357 being output to them. See SDL_x11image.c for more details. |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
358 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
359 X11_DisableAutoRefresh (this); |
0 | 360 #endif |
361 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
362 /* We're all done.. */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
363 return (overlay); |
0 | 364 } |
365 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
366 int |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
367 X11_LockYUVOverlay (_THIS, SDL_Overlay * overlay) |
0 | 368 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
369 return (0); |
0 | 370 } |
371 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
372 void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
373 X11_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay) |
0 | 374 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
375 return; |
0 | 376 } |
377 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
378 int |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
379 X11_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, SDL_Rect * src, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
380 SDL_Rect * dst) |
0 | 381 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
382 struct private_yuvhwdata *hwdata; |
0 | 383 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
384 hwdata = overlay->hwdata; |
1642 | 385 |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
386 #ifndef NO_SHARED_MEMORY |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
387 if (hwdata->yuv_use_mitshm) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
388 SDL_NAME (XvShmPutImage) (GFX_Display, hwdata->port, SDL_Window, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
389 SDL_GC, hwdata->image, src->x, src->y, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
390 src->w, src->h, dst->x, dst->y, dst->w, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
391 dst->h, False); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
392 } else |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
393 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
394 { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
395 SDL_NAME (XvPutImage) (GFX_Display, hwdata->port, SDL_Window, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
396 SDL_GC, hwdata->image, src->x, src->y, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
397 src->w, src->h, dst->x, dst->y, dst->w, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
398 dst->h); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
399 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
400 XSync (GFX_Display, False); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
401 return (0); |
0 | 402 } |
403 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
404 void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
405 X11_FreeYUVOverlay (_THIS, SDL_Overlay * overlay) |
0 | 406 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
407 struct private_yuvhwdata *hwdata; |
0 | 408 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
409 hwdata = overlay->hwdata; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
410 if (hwdata) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
411 SDL_NAME (XvUngrabPort) (GFX_Display, hwdata->port, CurrentTime); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
412 #ifndef NO_SHARED_MEMORY |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
413 if (hwdata->yuv_use_mitshm) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
414 XShmDetach (GFX_Display, &hwdata->yuvshm); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
415 shmdt (hwdata->yuvshm.shmaddr); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
416 } |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
417 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
418 if (hwdata->image) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
419 XFree (hwdata->image); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
420 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
421 SDL_free (hwdata); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
422 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
423 if (overlay->pitches) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
424 SDL_free (overlay->pitches); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
425 overlay->pitches = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
426 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
427 if (overlay->pixels) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
428 SDL_free (overlay->pixels); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
429 overlay->pixels = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
430 } |
0 | 431 #ifdef XFREE86_REFRESH_HACK |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
432 X11_EnableAutoRefresh (this); |
0 | 433 #endif |
434 } | |
435 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
436 #endif /* SDL_VIDEO_DRIVER_X11_XV */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
437 /* vi: set ts=4 sw=4 expandtab: */ |