Added a hint "SDL_SURFACE_MALLOC" to disable aligned surface allocation
This is needed for sdl12-compat, where all surfaces were not aligned.
This commit is contained in:
@@ -229,12 +229,16 @@ SDL_Surface *SDL_CreateSurface(int width, int height, SDL_PixelFormat format)
|
|||||||
|
|
||||||
if (surface->w && surface->h && format != SDL_PIXELFORMAT_MJPG) {
|
if (surface->w && surface->h && format != SDL_PIXELFORMAT_MJPG) {
|
||||||
surface->flags &= ~SDL_SURFACE_PREALLOCATED;
|
surface->flags &= ~SDL_SURFACE_PREALLOCATED;
|
||||||
|
if (SDL_GetHintBoolean("SDL_SURFACE_MALLOC", false)) {
|
||||||
|
surface->pixels = SDL_malloc(size);
|
||||||
|
} else {
|
||||||
|
surface->flags |= SDL_SURFACE_SIMD_ALIGNED;
|
||||||
surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size);
|
surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size);
|
||||||
|
}
|
||||||
if (!surface->pixels) {
|
if (!surface->pixels) {
|
||||||
SDL_DestroySurface(surface);
|
SDL_DestroySurface(surface);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
surface->flags |= SDL_SURFACE_SIMD_ALIGNED;
|
|
||||||
|
|
||||||
// This is important for bitmaps
|
// This is important for bitmaps
|
||||||
SDL_memset(surface->pixels, 0, size);
|
SDL_memset(surface->pixels, 0, size);
|
||||||
|
|||||||
Reference in New Issue
Block a user