MCPcopy Index your code
hub / github.com/assaultcube/AC / fixsurfaceformat

Function fixsurfaceformat

source/src/texture.cpp:257–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257SDL_Surface *fixsurfaceformat(SDL_Surface *s)
258{
259 if(!s) return NULL;
260 if(!s->pixels || min(s->w, s->h) <= 0 || s->format->BytesPerPixel <= 0)
261 {
262 SDL_FreeSurface(s);
263 return NULL;
264 }
265 static const uint rgbmasks[] = { RGBMASKS }, rgbamasks[] = { RGBAMASKS };
266 switch(s->format->BytesPerPixel)
267 {
268 case 1:
269 if(!checkgrayscale(s))
270 {
271 Uint32 ck;
272 SDL_GetColorKey(s, &ck);
273 return ck ? forcergbasurface(s) : forcergbsurface(s);
274 }
275 break;
276 case 3:
277 if(s->format->Rmask != rgbmasks[0] || s->format->Gmask != rgbmasks[1] || s->format->Bmask != rgbmasks[2])
278 return forcergbsurface(s);
279 break;
280 case 4:
281 if(s->format->Rmask != rgbamasks[0] || s->format->Gmask != rgbamasks[1] || s->format->Bmask != rgbamasks[2] || s->format->Amask != rgbamasks[3])
282 return s->format->Amask ? forcergbasurface(s) : forcergbsurface(s);
283 break;
284 }
285 return s;
286}
287
288GLenum texformat(int bpp)
289{

Callers 1

loadsurfaceFunction · 0.85

Calls 4

minFunction · 0.85
checkgrayscaleFunction · 0.85
forcergbasurfaceFunction · 0.85
forcergbsurfaceFunction · 0.85

Tested by

no test coverage detected