comparison src/video/SDL_video.c @ 2267:c785543d1843

Okay, still some bugs, but everything builds again...
author Sam Lantinga <slouken@libsdl.org>
date Sat, 18 Aug 2007 05:39:09 +0000
parents e61ad15a205f
children 3202e4826c57
comparison
equal deleted inserted replaced
2266:e61ad15a205f 2267:c785543d1843
1550 (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { 1550 (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
1551 SDL_SetError("Unknown pixel format"); 1551 SDL_SetError("Unknown pixel format");
1552 return 0; 1552 return 0;
1553 } 1553 }
1554 } else { 1554 } else {
1555 if (surface->format->Amask || !(flags & (SDL_COPY_COLORKEY|SDL_COPY_MASK|SDL_COPY_BLEND))) { 1555 if (surface->format->Amask
1556 || !(surface->map->info.flags &
1557 (SDL_COPY_COLORKEY | SDL_COPY_MASK | SDL_COPY_BLEND))) {
1556 bpp = fmt->BitsPerPixel; 1558 bpp = fmt->BitsPerPixel;
1557 Rmask = fmt->Rmask; 1559 Rmask = fmt->Rmask;
1558 Gmask = fmt->Gmask; 1560 Gmask = fmt->Gmask;
1559 Bmask = fmt->Bmask; 1561 Bmask = fmt->Bmask;
1560 Amask = fmt->Amask; 1562 Amask = fmt->Amask;
1600 1602
1601 /* Set up a destination surface for the texture update */ 1603 /* Set up a destination surface for the texture update */
1602 dst_fmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask); 1604 dst_fmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
1603 if (dst_fmt) { 1605 if (dst_fmt) {
1604 if (SDL_ISPIXELFORMAT_INDEXED(format)) { 1606 if (SDL_ISPIXELFORMAT_INDEXED(format)) {
1605 dst_fmt->palette = SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format))); 1607 dst_fmt->palette =
1608 SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format)));
1606 if (dst_fmt->palette) { 1609 if (dst_fmt->palette) {
1607 if (fmt->palette) { 1610 /* FIXME: Should we try to copy fmt->palette? */
1608 fixme 1611 SDL_DitherColors(dst_fmt->palette->colors,
1609 } else { 1612 SDL_BITSPERPIXEL(format));
1610 SDL_DitherColors(dst_fmt->palette->colors, SDL_BITSPERPIXEL(format));
1611 }
1612 }
1613 if (fmt->palette) {
1614 dst_fmt->palette = fmt->palette;
1615 } else {
1616 } 1613 }
1617 } 1614 }
1618 1615
1619 cvt = SDL_ConvertSurface(surface, fmt, 0); 1616 dst = SDL_ConvertSurface(surface, dst_fmt, 0);
1620 if (cvt) { 1617 if (dst) {
1621 SDL_UpdateTexture(textureID, NULL, cvt->pixels, cvt->pitch); 1618 SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch);
1622 SDL_FreeSurface(cvt); 1619 SDL_FreeSurface(dst);
1623 } 1620 }
1624 SDL_FreeFormat(fmt); 1621 if (dst_fmt->palette) {
1622 SDL_FreePalette(dst_fmt->palette);
1623 }
1624 SDL_FreeFormat(dst_fmt);
1625 }
1626 if (!dst) {
1627 SDL_DestroyTexture(textureID);
1628 return 0;
1625 } 1629 }
1626 } 1630 }
1627 1631
1628 if (SDL_ISPIXELFORMAT_INDEXED(format) && fmt->palette) { 1632 if (SDL_ISPIXELFORMAT_INDEXED(format) && fmt->palette) {
1629 SDL_SetTexturePalette(textureID, fmt->palette->colors, 0, fmt->palette->ncolors); 1633 SDL_SetTexturePalette(textureID, fmt->palette->colors, 0,
1634 fmt->palette->ncolors);
1630 } 1635 }
1631 1636
1632 return textureID; 1637 return textureID;
1633 } 1638 }
1634 1639