Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11image.c @ 566:d6e7d7006062
Enable the glXGetProcAddressARB code (fixes problems with NVidia drivers)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 20 Jan 2003 00:25:28 +0000 |
parents | b0c5a13a4243 |
children | 6399f4e90211 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
297
f6ffac90895c
Updated copyright information for 2002
Sam Lantinga <slouken@libsdl.org>
parents:
270
diff
changeset
|
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
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 | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
166
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 #include <stdlib.h> | |
166
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
29 #include <unistd.h> |
0 | 30 |
31 #include "SDL_error.h" | |
32 #include "SDL_endian.h" | |
161
eb6b76a95f2d
An expose event is now sent when using XVideo output.
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
33 #include "SDL_events_c.h" |
0 | 34 #include "SDL_x11image_c.h" |
35 | |
36 #ifndef NO_SHARED_MEMORY | |
37 | |
38 /* Shared memory information */ | |
39 extern int XShmQueryExtension(Display *dpy); /* Not in X11 headers */ | |
40 | |
41 /* Shared memory error handler routine */ | |
42 static int shm_error; | |
43 static int (*X_handler)(Display *, XErrorEvent *) = NULL; | |
44 static int shm_errhandler(Display *d, XErrorEvent *e) | |
45 { | |
46 if ( e->error_code == BadAccess ) { | |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
47 shm_error = 1; |
0 | 48 return(0); |
49 } else | |
50 return(X_handler(d,e)); | |
51 } | |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
52 |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
53 static void try_mitshm(_THIS, SDL_Surface *screen) |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
54 { |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
55 if(!use_mitshm) |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
56 return; |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
57 shminfo.shmid = shmget(IPC_PRIVATE, screen->h*screen->pitch, |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
58 IPC_CREAT | 0777); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
59 if ( shminfo.shmid >= 0 ) { |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
60 shminfo.shmaddr = (char *)shmat(shminfo.shmid, 0, 0); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
61 shminfo.readOnly = False; |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
62 if ( shminfo.shmaddr != (char *)-1 ) { |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
63 shm_error = False; |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
64 X_handler = XSetErrorHandler(shm_errhandler); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
65 XShmAttach(SDL_Display, &shminfo); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
66 XSync(SDL_Display, True); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
67 XSetErrorHandler(X_handler); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
68 if (shm_error) |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
69 shmdt(shminfo.shmaddr); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
70 } else { |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
71 shm_error = True; |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
72 } |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
73 shmctl(shminfo.shmid, IPC_RMID, NULL); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
74 } else { |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
75 shm_error = True; |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
76 } |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
77 if ( shm_error ) |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
78 use_mitshm = 0; |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
79 if ( use_mitshm ) |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
80 screen->pixels = shminfo.shmaddr; |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
81 } |
0 | 82 #endif /* ! NO_SHARED_MEMORY */ |
83 | |
84 /* Various screen update functions available */ | |
85 static void X11_NormalUpdate(_THIS, int numrects, SDL_Rect *rects); | |
86 static void X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect *rects); | |
87 | |
88 int X11_SetupImage(_THIS, SDL_Surface *screen) | |
89 { | |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
90 #ifndef NO_SHARED_MEMORY |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
91 try_mitshm(this, screen); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
92 if(use_mitshm) { |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
93 SDL_Ximage = XShmCreateImage(SDL_Display, SDL_Visual, |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
94 this->hidden->depth, ZPixmap, |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
95 shminfo.shmaddr, &shminfo, |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
96 screen->w, screen->h); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
97 if(!SDL_Ximage) { |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
98 XShmDetach(SDL_Display, &shminfo); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
99 XSync(SDL_Display, False); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
100 shmdt(shminfo.shmaddr); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
101 screen->pixels = NULL; |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
102 goto error; |
0 | 103 } |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
104 this->UpdateRects = X11_MITSHMUpdate; |
0 | 105 } |
551
b0c5a13a4243
Doh! Compile error if there was no X11 shared image support
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
106 if(!use_mitshm) |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
107 #endif /* not NO_SHARED_MEMORY */ |
551
b0c5a13a4243
Doh! Compile error if there was no X11 shared image support
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
108 { |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
109 int bpp; |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
110 screen->pixels = malloc(screen->h*screen->pitch); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
111 if ( screen->pixels == NULL ) { |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
112 SDL_OutOfMemory(); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
113 return -1; |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
114 } |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
115 bpp = screen->format->BytesPerPixel; |
0 | 116 SDL_Ximage = XCreateImage(SDL_Display, SDL_Visual, |
117 this->hidden->depth, ZPixmap, 0, | |
118 (char *)screen->pixels, | |
119 screen->w, screen->h, | |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
120 32, 0); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
121 if ( SDL_Ximage == NULL ) |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
122 goto error; |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
123 /* XPutImage will convert byte sex automatically */ |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
124 SDL_Ximage->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN) |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
125 ? MSBFirst : LSBFirst; |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
126 this->UpdateRects = X11_NormalUpdate; |
0 | 127 } |
128 screen->pitch = SDL_Ximage->bytes_per_line; | |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
129 return(0); |
0 | 130 |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
131 error: |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
132 SDL_SetError("Couldn't create XImage"); |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
133 return 1; |
0 | 134 } |
135 | |
136 void X11_DestroyImage(_THIS, SDL_Surface *screen) | |
137 { | |
138 if ( SDL_Ximage ) { | |
139 XDestroyImage(SDL_Ximage); | |
140 #ifndef NO_SHARED_MEMORY | |
141 if ( use_mitshm ) { | |
142 XShmDetach(SDL_Display, &shminfo); | |
143 XSync(SDL_Display, False); | |
144 shmdt(shminfo.shmaddr); | |
145 } | |
146 #endif /* ! NO_SHARED_MEMORY */ | |
147 SDL_Ximage = NULL; | |
148 } | |
149 if ( screen ) { | |
150 screen->pixels = NULL; | |
151 } | |
152 } | |
153 | |
166
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
154 /* Determine the number of CPUs in the system */ |
0 | 155 static int num_CPU(void) |
156 { | |
157 static int num_cpus = 0; | |
158 | |
159 if(!num_cpus) { | |
166
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
160 #if defined(__linux) |
0 | 161 char line[BUFSIZ]; |
162 FILE *pstat = fopen("/proc/stat", "r"); | |
163 if ( pstat ) { | |
164 while ( fgets(line, sizeof(line), pstat) ) { | |
165 if (memcmp(line, "cpu", 3) == 0 && line[3] != ' ') { | |
166 ++num_cpus; | |
167 } | |
168 } | |
169 fclose(pstat); | |
170 } | |
166
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
171 #elif defined(_SC_NPROCESSORS_ONLN) |
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
172 /* number of processors online (SVR4.0MP compliant machines) */ |
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
173 num_cpus = sysconf(_SC_NPROCESSORS_ONLN); |
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
174 #elif defined(_SC_NPROCESSORS_CONF) |
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
175 /* number of processors configured (SVR4.0MP compliant machines) */ |
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
176 num_cpus = sysconf(_SC_NPROCESSORS_CONF); |
0 | 177 #endif |
178 if ( num_cpus <= 0 ) { | |
179 num_cpus = 1; | |
180 } | |
181 } | |
182 return num_cpus; | |
183 } | |
184 | |
185 int X11_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags) | |
186 { | |
187 int retval; | |
188 | |
189 X11_DestroyImage(this, screen); | |
190 if ( flags & SDL_OPENGL ) { /* No image when using GL */ | |
191 retval = 0; | |
192 } else { | |
193 retval = X11_SetupImage(this, screen); | |
194 /* We support asynchronous blitting on the display */ | |
195 if ( flags & SDL_ASYNCBLIT ) { | |
196 /* This is actually slower on single-CPU systems, | |
197 probably because of CPU contention between the | |
198 X server and the application. | |
199 Note: Is this still true with XFree86 4.0? | |
200 */ | |
201 if ( num_CPU() > 1 ) { | |
202 screen->flags |= SDL_ASYNCBLIT; | |
203 } | |
204 } | |
205 } | |
206 return(retval); | |
207 } | |
208 | |
209 /* We don't actually allow hardware surfaces other than the main one */ | |
210 int X11_AllocHWSurface(_THIS, SDL_Surface *surface) | |
211 { | |
212 return(-1); | |
213 } | |
214 void X11_FreeHWSurface(_THIS, SDL_Surface *surface) | |
215 { | |
216 return; | |
217 } | |
218 | |
219 int X11_LockHWSurface(_THIS, SDL_Surface *surface) | |
220 { | |
221 if ( (surface == SDL_VideoSurface) && blit_queued ) { | |
222 XSync(GFX_Display, False); | |
223 blit_queued = 0; | |
224 } | |
225 return(0); | |
226 } | |
227 void X11_UnlockHWSurface(_THIS, SDL_Surface *surface) | |
228 { | |
229 return; | |
230 } | |
231 | |
232 int X11_FlipHWSurface(_THIS, SDL_Surface *surface) | |
233 { | |
234 return(0); | |
235 } | |
236 | |
237 static void X11_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) | |
238 { | |
239 int i; | |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
240 |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
241 for (i = 0; i < numrects; ++i) { |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
242 if ( rects[i].w == 0 || rects[i].h == 0 ) { /* Clipped? */ |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
243 continue; |
0 | 244 } |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
245 XPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage, |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
246 rects[i].x, rects[i].y, |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
247 rects[i].x, rects[i].y, rects[i].w, rects[i].h); |
0 | 248 } |
249 if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) { | |
250 XFlush(GFX_Display); | |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
251 blit_queued = 1; |
0 | 252 } else { |
253 XSync(GFX_Display, False); | |
254 } | |
255 } | |
256 | |
257 static void X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect *rects) | |
258 { | |
259 #ifndef NO_SHARED_MEMORY | |
260 int i; | |
261 | |
262 for ( i=0; i<numrects; ++i ) { | |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
263 if ( rects[i].w == 0 || rects[i].h == 0 ) { /* Clipped? */ |
0 | 264 continue; |
265 } | |
266 XShmPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage, | |
267 rects[i].x, rects[i].y, | |
268 rects[i].x, rects[i].y, rects[i].w, rects[i].h, | |
269 False); | |
270 } | |
271 if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) { | |
272 XFlush(GFX_Display); | |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
273 blit_queued = 1; |
0 | 274 } else { |
275 XSync(GFX_Display, False); | |
276 } | |
277 #endif /* ! NO_SHARED_MEMORY */ | |
278 } | |
279 | |
280 /* There's a problem with the automatic refreshing of the display. | |
281 Even though the XVideo code uses the GFX_Display to update the | |
282 video memory, it appears that updating the window asynchronously | |
283 from a different thread will cause "blackouts" of the window. | |
284 This is a sort of a hacked workaround for the problem. | |
285 */ | |
286 static int enable_autorefresh = 1; | |
287 | |
288 void X11_DisableAutoRefresh(_THIS) | |
289 { | |
290 --enable_autorefresh; | |
291 } | |
292 | |
293 void X11_EnableAutoRefresh(_THIS) | |
294 { | |
295 ++enable_autorefresh; | |
296 } | |
297 | |
298 void X11_RefreshDisplay(_THIS) | |
299 { | |
161
eb6b76a95f2d
An expose event is now sent when using XVideo output.
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
300 /* Don't refresh a display that doesn't have an image (like GL) |
eb6b76a95f2d
An expose event is now sent when using XVideo output.
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
301 Instead, post an expose event so the application can refresh. |
eb6b76a95f2d
An expose event is now sent when using XVideo output.
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
302 */ |
0 | 303 if ( ! SDL_Ximage || (enable_autorefresh <= 0) ) { |
161
eb6b76a95f2d
An expose event is now sent when using XVideo output.
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
304 SDL_PrivateExpose(); |
0 | 305 return; |
306 } | |
307 #ifndef NO_SHARED_MEMORY | |
308 if ( this->UpdateRects == X11_MITSHMUpdate ) { | |
309 XShmPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage, | |
310 0, 0, 0, 0, this->screen->w, this->screen->h, | |
311 False); | |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
312 } else |
0 | 313 #endif /* ! NO_SHARED_MEMORY */ |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
314 { |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
315 XPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage, |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
316 0, 0, 0, 0, this->screen->w, this->screen->h); |
0 | 317 } |
318 XSync(SDL_Display, False); | |
319 } |