Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11render.c @ 4612:9a5db97cd569
Advertise support for all supported texture formats.
author | Sunny Sachanandani <sunnysachanandani@gmail.com> |
---|---|
date | Thu, 22 Jul 2010 10:53:41 +0530 |
parents | a2ed55b5ff85 |
children | 56b888179f95 |
comparison
equal
deleted
inserted
replaced
4611:a2ed55b5ff85 | 4612:9a5db97cd569 |
---|---|
250 | 250 |
251 return SDL_TRUE; | 251 return SDL_TRUE; |
252 } | 252 } |
253 #endif | 253 #endif |
254 | 254 |
255 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER | |
256 static Uint32 | |
257 XRenderPictFormatToSDLPixelFormatEnum(XRenderPictFormat *pict_format) { | |
258 if (pict_format->type != PictTypeDirect) { | |
259 SDL_SetError("Indexed pict formats not supported ATM"); | |
260 return 0; | |
261 } | |
262 Uint32 Amask, Rmask, Gmask, Bmask; | |
263 int bpp; | |
264 | |
265 Rmask = pict_format->direct.redMask << pict_format->direct.red; | |
266 Gmask = pict_format->direct.greenMask << pict_format->direct.green; | |
267 Bmask = pict_format->direct.blueMask << pict_format->direct.blue; | |
268 Amask = pict_format->direct.alphaMask << pict_format->direct.alpha; | |
269 bpp = pict_format->depth; | |
270 | |
271 Uint32 format; | |
272 format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask); | |
273 return format; | |
274 } | |
275 #endif | |
276 | |
255 void | 277 void |
256 X11_AddRenderDriver(_THIS) | 278 X11_AddRenderDriver(_THIS) |
257 { | 279 { |
258 SDL_RendererInfo *info = &X11_RenderDriver.info; | 280 SDL_RendererInfo *info = &X11_RenderDriver.info; |
259 SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode; | 281 SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode; |
268 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU; | 290 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU; |
269 | 291 |
270 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER | 292 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
271 int major, minor; | 293 int major, minor; |
272 if (CheckXRender(data->display, &major, &minor)) { | 294 if (CheckXRender(data->display, &major, &minor)) { |
273 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_ARGB8888; | 295 XRenderPictFormat templ; |
296 templ.type = PictTypeDirect; | |
297 XRenderPictFormat *pict_format; | |
298 Uint32 format; | |
299 int i = 0; | |
300 while (info->num_texture_formats < 50) { | |
301 pict_format = | |
302 XRenderFindFormat(data->display, PictFormatType, &templ, i++); | |
303 if (pict_format) { | |
304 format = XRenderPictFormatToSDLPixelFormatEnum(pict_format); | |
305 if (format != SDL_PIXELTYPE_UNKNOWN) { | |
306 info->texture_formats[info->num_texture_formats++] = format; | |
307 } | |
308 } | |
309 else | |
310 break; | |
311 } | |
274 info->blend_modes = (SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | | 312 info->blend_modes = (SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | |
275 SDL_BLENDMODE_MOD | SDL_BLENDMODE_MASK); | 313 SDL_BLENDMODE_MOD | SDL_BLENDMODE_MASK); |
276 info->scale_modes = (SDL_TEXTURESCALEMODE_FAST | SDL_TEXTURESCALEMODE_SLOW | | 314 info->scale_modes = (SDL_TEXTURESCALEMODE_FAST | SDL_TEXTURESCALEMODE_SLOW | |
277 SDL_TEXTURESCALEMODE_BEST); | 315 SDL_TEXTURESCALEMODE_BEST); |
278 } | 316 } |
377 data->xwindow_pict, | 415 data->xwindow_pict, |
378 0, 0, | 416 0, 0, |
379 0, 0, | 417 0, 0, |
380 0, 0, | 418 0, 0, |
381 window->w, window->h); | 419 window->w, window->h); |
382 /* Add some blending modes to the list of supported blending modes */ | |
383 renderer->info.blend_modes |= | |
384 (SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MASK | SDL_BLENDMODE_MOD); | |
385 renderer->info.scale_modes |= | |
386 (SDL_TEXTURESCALEMODE_FAST | SDL_TEXTURESCALEMODE_SLOW | SDL_TEXTURESCALEMODE_BEST); | |
387 /* Create a clip mask that is used for rendering primitives. */ | 420 /* Create a clip mask that is used for rendering primitives. */ |
388 data->stencil = XCreatePixmap(data->display, data->xwindow, | 421 data->stencil = XCreatePixmap(data->display, data->xwindow, |
389 window->w, window->h, 32); | 422 window->w, window->h, 32); |
390 | 423 |
391 /* Create the GC for the clip mask. */ | 424 /* Create the GC for the clip mask. */ |
420 // Set the default blending mode. | 453 // Set the default blending mode. |
421 renderer->blendMode = SDL_BLENDMODE_BLEND; | 454 renderer->blendMode = SDL_BLENDMODE_BLEND; |
422 data->blend_op = PictOpOver; | 455 data->blend_op = PictOpOver; |
423 } | 456 } |
424 #endif | 457 #endif |
425 | |
426 if (flags & SDL_RENDERER_SINGLEBUFFER) { | 458 if (flags & SDL_RENDERER_SINGLEBUFFER) { |
427 renderer->info.flags |= | 459 renderer->info.flags |= |
428 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY); | 460 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY); |
429 n = 0; | 461 n = 0; |
430 } else if (flags & SDL_RENDERER_PRESENTFLIP2) { | 462 } else if (flags & SDL_RENDERER_PRESENTFLIP2) { |