mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-27 02:46:08 +08:00
Added a hint "SDL_SURFACE_MALLOC" to disable aligned surface allocation
This is needed for sdl12-compat, where all surfaces were not aligned.
(cherry picked from commit dd01e096e9)
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "../SDL_internal.h"
|
#include "../SDL_internal.h"
|
||||||
|
|
||||||
|
#include "SDL_hints.h"
|
||||||
#include "SDL_video.h"
|
#include "SDL_video.h"
|
||||||
#include "SDL_sysvideo.h"
|
#include "SDL_sysvideo.h"
|
||||||
#include "SDL_blit.h"
|
#include "SDL_blit.h"
|
||||||
@@ -153,13 +154,17 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
surface->pixels = SDL_SIMDAlloc(size);
|
if (SDL_GetHintBoolean("SDL_SURFACE_MALLOC", SDL_FALSE)) {
|
||||||
|
surface->pixels = SDL_malloc(size);
|
||||||
|
} else {
|
||||||
|
surface->flags |= SDL_SIMD_ALIGNED;
|
||||||
|
surface->pixels = SDL_SIMDAlloc(size);
|
||||||
|
}
|
||||||
if (!surface->pixels) {
|
if (!surface->pixels) {
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
surface->flags |= SDL_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