comparison src/video/SDL_RLEaccel.c @ 2257:340942cfda48

Moved the colorkey and per-surface alpha into the blit info, in preparation for support for general color channel modulation. Removed and consolidated some data in the blit info.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 17 Aug 2007 00:54:53 +0000
parents 926294b2bb4e
children bee005ace1bf
comparison
equal deleted inserted replaced
2256:e893d24ad8db 2257:340942cfda48
857 /* Set up the source and destination pointers */ 857 /* Set up the source and destination pointers */
858 x = dstrect->x; 858 x = dstrect->x;
859 y = dstrect->y; 859 y = dstrect->y;
860 dstbuf = (Uint8 *) dst->pixels 860 dstbuf = (Uint8 *) dst->pixels
861 + y * dst->pitch + x * src->format->BytesPerPixel; 861 + y * dst->pitch + x * src->format->BytesPerPixel;
862 srcbuf = (Uint8 *) src->map->sw_data->aux_data; 862 srcbuf = (Uint8 *) src->map->data;
863 863
864 { 864 {
865 /* skip lines at the top if neccessary */ 865 /* skip lines at the top if neccessary */
866 int vskip = srcrect->y; 866 int vskip = srcrect->y;
867 int ofs = 0; 867 int ofs = 0;
904 904
905 } 905 }
906 } 906 }
907 907
908 alpha = (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA 908 alpha = (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA
909 ? src->format->alpha : 255; 909 ? (src->map->cmod >> 24) : 255;
910 /* if left or right edge clipping needed, call clip blit */ 910 /* if left or right edge clipping needed, call clip blit */
911 if (srcrect->x || srcrect->w != src->w) { 911 if (srcrect->x || srcrect->w != src->w) {
912 RLEClipBlit(w, srcbuf, dst, dstbuf, srcrect, alpha); 912 RLEClipBlit(w, srcbuf, dst, dstbuf, srcrect, alpha);
913 } else { 913 } else {
914 SDL_PixelFormat *fmt = src->format; 914 SDL_PixelFormat *fmt = src->format;
1131 } 1131 }
1132 1132
1133 x = dstrect->x; 1133 x = dstrect->x;
1134 y = dstrect->y; 1134 y = dstrect->y;
1135 dstbuf = (Uint8 *) dst->pixels + y * dst->pitch + x * df->BytesPerPixel; 1135 dstbuf = (Uint8 *) dst->pixels + y * dst->pitch + x * df->BytesPerPixel;
1136 srcbuf = (Uint8 *) src->map->sw_data->aux_data + sizeof(RLEDestFormat); 1136 srcbuf = (Uint8 *) src->map->data + sizeof(RLEDestFormat);
1137 1137
1138 { 1138 {
1139 /* skip lines at the top if necessary */ 1139 /* skip lines at the top if necessary */
1140 int vskip = srcrect->y; 1140 int vskip = srcrect->y;
1141 if (vskip) { 1141 if (vskip) {
1626 /* realloc the buffer to release unused memory */ 1626 /* realloc the buffer to release unused memory */
1627 { 1627 {
1628 Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); 1628 Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf);
1629 if (!p) 1629 if (!p)
1630 p = rlebuf; 1630 p = rlebuf;
1631 surface->map->sw_data->aux_data = p; 1631 surface->map->data = p;
1632 } 1632 }
1633 1633
1634 return 0; 1634 return 0;
1635 } 1635 }
1636 1636
1713 curbuf = srcbuf; 1713 curbuf = srcbuf;
1714 maxn = bpp == 4 ? 65535 : 255; 1714 maxn = bpp == 4 ? 65535 : 255;
1715 skip = run = 0; 1715 skip = run = 0;
1716 dst = rlebuf; 1716 dst = rlebuf;
1717 rgbmask = ~surface->format->Amask; 1717 rgbmask = ~surface->format->Amask;
1718 ckey = surface->format->colorkey & rgbmask; 1718 ckey = surface->map->ckey & rgbmask;
1719 lastline = dst; 1719 lastline = dst;
1720 getpix = getpixes[bpp - 1]; 1720 getpix = getpixes[bpp - 1];
1721 w = surface->w; 1721 w = surface->w;
1722 h = surface->h; 1722 h = surface->h;
1723 1723
1792 { 1792 {
1793 /* If realloc returns NULL, the original block is left intact */ 1793 /* If realloc returns NULL, the original block is left intact */
1794 Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); 1794 Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf);
1795 if (!p) 1795 if (!p)
1796 p = rlebuf; 1796 p = rlebuf;
1797 surface->map->sw_data->aux_data = p; 1797 surface->map->data = p;
1798 } 1798 }
1799 1799
1800 return (0); 1800 return (0);
1801 } 1801 }
1802 1802
1857 UnRLEAlpha(SDL_Surface * surface) 1857 UnRLEAlpha(SDL_Surface * surface)
1858 { 1858 {
1859 Uint8 *srcbuf; 1859 Uint8 *srcbuf;
1860 Uint32 *dst; 1860 Uint32 *dst;
1861 SDL_PixelFormat *sf = surface->format; 1861 SDL_PixelFormat *sf = surface->format;
1862 RLEDestFormat *df = surface->map->sw_data->aux_data; 1862 RLEDestFormat *df = surface->map->data;
1863 int (*uncopy_opaque) (Uint32 *, void *, int, 1863 int (*uncopy_opaque) (Uint32 *, void *, int,
1864 RLEDestFormat *, SDL_PixelFormat *); 1864 RLEDestFormat *, SDL_PixelFormat *);
1865 int (*uncopy_transl) (Uint32 *, void *, int, 1865 int (*uncopy_transl) (Uint32 *, void *, int,
1866 RLEDestFormat *, SDL_PixelFormat *); 1866 RLEDestFormat *, SDL_PixelFormat *);
1867 int w = surface->w; 1867 int w = surface->w;
1946 surface->flags |= SDL_RLEACCEL; 1946 surface->flags |= SDL_RLEACCEL;
1947 return; 1947 return;
1948 } 1948 }
1949 1949
1950 /* fill it with the background colour */ 1950 /* fill it with the background colour */
1951 SDL_FillRect(surface, NULL, surface->format->colorkey); 1951 SDL_FillRect(surface, NULL, surface->map->ckey);
1952 1952
1953 /* now render the encoded surface */ 1953 /* now render the encoded surface */
1954 full.x = full.y = 0; 1954 full.x = full.y = 0;
1955 full.w = surface->w; 1955 full.w = surface->w;
1956 full.h = surface->h; 1956 full.h = surface->h;
1965 return; 1965 return;
1966 } 1966 }
1967 } 1967 }
1968 } 1968 }
1969 1969
1970 if (surface->map && surface->map->sw_data->aux_data) { 1970 if (surface->map && surface->map->data) {
1971 SDL_free(surface->map->sw_data->aux_data); 1971 SDL_free(surface->map->data);
1972 surface->map->sw_data->aux_data = NULL; 1972 surface->map->data = NULL;
1973 } 1973 }
1974 } 1974 }
1975 } 1975 }
1976 1976
1977 /* vi: set ts=4 sw=4 expandtab: */ 1977 /* vi: set ts=4 sw=4 expandtab: */