comparison src/video/SDL_video.c @ 3169:f294338ca6eb

indent
author Sam Lantinga <slouken@libsdl.org>
date Sun, 07 Jun 2009 02:45:55 +0000
parents 3a63a5824557
children 72edc980789b
comparison
equal deleted inserted replaced
3168:6338b7f2d024 3169:f294338ca6eb
1633 /* Need a format with alpha */ 1633 /* Need a format with alpha */
1634 int it; 1634 int it;
1635 int apfmt; 1635 int apfmt;
1636 1636
1637 /* Pixel formats with alpha, sorted by best first */ 1637 /* Pixel formats with alpha, sorted by best first */
1638 static const Uint32 sdl_alpha_pformats[]={ 1638 static const Uint32 sdl_alpha_pformats[] = {
1639 SDL_PIXELFORMAT_ARGB8888, 1639 SDL_PIXELFORMAT_ARGB8888,
1640 SDL_PIXELFORMAT_RGBA8888, 1640 SDL_PIXELFORMAT_RGBA8888,
1641 SDL_PIXELFORMAT_ABGR8888, 1641 SDL_PIXELFORMAT_ABGR8888,
1642 SDL_PIXELFORMAT_BGRA8888, 1642 SDL_PIXELFORMAT_BGRA8888,
1643 SDL_PIXELFORMAT_ARGB1555, 1643 SDL_PIXELFORMAT_ARGB1555,
1644 SDL_PIXELFORMAT_ABGR1555, 1644 SDL_PIXELFORMAT_ABGR1555,
1645 SDL_PIXELFORMAT_ARGB4444, 1645 SDL_PIXELFORMAT_ARGB4444,
1646 SDL_PIXELFORMAT_ABGR4444, 1646 SDL_PIXELFORMAT_ABGR4444,
1647 SDL_PIXELFORMAT_ARGB2101010, 1647 SDL_PIXELFORMAT_ARGB2101010,
1648 SDL_PIXELFORMAT_UNKNOWN}; 1648 SDL_PIXELFORMAT_UNKNOWN
1649 };
1649 1650
1650 bpp = 32; 1651 bpp = 32;
1651 Rmask = 0x00FF0000; 1652 Rmask = 0x00FF0000;
1652 Gmask = 0x0000FF00; 1653 Gmask = 0x0000FF00;
1653 Bmask = 0x000000FF; 1654 Bmask = 0x000000FF;
1654 Amask = 0xFF000000; 1655 Amask = 0xFF000000;
1655 1656
1656 format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask); 1657 format =
1658 SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
1657 if (!format) { 1659 if (!format) {
1658 SDL_SetError("Unknown pixel format"); 1660 SDL_SetError("Unknown pixel format");
1659 return 0; 1661 return 0;
1660 } 1662 }
1661 1663
1662 /* Search this format in the supported texture formats */ 1664 /* Search this format in the supported texture formats */
1663 /* by current renderer */ 1665 /* by current renderer */
1664 for (it=0; it<renderer->info.num_texture_formats; it++) 1666 for (it = 0; it < renderer->info.num_texture_formats; it++) {
1665 { 1667 if (renderer->info.texture_formats[it] == format) {
1666 if (renderer->info.texture_formats[it]==format) 1668 break;
1667 {
1668 break;
1669 } 1669 }
1670 } 1670 }
1671 1671
1672 /* If this format can't be found, search any best */ 1672 /* If this format can't be found, search any best */
1673 /* compatible format with alpha which renderer provides */ 1673 /* compatible format with alpha which renderer provides */
1674 if (it==renderer->info.num_texture_formats) 1674 if (it == renderer->info.num_texture_formats) {
1675 { 1675 apfmt = 0;
1676 apfmt=0; 1676 for (;;) {
1677 for (;;) 1677 if (sdl_alpha_pformats[apfmt] == SDL_PIXELFORMAT_UNKNOWN) {
1678 {
1679 if (sdl_alpha_pformats[apfmt]==SDL_PIXELFORMAT_UNKNOWN)
1680 {
1681 break; 1678 break;
1682 } 1679 }
1683 1680
1684 for (it=0; it<renderer->info.num_texture_formats; it++) 1681 for (it = 0; it < renderer->info.num_texture_formats;
1685 { 1682 it++) {
1686 if (renderer->info.texture_formats[it]==sdl_alpha_pformats[apfmt]) 1683 if (renderer->info.texture_formats[it] ==
1687 { 1684 sdl_alpha_pformats[apfmt]) {
1688 break; 1685 break;
1689 } 1686 }
1690 } 1687 }
1691 1688
1692 if (it!=renderer->info.num_texture_formats) 1689 if (it != renderer->info.num_texture_formats) {
1693 { 1690 /* Compatible format has been found */
1694 /* Compatible format has been found */ 1691 break;
1695 break;
1696 } 1692 }
1697 apfmt++; 1693 apfmt++;
1698 } 1694 }
1699 1695
1700 /* If compatible format can't be found, then return an error */ 1696 /* If compatible format can't be found, then return an error */
1701 if (it==renderer->info.num_texture_formats) 1697 if (it == renderer->info.num_texture_formats) {
1702 {
1703 SDL_SetError("Compatible pixel format can't be found"); 1698 SDL_SetError("Compatible pixel format can't be found");
1704 return 0; 1699 return 0;
1705 } 1700 }
1706 1701
1707 /* Convert found pixel format back to color masks */ 1702 /* Convert found pixel format back to color masks */
1708 if (SDL_PixelFormatEnumToMasks(renderer->info.texture_formats[it], 1703 if (SDL_PixelFormatEnumToMasks
1709 &bpp, &Rmask, &Gmask, &Bmask, &Amask)!=SDL_TRUE) 1704 (renderer->info.texture_formats[it], &bpp, &Rmask, &Gmask,
1710 { 1705 &Bmask, &Amask) != SDL_TRUE) {
1711 SDL_SetError("Unknown pixel format"); 1706 SDL_SetError("Unknown pixel format");
1712 return 0; 1707 return 0;
1713 } 1708 }
1714 } 1709 }
1715 } 1710 }