mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-07 18:36:26 +00:00
Fixed bug 4484 - use SIMD aligned memory for SDL_Surface
Surfaces are allocated using SDL_SIMDAlloc() They are marked with SDL_SIMD_ALIGNED flag to appropriatly free them with SDL_SIMDFree() (Flag is cleared when pixels is free'd in RLE, in case user would hijack the pixels ptr) When providing its own memory pointer (SDL_CreateRGBSurfaceFrom()) and clearing SDL_PREALLOC to delegate to SDL the memory free, it's the responsability of the user to add SDL_SIMD_ALIGNED or not, whether the pointer has been allocated with SDL_malloc() or SDL_SIMDAlloc().
This commit is contained in:
@@ -120,12 +120,13 @@ SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
surface->pixels = SDL_malloc((size_t)size);
|
||||
surface->pixels = SDL_SIMDAlloc((size_t)size);
|
||||
if (!surface->pixels) {
|
||||
SDL_FreeSurface(surface);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
surface->flags |= SDL_SIMD_ALIGNED;
|
||||
/* This is important for bitmaps */
|
||||
SDL_memset(surface->pixels, 0, surface->h * surface->pitch);
|
||||
}
|
||||
|
Reference in New Issue
Block a user