Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11image.c @ 855:aa4ac9e65d92
I noticed MacOSX SDL sets up working directory to parent of executable.
On BeOS is should setup it the same way, but it only does when Tracker
wasn't restarted.
I checked code and it looks like a hack to me :(
It looks for env variable and than comapres it to default when OpenTracker
was started after boot, and wasn't restarted. That's probably ok, for that
exact case. Unfortunetly that variable isn't always like that. For
example, after Tracker crashes and is restarted, env variable most
probably is different (depends on how Tracker was restarted, by what
application, etc... for example: i have launcher application from which i
can restart Tracker, and after that nev variable points to that
application's directory, not Tracker's).
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 24 Feb 2004 18:58:40 +0000 |
parents | 26a0e2d69d39 |
children | 045f186426e1 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
3 Copyright (C) 1997-2004 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 ) { | |
810
26a0e2d69d39
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
47 shm_error = True; |
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); |
810
26a0e2d69d39
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
68 if ( shm_error ) |
270
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 } | |
605
6399f4e90211
IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents:
551
diff
changeset
|
171 #elif defined(__sgi) |
6399f4e90211
IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents:
551
diff
changeset
|
172 num_cpus = sysconf(_SC_NPROC_ONLN); |
166
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
173 #elif defined(_SC_NPROCESSORS_ONLN) |
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
174 /* number of processors online (SVR4.0MP compliant machines) */ |
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
175 num_cpus = sysconf(_SC_NPROCESSORS_ONLN); |
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
176 #elif defined(_SC_NPROCESSORS_CONF) |
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
177 /* number of processors configured (SVR4.0MP compliant machines) */ |
39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
Sam Lantinga <slouken@libsdl.org>
parents:
161
diff
changeset
|
178 num_cpus = sysconf(_SC_NPROCESSORS_CONF); |
0 | 179 #endif |
180 if ( num_cpus <= 0 ) { | |
181 num_cpus = 1; | |
182 } | |
183 } | |
184 return num_cpus; | |
185 } | |
186 | |
187 int X11_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags) | |
188 { | |
189 int retval; | |
190 | |
191 X11_DestroyImage(this, screen); | |
192 if ( flags & SDL_OPENGL ) { /* No image when using GL */ | |
193 retval = 0; | |
194 } else { | |
195 retval = X11_SetupImage(this, screen); | |
196 /* We support asynchronous blitting on the display */ | |
197 if ( flags & SDL_ASYNCBLIT ) { | |
198 /* This is actually slower on single-CPU systems, | |
199 probably because of CPU contention between the | |
200 X server and the application. | |
201 Note: Is this still true with XFree86 4.0? | |
202 */ | |
203 if ( num_CPU() > 1 ) { | |
204 screen->flags |= SDL_ASYNCBLIT; | |
205 } | |
206 } | |
207 } | |
208 return(retval); | |
209 } | |
210 | |
211 /* We don't actually allow hardware surfaces other than the main one */ | |
212 int X11_AllocHWSurface(_THIS, SDL_Surface *surface) | |
213 { | |
214 return(-1); | |
215 } | |
216 void X11_FreeHWSurface(_THIS, SDL_Surface *surface) | |
217 { | |
218 return; | |
219 } | |
220 | |
221 int X11_LockHWSurface(_THIS, SDL_Surface *surface) | |
222 { | |
223 if ( (surface == SDL_VideoSurface) && blit_queued ) { | |
224 XSync(GFX_Display, False); | |
225 blit_queued = 0; | |
226 } | |
227 return(0); | |
228 } | |
229 void X11_UnlockHWSurface(_THIS, SDL_Surface *surface) | |
230 { | |
231 return; | |
232 } | |
233 | |
234 int X11_FlipHWSurface(_THIS, SDL_Surface *surface) | |
235 { | |
236 return(0); | |
237 } | |
238 | |
239 static void X11_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) | |
240 { | |
241 int i; | |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
242 |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
243 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
|
244 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
|
245 continue; |
0 | 246 } |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
247 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
|
248 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
|
249 rects[i].x, rects[i].y, rects[i].w, rects[i].h); |
0 | 250 } |
251 if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) { | |
252 XFlush(GFX_Display); | |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
253 blit_queued = 1; |
0 | 254 } else { |
255 XSync(GFX_Display, False); | |
256 } | |
257 } | |
258 | |
259 static void X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect *rects) | |
260 { | |
261 #ifndef NO_SHARED_MEMORY | |
262 int i; | |
263 | |
264 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
|
265 if ( rects[i].w == 0 || rects[i].h == 0 ) { /* Clipped? */ |
0 | 266 continue; |
267 } | |
268 XShmPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage, | |
269 rects[i].x, rects[i].y, | |
270 rects[i].x, rects[i].y, rects[i].w, rects[i].h, | |
271 False); | |
272 } | |
273 if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) { | |
274 XFlush(GFX_Display); | |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
275 blit_queued = 1; |
0 | 276 } else { |
277 XSync(GFX_Display, False); | |
278 } | |
279 #endif /* ! NO_SHARED_MEMORY */ | |
280 } | |
281 | |
282 /* There's a problem with the automatic refreshing of the display. | |
283 Even though the XVideo code uses the GFX_Display to update the | |
284 video memory, it appears that updating the window asynchronously | |
285 from a different thread will cause "blackouts" of the window. | |
286 This is a sort of a hacked workaround for the problem. | |
287 */ | |
288 static int enable_autorefresh = 1; | |
289 | |
290 void X11_DisableAutoRefresh(_THIS) | |
291 { | |
292 --enable_autorefresh; | |
293 } | |
294 | |
295 void X11_EnableAutoRefresh(_THIS) | |
296 { | |
297 ++enable_autorefresh; | |
298 } | |
299 | |
300 void X11_RefreshDisplay(_THIS) | |
301 { | |
161
eb6b76a95f2d
An expose event is now sent when using XVideo output.
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
302 /* 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
|
303 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
|
304 */ |
0 | 305 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
|
306 SDL_PrivateExpose(); |
0 | 307 return; |
308 } | |
309 #ifndef NO_SHARED_MEMORY | |
310 if ( this->UpdateRects == X11_MITSHMUpdate ) { | |
311 XShmPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage, | |
312 0, 0, 0, 0, this->screen->w, this->screen->h, | |
313 False); | |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
314 } else |
0 | 315 #endif /* ! NO_SHARED_MEMORY */ |
270
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
316 { |
37fa1484f71b
From: "Mattias Engdeg�rd" <f91-men@nada.kth.se>
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
317 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
|
318 0, 0, 0, 0, this->screen->w, this->screen->h); |
0 | 319 } |
320 XSync(SDL_Display, False); | |
321 } |