RageSurface *RageDisplay::CreateSurfaceFromPixfmt( RagePixelFormat pixfmt, void *pixels, int width, int height, int pitch ) { const RagePixelFormatDesc *tpf = GetPixelFormatDesc(pixfmt); RageSurface *surf = CreateSurfaceFrom( width, height, tpf->bpp, tpf->masks[0], tpf->masks[1], tpf->masks[2], tpf->masks[3], (uint8_t *) pixels, pitch ); return surf; }
RagePixelFormat RageDisplay::FindPixelFormat( int iBPP, unsigned iRmask, unsigned iGmask, unsigned iBmask, unsigned iAmask, bool bRealtime ) { RagePixelFormatDesc tmp = { iBPP, { iRmask, iGmask, iBmask, iAmask } }; FOREACH_ENUM( RagePixelFormat, iPixFmt ) { const RagePixelFormatDesc *pf = GetPixelFormatDesc( RagePixelFormat(iPixFmt) ); if( !SupportsTextureFormat(RagePixelFormat(iPixFmt), bRealtime) ) continue; if( memcmp(pf, &tmp, sizeof(tmp)) ) continue; return iPixFmt; } return RagePixelFormat_Invalid; }
RageDisplay::PixelFormat RageDisplay::FindPixelFormat( int bpp, unsigned Rmask, unsigned Gmask, unsigned Bmask, unsigned Amask, bool realtime ) { PixelFormatDesc tmp = { bpp, { Rmask, Gmask, Bmask, Amask } }; for(int pixfmt = 0; pixfmt < NUM_PIX_FORMATS; ++pixfmt) { const PixelFormatDesc *pf = GetPixelFormatDesc(PixelFormat(pixfmt)); if(!SupportsTextureFormat( PixelFormat(pixfmt), realtime )) continue; if(memcmp(pf, &tmp, sizeof(tmp))) continue; return PixelFormat(pixfmt); } return NUM_PIX_FORMATS; }