comparison src/video/SDL_video.c @ 3186:51750b7a966f

indent
author Sam Lantinga <slouken@libsdl.org>
date Wed, 10 Jun 2009 13:34:20 +0000
parents 72edc980789b
children 413672b09bb3
comparison
equal deleted inserted replaced
3185:44d5474c2c8a 3186:51750b7a966f
411 modes[nmodes] = *mode; 411 modes[nmodes] = *mode;
412 display->num_display_modes++; 412 display->num_display_modes++;
413 413
414 /* Re-sort video modes */ 414 /* Re-sort video modes */
415 SDL_qsort(display->display_modes, display->num_display_modes, 415 SDL_qsort(display->display_modes, display->num_display_modes,
416 sizeof(SDL_DisplayMode), cmpmodes); 416 sizeof(SDL_DisplayMode), cmpmodes);
417 417
418 return SDL_TRUE; 418 return SDL_TRUE;
419 } 419 }
420 420
421 int 421 int
1632 (SDL_COPY_COLORKEY | SDL_COPY_MASK | SDL_COPY_BLEND))) { 1632 (SDL_COPY_COLORKEY | SDL_COPY_MASK | SDL_COPY_BLEND))) {
1633 int it; 1633 int it;
1634 int pfmt; 1634 int pfmt;
1635 1635
1636 /* Pixel formats, sorted by best first */ 1636 /* Pixel formats, sorted by best first */
1637 static const Uint32 sdl_pformats[]={ 1637 static const Uint32 sdl_pformats[] = {
1638 SDL_PIXELFORMAT_ARGB8888, 1638 SDL_PIXELFORMAT_ARGB8888,
1639 SDL_PIXELFORMAT_RGBA8888, 1639 SDL_PIXELFORMAT_RGBA8888,
1640 SDL_PIXELFORMAT_ABGR8888, 1640 SDL_PIXELFORMAT_ABGR8888,
1641 SDL_PIXELFORMAT_BGRA8888, 1641 SDL_PIXELFORMAT_BGRA8888,
1642 SDL_PIXELFORMAT_RGB888, 1642 SDL_PIXELFORMAT_RGB888,
1643 SDL_PIXELFORMAT_BGR888, 1643 SDL_PIXELFORMAT_BGR888,
1644 SDL_PIXELFORMAT_RGB24, 1644 SDL_PIXELFORMAT_RGB24,
1645 SDL_PIXELFORMAT_BGR24, 1645 SDL_PIXELFORMAT_BGR24,
1646 SDL_PIXELFORMAT_RGB565, 1646 SDL_PIXELFORMAT_RGB565,
1647 SDL_PIXELFORMAT_BGR565, 1647 SDL_PIXELFORMAT_BGR565,
1648 SDL_PIXELFORMAT_ARGB1555, 1648 SDL_PIXELFORMAT_ARGB1555,
1649 SDL_PIXELFORMAT_ABGR1555, 1649 SDL_PIXELFORMAT_ABGR1555,
1650 SDL_PIXELFORMAT_RGB555, 1650 SDL_PIXELFORMAT_RGB555,
1651 SDL_PIXELFORMAT_BGR555, 1651 SDL_PIXELFORMAT_BGR555,
1652 SDL_PIXELFORMAT_ARGB4444, 1652 SDL_PIXELFORMAT_ARGB4444,
1653 SDL_PIXELFORMAT_ABGR4444, 1653 SDL_PIXELFORMAT_ABGR4444,
1654 SDL_PIXELFORMAT_RGB444, 1654 SDL_PIXELFORMAT_RGB444,
1655 SDL_PIXELFORMAT_ARGB2101010, 1655 SDL_PIXELFORMAT_ARGB2101010,
1656 SDL_PIXELFORMAT_INDEX8, 1656 SDL_PIXELFORMAT_INDEX8,
1657 SDL_PIXELFORMAT_INDEX4LSB, 1657 SDL_PIXELFORMAT_INDEX4LSB,
1658 SDL_PIXELFORMAT_INDEX4MSB, 1658 SDL_PIXELFORMAT_INDEX4MSB,
1659 SDL_PIXELFORMAT_RGB332, 1659 SDL_PIXELFORMAT_RGB332,
1660 SDL_PIXELFORMAT_INDEX1LSB, 1660 SDL_PIXELFORMAT_INDEX1LSB,
1661 SDL_PIXELFORMAT_INDEX1MSB, 1661 SDL_PIXELFORMAT_INDEX1MSB,
1662 SDL_PIXELFORMAT_UNKNOWN}; 1662 SDL_PIXELFORMAT_UNKNOWN
1663 };
1663 1664
1664 bpp = fmt->BitsPerPixel; 1665 bpp = fmt->BitsPerPixel;
1665 Rmask = fmt->Rmask; 1666 Rmask = fmt->Rmask;
1666 Gmask = fmt->Gmask; 1667 Gmask = fmt->Gmask;
1667 Bmask = fmt->Bmask; 1668 Bmask = fmt->Bmask;
1668 Amask = fmt->Amask; 1669 Amask = fmt->Amask;
1669 1670
1670 format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask); 1671 format =
1672 SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
1671 if (!format) { 1673 if (!format) {
1672 SDL_SetError("Unknown pixel format"); 1674 SDL_SetError("Unknown pixel format");
1673 return 0; 1675 return 0;
1674 } 1676 }
1675 1677
1676 /* Search requested format in the supported texture */ 1678 /* Search requested format in the supported texture */
1677 /* formats by current renderer */ 1679 /* formats by current renderer */
1678 for (it=0; it<renderer->info.num_texture_formats; it++) 1680 for (it = 0; it < renderer->info.num_texture_formats; it++) {
1679 { 1681 if (renderer->info.texture_formats[it] == format) {
1680 if (renderer->info.texture_formats[it]==format) 1682 break;
1681 {
1682 break;
1683 } 1683 }
1684 } 1684 }
1685 1685
1686 /* If requested format can't be found, search any best */ 1686 /* If requested format can't be found, search any best */
1687 /* format which renderer provides */ 1687 /* format which renderer provides */
1688 if (it==renderer->info.num_texture_formats) 1688 if (it == renderer->info.num_texture_formats) {
1689 { 1689 pfmt = 0;
1690 pfmt=0; 1690 for (;;) {
1691 for (;;) 1691 if (sdl_pformats[pfmt] == SDL_PIXELFORMAT_UNKNOWN) {
1692 {
1693 if (sdl_pformats[pfmt]==SDL_PIXELFORMAT_UNKNOWN)
1694 {
1695 break; 1692 break;
1696 } 1693 }
1697 1694
1698 for (it=0; it<renderer->info.num_texture_formats; it++) 1695 for (it = 0; it < renderer->info.num_texture_formats;
1699 { 1696 it++) {
1700 if (renderer->info.texture_formats[it]==sdl_pformats[pfmt]) 1697 if (renderer->info.texture_formats[it] ==
1701 { 1698 sdl_pformats[pfmt]) {
1702 break; 1699 break;
1703 } 1700 }
1704 } 1701 }
1705 1702
1706 if (it!=renderer->info.num_texture_formats) 1703 if (it != renderer->info.num_texture_formats) {
1707 { 1704 /* The best format has been found */
1708 /* The best format has been found */ 1705 break;
1709 break;
1710 } 1706 }
1711 pfmt++; 1707 pfmt++;
1712 } 1708 }
1713 1709
1714 /* If any format can't be found, then return an error */ 1710 /* If any format can't be found, then return an error */
1715 if (it==renderer->info.num_texture_formats) 1711 if (it == renderer->info.num_texture_formats) {
1716 { 1712 SDL_SetError
1717 SDL_SetError("Any of the supported pixel formats can't be found"); 1713 ("Any of the supported pixel formats can't be found");
1718 return 0; 1714 return 0;
1719 } 1715 }
1720 1716
1721 /* Convert found pixel format back to color masks */ 1717 /* Convert found pixel format back to color masks */
1722 if (SDL_PixelFormatEnumToMasks(renderer->info.texture_formats[it], 1718 if (SDL_PixelFormatEnumToMasks
1723 &bpp, &Rmask, &Gmask, &Bmask, &Amask)!=SDL_TRUE) 1719 (renderer->info.texture_formats[it], &bpp, &Rmask, &Gmask,
1724 { 1720 &Bmask, &Amask) != SDL_TRUE) {
1725 SDL_SetError("Unknown pixel format"); 1721 SDL_SetError("Unknown pixel format");
1726 return 0; 1722 return 0;
1727 } 1723 }
1728 } 1724 }
1729 } else { 1725 } else {