Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11yuv.c @ 4393:9afe12fb4c41 SDL-1.2
Fixed bug #901
Tim Angus 2009-12-11 11:45:46 PST
Disable mouse event generation when state is not SDL_APPMOUSEFOCUS
If a Windows SDL application is minimised by using alt-tab, SDL_APPMOUSEFOCUS
is lost as part of the minimisation. Unfortunately, the directx driver doesn't
pay any attention to this state when generating mouse button events, so
clicking on the Desktop can cause mouse clicks in the SDL application, while
it's still minimised. The attached patch fixes this. It looks much more
complicated than it actually is due to indentation; here it is ignoring
whitespace:
tma@abraxas:~/sources/SDL-1.2-svn$ svn diff -x -b
Index: src/video/windx5/SDL_dx5events.c
===================================================================
--- src/video/windx5/SDL_dx5events.c (revision 5376)
+++ src/video/windx5/SDL_dx5events.c (working copy)
@@ -374,10 +374,9 @@
if ( !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
mouse_lost = 1;
ClipCursor(NULL);
- }
-
+ } else {
/* If the mouse was lost, regain some sense of mouse state */
- if ( mouse_lost && (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
+ if ( mouse_lost ) {
POINT mouse_pos;
Uint8 old_state;
Uint8 new_state;
@@ -548,6 +547,7 @@
if ( xrel || yrel ) {
post_mouse_motion(1, xrel, yrel);
}
+ }
}
/* The main Win32 event handler */
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 14 Dec 2009 22:41:31 +0000 |
parents | a1b03ba2fcd0 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
4159 | 3 Copyright (C) 1997-2009 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 | |
4106
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
47 /* Workaround intel i810 video overlay waiting with failing until the |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
48 first Xv[Shm]PutImage call <sigh> */ |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
49 #define INTEL_XV_BADALLOC_WORKAROUND |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
50 |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
51 /* Fix for the NVidia GeForce 2 - use the last available adaptor */ |
341
6ca967a46bf1
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
52 /*#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
|
53 |
0 | 54 /* The functions used to manipulate software video overlays */ |
55 static struct private_yuvhwfuncs x11_yuvfuncs = { | |
56 X11_LockYUVOverlay, | |
57 X11_UnlockYUVOverlay, | |
58 X11_DisplayYUVOverlay, | |
59 X11_FreeYUVOverlay | |
60 }; | |
61 | |
62 struct private_yuvhwdata { | |
63 int port; | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
64 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
65 int yuv_use_mitshm; |
0 | 66 XShmSegmentInfo yuvshm; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
67 #endif |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
68 SDL_NAME(XvImage) *image; |
0 | 69 }; |
70 | |
71 | |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
72 static int (*X_handler)(Display *, XErrorEvent *) = NULL; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
73 |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
74 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
75 /* Shared memory error handler routine */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
76 static int shm_error; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
77 static int shm_errhandler(Display *d, XErrorEvent *e) |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
78 { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
79 if ( e->error_code == BadAccess ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
80 shm_error = True; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
81 return(0); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
82 } else |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
83 return(X_handler(d,e)); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
84 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
85 #endif /* !NO_SHARED_MEMORY */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
86 |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
87 static int xv_error; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
88 static int xv_errhandler(Display *d, XErrorEvent *e) |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
89 { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
90 if ( e->error_code == BadMatch ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
91 xv_error = True; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
92 return(0); |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
93 } else |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
94 return(X_handler(d,e)); |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
95 } |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
96 |
4106
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
97 #ifdef INTEL_XV_BADALLOC_WORKAROUND |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
98 static int intel_errhandler(Display *d, XErrorEvent *e) |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
99 { |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
100 if ( e->error_code == BadAlloc ) { |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
101 xv_error = True; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
102 return(0); |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
103 } else |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
104 return(X_handler(d,e)); |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
105 } |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
106 |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
107 static void X11_ClearYUVOverlay(SDL_Overlay *overlay) |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
108 { |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
109 int x,y; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
110 |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
111 switch (overlay->format) |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
112 { |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
113 case SDL_YV12_OVERLAY: |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
114 case SDL_IYUV_OVERLAY: |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
115 for (y = 0; y < overlay->h; y++) |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
116 memset(overlay->pixels[0] + y * overlay->pitches[0], |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
117 0, overlay->w); |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
118 |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
119 for (y = 0; y < (overlay->h / 2); y++) |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
120 { |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
121 memset(overlay->pixels[1] + y * overlay->pitches[1], |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
122 -128, overlay->w / 2); |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
123 memset(overlay->pixels[2] + y * overlay->pitches[2], |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
124 -128, overlay->w / 2); |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
125 } |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
126 break; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
127 case SDL_YUY2_OVERLAY: |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
128 case SDL_YVYU_OVERLAY: |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
129 for (y = 0; y < overlay->h; y++) |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
130 { |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
131 for (x = 0; x < overlay->w; x += 2) |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
132 { |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
133 Uint8 *pixel_pair = overlay->pixels[0] + |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
134 y * overlay->pitches[0] + x * 2; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
135 pixel_pair[0] = 0; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
136 pixel_pair[1] = -128; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
137 pixel_pair[2] = 0; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
138 pixel_pair[3] = -128; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
139 } |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
140 } |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
141 break; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
142 case SDL_UYVY_OVERLAY: |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
143 for (y = 0; y < overlay->h; y++) |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
144 { |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
145 for (x = 0; x < overlay->w; x += 2) |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
146 { |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
147 Uint8 *pixel_pair = overlay->pixels[0] + |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
148 y * overlay->pitches[0] + x * 2; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
149 pixel_pair[0] = -128; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
150 pixel_pair[1] = 0; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
151 pixel_pair[2] = -128; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
152 pixel_pair[3] = 0; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
153 } |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
154 } |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
155 break; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
156 } |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
157 } |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
158 #endif |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
159 |
0 | 160 SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display) |
161 { | |
162 SDL_Overlay *overlay; | |
163 struct private_yuvhwdata *hwdata; | |
164 int xv_port; | |
1196
b81f54c3963f
Fixed compile warnings with gcc 4
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
165 unsigned int i, j, k; |
b81f54c3963f
Fixed compile warnings with gcc 4
Sam Lantinga <slouken@libsdl.org>
parents:
1168
diff
changeset
|
166 unsigned int adaptors; |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
167 SDL_NAME(XvAdaptorInfo) *ainfo; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
168 int bpp; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
169 #ifndef NO_SHARED_MEMORY |
0 | 170 XShmSegmentInfo *yuvshm; |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
171 #endif |
4106
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
172 #ifdef INTEL_XV_BADALLOC_WORKAROUND |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
173 int intel_adapter = False; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
174 #endif |
0 | 175 |
176 /* Look for the XVideo extension with a valid port for this format */ | |
177 xv_port = -1; | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
178 if ( (Success == SDL_NAME(XvQueryExtension)(GFX_Display, &j, &j, &j, &j, &j)) && |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
179 (Success == SDL_NAME(XvQueryAdaptors)(GFX_Display, |
0 | 180 RootWindow(GFX_Display, SDL_Screen), |
181 &adaptors, &ainfo)) ) { | |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
182 #ifdef USE_LAST_ADAPTOR |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
183 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
|
184 #else |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
185 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
|
186 #endif /* USE_LAST_ADAPTOR */ |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
187 { |
0 | 188 /* Check to see if the visual can be used */ |
189 if ( BUGGY_XFREE86(<=, 4001) ) { | |
190 int visual_ok = 0; | |
191 for ( j=0; j<ainfo[i].num_formats; ++j ) { | |
192 if ( ainfo[i].formats[j].visual_id == | |
193 SDL_Visual->visualid ) { | |
194 visual_ok = 1; | |
195 break; | |
196 } | |
197 } | |
198 if ( ! visual_ok ) { | |
199 continue; | |
200 } | |
201 } | |
4106
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
202 #ifdef INTEL_XV_BADALLOC_WORKAROUND |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
203 if ( !strcmp(ainfo[i].name, "Intel(R) Video Overla")) |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
204 intel_adapter = True; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
205 else |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
206 intel_adapter = False; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
207 #endif |
0 | 208 if ( (ainfo[i].type & XvInputMask) && |
209 (ainfo[i].type & XvImageMask) ) { | |
210 int num_formats; | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
211 SDL_NAME(XvImageFormatValues) *formats; |
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
212 formats = SDL_NAME(XvListImageFormats)(GFX_Display, |
0 | 213 ainfo[i].base_id, &num_formats); |
182
d4ebd1bbea9a
Fix XVideo on GeForce by using last available adaptor
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
214 #ifdef USE_LAST_ADAPTOR |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
215 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
|
216 #else |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
217 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
|
218 #endif /* USE_LAST_ADAPTOR */ |
659
e3d0517bf67e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
494
diff
changeset
|
219 { |
0 | 220 if ( (Uint32)formats[j].id == format ) { |
221 for ( k=0; k < ainfo[i].num_ports; ++k ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
222 if ( Success == SDL_NAME(XvGrabPort)(GFX_Display, ainfo[i].base_id+k, CurrentTime) ) { |
0 | 223 xv_port = ainfo[i].base_id+k; |
224 break; | |
225 } | |
226 } | |
227 } | |
228 } | |
410
365f57b7c4ac
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
409
diff
changeset
|
229 if ( formats ) { |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
230 XFree(formats); |
410
365f57b7c4ac
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
409
diff
changeset
|
231 } |
0 | 232 } |
233 } | |
409
1c3cf7231cd4
Fixed memory leaks in YUV code
Sam Lantinga <slouken@libsdl.org>
parents:
341
diff
changeset
|
234 SDL_NAME(XvFreeAdaptorInfo)(ainfo); |
0 | 235 } |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
236 |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
237 /* Precalculate the bpp for the pitch workaround below */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
238 switch (format) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
239 /* Add any other cases we need to support... */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
240 case SDL_YUY2_OVERLAY: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
241 case SDL_UYVY_OVERLAY: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
242 case SDL_YVYU_OVERLAY: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
243 bpp = 2; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
244 break; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
245 default: |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
246 bpp = 1; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
247 break; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
248 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
249 |
434
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
250 #if 0 |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
251 /* |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
252 * !!! FIXME: |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
253 * "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
|
254 * 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
|
255 * 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
|
256 * |
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
257 * 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
|
258 * 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
|
259 * more closely... --ryan. |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
260 */ |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
261 for ( i=0; i < adaptors; ++i ) { |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
262 if (ainfo[i].name != NULL) Xfree(ainfo[i].name); |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
263 if (ainfo[i].formats != NULL) Xfree(ainfo[i].formats); |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
264 } |
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
265 Xfree(ainfo); |
434
ed58b98c0d9d
Commented double-free buggy code. Will examine more closely later.
Ryan C. Gordon <icculus@icculus.org>
parents:
429
diff
changeset
|
266 #endif |
429
c1666427297c
Memory leak fixes by Bill May.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
267 |
0 | 268 if ( xv_port == -1 ) { |
269 SDL_SetError("No available video ports for requested format"); | |
270 return(NULL); | |
271 } | |
272 | |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
273 /* Enable auto-painting of the overlay colorkey */ |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
274 { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
275 static const char *attr[] = { "XV_AUTOPAINT_COLORKEY", "XV_AUTOPAINT_COLOURKEY" }; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
276 unsigned int i; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
277 |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
278 SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, True); |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
279 X_handler = XSetErrorHandler(xv_errhandler); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
280 for ( i=0; i < sizeof(attr)/(sizeof attr[0]); ++i ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
281 Atom a; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
282 |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
283 xv_error = False; |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
284 a = XInternAtom(GFX_Display, attr[i], True); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
285 if ( a != None ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
286 SDL_NAME(XvSetPortAttribute)(GFX_Display, xv_port, a, 1); |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
287 XSync(GFX_Display, True); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
288 if ( ! xv_error ) { |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
289 break; |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
290 } |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
291 } |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
292 } |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
293 XSetErrorHandler(X_handler); |
950
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
294 SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, False); |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
295 } |
b7a5c1b64829
Date: Tue, 24 Aug 2004 06:16:32 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
813
diff
changeset
|
296 |
0 | 297 /* Create the overlay structure */ |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
298 overlay = (SDL_Overlay *)SDL_malloc(sizeof *overlay); |
0 | 299 if ( overlay == NULL ) { |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
300 SDL_NAME(XvUngrabPort)(GFX_Display, xv_port, CurrentTime); |
0 | 301 SDL_OutOfMemory(); |
302 return(NULL); | |
303 } | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
304 SDL_memset(overlay, 0, (sizeof *overlay)); |
0 | 305 |
306 /* Fill in the basic members */ | |
307 overlay->format = format; | |
308 overlay->w = width; | |
309 overlay->h = height; | |
310 | |
311 /* Set up the YUV surface function structure */ | |
312 overlay->hwfuncs = &x11_yuvfuncs; | |
313 overlay->hw_overlay = 1; | |
314 | |
315 /* Create the pixel data and lookup tables */ | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
316 hwdata = (struct private_yuvhwdata *)SDL_malloc(sizeof *hwdata); |
0 | 317 overlay->hwdata = hwdata; |
318 if ( hwdata == NULL ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
319 SDL_NAME(XvUngrabPort)(GFX_Display, xv_port, CurrentTime); |
0 | 320 SDL_OutOfMemory(); |
321 SDL_FreeYUVOverlay(overlay); | |
322 return(NULL); | |
323 } | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
324 hwdata->port = xv_port; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
325 #ifndef NO_SHARED_MEMORY |
0 | 326 yuvshm = &hwdata->yuvshm; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
327 SDL_memset(yuvshm, 0, sizeof(*yuvshm)); |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
328 hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format, |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
329 0, width, height, yuvshm); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
330 #ifdef PITCH_WORKAROUND |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
331 if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
332 /* Ajust overlay width according to pitch */ |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
333 XFree(hwdata->image); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
334 width = hwdata->image->pitches[0] / bpp; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
335 hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
336 0, width, height, yuvshm); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
337 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
338 #endif /* PITCH_WORKAROUND */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
339 hwdata->yuv_use_mitshm = (hwdata->image != NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
340 if ( hwdata->yuv_use_mitshm ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
341 yuvshm->shmid = shmget(IPC_PRIVATE, hwdata->image->data_size, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
342 IPC_CREAT | 0777); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
343 if ( yuvshm->shmid >= 0 ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
344 yuvshm->shmaddr = (char *)shmat(yuvshm->shmid, 0, 0); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
345 yuvshm->readOnly = False; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
346 if ( yuvshm->shmaddr != (char *)-1 ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
347 shm_error = False; |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
348 X_handler = XSetErrorHandler(shm_errhandler); |
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
349 XShmAttach(GFX_Display, yuvshm); |
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
350 XSync(GFX_Display, True); |
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
351 XSetErrorHandler(X_handler); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
352 if ( shm_error ) |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
353 shmdt(yuvshm->shmaddr); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
354 } else { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
355 shm_error = True; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
356 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
357 shmctl(yuvshm->shmid, IPC_RMID, NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
358 } else { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
359 shm_error = True; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
360 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
361 if ( shm_error ) { |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
362 XFree(hwdata->image); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
363 hwdata->yuv_use_mitshm = 0; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
364 } else { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
365 hwdata->image->data = yuvshm->shmaddr; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
366 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
367 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
368 if ( !hwdata->yuv_use_mitshm ) |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
369 #endif /* NO_SHARED_MEMORY */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
370 { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
371 hwdata->image = SDL_NAME(XvCreateImage)(GFX_Display, xv_port, format, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
372 0, width, height); |
0 | 373 |
374 #ifdef PITCH_WORKAROUND | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
375 if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
376 /* Ajust overlay width according to pitch */ |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
377 XFree(hwdata->image); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
378 width = hwdata->image->pitches[0] / bpp; |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
379 hwdata->image = SDL_NAME(XvCreateImage)(GFX_Display, xv_port, format, |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
380 0, width, height); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
381 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
382 #endif /* PITCH_WORKAROUND */ |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
383 if ( hwdata->image == NULL ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
384 SDL_SetError("Couldn't create XVideo image"); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
385 SDL_FreeYUVOverlay(overlay); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
386 return(NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
387 } |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
388 hwdata->image->data = SDL_malloc(hwdata->image->data_size); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
389 if ( hwdata->image->data == NULL ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
390 SDL_OutOfMemory(); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
391 SDL_FreeYUVOverlay(overlay); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
392 return(NULL); |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
393 } |
0 | 394 } |
395 | |
396 /* Find the pitch and offset values for the overlay */ | |
397 overlay->planes = hwdata->image->num_planes; | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
398 overlay->pitches = (Uint16 *)SDL_malloc(overlay->planes * sizeof(Uint16)); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
399 overlay->pixels = (Uint8 **)SDL_malloc(overlay->planes * sizeof(Uint8 *)); |
0 | 400 if ( !overlay->pitches || !overlay->pixels ) { |
401 SDL_OutOfMemory(); | |
402 SDL_FreeYUVOverlay(overlay); | |
403 return(NULL); | |
404 } | |
405 for ( i=0; i<overlay->planes; ++i ) { | |
406 overlay->pitches[i] = hwdata->image->pitches[i]; | |
407 overlay->pixels[i] = (Uint8 *)hwdata->image->data + | |
408 hwdata->image->offsets[i]; | |
409 } | |
410 | |
411 #ifdef XFREE86_REFRESH_HACK | |
412 /* Work around an XFree86 X server bug (?) | |
413 We can't perform normal updates in windows that have video | |
414 being output to them. See SDL_x11image.c for more details. | |
415 */ | |
416 X11_DisableAutoRefresh(this); | |
417 #endif | |
418 | |
4106
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
419 #ifdef INTEL_XV_BADALLOC_WORKAROUND |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
420 /* HACK, GRRR sometimes (i810) creating the overlay succeeds, but the |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
421 first call to XvShm[Put]Image to a mapped window fails with: |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
422 "BadAlloc (insufficient resources for operation)". This happens with |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
423 certain formats when the XvImage is too large to the i810's liking. |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
424 |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
425 We work around this by doing a test XvShm[Put]Image with a black |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
426 Xv image, this may cause some flashing, so only do this check if we |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
427 are running on an intel Xv-adapter. */ |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
428 if (intel_adapter) |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
429 { |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
430 xv_error = False; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
431 X_handler = XSetErrorHandler(intel_errhandler); |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
432 |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
433 X11_ClearYUVOverlay(overlay); |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
434 |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
435 /* We set the destination height and width to 1 pixel to avoid |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
436 putting a large black rectangle over the screen, thus |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
437 strongly reducing possible flashing. */ |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
438 #ifndef NO_SHARED_MEMORY |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
439 if ( hwdata->yuv_use_mitshm ) { |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
440 SDL_NAME(XvShmPutImage)(GFX_Display, hwdata->port, |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
441 SDL_Window, SDL_GC, |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
442 hwdata->image, |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
443 0, 0, overlay->w, overlay->h, |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
444 0, 0, 1, 1, False); |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
445 } |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
446 else |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
447 #endif |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
448 { |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
449 SDL_NAME(XvPutImage)(GFX_Display, hwdata->port, |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
450 SDL_Window, SDL_GC, |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
451 hwdata->image, |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
452 0, 0, overlay->w, overlay->h, |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
453 0, 0, 1, 1); |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
454 } |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
455 XSync(GFX_Display, False); |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
456 XSetErrorHandler(X_handler); |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
457 |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
458 if (xv_error) |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
459 { |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
460 X11_FreeYUVOverlay(this, overlay); |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
461 return NULL; |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
462 } |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
463 /* Repair the (1 pixel worth of) damage we've just done */ |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
464 X11_RefreshDisplay(this); |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
465 } |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
466 #endif |
12bb6311fd5d
Hans de Goede fixed bug #495
Sam Lantinga <slouken@libsdl.org>
parents:
1643
diff
changeset
|
467 |
0 | 468 /* We're all done.. */ |
469 return(overlay); | |
470 } | |
471 | |
472 int X11_LockYUVOverlay(_THIS, SDL_Overlay *overlay) | |
473 { | |
474 return(0); | |
475 } | |
476 | |
477 void X11_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay) | |
478 { | |
479 return; | |
480 } | |
481 | |
1643
51038e80ae59
More general fix for bug #189
Sam Lantinga <slouken@libsdl.org>
parents:
1642
diff
changeset
|
482 int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst) |
0 | 483 { |
484 struct private_yuvhwdata *hwdata; | |
485 | |
486 hwdata = overlay->hwdata; | |
1642 | 487 |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
488 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
489 if ( hwdata->yuv_use_mitshm ) { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
490 SDL_NAME(XvShmPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, |
1642 | 491 hwdata->image, |
1643
51038e80ae59
More general fix for bug #189
Sam Lantinga <slouken@libsdl.org>
parents:
1642
diff
changeset
|
492 src->x, src->y, src->w, src->h, |
51038e80ae59
More general fix for bug #189
Sam Lantinga <slouken@libsdl.org>
parents:
1642
diff
changeset
|
493 dst->x, dst->y, dst->w, dst->h, False); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
494 } |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
495 else |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
496 #endif |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
497 { |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
498 SDL_NAME(XvPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, |
1642 | 499 hwdata->image, |
1643
51038e80ae59
More general fix for bug #189
Sam Lantinga <slouken@libsdl.org>
parents:
1642
diff
changeset
|
500 src->x, src->y, src->w, src->h, |
51038e80ae59
More general fix for bug #189
Sam Lantinga <slouken@libsdl.org>
parents:
1642
diff
changeset
|
501 dst->x, dst->y, dst->w, dst->h); |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
502 } |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
503 XSync(GFX_Display, False); |
0 | 504 return(0); |
505 } | |
506 | |
507 void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) | |
508 { | |
509 struct private_yuvhwdata *hwdata; | |
510 | |
511 hwdata = overlay->hwdata; | |
512 if ( hwdata ) { | |
292
eadc0746dfaf
Added SDL_LockRect() and SDL_UnlockRect()
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
513 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
|
514 #ifndef NO_SHARED_MEMORY |
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
515 if ( hwdata->yuv_use_mitshm ) { |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
516 XShmDetach(GFX_Display, &hwdata->yuvshm); |
0 | 517 shmdt(hwdata->yuvshm.shmaddr); |
518 } | |
813
6a2c6717b386
Added support for remote XVideo (thanks Frederic!)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
519 #endif |
0 | 520 if ( hwdata->image ) { |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
521 XFree(hwdata->image); |
0 | 522 } |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
523 SDL_free(hwdata); |
0 | 524 } |
525 if ( overlay->pitches ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
526 SDL_free(overlay->pitches); |
0 | 527 overlay->pitches = NULL; |
528 } | |
529 if ( overlay->pixels ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
530 SDL_free(overlay->pixels); |
0 | 531 overlay->pixels = NULL; |
532 } | |
533 #ifdef XFREE86_REFRESH_HACK | |
534 X11_EnableAutoRefresh(this); | |
535 #endif | |
536 } | |
537 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
538 #endif /* SDL_VIDEO_DRIVER_X11_XV */ |