Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11render.c @ 4605:0b3a509c53a0
Respect environment variables.
author | Sunny Sachanandani <sunnysachanandani@gmail.com> |
---|---|
date | Mon, 19 Jul 2010 21:02:49 +0530 |
parents | d7535d7a40ea |
children | 4e145485971b |
comparison
equal
deleted
inserted
replaced
4604:d7535d7a40ea | 4605:0b3a509c53a0 |
---|---|
174 rect.h = texture->h; | 174 rect.h = texture->h; |
175 SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w, | 175 SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w, |
176 texture->h, data->pixels, data->pitch); | 176 texture->h, data->pixels, data->pitch); |
177 } | 177 } |
178 | 178 |
179 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER | |
180 static SDL_bool | |
181 CheckXRender(Display *display, int *major, int *minor) { | |
182 const char *env; | |
183 | |
184 *major = *minor = 0; | |
185 | |
186 env = SDL_getenv("SDL_VIDEO_X11_XRENDER"); | |
187 | |
188 if (env && !SDL_atoi(env)) { | |
189 return SDL_FALSE; | |
190 } | |
191 | |
192 if (!SDL_X11_HAVE_XRENDER) { | |
193 return SDL_FALSE; | |
194 } | |
195 | |
196 if (!XRenderQueryVersion(display, major, minor)) { | |
197 return SDL_FALSE; | |
198 } | |
199 | |
200 return SDL_TRUE; | |
201 } | |
202 #endif | |
203 | |
204 #ifdef SDL_VIDEO_DRIVER_X11_XFIXES | |
205 static SDL_bool | |
206 CheckXFixes(Display *display, int *major, int *minor) { | |
207 const char *env; | |
208 | |
209 *major = *minor = 0; | |
210 | |
211 env = SDL_getenv("SDL_VIDEO_X11_XFIXES"); | |
212 | |
213 if (env && !SDL_atoi(env)) { | |
214 return SDL_FALSE; | |
215 } | |
216 | |
217 if (!SDL_X11_HAVE_XFIXES) { | |
218 return SDL_FALSE; | |
219 } | |
220 | |
221 if (!XFixesQueryVersion(display, major, minor)) { | |
222 return SDL_FALSE; | |
223 } | |
224 | |
225 return SDL_TRUE; | |
226 } | |
227 #endif | |
228 | |
229 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE | |
230 static SDL_bool | |
231 CheckXDamage(Display *display, int *major, int *minor) { | |
232 const char *env; | |
233 | |
234 *major = *minor = 0; | |
235 | |
236 env = SDL_getenv("SDL_VIDEO_X11_XDAMAGE"); | |
237 | |
238 if (env && !SDL_atoi(env)) { | |
239 return SDL_FALSE; | |
240 } | |
241 | |
242 if (!SDL_X11_HAVE_XDAMAGE) { | |
243 return SDL_FALSE; | |
244 } | |
245 | |
246 if (!XDamageQueryVersion(display, major, minor)) { | |
247 return SDL_FALSE; | |
248 } | |
249 | |
250 return SDL_TRUE; | |
251 } | |
252 #endif | |
253 | |
179 void | 254 void |
180 X11_AddRenderDriver(_THIS) | 255 X11_AddRenderDriver(_THIS) |
181 { | 256 { |
182 SDL_RendererInfo *info = &X11_RenderDriver.info; | 257 SDL_RendererInfo *info = &X11_RenderDriver.info; |
183 SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode; | 258 SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode; |
259 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; | |
184 int i; | 260 int i; |
185 | 261 |
186 info->texture_formats[info->num_texture_formats++] = mode->format; | 262 info->texture_formats[info->num_texture_formats++] = mode->format; |
187 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YV12; | 263 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YV12; |
188 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_IYUV; | 264 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_IYUV; |
189 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YUY2; | 265 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YUY2; |
190 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_UYVY; | 266 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_UYVY; |
191 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU; | 267 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU; |
192 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_ARGB8888; | 268 |
269 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER | |
270 int major, minor; | |
271 if (CheckXRender(data->display, &major, &minor)) { | |
272 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_ARGB8888; | |
273 } | |
274 #endif | |
193 | 275 |
194 for (i = 0; i < _this->num_displays; ++i) { | 276 for (i = 0; i < _this->num_displays; ++i) { |
195 SDL_AddRenderDriver(&_this->displays[i], &X11_RenderDriver); | 277 SDL_AddRenderDriver(&_this->displays[i], &X11_RenderDriver); |
196 } | 278 } |
197 } | 279 } |
253 renderer->driverdata = data; | 335 renderer->driverdata = data; |
254 | 336 |
255 renderer->info.flags = SDL_RENDERER_ACCELERATED; | 337 renderer->info.flags = SDL_RENDERER_ACCELERATED; |
256 | 338 |
257 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER | 339 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
258 data->use_xrender = SDL_FALSE; | 340 int major, minor; |
259 data->use_xdamage = SDL_FALSE; | 341 data->use_xrender = CheckXRender(data->display, &major, &minor); |
260 int event_basep, error_basep; | |
261 if (SDL_X11_HAVE_XRENDER) { | |
262 /* Query the extension. This is the server runtime check. */ | |
263 if(XRenderQueryExtension(data->display, | |
264 &event_basep, &error_basep) == True) | |
265 data->use_xrender = SDL_TRUE; | |
266 } | |
267 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE | 342 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
343 if (CheckXDamage(data->display, &major, &minor)) { | |
344 if (CheckXFixes(data->display, &major, &minor)) { | |
345 if (major >= 2) | |
346 data->use_xdamage = SDL_TRUE; | |
347 } | |
348 } | |
349 #endif | |
268 if (data->use_xrender) { | 350 if (data->use_xrender) { |
269 if(SDL_X11_HAVE_XDAMAGE && SDL_X11_HAVE_XFIXES) { | |
270 /* Query XDamage and XFixes */ | |
271 if(XDamageQueryExtension(data->display, | |
272 &event_basep, | |
273 &error_basep) == True && | |
274 (XFixesQueryExtension(data->display, | |
275 &event_basep, | |
276 &error_basep) == True)) { | |
277 int major_version, minor_version; | |
278 XFixesQueryVersion(data->display, | |
279 &major_version, | |
280 &minor_version); | |
281 /* Only XFixes v 2 or greater | |
282 * Required for XFixesSetPictureClipRegion() */ | |
283 if(major_version >= 2) | |
284 data->use_xdamage = SDL_TRUE; | |
285 } | |
286 } | |
287 #endif | |
288 /* Find the PictFormat from the visual. | 351 /* Find the PictFormat from the visual. |
289 * Should be an RGB PictFormat most of the time. */ | 352 * Should be an RGB PictFormat most of the time. */ |
290 data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, | 353 data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, |
291 data->visual); | 354 data->visual); |
292 if (!data->xwindow_pict_fmt) { | 355 if (!data->xwindow_pict_fmt) { |