Cleaned up various type conversion issues

This makes sure SDL_PixelFormatEnum flows through the internal code correctly, as well as fixing a number of other minor issues.
main
Sam Lantinga 2024-03-07 05:20:20 -08:00
parent f53bdc9531
commit 33eaddc565
85 changed files with 391 additions and 369 deletions

View File

@ -63,11 +63,11 @@ typedef struct SDL_Camera SDL_Camera;
*/
typedef struct SDL_CameraSpec
{
Uint32 format; /**< Frame SDL_PixelFormatEnum format */
int width; /**< Frame width */
int height; /**< Frame height */
int interval_numerator; /**< Frame rate numerator ((dom / num) == fps, (num / dom) == duration) */
int interval_denominator; /**< Frame rate demoninator ((dom / num) == fps, (num / dom) == duration) */
SDL_PixelFormatEnum format; /**< Frame format */
int width; /**< Frame width */
int height; /**< Frame height */
int interval_numerator; /**< Frame rate numerator ((dom / num) == fps, (num / dom) == duration) */
int interval_denominator; /**< Frame rate demoninator ((dom / num) == fps, (num / dom) == duration) */
} SDL_CameraSpec;
/**

View File

@ -133,6 +133,7 @@ typedef enum
*/
typedef enum
{
SDL_PEN_TYPE_UNKNOWN = 0,
SDL_PEN_TYPE_ERASER = 1, /**< Eraser */
SDL_PEN_TYPE_PEN, /**< Generic pen; this is the default. */
SDL_PEN_TYPE_PENCIL, /**< Pencil */

View File

@ -25,7 +25,7 @@
/* Push */
int SDL_ListAdd(SDL_ListNode **head, void *ent)
{
SDL_ListNode *node = SDL_malloc(sizeof(*node));
SDL_ListNode *node = (SDL_ListNode *)SDL_malloc(sizeof(*node));
if (!node) {
return -1;

View File

@ -150,7 +150,7 @@ SDL_PropertiesID SDL_CreateProperties(void)
return 0;
}
properties = SDL_calloc(1, sizeof(*properties));
properties = (SDL_Properties *)SDL_calloc(1, sizeof(*properties));
if (!properties) {
goto error;
}

View File

@ -666,7 +666,7 @@ int SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len)
SDL_UnlockMutex(stream->lock);
size_t chunk_size = SDL_GetAudioQueueChunkSize(stream->queue);
track = SDL_CreateChunkedAudioTrack(&src_spec, buf, len, chunk_size);
track = SDL_CreateChunkedAudioTrack(&src_spec, (const Uint8 *)buf, len, chunk_size);
if (!track) {
return -1;
@ -682,7 +682,7 @@ int SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len)
if (track) {
SDL_AddTrackToAudioQueue(stream->queue, track);
} else {
retval = SDL_WriteToAudioQueue(stream->queue, &stream->src_spec, buf, len);
retval = SDL_WriteToAudioQueue(stream->queue, &stream->src_spec, (const Uint8 *)buf, len);
}
if (retval == 0) {
@ -874,7 +874,7 @@ static int GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int ou
// Note, this is just to avoid extra copies.
// Some other formats may fit directly into the output buffer, but i'd rather process data in a SIMD-aligned buffer.
if ((src_format == dst_format) && (src_channels == dst_channels)) {
input_buffer = buf;
input_buffer = (Uint8 *)buf;
} else {
input_buffer = EnsureAudioStreamWorkBufferSize(stream, output_frames * max_frame_size);

View File

@ -134,14 +134,14 @@ static SDL_AudioChunk *CreateAudioTrackChunk(SDL_ChunkedAudioTrack *track)
static size_t AvailChunkedAudioTrack(void *ctx)
{
SDL_ChunkedAudioTrack *track = ctx;
SDL_ChunkedAudioTrack *track = (SDL_ChunkedAudioTrack *)ctx;
return track->queued_bytes;
}
static int WriteToChunkedAudioTrack(void *ctx, const Uint8 *data, size_t len)
{
SDL_ChunkedAudioTrack *track = ctx;
SDL_ChunkedAudioTrack *track = (SDL_ChunkedAudioTrack *)ctx;
SDL_AudioChunk *chunk = track->tail;
@ -200,7 +200,7 @@ static int WriteToChunkedAudioTrack(void *ctx, const Uint8 *data, size_t len)
static size_t ReadFromChunkedAudioTrack(void *ctx, Uint8 *data, size_t len, SDL_bool advance)
{
SDL_ChunkedAudioTrack *track = ctx;
SDL_ChunkedAudioTrack *track = (SDL_ChunkedAudioTrack *)ctx;
SDL_AudioChunk *chunk = track->head;
size_t total = 0;
@ -245,7 +245,7 @@ static size_t ReadFromChunkedAudioTrack(void *ctx, Uint8 *data, size_t len, SDL_
static void DestroyChunkedAudioTrack(void *ctx)
{
SDL_ChunkedAudioTrack *track = ctx;
SDL_ChunkedAudioTrack *track = (SDL_ChunkedAudioTrack *)ctx;
DestroyAudioChunks(track->head);
DestroyAudioChunks(track->free_chunks);
SDL_free(track);
@ -420,7 +420,7 @@ void *SDL_BeginAudioQueueIter(SDL_AudioQueue *queue)
size_t SDL_NextAudioQueueIter(SDL_AudioQueue *queue, void **inout_iter, SDL_AudioSpec *out_spec, SDL_bool *out_flushed)
{
SDL_AudioTrack *iter = *inout_iter;
SDL_AudioTrack *iter = (SDL_AudioTrack *)(*inout_iter);
SDL_assert(iter != NULL);
SDL_copyp(out_spec, &iter->spec);

View File

@ -532,6 +532,7 @@ static int DSOUND_OpenDevice(SDL_AudioDevice *device)
}
const DWORD numchunks = 8;
DWORD bufsize;
SDL_bool tried_format = SDL_FALSE;
SDL_AudioFormat test_format;
const SDL_AudioFormat *closefmts = SDL_ClosestAudioFormats(device->spec.format);
@ -548,7 +549,7 @@ static int DSOUND_OpenDevice(SDL_AudioDevice *device)
// Update the fragment size as size in bytes
SDL_UpdatedAudioDeviceFormat(device);
const DWORD bufsize = numchunks * device->buffer_size;
bufsize = numchunks * device->buffer_size;
if ((bufsize < DSBSIZE_MIN) || (bufsize > DSBSIZE_MAX)) {
SDL_SetError("Sound buffer size must be between %d and %d",
(int)((DSBSIZE_MIN < numchunks) ? 1 : DSBSIZE_MIN / numchunks),

View File

@ -71,7 +71,7 @@ static void ManagementThreadMainloop(void)
{
SDL_LockMutex(ManagementThreadLock);
ManagementThreadPendingTask *task;
while (((task = SDL_AtomicGetPtr((void **) &ManagementThreadPendingTasks)) != NULL) || !SDL_AtomicGet(&ManagementThreadShutdown)) {
while (((task = (ManagementThreadPendingTask *)SDL_AtomicGetPtr((void **)&ManagementThreadPendingTasks)) != NULL) || !SDL_AtomicGet(&ManagementThreadShutdown)) {
if (!task) {
SDL_WaitCondition(ManagementThreadCondition, ManagementThreadLock); // block until there's something to do.
} else {
@ -102,7 +102,7 @@ int WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, in
return SDL_SetError("Can't add task, we're shutting down");
}
ManagementThreadPendingTask *pending = SDL_calloc(1, sizeof(ManagementThreadPendingTask));
ManagementThreadPendingTask *pending = (ManagementThreadPendingTask *)SDL_calloc(1, sizeof(ManagementThreadPendingTask));
if (!pending) {
return -1;
}
@ -124,7 +124,7 @@ int WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, in
// add to end of task list.
ManagementThreadPendingTask *prev = NULL;
for (ManagementThreadPendingTask *i = SDL_AtomicGetPtr((void **) &ManagementThreadPendingTasks); i; i = i->next) {
for (ManagementThreadPendingTask *i = (ManagementThreadPendingTask *)SDL_AtomicGetPtr((void **)&ManagementThreadPendingTasks); i; i = i->next) {
prev = i;
}

View File

@ -79,7 +79,7 @@ char *SDL_GetCameraThreadName(SDL_CameraDevice *device, char *buf, size_t buflen
return buf;
}
int SDL_AddCameraFormat(CameraFormatAddData *data, Uint32 fmt, int w, int h, int interval_numerator, int interval_denominator)
int SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormatEnum fmt, int w, int h, int interval_numerator, int interval_denominator)
{
SDL_assert(data != NULL);
if (data->allocated_specs <= data->num_specs) {
@ -148,7 +148,7 @@ static int ZombieAcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, Uint
if (!device->zombie_pixels) {
// attempt to allocate and initialize a fake frame of pixels.
const size_t buflen = GetFrameBufLen(&device->actual_spec);
device->zombie_pixels = SDL_aligned_alloc(SDL_SIMDGetAlignment(), buflen);
device->zombie_pixels = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), buflen);
if (!device->zombie_pixels) {
*timestampNS = 0;
return 0; // oh well, say there isn't a frame yet, so we'll go back to waiting. Maybe allocation will succeed later...?
@ -434,7 +434,7 @@ SDL_CameraDevice *SDL_AddCameraDevice(const char *name, SDL_CameraPosition posit
return NULL;
}
device->all_specs = SDL_calloc(num_specs + 1, sizeof (*specs));
device->all_specs = (SDL_CameraSpec *)SDL_calloc(num_specs + 1, sizeof (*specs));
if (!device->all_specs) {
SDL_DestroyMutex(device->lock);
SDL_free(device->name);
@ -982,8 +982,8 @@ static void ChooseBestCameraSpec(SDL_CameraDevice *device, const SDL_CameraSpec
SDL_assert(closest->height > 0);
// okay, we have what we think is the best resolution, now we just need the best format that supports it...
const Uint32 wantfmt = spec->format;
Uint32 bestfmt = SDL_PIXELFORMAT_UNKNOWN;
const SDL_PixelFormatEnum wantfmt = spec->format;
SDL_PixelFormatEnum bestfmt = SDL_PIXELFORMAT_UNKNOWN;
for (int i = 0; i < num_specs; i++) {
const SDL_CameraSpec *thisspec = &device->all_specs[i];
if ((thisspec->width == closest->width) && (thisspec->height == closest->height)) {
@ -1106,7 +1106,7 @@ SDL_Camera *SDL_OpenCameraDevice(SDL_CameraDeviceID instance_id, const SDL_Camer
if (device->needs_scaling && device->needs_conversion) {
const SDL_bool downsampling_first = (device->needs_scaling < 0);
const SDL_CameraSpec *s = downsampling_first ? &device->spec : &closest;
const Uint32 fmt = downsampling_first ? closest.format : device->spec.format;
const SDL_PixelFormatEnum fmt = downsampling_first ? closest.format : device->spec.format;
device->conversion_surface = SDL_CreateSurface(s->width, s->height, fmt);
}

View File

@ -64,7 +64,7 @@ typedef struct CameraFormatAddData
int allocated_specs;
} CameraFormatAddData;
int SDL_AddCameraFormat(CameraFormatAddData *data, Uint32 fmt, int w, int h, int interval_numerator, int interval_denominator);
int SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormatEnum fmt, int w, int h, int interval_numerator, int interval_denominator);
typedef struct SurfaceList
{

View File

@ -73,7 +73,11 @@ SDL_DEFINE_MEDIATYPE_GUID(MFVideoFormat_NV21, FCC('NV21'));
#pragma GCC diagnostic pop
#endif
static const struct { const GUID *guid; const Uint32 sdlfmt; } fmtmappings[] = {
static const struct
{
const GUID *guid;
const SDL_PixelFormatEnum sdlfmt;
} fmtmappings[] = {
// This is not every possible format, just popular ones that SDL can reasonably handle.
// (and we should probably trim this list more.)
{ &SDL_MFVideoFormat_RGB555, SDL_PIXELFORMAT_XRGB1555 },
@ -91,7 +95,8 @@ static const struct { const GUID *guid; const Uint32 sdlfmt; } fmtmappings[] = {
{ &SDL_MFVideoFormat_NV21, SDL_PIXELFORMAT_NV21 }
};
static Uint32 MFVidFmtGuidToSDLFmt(const GUID *guid) {
static SDL_PixelFormatEnum MFVidFmtGuidToSDLFmt(const GUID *guid)
{
for (size_t i = 0; i < SDL_arraysize(fmtmappings); i++) {
if (WIN_IsEqualGUID(guid, fmtmappings[i].guid)) {
return fmtmappings[i].sdlfmt;
@ -734,7 +739,7 @@ static void GatherCameraSpecs(IMFMediaSource *source, CameraFormatAddData *add_d
if (SUCCEEDED(ret) && WIN_IsEqualGUID(&type, &SDL_MFMediaType_Video)) {
ret = IMFMediaType_GetGUID(mediatype, &SDL_MF_MT_SUBTYPE, &type);
if (SUCCEEDED(ret)) {
const Uint32 sdlfmt = MFVidFmtGuidToSDLFmt(&type);
const SDL_PixelFormatEnum sdlfmt = MFVidFmtGuidToSDLFmt(&type);
if (sdlfmt != SDL_PIXELFORMAT_UNKNOWN) {
UINT64 val = 0;
UINT32 w = 0, h = 0;
@ -858,18 +863,18 @@ static void MEDIAFOUNDATION_Deinitialize(void)
static SDL_bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl)
{
// !!! FIXME: slide this off into a subroutine
HANDLE mf = LoadLibrary(TEXT("Mf.dll")); // this library is available in Vista and later, but also can be on XP with service packs and Windows
HMODULE mf = LoadLibrary(TEXT("Mf.dll")); // this library is available in Vista and later, but also can be on XP with service packs and Windows
if (!mf) {
return SDL_FALSE;
}
HANDLE mfplat = LoadLibrary(TEXT("Mfplat.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now!
HMODULE mfplat = LoadLibrary(TEXT("Mfplat.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now!
if (!mfplat) {
FreeLibrary(mf);
return SDL_FALSE;
}
HANDLE mfreadwrite = LoadLibrary(TEXT("Mfreadwrite.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now!
HMODULE mfreadwrite = LoadLibrary(TEXT("Mfreadwrite.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now!
if (!mfreadwrite) {
FreeLibrary(mfplat);
FreeLibrary(mf);

View File

@ -594,7 +594,7 @@ static int V4L2_OpenDevice(SDL_CameraDevice *device, const SDL_CameraSpec *spec)
}
size_t size, pitch;
SDL_CalculateSize(device->spec.format, device->spec.width, device->spec.height, &size, &pitch, SDL_FALSE);
SDL_CalculateSurfaceSize(device->spec.format, device->spec.width, device->spec.height, &size, &pitch, SDL_FALSE);
int rc = 0;
switch (io) {

View File

@ -147,7 +147,7 @@ static SDL_AudioDevice *SDL_IMMDevice_Add(const SDL_bool iscapture, const char *
if (!device) {
// handle is freed by SDL_IMMDevice_FreeDeviceHandle!
SDL_IMMDevice_HandleData *handle = SDL_malloc(sizeof(SDL_IMMDevice_HandleData));
SDL_IMMDevice_HandleData *handle = (SDL_IMMDevice_HandleData *)SDL_malloc(sizeof(SDL_IMMDevice_HandleData));
if (!handle) {
return NULL;
}

View File

@ -1308,7 +1308,7 @@ int SDL_AddEventWatch(SDL_EventFilter filter, void *userdata)
{
SDL_EventWatcher *event_watchers;
event_watchers = SDL_realloc(SDL_event_watchers, (SDL_event_watchers_count + 1) * sizeof(*event_watchers));
event_watchers = (SDL_EventWatcher *)SDL_realloc(SDL_event_watchers, (SDL_event_watchers_count + 1) * sizeof(*event_watchers));
if (event_watchers) {
SDL_EventWatcher *watcher;

View File

@ -57,10 +57,10 @@ struct SDL_Keyboard
static SDL_Keyboard SDL_keyboard;
static const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES] = {
/* 0 */ 0,
/* 1 */ 0,
/* 2 */ 0,
/* 3 */ 0,
/* 0 */ SDLK_UNKNOWN,
/* 1 */ SDLK_UNKNOWN,
/* 2 */ SDLK_UNKNOWN,
/* 3 */ SDLK_UNKNOWN,
/* 4 */ 'a',
/* 5 */ 'b',
/* 6 */ 'c',
@ -157,7 +157,7 @@ static const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES] = {
/* 97 */ SDLK_KP_9,
/* 98 */ SDLK_KP_0,
/* 99 */ SDLK_KP_PERIOD,
/* 100 */ 0,
/* 100 */ SDLK_UNKNOWN,
/* 101 */ SDLK_APPLICATION,
/* 102 */ SDLK_POWER,
/* 103 */ SDLK_KP_EQUALS,
@ -187,29 +187,29 @@ static const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES] = {
/* 127 */ SDLK_MUTE,
/* 128 */ SDLK_VOLUMEUP,
/* 129 */ SDLK_VOLUMEDOWN,
/* 130 */ 0,
/* 131 */ 0,
/* 132 */ 0,
/* 130 */ SDLK_UNKNOWN,
/* 131 */ SDLK_UNKNOWN,
/* 132 */ SDLK_UNKNOWN,
/* 133 */ SDLK_KP_COMMA,
/* 134 */ SDLK_KP_EQUALSAS400,
/* 135 */ 0,
/* 136 */ 0,
/* 137 */ 0,
/* 138 */ 0,
/* 139 */ 0,
/* 140 */ 0,
/* 141 */ 0,
/* 142 */ 0,
/* 143 */ 0,
/* 144 */ 0,
/* 145 */ 0,
/* 146 */ 0,
/* 147 */ 0,
/* 148 */ 0,
/* 149 */ 0,
/* 150 */ 0,
/* 151 */ 0,
/* 152 */ 0,
/* 135 */ SDLK_UNKNOWN,
/* 136 */ SDLK_UNKNOWN,
/* 137 */ SDLK_UNKNOWN,
/* 138 */ SDLK_UNKNOWN,
/* 139 */ SDLK_UNKNOWN,
/* 140 */ SDLK_UNKNOWN,
/* 141 */ SDLK_UNKNOWN,
/* 142 */ SDLK_UNKNOWN,
/* 143 */ SDLK_UNKNOWN,
/* 144 */ SDLK_UNKNOWN,
/* 145 */ SDLK_UNKNOWN,
/* 146 */ SDLK_UNKNOWN,
/* 147 */ SDLK_UNKNOWN,
/* 148 */ SDLK_UNKNOWN,
/* 149 */ SDLK_UNKNOWN,
/* 150 */ SDLK_UNKNOWN,
/* 151 */ SDLK_UNKNOWN,
/* 152 */ SDLK_UNKNOWN,
/* 153 */ SDLK_ALTERASE,
/* 154 */ SDLK_SYSREQ,
/* 155 */ SDLK_CANCEL,
@ -222,17 +222,17 @@ static const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES] = {
/* 162 */ SDLK_CLEARAGAIN,
/* 163 */ SDLK_CRSEL,
/* 164 */ SDLK_EXSEL,
/* 165 */ 0,
/* 166 */ 0,
/* 167 */ 0,
/* 168 */ 0,
/* 169 */ 0,
/* 170 */ 0,
/* 171 */ 0,
/* 172 */ 0,
/* 173 */ 0,
/* 174 */ 0,
/* 175 */ 0,
/* 165 */ SDLK_UNKNOWN,
/* 166 */ SDLK_UNKNOWN,
/* 167 */ SDLK_UNKNOWN,
/* 168 */ SDLK_UNKNOWN,
/* 169 */ SDLK_UNKNOWN,
/* 170 */ SDLK_UNKNOWN,
/* 171 */ SDLK_UNKNOWN,
/* 172 */ SDLK_UNKNOWN,
/* 173 */ SDLK_UNKNOWN,
/* 174 */ SDLK_UNKNOWN,
/* 175 */ SDLK_UNKNOWN,
/* 176 */ SDLK_KP_00,
/* 177 */ SDLK_KP_000,
/* 178 */ SDLK_THOUSANDSSEPARATOR,
@ -279,8 +279,8 @@ static const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES] = {
/* 219 */ SDLK_KP_OCTAL,
/* 220 */ SDLK_KP_DECIMAL,
/* 221 */ SDLK_KP_HEXADECIMAL,
/* 222 */ 0,
/* 223 */ 0,
/* 222 */ SDLK_UNKNOWN,
/* 223 */ SDLK_UNKNOWN,
/* 224 */ SDLK_LCTRL,
/* 225 */ SDLK_LSHIFT,
/* 226 */ SDLK_LALT,
@ -289,31 +289,31 @@ static const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES] = {
/* 229 */ SDLK_RSHIFT,
/* 230 */ SDLK_RALT,
/* 231 */ SDLK_RGUI,
/* 232 */ 0,
/* 233 */ 0,
/* 234 */ 0,
/* 235 */ 0,
/* 236 */ 0,
/* 237 */ 0,
/* 238 */ 0,
/* 239 */ 0,
/* 240 */ 0,
/* 241 */ 0,
/* 242 */ 0,
/* 243 */ 0,
/* 244 */ 0,
/* 245 */ 0,
/* 246 */ 0,
/* 247 */ 0,
/* 248 */ 0,
/* 249 */ 0,
/* 250 */ 0,
/* 251 */ 0,
/* 252 */ 0,
/* 253 */ 0,
/* 254 */ 0,
/* 255 */ 0,
/* 256 */ 0,
/* 232 */ SDLK_UNKNOWN,
/* 233 */ SDLK_UNKNOWN,
/* 234 */ SDLK_UNKNOWN,
/* 235 */ SDLK_UNKNOWN,
/* 236 */ SDLK_UNKNOWN,
/* 237 */ SDLK_UNKNOWN,
/* 238 */ SDLK_UNKNOWN,
/* 239 */ SDLK_UNKNOWN,
/* 240 */ SDLK_UNKNOWN,
/* 241 */ SDLK_UNKNOWN,
/* 242 */ SDLK_UNKNOWN,
/* 243 */ SDLK_UNKNOWN,
/* 244 */ SDLK_UNKNOWN,
/* 245 */ SDLK_UNKNOWN,
/* 246 */ SDLK_UNKNOWN,
/* 247 */ SDLK_UNKNOWN,
/* 248 */ SDLK_UNKNOWN,
/* 249 */ SDLK_UNKNOWN,
/* 250 */ SDLK_UNKNOWN,
/* 251 */ SDLK_UNKNOWN,
/* 252 */ SDLK_UNKNOWN,
/* 253 */ SDLK_UNKNOWN,
/* 254 */ SDLK_UNKNOWN,
/* 255 */ SDLK_UNKNOWN,
/* 256 */ SDLK_UNKNOWN,
/* 257 */ SDLK_MODE,
/* 258 */ SDLK_AUDIONEXT,
/* 259 */ SDLK_AUDIOPREV,
@ -822,7 +822,7 @@ int SDL_SetKeyboardFocus(SDL_Window *window)
return 0;
}
static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, SDL_KeyboardFlags flags, Uint8 state, SDL_Scancode scancode, SDL_Keycode keycode)
static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, Uint8 state, SDL_Scancode scancode, SDL_Keycode keycode)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
int posted;

View File

@ -1306,7 +1306,7 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
if (mouse->CreateCursor) {
cursor = mouse->CreateCursor(surface, hot_x, hot_y);
} else {
cursor = SDL_calloc(1, sizeof(*cursor));
cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor));
}
if (cursor) {
cursor->next = mouse->cursors;

View File

@ -97,8 +97,8 @@ static int SDLCALL pen_compare(const void *lhs, const void *rhs)
static int SDLCALL pen_header_compare(const void *lhs, const void *rhs)
{
const struct SDL_Pen_header *l = lhs;
const struct SDL_Pen_header *r = rhs;
const SDL_PenHeader *l = (const SDL_PenHeader *)lhs;
const SDL_PenHeader *r = (const SDL_PenHeader *)rhs;
int l_detached = l->flags & SDL_PEN_FLAG_DETACHED;
int r_detached = r->flags & SDL_PEN_FLAG_DETACHED;
@ -121,15 +121,13 @@ SDL_Pen *SDL_GetPenPtr(Uint32 instance_id)
}
if (pen_handler.sorted) {
struct SDL_Pen_header key;
SDL_PenHeader key;
SDL_Pen *pen;
SDL_zero(key);
key.id = instance_id;
pen = SDL_bsearch(&key, pen_handler.pens,
pen_handler.pens_known, sizeof(SDL_Pen),
pen_header_compare);
pen = (SDL_Pen *)SDL_bsearch(&key, pen_handler.pens, pen_handler.pens_known, sizeof(SDL_Pen), pen_header_compare);
if (pen) {
return pen;
}
@ -149,7 +147,7 @@ SDL_PenID *SDL_GetPens(int *count)
{
int i;
int pens_nr = (int)pen_handler.pens_attached;
SDL_PenID *pens = SDL_calloc(pens_nr + 1, sizeof(SDL_PenID));
SDL_PenID *pens = (SDL_PenID *)SDL_calloc(pens_nr + 1, sizeof(SDL_PenID));
if (!pens) { /* OOM */
return pens;
}
@ -222,7 +220,7 @@ const char *SDL_GetPenName(SDL_PenID instance_id)
SDL_PenSubtype SDL_GetPenType(SDL_PenID instance_id)
{
SDL_PenSubtype result;
SDL_LOAD_LOCK_PEN(pen, instance_id, 0u);
SDL_LOAD_LOCK_PEN(pen, instance_id, SDL_PEN_TYPE_UNKNOWN);
result = pen->type;
SDL_UNLOCK_PENS();
return result;
@ -293,11 +291,11 @@ SDL_Pen *SDL_PenModifyBegin(Uint32 instance_id)
size_t pens_to_allocate = pen_handler.pens_allocated + alloc_growth_constant;
SDL_Pen *pens;
if (pen_handler.pens) {
pens = SDL_realloc(pen_handler.pens, sizeof(SDL_Pen) * pens_to_allocate);
pens = (SDL_Pen *)SDL_realloc(pen_handler.pens, sizeof(SDL_Pen) * pens_to_allocate);
SDL_memset(pens + pen_handler.pens_known, 0,
sizeof(SDL_Pen) * (pens_to_allocate - pen_handler.pens_allocated));
} else {
pens = SDL_calloc(sizeof(SDL_Pen), pens_to_allocate);
pens = (SDL_Pen *)SDL_calloc(sizeof(SDL_Pen), pens_to_allocate);
}
pen_handler.pens = pens;
pen_handler.pens_allocated = pens_to_allocate;
@ -305,13 +303,13 @@ SDL_Pen *SDL_PenModifyBegin(Uint32 instance_id)
pen = &pen_handler.pens[pen_handler.pens_known];
pen_handler.pens_known += 1;
/* Default pen initialisation */
/* Default pen initialization */
pen->header.id = id;
pen->header.flags = SDL_PEN_FLAG_NEW;
pen->info.num_buttons = SDL_PEN_INFO_UNKNOWN;
pen->info.max_tilt = SDL_PEN_INFO_UNKNOWN;
pen->type = SDL_PEN_TYPE_PEN;
pen->name = SDL_calloc(1, SDL_PEN_MAX_NAME); /* Never deallocated */
pen->name = (char *)SDL_calloc(1, SDL_PEN_MAX_NAME); /* Never deallocated */
}
return pen;
}
@ -798,7 +796,7 @@ int SDL_SendPenWindowEvent(Uint64 timestamp, SDL_PenID instance_id, SDL_Window *
static void SDLCALL SDL_PenUpdateHint(void *userdata, const char *name, const char *oldvalue, const char *newvalue)
{
int *var = userdata;
int *var = (int *)userdata;
if (newvalue == NULL) {
return;
}

View File

@ -56,6 +56,13 @@ typedef struct SDL_PenStatusInfo
Uint16 buttons; /* SDL_BUTTON(1) | SDL_BUTTON(2) | ... | SDL_PEN_DOWN_MASK */
} SDL_PenStatusInfo;
typedef struct
{
SDL_PenID id; /* id determines sort order unless SDL_PEN_FLAG_DETACHED is set */
Uint32 flags; /* SDL_PEN_FLAG_* | SDK_PEN_DOWN_MASK | SDL_PEN_INK_MASK | SDL_PEN_ERASER_MASK | SDL_PEN_AXIS_* */
SDL_Window *window; /* Current SDL window for this pen, or NULL */
} SDL_PenHeader;
/**
* Internal (backend driver-independent) pen representation
*
@ -66,12 +73,7 @@ typedef struct SDL_PenStatusInfo
typedef struct SDL_Pen
{
/* Backend driver MUST NOT not write to: */
struct SDL_Pen_header
{
SDL_PenID id; /* id determines sort order unless SDL_PEN_FLAG_DETACHED is set */
Uint32 flags; /* SDL_PEN_FLAG_* | SDK_PEN_DOWN_MASK | SDL_PEN_INK_MASK | SDL_PEN_ERASER_MASK | SDL_PEN_AXIS_* */
SDL_Window *window; /* Current SDL window for this pen, or NULL */
} header;
SDL_PenHeader header;
SDL_PenStatusInfo last; /* Last reported status, normally read-only for backend */

View File

@ -690,7 +690,7 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, SDL_bool freesrc)
if (size >= SDL_SIZE_MAX) {
newdata = NULL;
} else {
newdata = SDL_realloc(data, (size_t)(size + 1));
newdata = (char *)SDL_realloc(data, (size_t)(size + 1));
}
if (!newdata) {
SDL_free(data);

View File

@ -536,7 +536,7 @@ static int SDL_SYS_SetDirection(DIEFFECT *effect, const SDL_HapticDirection *dir
}
/* Has axes. */
rglDir = SDL_malloc(sizeof(LONG) * naxes);
rglDir = (LONG *)SDL_malloc(sizeof(LONG) * naxes);
if (!rglDir) {
return -1;
}
@ -610,7 +610,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
dest->dwFlags = DIEFF_OBJECTOFFSETS; /* Seems obligatory. */
/* Envelope. */
envelope = SDL_calloc(1, sizeof(DIENVELOPE));
envelope = (DIENVELOPE *)SDL_calloc(1, sizeof(DIENVELOPE));
if (!envelope) {
return -1;
}
@ -624,7 +624,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
dest->cAxes = haptic->naxes;
}
if (dest->cAxes > 0) {
axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
axes = (DWORD *)SDL_malloc(sizeof(DWORD) * dest->cAxes);
if (!axes) {
return -1;
}
@ -642,7 +642,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
switch (src->type) {
case SDL_HAPTIC_CONSTANT:
hap_constant = &src->constant;
constant = SDL_calloc(1, sizeof(DICONSTANTFORCE));
constant = (DICONSTANTFORCE *)SDL_calloc(1, sizeof(DICONSTANTFORCE));
if (!constant) {
return -1;
}
@ -682,7 +682,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
case SDL_HAPTIC_SAWTOOTHUP:
case SDL_HAPTIC_SAWTOOTHDOWN:
hap_periodic = &src->periodic;
periodic = SDL_calloc(1, sizeof(DIPERIODIC));
periodic = (DIPERIODIC *)SDL_calloc(1, sizeof(DIPERIODIC));
if (!periodic) {
return -1;
}
@ -725,7 +725,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
case SDL_HAPTIC_INERTIA:
case SDL_HAPTIC_FRICTION:
hap_condition = &src->condition;
condition = SDL_calloc(dest->cAxes, sizeof(DICONDITION));
condition = (DICONDITION *)SDL_calloc(dest->cAxes, sizeof(DICONDITION));
if (!condition) {
return -1;
}
@ -765,7 +765,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
case SDL_HAPTIC_RAMP:
hap_ramp = &src->ramp;
ramp = SDL_calloc(1, sizeof(DIRAMPFORCE));
ramp = (DIRAMPFORCE *)SDL_calloc(1, sizeof(DIRAMPFORCE));
if (!ramp) {
return -1;
}
@ -802,7 +802,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
case SDL_HAPTIC_CUSTOM:
hap_custom = &src->custom;
custom = SDL_calloc(1, sizeof(DICUSTOMFORCE));
custom = (DICUSTOMFORCE *)SDL_calloc(1, sizeof(DICUSTOMFORCE));
if (!custom) {
return -1;
}
@ -811,8 +811,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
custom->cChannels = hap_custom->channels;
custom->dwSamplePeriod = hap_custom->period * 1000UL;
custom->cSamples = hap_custom->samples;
custom->rglForceData =
SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
custom->rglForceData = (LPLONG)SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) { /* Copy data. */
custom->rglForceData[i] = CCONVERT(hap_custom->data[i]);
}

View File

@ -292,17 +292,18 @@ static void HandleJoystickHat(Uint64 timestamp, SDL_Gamepad *gamepad, int hat, U
duplicate events. */
static void RecenterGamepad(SDL_Gamepad *gamepad)
{
SDL_GamepadButton button;
SDL_GamepadAxis axis;
int i;
Uint64 timestamp = SDL_GetTicksNS();
for (button = (SDL_GamepadButton)0; button < SDL_GAMEPAD_BUTTON_MAX; button++) {
for (i = 0; i < SDL_GAMEPAD_BUTTON_MAX; ++i) {
SDL_GamepadButton button = (SDL_GamepadButton)i;
if (SDL_GetGamepadButton(gamepad, button)) {
SDL_SendGamepadButton(timestamp, gamepad, button, SDL_RELEASED);
}
}
for (axis = (SDL_GamepadAxis)0; axis < SDL_GAMEPAD_AXIS_MAX; axis++) {
for (i = 0; i < SDL_GAMEPAD_AXIS_MAX; ++i) {
SDL_GamepadAxis axis = (SDL_GamepadAxis)i;
if (SDL_GetGamepadAxis(gamepad, axis) != 0) {
SDL_SendGamepadAxis(timestamp, gamepad, axis, 0);
}
@ -1438,7 +1439,7 @@ static char *SDL_PrivateGetGamepadGUIDFromMappingString(const char *pMapping)
{
const char *pFirstComma = SDL_strchr(pMapping, ',');
if (pFirstComma) {
char *pchGUID = SDL_malloc(pFirstComma - pMapping + 1);
char *pchGUID = (char *)SDL_malloc(pFirstComma - pMapping + 1);
if (!pchGUID) {
return NULL;
}
@ -1486,7 +1487,7 @@ static char *SDL_PrivateGetGamepadNameFromMappingString(const char *pMapping)
return NULL;
}
pchName = SDL_malloc(pSecondComma - pFirstComma);
pchName = (char *)SDL_malloc(pSecondComma - pFirstComma);
if (!pchName) {
return NULL;
}
@ -1619,7 +1620,7 @@ static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, co
}
AddMappingChangeTracking(pGamepadMapping);
} else {
pGamepadMapping = SDL_malloc(sizeof(*pGamepadMapping));
pGamepadMapping = (GamepadMapping_t *)SDL_malloc(sizeof(*pGamepadMapping));
if (!pGamepadMapping) {
PopMappingChangeTracking();
SDL_free(pchName);
@ -2103,7 +2104,7 @@ static char *CreateMappingString(GamepadMapping_t *mapping, SDL_JoystickGUID gui
needed += SDL_GAMEPAD_PLATFORM_FIELD_SIZE + SDL_strlen(platform) + 1;
}
pMappingString = SDL_malloc(needed);
pMappingString = (char *)SDL_malloc(needed);
if (!pMappingString) {
return NULL;
}

View File

@ -204,7 +204,7 @@ static SDL_bool HIDAPI_DriverShield_OpenJoystick(SDL_HIDAPI_Device *device, SDL_
static int HIDAPI_DriverShield_SendNextRumble(SDL_HIDAPI_Device *device)
{
SDL_DriverShield_Context *ctx = device->context;
SDL_DriverShield_Context *ctx = (SDL_DriverShield_Context *)device->context;
Uint8 rumble_data[3];
if (!ctx->rumble_update_pending) {
@ -235,7 +235,7 @@ static int HIDAPI_DriverShield_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joy
return 0;
} else {
SDL_DriverShield_Context *ctx = device->context;
SDL_DriverShield_Context *ctx = (SDL_DriverShield_Context *)device->context;
/* The rumble motors are quite intense, so tone down the intensity like the official driver does */
ctx->left_motor_amplitude = low_frequency_rumble >> 11;
@ -268,7 +268,7 @@ static int HIDAPI_DriverShield_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joy
static int HIDAPI_DriverShield_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size)
{
const Uint8 *data_bytes = data;
const Uint8 *data_bytes = (const Uint8 *)data;
if (size > 1) {
/* Single command byte followed by a variable length payload */

View File

@ -128,6 +128,14 @@ typedef struct
Uint8 ucNExtensionBytes;
} WiiButtonData;
typedef struct
{
Uint16 min;
Uint16 max;
Uint16 center;
Uint16 deadzone;
} StickCalibrationData;
typedef struct
{
SDL_HIDAPI_Device *device;
@ -147,13 +155,7 @@ typedef struct
Uint64 m_ulNextMotionPlusCheck;
SDL_bool m_bDisconnected;
struct StickCalibrationData
{
Uint16 min;
Uint16 max;
Uint16 center;
Uint16 deadzone;
} m_StickCalibrationData[6];
StickCalibrationData m_StickCalibrationData[6];
} SDL_DriverWii_Context;
static void HIDAPI_DriverWii_RegisterHints(SDL_HintCallback callback, void *userdata)
@ -857,7 +859,7 @@ static int HIDAPI_DriverWii_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device,
return 0;
}
static void PostStickCalibrated(Uint64 timestamp, SDL_Joystick *joystick, struct StickCalibrationData *calibration, Uint8 axis, Uint16 data)
static void PostStickCalibrated(Uint64 timestamp, SDL_Joystick *joystick, StickCalibrationData *calibration, Uint8 axis, Uint16 data)
{
Sint16 value = 0;
if (!calibration->center) {
@ -1366,7 +1368,7 @@ static void HandleStatus(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick)
static void HandleResponse(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick)
{
EWiiInputReportIDs type = ctx->m_rgucReadBuffer[0];
EWiiInputReportIDs type = (EWiiInputReportIDs)ctx->m_rgucReadBuffer[0];
WiiButtonData data;
SDL_assert(type == k_eWiiInputReportIDs_Acknowledge || type == k_eWiiInputReportIDs_ReadMemory);
SDL_zero(data);
@ -1473,7 +1475,7 @@ static void HandleButtonPacket(SDL_DriverWii_Context *ctx, SDL_Joystick *joystic
static void HandleInput(SDL_DriverWii_Context *ctx, SDL_Joystick *joystick)
{
EWiiInputReportIDs type = ctx->m_rgucReadBuffer[0];
EWiiInputReportIDs type = (EWiiInputReportIDs)ctx->m_rgucReadBuffer[0];
/* Set up for handling input */
ctx->timestamp = SDL_GetTicksNS();

View File

@ -122,7 +122,7 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des
return SDL_SetError("Unsupported virtual joystick description version %u", desc->version);
}
hwdata = SDL_calloc(1, sizeof(joystick_hwdata));
hwdata = (joystick_hwdata *)SDL_calloc(1, sizeof(joystick_hwdata));
if (!hwdata) {
VIRTUAL_FreeHWData(hwdata);
return 0;
@ -207,7 +207,7 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des
/* Allocate fields for different control-types */
if (hwdata->desc.naxes > 0) {
hwdata->axes = SDL_calloc(hwdata->desc.naxes, sizeof(Sint16));
hwdata->axes = (Sint16 *)SDL_calloc(hwdata->desc.naxes, sizeof(Sint16));
if (!hwdata->axes) {
VIRTUAL_FreeHWData(hwdata);
return 0;
@ -222,14 +222,14 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des
}
}
if (hwdata->desc.nbuttons > 0) {
hwdata->buttons = SDL_calloc(hwdata->desc.nbuttons, sizeof(Uint8));
hwdata->buttons = (Uint8 *)SDL_calloc(hwdata->desc.nbuttons, sizeof(Uint8));
if (!hwdata->buttons) {
VIRTUAL_FreeHWData(hwdata);
return 0;
}
}
if (hwdata->desc.nhats > 0) {
hwdata->hats = SDL_calloc(hwdata->desc.nhats, sizeof(Uint8));
hwdata->hats = (Uint8 *)SDL_calloc(hwdata->desc.nhats, sizeof(Uint8));
if (!hwdata->hats) {
VIRTUAL_FreeHWData(hwdata);
return 0;

View File

@ -368,7 +368,7 @@ static SDL_RenderCommand *AllocateRenderCommand(SDL_Renderer *renderer)
renderer->render_commands_pool = retval->next;
retval->next = NULL;
} else {
retval = SDL_calloc(1, sizeof(*retval));
retval = (SDL_RenderCommand *)SDL_calloc(1, sizeof(*retval));
if (!retval) {
return NULL;
}
@ -897,8 +897,8 @@ static void SDL_CalculateSimulatedVSyncInterval(SDL_Renderer *renderer, SDL_Wind
SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props)
{
#ifndef SDL_RENDER_DISABLED
SDL_Window *window = SDL_GetProperty(props, SDL_PROP_RENDERER_CREATE_WINDOW_POINTER, NULL);
SDL_Surface *surface = SDL_GetProperty(props, SDL_PROP_RENDERER_CREATE_SURFACE_POINTER, NULL);
SDL_Window *window = (SDL_Window *)SDL_GetProperty(props, SDL_PROP_RENDERER_CREATE_WINDOW_POINTER, NULL);
SDL_Surface *surface = (SDL_Surface *)SDL_GetProperty(props, SDL_PROP_RENDERER_CREATE_SURFACE_POINTER, NULL);
const char *name = SDL_GetStringProperty(props, SDL_PROP_RENDERER_CREATE_NAME_STRING, NULL);
SDL_Renderer *renderer = NULL;
const int n = SDL_GetNumRenderDrivers();
@ -1238,7 +1238,7 @@ static Uint32 GetClosestSupportedFormat(SDL_Renderer *renderer, Uint32 format)
SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props)
{
SDL_Texture *texture;
Uint32 format = (Uint32)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER, SDL_PIXELFORMAT_UNKNOWN);
SDL_PixelFormatEnum format = (SDL_PixelFormatEnum)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER, SDL_PIXELFORMAT_UNKNOWN);
int access = (int)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER, SDL_TEXTUREACCESS_STATIC);
int w = (int)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER, 0);
int h = (int)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER, 0);
@ -1399,7 +1399,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
SDL_bool needAlpha;
SDL_bool direct_update;
int i;
Uint32 format = SDL_PIXELFORMAT_UNKNOWN;
SDL_PixelFormatEnum format = SDL_PIXELFORMAT_UNKNOWN;
SDL_Texture *texture;
SDL_PropertiesID surface_props, props;
SDL_Colorspace surface_colorspace = SDL_COLORSPACE_UNKNOWN;
@ -2359,7 +2359,7 @@ SDL_Texture *SDL_GetRenderTarget(SDL_Renderer *renderer)
if (renderer->target == renderer->logical_target) {
return NULL;
} else {
return SDL_GetProperty(SDL_GetTextureProperties(renderer->target), SDL_PROP_TEXTURE_PARENT_POINTER, renderer->target);
return (SDL_Texture *)SDL_GetProperty(SDL_GetTextureProperties(renderer->target), SDL_PROP_TEXTURE_PARENT_POINTER, renderer->target);
}
}
@ -4084,7 +4084,7 @@ static int SDLCALL SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer,
s.h *= -1;
s.y -= s.h;
}
SDL_RenderTextureRotated(renderer, texture, &s, &d, 0, NULL, flags);
SDL_RenderTextureRotated(renderer, texture, &s, &d, 0, NULL, (SDL_FlipMode)flags);
}
#if DEBUG_SW_RENDER_GEOMETRY

View File

@ -66,7 +66,7 @@ struct SDL_Texture
SDL_Colorspace colorspace; /**< The colorspace of the texture */
float SDR_white_point; /**< The SDR white point for this content */
float HDR_headroom; /**< The HDR headroom needed by this content */
Uint32 format; /**< The pixel format of the texture */
SDL_PixelFormatEnum format; /**< The pixel format of the texture */
int access; /**< SDL_TextureAccess */
int w; /**< The width of the texture */
int h; /**< The height of the texture */

View File

@ -27,7 +27,7 @@
#include "SDL_yuv_sw_c.h"
#include "../video/SDL_yuv_c.h"
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormatEnum format, int w, int h)
{
SDL_SW_YUVTexture *swdata;
@ -212,6 +212,8 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
}
}
}
default:
return SDL_SetError("Unsupported YUV format");
}
return 0;
}
@ -316,6 +318,8 @@ int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
return SDL_SetError("YV12, IYUV, NV12, NV21 textures only support full surface locks");
}
break;
default:
return SDL_SetError("Unsupported YUV format");
}
if (rect) {
@ -332,7 +336,7 @@ void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture *swdata)
}
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
Uint32 target_format, int w, int h, void *pixels,
SDL_PixelFormatEnum target_format, int w, int h, void *pixels,
int pitch)
{
int stretch;

View File

@ -28,8 +28,8 @@
struct SDL_SW_YUVTexture
{
Uint32 format;
Uint32 target_format;
SDL_PixelFormatEnum format;
SDL_PixelFormatEnum target_format;
int w, h;
Uint8 *pixels;
@ -44,7 +44,7 @@ struct SDL_SW_YUVTexture
typedef struct SDL_SW_YUVTexture SDL_SW_YUVTexture;
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h);
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormatEnum format, int w, int h);
int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture *swdata, void **pixels,
int *pitch);
int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
@ -60,7 +60,7 @@ int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
void **pixels, int *pitch);
void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture *swdata);
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
Uint32 target_format, int w, int h, void *pixels,
SDL_PixelFormatEnum target_format, int w, int h, void *pixels,
int pitch);
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata);

View File

@ -209,7 +209,7 @@ static D3DFORMAT PixelFormatToD3DFMT(Uint32 format)
}
}
static Uint32 D3DFMTToPixelFormat(D3DFORMAT format)
static SDL_PixelFormatEnum D3DFMTToPixelFormat(D3DFORMAT format)
{
switch (format) {
case D3DFMT_R5G6B5:
@ -1552,7 +1552,7 @@ static int D3D_Reset(SDL_Renderer *renderer)
static int D3D_SetVSync(SDL_Renderer *renderer, const int vsync)
{
D3D_RenderData *data = renderer->driverdata;
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
if (vsync) {
data->pparams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;

View File

@ -242,7 +242,7 @@ static const GUID SDL_DXGI_DEBUG_ALL = { 0xe48ae283, 0xda80, 0x490b, { 0x87, 0xe
#pragma GCC diagnostic pop
#endif
Uint32 D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat)
SDL_PixelFormatEnum D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat)
{
switch (dxgiFormat) {
case DXGI_FORMAT_B8G8R8A8_UNORM:

View File

@ -303,12 +303,12 @@ static const GUID SDL_IID_ID3D12InfoQueue = { 0x0742a90b, 0xc387, 0x483f, { 0xb9
#pragma GCC diagnostic pop
#endif
UINT D3D12_Align(UINT location, UINT alignment)
static UINT D3D12_Align(UINT location, UINT alignment)
{
return (location + (alignment - 1)) & ~(alignment - 1);
}
Uint32 D3D12_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat)
static SDL_PixelFormatEnum D3D12_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat)
{
switch (dxgiFormat) {
case DXGI_FORMAT_B8G8R8A8_UNORM:

View File

@ -281,7 +281,7 @@ static void APIENTRY GL_HandleDebugMessage(GLenum source, GLenum type, GLuint id
if (type == GL_DEBUG_TYPE_ERROR_ARB) {
/* Record this error */
int errors = data->errors + 1;
char **error_messages = SDL_realloc(data->error_messages, errors * sizeof(*data->error_messages));
char **error_messages = (char **)SDL_realloc(data->error_messages, errors * sizeof(*data->error_messages));
if (error_messages) {
data->errors = errors;
data->error_messages = error_messages;
@ -310,7 +310,7 @@ static GL_FBOList *GL_GetFBO(GL_RenderData *data, Uint32 w, Uint32 h)
}
if (!result) {
result = SDL_malloc(sizeof(GL_FBOList));
result = (GL_FBOList *)SDL_malloc(sizeof(GL_FBOList));
if (result) {
result->w = w;
result->h = h;
@ -1451,7 +1451,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
static SDL_Surface *GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect)
{
GL_RenderData *data = (GL_RenderData *)renderer->driverdata;
Uint32 format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ARGB8888;
SDL_PixelFormatEnum format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ARGB8888;
GLint internalFormat;
GLenum targetFormat, type;
int w, h;

View File

@ -165,7 +165,7 @@ typedef struct
typedef struct GLES2_RenderData
{
SDL_GLContext *context;
SDL_GLContext context;
SDL_bool debug_enabled;
@ -289,7 +289,7 @@ static GLES2_FBOList *GLES2_GetFBO(GLES2_RenderData *data, Uint32 w, Uint32 h)
result = result->next;
}
if (!result) {
result = SDL_malloc(sizeof(GLES2_FBOList));
result = (GLES2_FBOList *)SDL_malloc(sizeof(GLES2_FBOList));
result->w = w;
result->h = h;
data->glGenFramebuffers(1, &result->FBO);
@ -1051,6 +1051,8 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo
case SDL_PIXELFORMAT_BGRX32:
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
break;
default:
break;
}
break;
case SDL_PIXELFORMAT_RGBA32:
@ -1062,6 +1064,8 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo
case SDL_PIXELFORMAT_RGBX32:
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
break;
default:
break;
}
break;
case SDL_PIXELFORMAT_BGRX32:
@ -1075,6 +1079,8 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo
case SDL_PIXELFORMAT_RGBX32:
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
break;
default:
break;
}
break;
case SDL_PIXELFORMAT_RGBX32:
@ -1088,6 +1094,8 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo
case SDL_PIXELFORMAT_BGRX32:
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
break;
default:
break;
}
break;
#if SDL_HAVE_YUV
@ -1628,7 +1636,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
SDL_SetNumberProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER, data->texture_type);
if (texture->access == SDL_TEXTUREACCESS_TARGET) {
data->fbo = GLES2_GetFBO(renderer->driverdata, texture->w, texture->h);
data->fbo = GLES2_GetFBO((GLES2_RenderData *)renderer->driverdata, texture->w, texture->h);
} else {
data->fbo = NULL;
}
@ -1959,7 +1967,7 @@ static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
static SDL_Surface *GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect)
{
GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata;
Uint32 format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_RGBA32;
SDL_PixelFormatEnum format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_RGBA32;
int w, h;
SDL_Surface *surface;

View File

@ -112,20 +112,17 @@ static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
g = (Uint8)SDL_roundf(SDL_clamp(texture->color.g, 0.0f, 1.0f) * 255.0f);
b = (Uint8)SDL_roundf(SDL_clamp(texture->color.b, 0.0f, 1.0f) * 255.0f);
a = (Uint8)SDL_roundf(SDL_clamp(texture->color.a, 0.0f, 1.0f) * 255.0f);
SDL_SetSurfaceColorMod(texture->driverdata, r, g, b);
SDL_SetSurfaceAlphaMod(texture->driverdata, a);
SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode);
SDL_SetSurfaceColorMod(surface, r, g, b);
SDL_SetSurfaceAlphaMod(surface, a);
SDL_SetSurfaceBlendMode(surface, texture->blendMode);
/* Only RLE encode textures without an alpha channel since the RLE coder
* discards the color values of pixels with an alpha value of zero.
*/
if (texture->access == SDL_TEXTUREACCESS_STATIC && !surface->format->Amask) {
SDL_SetSurfaceRLE(texture->driverdata, 1);
SDL_SetSurfaceRLE(surface, 1);
}
if (!texture->driverdata) {
return -1;
}
return 0;
}
@ -1024,7 +1021,7 @@ static void SW_DestroyRenderer(SDL_Renderer *renderer)
SDL_free(renderer);
}
static void SW_SelectBestFormats(SDL_Renderer *renderer, Uint32 format)
static void SW_SelectBestFormats(SDL_Renderer *renderer, SDL_PixelFormatEnum format)
{
/* Prefer the format used by the framebuffer by default. */
renderer->info.texture_formats[renderer->info.num_texture_formats++] = format;
@ -1080,6 +1077,8 @@ static void SW_SelectBestFormats(SDL_Renderer *renderer, Uint32 format)
case SDL_PIXELFORMAT_BGRA8888:
renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_BGRX8888;
break;
default:
break;
}
/* Ensure that we always have a SDL_PACKEDLAYOUT_8888 format. Having a matching component order increases the

View File

@ -278,7 +278,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
}
if (blend != SDL_BLENDMODE_NONE) {
int format = dst->format->format;
SDL_PixelFormatEnum format = dst->format->format;
/* need an alpha format */
if (!dst->format->Amask) {
@ -300,7 +300,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
SDL_SetSurfaceBlendMode(tmp, blend);
dstbpp = tmp->format->bytes_per_pixel;
dst_ptr = tmp->pixels;
dst_ptr = (Uint8 *)tmp->pixels;
dst_pitch = tmp->pitch;
} else {
@ -465,7 +465,7 @@ int SDL_SW_BlitTriangle(
Uint8 *dst_ptr;
int dst_pitch;
int *src_ptr;
const int *src_ptr;
int src_pitch;
Sint64 area, tmp64;
@ -583,7 +583,7 @@ int SDL_SW_BlitTriangle(
dst_pitch = dst->pitch;
/* Set source pointer */
src_ptr = src->pixels;
src_ptr = (const int *)src->pixels;
src_pitch = src->pitch;
is_clockwise = area > 0;

View File

@ -365,7 +365,7 @@ typedef struct
SDL_bool issueBatch;
} VULKAN_RenderData;
Uint32 VULKAN_VkFormatToSDLPixelFormat(VkFormat vkFormat)
static SDL_PixelFormatEnum VULKAN_VkFormatToSDLPixelFormat(VkFormat vkFormat)
{
switch (vkFormat) {
case VK_FORMAT_B8G8R8A8_UNORM:
@ -379,7 +379,7 @@ Uint32 VULKAN_VkFormatToSDLPixelFormat(VkFormat vkFormat)
}
}
Uint32 VULKAN_VkFormatGetNumPlanes(VkFormat vkFormat)
static int VULKAN_VkFormatGetNumPlanes(VkFormat vkFormat)
{
switch (vkFormat) {
case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM:
@ -392,7 +392,7 @@ Uint32 VULKAN_VkFormatGetNumPlanes(VkFormat vkFormat)
}
}
VkDeviceSize VULKAN_GetBytesPerPixel(VkFormat vkFormat)
static VkDeviceSize VULKAN_GetBytesPerPixel(VkFormat vkFormat)
{
switch (vkFormat) {
case VK_FORMAT_R8_UNORM:
@ -1482,7 +1482,7 @@ static VkResult VULKAN_FindPhysicalDevice(VULKAN_RenderData *rendererData)
if (deviceExtensionsAllocatedSize < deviceExtensionCount) {
SDL_free(deviceExtensions);
deviceExtensionsAllocatedSize = deviceExtensionCount;
deviceExtensions = SDL_malloc(sizeof(VkExtensionProperties) * deviceExtensionsAllocatedSize);
deviceExtensions = (VkExtensionProperties *)SDL_malloc(sizeof(VkExtensionProperties) * deviceExtensionsAllocatedSize);
if (!deviceExtensions) {
SDL_free(physicalDevices);
SDL_free(queueFamiliesProperties);
@ -1573,7 +1573,7 @@ static SDL_bool VULKAN_DeviceExtensionsFound(VULKAN_RenderData *rendererData, in
return SDL_FALSE;
}
if (extensionCount > 0 ) {
VkExtensionProperties *extensionProperties = SDL_calloc(sizeof(VkExtensionProperties), extensionCount);
VkExtensionProperties *extensionProperties = (VkExtensionProperties *)SDL_calloc(sizeof(VkExtensionProperties), extensionCount);
result = vkEnumerateDeviceExtensionProperties(rendererData->physicalDevice, NULL, &extensionCount, extensionProperties);
if (result != VK_SUCCESS ) {
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkEnumerateDeviceExtensionProperties): %s.\n", SDL_Vulkan_GetResultString(result));
@ -1606,7 +1606,7 @@ static SDL_bool VULKAN_InstanceExtensionFound(VULKAN_RenderData *rendererData, c
return SDL_FALSE;
}
if (extensionCount > 0 ) {
VkExtensionProperties *extensionProperties = SDL_calloc(extensionCount, sizeof(VkExtensionProperties));
VkExtensionProperties *extensionProperties = (VkExtensionProperties *)SDL_calloc(extensionCount, sizeof(VkExtensionProperties));
result = vkEnumerateInstanceExtensionProperties(NULL, &extensionCount, extensionProperties);
if (result != VK_SUCCESS ) {
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkEnumerateInstanceExtensionProperties( NULL, ... ): %s.\n", SDL_Vulkan_GetResultString(result));
@ -1633,7 +1633,7 @@ static SDL_bool VULKAN_ValidationLayersFound()
vkEnumerateInstanceLayerProperties(&instanceLayerCount, NULL);
if (instanceLayerCount > 0) {
VkLayerProperties *instanceLayers = SDL_calloc(instanceLayerCount, sizeof(VkLayerProperties));
VkLayerProperties *instanceLayers = (VkLayerProperties *)SDL_calloc(instanceLayerCount, sizeof(VkLayerProperties));
vkEnumerateInstanceLayerProperties(&instanceLayerCount, instanceLayers);
for (i = 0; i < instanceLayerCount; i++) {
if (!SDL_strcmp(SDL_VULKAN_VALIDATION_LAYER_NAME, instanceLayers[i].layerName)) {
@ -1690,7 +1690,8 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
renderer->output_colorspace == SDL_COLORSPACE_HDR10) {
rendererData->supportsEXTSwapchainColorspace = VULKAN_InstanceExtensionFound(rendererData, VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME);
if (!rendererData->supportsEXTSwapchainColorspace) {
return SDL_SetError("[Vulkan] Using HDR output but %s not supported", VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME);
SDL_SetError("[Vulkan] Using HDR output but %s not supported", VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME);
return VK_ERROR_UNKNOWN;
}
}
@ -1710,7 +1711,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
instanceCreateInfo.pApplicationInfo = &appInfo;
char const *const *instanceExtensions = SDL_Vulkan_GetInstanceExtensions(&instanceCreateInfo.enabledExtensionCount);
const char **instanceExtensionsCopy = SDL_calloc(instanceCreateInfo.enabledExtensionCount + 2, sizeof(const char *));
const char **instanceExtensionsCopy = (const char **)SDL_calloc(instanceCreateInfo.enabledExtensionCount + 2, sizeof(const char *));
for (uint32_t i = 0; i < instanceCreateInfo.enabledExtensionCount; i++) {
instanceExtensionsCopy[i] = instanceExtensions[i];
}
@ -1855,16 +1856,17 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
/* Create shaders / layouts */
for (uint32_t i = 0; i < NUM_SHADERS; i++) {
VULKAN_Shader shader = (VULKAN_Shader)i;
VkShaderModuleCreateInfo shaderModuleCreateInfo = { 0 };
shaderModuleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
VULKAN_GetVertexShader(i, &shaderModuleCreateInfo.pCode, &shaderModuleCreateInfo.codeSize);
VULKAN_GetVertexShader(shader, &shaderModuleCreateInfo.pCode, &shaderModuleCreateInfo.codeSize);
result = vkCreateShaderModule(rendererData->device, &shaderModuleCreateInfo, NULL, &rendererData->vertexShaderModules[i]);
if (result != VK_SUCCESS) {
VULKAN_DestroyAll(renderer);
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkCreateShaderModule(): %s\n", SDL_Vulkan_GetResultString(result));
return result;
}
VULKAN_GetPixelShader(i, &shaderModuleCreateInfo.pCode, &shaderModuleCreateInfo.codeSize);
VULKAN_GetPixelShader(shader, &shaderModuleCreateInfo.pCode, &shaderModuleCreateInfo.codeSize);
result = vkCreateShaderModule(rendererData->device, &shaderModuleCreateInfo, NULL, &rendererData->fragmentShaderModules[i]);
if (result != VK_SUCCESS) {
VULKAN_DestroyAll(renderer);
@ -1944,7 +1946,7 @@ static VkResult VULKAN_CreateFramebuffersAndRenderPasses(SDL_Renderer *renderer,
attachmentDescription.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
attachmentDescription.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
attachmentDescription.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
attachmentDescription.samples = 1;
attachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT;
attachmentDescription.flags = 0;
VkAttachmentReference colorAttachmentReference = { 0 };
@ -2084,7 +2086,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
return result;
}
if (presentModeCount > 0) {
VkPresentModeKHR *presentModes = SDL_calloc(presentModeCount, sizeof(VkPresentModeKHR));
VkPresentModeKHR *presentModes = (VkPresentModeKHR *)SDL_calloc(presentModeCount, sizeof(VkPresentModeKHR));
result = vkGetPhysicalDeviceSurfacePresentModesKHR(rendererData->physicalDevice, rendererData->surface, &presentModeCount, presentModes);
if (result != VK_SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkGetPhysicalDeviceSurfacePresentModesKHR(): %s\n", SDL_Vulkan_GetResultString(result));
@ -2150,7 +2152,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
return result;
}
rendererData->swapchainImages = SDL_malloc(sizeof(VkImage) * rendererData->swapchainImageCount);
rendererData->swapchainImages = (VkImage *)SDL_malloc(sizeof(VkImage) * rendererData->swapchainImageCount);
result = vkGetSwapchainImagesKHR(rendererData->device,
rendererData->swapchain,
&rendererData->swapchainImageCount,
@ -2185,9 +2187,9 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
}
SDL_free(rendererData->swapchainImageViews);
}
rendererData->swapchainImageViews = SDL_calloc(rendererData->swapchainImageCount, sizeof(VkImageView));
rendererData->swapchainImageViews = (VkImageView *)SDL_calloc(rendererData->swapchainImageCount, sizeof(VkImageView));
SDL_free(rendererData->swapchainImageLayouts);
rendererData->swapchainImageLayouts = SDL_calloc(rendererData->swapchainImageCount, sizeof(VkImageLayout));
rendererData->swapchainImageLayouts = (VkImageLayout *)SDL_calloc(rendererData->swapchainImageCount, sizeof(VkImageLayout));
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
imageViewCreateInfo.image = rendererData->swapchainImages[i];
result = vkCreateImageView(rendererData->device, &imageViewCreateInfo, NULL, &rendererData->swapchainImageViews[i]);
@ -2212,7 +2214,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
rendererData->currentCommandBuffer = VK_NULL_HANDLE;
rendererData->currentCommandBufferIndex = 0;
}
rendererData->commandBuffers = SDL_calloc(rendererData->swapchainImageCount, sizeof(VkCommandBuffer));
rendererData->commandBuffers = (VkCommandBuffer *)SDL_calloc(rendererData->swapchainImageCount, sizeof(VkCommandBuffer));
result = vkAllocateCommandBuffers(rendererData->device, &commandBufferAllocateInfo, rendererData->commandBuffers);
if (result != VK_SUCCESS) {
VULKAN_DestroyAll(renderer);
@ -2229,7 +2231,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
}
SDL_free(rendererData->fences);
}
rendererData->fences = SDL_calloc(rendererData->swapchainImageCount, sizeof(VkFence));
rendererData->fences = (VkFence *)SDL_calloc(rendererData->swapchainImageCount, sizeof(VkFence));
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
VkFenceCreateInfo fenceCreateInfo = { 0 };
fenceCreateInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
@ -2257,7 +2259,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
rendererData->renderPasses[i] = VK_NULL_HANDLE;
}
}
rendererData->framebuffers = SDL_calloc(rendererData->swapchainImageCount, sizeof(VkFramebuffer));
rendererData->framebuffers = (VkFramebuffer *)SDL_calloc(rendererData->swapchainImageCount, sizeof(VkFramebuffer));
result = VULKAN_CreateFramebuffersAndRenderPasses(renderer,
rendererData->swapchainSize.width,
rendererData->swapchainSize.height,
@ -2286,12 +2288,12 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
SDL_free(rendererData->descriptorPools);
SDL_free(rendererData->numDescriptorPools);
}
rendererData->descriptorPools = SDL_calloc(rendererData->swapchainImageCount, sizeof(VkDescriptorPool*));
rendererData->numDescriptorPools = SDL_calloc(rendererData->swapchainImageCount, sizeof(uint32_t));
rendererData->descriptorPools = (VkDescriptorPool **)SDL_calloc(rendererData->swapchainImageCount, sizeof(VkDescriptorPool*));
rendererData->numDescriptorPools = (uint32_t *)SDL_calloc(rendererData->swapchainImageCount, sizeof(uint32_t));
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
/* Start by just allocating one pool, it will grow if needed */
rendererData->numDescriptorPools[i] = 1;
rendererData->descriptorPools[i] = SDL_calloc(1, sizeof(VkDescriptorPool));
rendererData->descriptorPools[i] = (VkDescriptorPool *)SDL_calloc(1, sizeof(VkDescriptorPool));
rendererData->descriptorPools[i][0] = VULKAN_AllocateDescriptorPool(rendererData);
if (result != VK_SUCCESS) {
VULKAN_DestroyAll(renderer);
@ -2316,8 +2318,8 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
}
SDL_free(rendererData->renderingFinishedSemaphores);
}
rendererData->imageAvailableSemaphores = SDL_calloc(sizeof(VkSemaphore), rendererData->swapchainImageCount);
rendererData->renderingFinishedSemaphores = SDL_calloc(sizeof(VkSemaphore), rendererData->swapchainImageCount);
rendererData->imageAvailableSemaphores = (VkSemaphore *)SDL_calloc(sizeof(VkSemaphore), rendererData->swapchainImageCount);
rendererData->renderingFinishedSemaphores = (VkSemaphore *)SDL_calloc(sizeof(VkSemaphore), rendererData->swapchainImageCount);
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
rendererData->imageAvailableSemaphores[i] = VULKAN_CreateSemaphore(rendererData);
if (rendererData->imageAvailableSemaphores[i] == VK_NULL_HANDLE) {
@ -2341,12 +2343,12 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
}
SDL_free(rendererData->uploadBuffers);
}
rendererData->uploadBuffers = SDL_calloc(rendererData->swapchainImageCount, sizeof(VULKAN_Buffer*));
rendererData->uploadBuffers = (VULKAN_Buffer **)SDL_calloc(rendererData->swapchainImageCount, sizeof(VULKAN_Buffer*));
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
rendererData->uploadBuffers[i] = SDL_calloc(SDL_VULKAN_NUM_UPLOAD_BUFFERS, sizeof(VULKAN_Buffer));
rendererData->uploadBuffers[i] = (VULKAN_Buffer *)SDL_calloc(SDL_VULKAN_NUM_UPLOAD_BUFFERS, sizeof(VULKAN_Buffer));
}
SDL_free(rendererData->currentUploadBuffer);
rendererData->currentUploadBuffer = SDL_calloc(rendererData->swapchainImageCount, sizeof(int));
rendererData->currentUploadBuffer = (int *)SDL_calloc(rendererData->swapchainImageCount, sizeof(int));
/* Constant buffers */
if (rendererData->constantBuffers) {
@ -2361,12 +2363,12 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
SDL_free(rendererData->numConstantBuffers);
rendererData->constantBuffers = NULL;
}
rendererData->constantBuffers = SDL_calloc(rendererData->swapchainImageCount, sizeof(VULKAN_Buffer*));
rendererData->numConstantBuffers = SDL_calloc(rendererData->swapchainImageCount, sizeof(VULKAN_Buffer*));
rendererData->constantBuffers = (VULKAN_Buffer **)SDL_calloc(rendererData->swapchainImageCount, sizeof(VULKAN_Buffer*));
rendererData->numConstantBuffers = (uint32_t *)SDL_calloc(rendererData->swapchainImageCount, sizeof(uint32_t));
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
/* Start with just allocating one, will grow if needed */
rendererData->numConstantBuffers[i] = 1;
rendererData->constantBuffers[i] = SDL_calloc(1, sizeof(VULKAN_Buffer));
rendererData->constantBuffers[i] = (VULKAN_Buffer *)SDL_calloc(1, sizeof(VULKAN_Buffer));
result = VULKAN_AllocateBuffer(rendererData,
SDL_VULKAN_CONSTANT_BUFFER_DEFAULT_SIZE,
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
@ -2697,7 +2699,7 @@ static VkResult VULKAN_UpdateTextureInternal(VULKAN_RenderData *rendererData, Vk
const Uint8 *src;
Uint8 *dst;
VkResult result;
Uint32 planeCount = VULKAN_VkFormatGetNumPlanes(format);
int planeCount = VULKAN_VkFormatGetNumPlanes(format);
VULKAN_EnsureCommandBuffer(rendererData);
@ -2715,7 +2717,7 @@ static VkResult VULKAN_UpdateTextureInternal(VULKAN_RenderData *rendererData, Vk
}
src = (const Uint8 *)pixels;
dst = uploadBuffer->mappedBufferPtr;
dst = (Uint8 *)uploadBuffer->mappedBufferPtr;
if (length == (VkDeviceSize)pitch) {
SDL_memcpy(dst, src, (size_t)length * h);
} else {
@ -2778,7 +2780,7 @@ static VkResult VULKAN_UpdateTextureInternal(VULKAN_RenderData *rendererData, Vk
VULKAN_IssueBatch(rendererData);
}
return 0;
return VK_SUCCESS;
}
@ -3381,7 +3383,7 @@ static VkDescriptorSet VULKAN_AllocateDescriptorSet(SDL_Renderer *renderer, VULK
return VK_NULL_HANDLE;
}
rendererData->numDescriptorPools[rendererData->currentCommandBufferIndex]++;
VkDescriptorPool *descriptorPools = SDL_realloc(rendererData->descriptorPools[rendererData->currentCommandBufferIndex],
VkDescriptorPool *descriptorPools = (VkDescriptorPool *)SDL_realloc(rendererData->descriptorPools[rendererData->currentCommandBufferIndex],
sizeof(VkDescriptorPool) * rendererData->numDescriptorPools[rendererData->currentCommandBufferIndex]);
descriptorPools[rendererData->numDescriptorPools[rendererData->currentCommandBufferIndex] - 1] = descriptorPool;
rendererData->descriptorPools[rendererData->currentCommandBufferIndex] = descriptorPools;
@ -3550,7 +3552,7 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm
}
rendererData->numConstantBuffers[rendererData->currentCommandBufferIndex]++;
VULKAN_Buffer *newConstantBuffers = SDL_realloc(rendererData->constantBuffers[rendererData->currentCommandBufferIndex],
VULKAN_Buffer *newConstantBuffers = (VULKAN_Buffer *)SDL_realloc(rendererData->constantBuffers[rendererData->currentCommandBufferIndex],
sizeof(VULKAN_Buffer) * rendererData->numConstantBuffers[rendererData->currentCommandBufferIndex]);
newConstantBuffers[rendererData->numConstantBuffers[rendererData->currentCommandBufferIndex] - 1] = newConstantBuffer;
rendererData->constantBuffers[rendererData->currentCommandBufferIndex] = newConstantBuffers;
@ -3564,7 +3566,7 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm
SDL_memcpy(&rendererData->currentPipelineState->shader_constants, shader_constants, sizeof(*shader_constants));
/* Upload constants to persistently mapped buffer */
uint8_t *dst = rendererData->constantBuffers[rendererData->currentCommandBufferIndex][rendererData->currentConstantBufferIndex].mappedBufferPtr;
uint8_t *dst = (uint8_t *)rendererData->constantBuffers[rendererData->currentCommandBufferIndex][rendererData->currentConstantBufferIndex].mappedBufferPtr;
dst += constantBufferOffset;
SDL_memcpy(dst, &rendererData->currentPipelineState->shader_constants, sizeof(PixelShaderConstants));
}

View File

@ -47,13 +47,13 @@ static struct
void VULKAN_GetVertexShader(VULKAN_Shader shader, const uint32_t **outBytecode, size_t *outSize)
{
*outBytecode = VULKAN_shaders[shader].vs_shader_data;
*outBytecode = (const uint32_t *)VULKAN_shaders[shader].vs_shader_data;
*outSize = VULKAN_shaders[shader].vs_shader_size;
}
void VULKAN_GetPixelShader(VULKAN_Shader shader, const uint32_t **outBytecode, size_t *outSize)
{
*outBytecode = VULKAN_shaders[shader].ps_shader_data;
*outBytecode = (const uint32_t *)VULKAN_shaders[shader].ps_shader_data;
*outSize = VULKAN_shaders[shader].ps_shader_size;
}

View File

@ -883,11 +883,11 @@ done:
*/
/* encode 32bpp rgb + a into 16bpp rgb, losing alpha */
static int copy_opaque_16(void *dst, Uint32 *src, int n,
static int copy_opaque_16(void *dst, const Uint32 *src, int n,
SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt)
{
int i;
Uint16 *d = dst;
Uint16 *d = (Uint16 *)dst;
for (i = 0; i < n; i++) {
unsigned r, g, b;
RGB_FROM_PIXEL(*src, sfmt, r, g, b);
@ -899,11 +899,11 @@ static int copy_opaque_16(void *dst, Uint32 *src, int n,
}
/* decode opaque pixels from 16bpp to 32bpp rgb + a */
static int uncopy_opaque_16(Uint32 *dst, void *src, int n,
static int uncopy_opaque_16(Uint32 *dst, const void *src, int n,
RLEDestFormat *sfmt, SDL_PixelFormat *dfmt)
{
int i;
Uint16 *s = src;
const Uint16 *s = (const Uint16 *)src;
unsigned alpha = dfmt->Amask ? 255 : 0;
for (i = 0; i < n; i++) {
unsigned r, g, b;
@ -916,11 +916,11 @@ static int uncopy_opaque_16(Uint32 *dst, void *src, int n,
}
/* encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 565 */
static int copy_transl_565(void *dst, Uint32 *src, int n,
static int copy_transl_565(void *dst, const Uint32 *src, int n,
SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt)
{
int i;
Uint32 *d = dst;
Uint32 *d = (Uint32 *)dst;
for (i = 0; i < n; i++) {
unsigned r, g, b, a;
Uint16 pix;
@ -934,11 +934,11 @@ static int copy_transl_565(void *dst, Uint32 *src, int n,
}
/* encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 555 */
static int copy_transl_555(void *dst, Uint32 *src, int n,
static int copy_transl_555(void *dst, const Uint32 *src, int n,
SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt)
{
int i;
Uint32 *d = dst;
Uint32 *d = (Uint32 *)dst;
for (i = 0; i < n; i++) {
unsigned r, g, b, a;
Uint16 pix;
@ -952,11 +952,11 @@ static int copy_transl_555(void *dst, Uint32 *src, int n,
}
/* decode translucent pixels from 32bpp GORAB to 32bpp rgb + a */
static int uncopy_transl_16(Uint32 *dst, void *src, int n,
static int uncopy_transl_16(Uint32 *dst, const void *src, int n,
RLEDestFormat *sfmt, SDL_PixelFormat *dfmt)
{
int i;
Uint32 *s = src;
const Uint32 *s = (const Uint32 *)src;
for (i = 0; i < n; i++) {
unsigned r, g, b, a;
Uint32 pix = *s++;
@ -970,11 +970,11 @@ static int uncopy_transl_16(Uint32 *dst, void *src, int n,
}
/* encode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) */
static int copy_32(void *dst, Uint32 *src, int n,
static int copy_32(void *dst, const Uint32 *src, int n,
SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt)
{
int i;
Uint32 *d = dst;
Uint32 *d = (Uint32 *)dst;
for (i = 0; i < n; i++) {
unsigned r, g, b, a;
RGBA_FROM_8888(*src, sfmt, r, g, b, a);
@ -986,11 +986,11 @@ static int copy_32(void *dst, Uint32 *src, int n,
}
/* decode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) */
static int uncopy_32(Uint32 *dst, void *src, int n,
static int uncopy_32(Uint32 *dst, const void *src, int n,
RLEDestFormat *sfmt, SDL_PixelFormat *dfmt)
{
int i;
Uint32 *s = src;
const Uint32 *s = (const Uint32 *)src;
for (i = 0; i < n; i++) {
unsigned r, g, b, a;
Uint32 pixel = *s++;
@ -1017,9 +1017,9 @@ static int RLEAlphaSurface(SDL_Surface *surface)
int max_transl_run = 65535;
unsigned masksum;
Uint8 *rlebuf, *dst;
int (*copy_opaque)(void *, Uint32 *, int,
int (*copy_opaque)(void *, const Uint32 *, int,
SDL_PixelFormat *, SDL_PixelFormat *);
int (*copy_transl)(void *, Uint32 *, int,
int (*copy_transl)(void *, const Uint32 *, int,
SDL_PixelFormat *, SDL_PixelFormat *);
dest = surface->map->dst;
@ -1225,7 +1225,7 @@ static int RLEAlphaSurface(SDL_Surface *surface)
/* reallocate the buffer to release unused memory */
{
Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf);
Uint8 *p = (Uint8 *)SDL_realloc(rlebuf, dst - rlebuf);
if (!p) {
p = rlebuf;
}
@ -1393,7 +1393,7 @@ static int RLEColorkeySurface(SDL_Surface *surface)
/* reallocate the buffer to release unused memory */
{
/* If SDL_realloc returns NULL, the original block is left intact */
Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf);
Uint8 *p = (Uint8 *)SDL_realloc(rlebuf, dst - rlebuf);
if (!p) {
p = rlebuf;
}
@ -1475,10 +1475,10 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface)
Uint8 *srcbuf;
Uint32 *dst;
SDL_PixelFormat *sf = surface->format;
RLEDestFormat *df = surface->map->data;
int (*uncopy_opaque)(Uint32 *, void *, int,
RLEDestFormat *df = (RLEDestFormat *)surface->map->data;
int (*uncopy_opaque)(Uint32 *, const void *, int,
RLEDestFormat *, SDL_PixelFormat *);
int (*uncopy_transl)(Uint32 *, void *, int,
int (*uncopy_transl)(Uint32 *, const void *, int,
RLEDestFormat *, SDL_PixelFormat *);
int w = surface->w;
int bpp = df->bytes_per_pixel;
@ -1503,7 +1503,7 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface)
/* fill background with transparent pixels */
SDL_memset(surface->pixels, 0, (size_t)surface->h * surface->pitch);
dst = surface->pixels;
dst = (Uint32 *)surface->pixels;
srcbuf = (Uint8 *)(df + 1);
for (;;) {
/* copy opaque pixels */

View File

@ -3203,7 +3203,7 @@ struct blit_table
Uint32 srcR, srcG, srcB;
int dstbpp;
Uint32 dstR, dstG, dstB;
enum blit_features blit_features;
Uint32 blit_features;
SDL_BlitFunc blitfunc;
Uint32 alpha; /* bitwise NO_ALPHA, SET_ALPHA, COPY_ALPHA */
};

View File

@ -667,7 +667,7 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, SDL_bool freedst)
) {
intermediate_surface = surface;
} else {
Uint32 pixel_format;
SDL_PixelFormatEnum pixel_format;
/* If the surface has a colorkey or alpha channel we'll save a
32-bit BMP with alpha channel, otherwise save a 24-bit BMP. */

View File

@ -297,7 +297,7 @@ char *SDL_GetClipboardText(void)
text_mime_types = SDL_GetTextMimeTypes(_this, &num_mime_types);
for (i = 0; i < num_mime_types; ++i) {
text = SDL_GetClipboardData(text_mime_types[i], &length);
text = (char *)SDL_GetClipboardData(text_mime_types[i], &length);
if (text) {
break;
}

View File

@ -1216,7 +1216,7 @@ int SDL_EGL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context)
return 0;
}
EGLSurface *SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, NativeWindowType nw)
EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, NativeWindowType nw)
{
#ifdef SDL_VIDEO_DRIVER_ANDROID
EGLint format_wanted;
@ -1226,7 +1226,7 @@ EGLSurface *SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, Na
EGLint attribs[33];
int attr = 0;
EGLSurface *surface;
EGLSurface surface;
if (SDL_EGL_ChooseConfig(_this) != 0) {
return EGL_NO_SURFACE;

View File

@ -129,7 +129,7 @@ extern int SDL_EGL_ChooseConfig(SDL_VideoDevice *_this);
extern int SDL_EGL_SetSwapInterval(SDL_VideoDevice *_this, int interval);
extern int SDL_EGL_GetSwapInterval(SDL_VideoDevice *_this, int *interval);
extern int SDL_EGL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context);
extern EGLSurface *SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, NativeWindowType nw);
extern EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, NativeWindowType nw);
extern void SDL_EGL_DestroySurface(SDL_VideoDevice *_this, EGLSurface egl_surface);
extern EGLSurface SDL_EGL_CreateOffscreenSurface(SDL_VideoDevice *_this, int width, int height);

View File

@ -590,7 +590,7 @@ SDL_PixelFormat *SDL_CreatePixelFormat(SDL_PixelFormatEnum pixel_format)
}
/* Allocate an empty pixel format structure, and initialize it */
format = SDL_malloc(sizeof(*format));
format = (SDL_PixelFormat *)SDL_malloc(sizeof(*format));
if (!format) {
SDL_UnlockSpinlock(&formats_lock);
return NULL;
@ -720,7 +720,7 @@ void SDL_DestroyPixelFormat(SDL_PixelFormat *format)
return;
}
SDL_Colorspace SDL_GetDefaultColorspaceForFormat(Uint32 format)
SDL_Colorspace SDL_GetDefaultColorspaceForFormat(SDL_PixelFormatEnum format)
{
if (SDL_ISPIXELFORMAT_FOURCC(format)) {
if (format == SDL_PIXELFORMAT_P010) {
@ -1393,7 +1393,7 @@ SDL_BlitMap *SDL_AllocBlitMap(void)
void SDL_InvalidateAllBlitMap(SDL_Surface *surface)
{
SDL_ListNode *l = surface->list_blitmap;
SDL_ListNode *l = (SDL_ListNode *)surface->list_blitmap;
surface->list_blitmap = NULL;

View File

@ -30,8 +30,8 @@
/* Pixel format functions */
extern int SDL_InitFormat(SDL_PixelFormat *format, SDL_PixelFormatEnum pixel_format);
extern int SDL_CalculateSize(Uint32 format, int width, int height, size_t *size, size_t *pitch, SDL_bool minimalPitch);
extern SDL_Colorspace SDL_GetDefaultColorspaceForFormat(Uint32 pixel_format);
extern int SDL_CalculateSurfaceSize(SDL_PixelFormatEnum format, int width, int height, size_t *size, size_t *pitch, SDL_bool minimalPitch);
extern SDL_Colorspace SDL_GetDefaultColorspaceForFormat(SDL_PixelFormatEnum pixel_format);
/* Colorspace conversion functions */
extern float SDL_sRGBtoLinear(float v);
@ -60,6 +60,6 @@ extern float SDL_GetSurfaceHDRHeadroom(SDL_Surface *surface, SDL_Colorspace colo
extern void SDL_DitherColors(SDL_Color *colors, int bpp);
extern Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
extern void SDL_DetectPalette(SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel);
extern SDL_Surface *SDL_DuplicatePixels(int width, int height, Uint32 format, SDL_Colorspace colorspace, void *pixels, int pitch);
extern SDL_Surface *SDL_DuplicatePixels(int width, int height, SDL_PixelFormatEnum format, SDL_Colorspace colorspace, void *pixels, int pitch);
#endif /* SDL_pixels_c_h_ */

View File

@ -74,7 +74,7 @@ static int SDL_CalculateRGBSize(Uint32 format, size_t width, size_t height, size
return 0;
}
int SDL_CalculateSize(Uint32 format, int width, int height, size_t *size, size_t *pitch, SDL_bool minimalPitch)
int SDL_CalculateSurfaceSize(SDL_PixelFormatEnum format, int width, int height, size_t *size, size_t *pitch, SDL_bool minimalPitch)
{
size_t p = 0, sz = 0;
@ -128,7 +128,7 @@ SDL_Surface *SDL_CreateSurface(int width, int height, SDL_PixelFormatEnum format
return NULL;
}
if (SDL_CalculateSize(format, width, height, &size, &pitch, SDL_FALSE /* not minimal pitch */) < 0) {
if (SDL_CalculateSurfaceSize(format, width, height, &size, &pitch, SDL_FALSE /* not minimal pitch */) < 0) {
/* Overflow... */
return NULL;
}
@ -221,7 +221,7 @@ SDL_Surface *SDL_CreateSurfaceFrom(void *pixels, int width, int height, int pitc
} else {
size_t minimalPitch;
if (SDL_CalculateSize(format, width, height, NULL, &minimalPitch, SDL_TRUE /* minimal pitch */) < 0) {
if (SDL_CalculateSurfaceSize(format, width, height, NULL, &minimalPitch, SDL_TRUE /* minimal pitch */) < 0) {
/* Overflow... */
return NULL;
}
@ -1080,7 +1080,7 @@ int SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect,
/* Change source format if not appropriate for scaling */
if (src->format->bytes_per_pixel != 4 || src->format->format == SDL_PIXELFORMAT_ARGB2101010) {
SDL_Rect tmprect;
int fmt;
SDL_PixelFormatEnum fmt;
tmprect.x = 0;
tmprect.y = 0;
tmprect.w = src->w;
@ -1250,7 +1250,7 @@ int SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMode flip)
}
}
static SDL_Surface *SDL_ConvertSurfaceWithPixelFormatAndColorspace(SDL_Surface *surface, const SDL_PixelFormat *format, Uint32 colorspace, SDL_PropertiesID props)
static SDL_Surface *SDL_ConvertSurfaceWithPixelFormatAndColorspace(SDL_Surface *surface, const SDL_PixelFormat *format, SDL_Colorspace colorspace, SDL_PropertiesID props)
{
SDL_Surface *convert;
SDL_Colorspace src_colorspace;
@ -1583,7 +1583,7 @@ SDL_Surface *SDL_ConvertSurfaceFormatAndColorspace(SDL_Surface *surface, SDL_Pix
/*
* Create a surface on the stack for quick blit operations
*/
static SDL_bool SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, SDL_Colorspace colorspace, SDL_PropertiesID props, void *pixels, int pitch, SDL_Surface *surface, SDL_PixelFormat *format, SDL_BlitMap *blitmap)
static SDL_bool SDL_CreateSurfaceOnStack(int width, int height, SDL_PixelFormatEnum pixel_format, SDL_Colorspace colorspace, SDL_PropertiesID props, void *pixels, int pitch, SDL_Surface *surface, SDL_PixelFormat *format, SDL_BlitMap *blitmap)
{
if (SDL_ISPIXELFORMAT_INDEXED(pixel_format)) {
SDL_SetError("Indexed pixel formats not supported");
@ -1635,7 +1635,7 @@ static void SDL_DestroySurfaceOnStack(SDL_Surface *surface)
}
}
SDL_Surface *SDL_DuplicatePixels(int width, int height, Uint32 format, SDL_Colorspace colorspace, void *pixels, int pitch)
SDL_Surface *SDL_DuplicatePixels(int width, int height, SDL_PixelFormatEnum format, SDL_Colorspace colorspace, void *pixels, int pitch)
{
SDL_Surface *surface = SDL_CreateSurface(width, height, format);
if (surface) {

View File

@ -250,7 +250,7 @@ struct SDL_VideoDevice
int (*SetWindowMouseGrab)(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed);
int (*SetWindowKeyboardGrab)(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed);
void (*DestroyWindow)(SDL_VideoDevice *_this, SDL_Window *window);
int (*CreateWindowFramebuffer)(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch);
int (*CreateWindowFramebuffer)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
int (*UpdateWindowFramebuffer)(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
void (*DestroyWindowFramebuffer)(SDL_VideoDevice *_this, SDL_Window *window);
void (*OnWindowEnter)(SDL_VideoDevice *_this, SDL_Window *window);

View File

@ -236,7 +236,7 @@ static void SDLCALL SDL_CleanupWindowTextureData(void *userdata, void *value)
SDL_free(data);
}
static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
{
SDL_RendererInfo info;
SDL_PropertiesID props = SDL_GetWindowProperties(window);
@ -363,7 +363,7 @@ static int SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window,
SDL_GetWindowSizeInPixels(window, &w, &h);
data = SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_TEXTUREDATA_POINTER, NULL);
data = (SDL_WindowTextureData *)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_TEXTUREDATA_POINTER, NULL);
if (!data || !data->texture) {
return SDL_SetError("No window texture data");
}
@ -395,7 +395,7 @@ int SDL_SetWindowTextureVSync(SDL_Window *window, int vsync)
{
SDL_WindowTextureData *data;
data = SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_TEXTUREDATA_POINTER, NULL);
data = (SDL_WindowTextureData *)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_TEXTUREDATA_POINTER, NULL);
if (!data) {
return -1;
}
@ -2010,7 +2010,7 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props)
int y = (int)SDL_GetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, SDL_WINDOWPOS_UNDEFINED);
int w = (int)SDL_GetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, 0);
int h = (int)SDL_GetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, 0);
SDL_Window *parent = SDL_GetProperty(props, SDL_PROP_WINDOW_CREATE_PARENT_POINTER, NULL);
SDL_Window *parent = (SDL_Window *)SDL_GetProperty(props, SDL_PROP_WINDOW_CREATE_PARENT_POINTER, NULL);
SDL_WindowFlags flags = SDL_GetWindowFlagProperties(props);
SDL_WindowFlags type_flags, graphics_flags;
SDL_bool undefined_x = SDL_FALSE;
@ -3047,7 +3047,7 @@ int SDL_SyncWindow(SDL_Window *window)
static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window)
{
Uint32 format = 0;
SDL_PixelFormatEnum format = SDL_PIXELFORMAT_UNKNOWN;
void *pixels = NULL;
int pitch = 0;
SDL_bool created_framebuffer = SDL_FALSE;

View File

@ -143,9 +143,9 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList(
}
if (count == 0) {
retval = SDL_calloc(1, sizeof(VkExtensionProperties)); // so we can return non-null
retval = (VkExtensionProperties *)SDL_calloc(1, sizeof(VkExtensionProperties)); // so we can return non-null
} else {
retval = SDL_calloc(count, sizeof(VkExtensionProperties));
retval = (VkExtensionProperties *)SDL_calloc(count, sizeof(VkExtensionProperties));
}
if (!retval) {
@ -226,7 +226,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
goto error;
}
physicalDevices = SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount);
physicalDevices = (VkPhysicalDevice *)SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount);
if (!physicalDevices) {
goto error;
}
@ -268,7 +268,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
continue;
}
displayProperties = SDL_malloc(sizeof(VkDisplayPropertiesKHR) * displayPropertiesCount);
displayProperties = (VkDisplayPropertiesKHR *)SDL_malloc(sizeof(VkDisplayPropertiesKHR) * displayPropertiesCount);
if (!displayProperties) {
goto error;
}
@ -296,7 +296,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
}
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display modes: %u", displayModePropertiesCount);
displayModeProperties = SDL_malloc(sizeof(VkDisplayModePropertiesKHR) * displayModePropertiesCount);
displayModeProperties = (VkDisplayModePropertiesKHR *)SDL_malloc(sizeof(VkDisplayModePropertiesKHR) * displayModePropertiesCount);
if (!displayModeProperties) {
goto error;
}
@ -342,7 +342,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
}
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display planes: %u", displayPlanePropertiesCount);
displayPlaneProperties = SDL_malloc(sizeof(VkDisplayPlanePropertiesKHR) * displayPlanePropertiesCount);
displayPlaneProperties = (VkDisplayPlanePropertiesKHR *)SDL_malloc(sizeof(VkDisplayPlanePropertiesKHR) * displayPlanePropertiesCount);
if (!displayPlaneProperties) {
goto error;
}
@ -372,7 +372,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of supported displays for plane %u: %u", i, planeSupportedDisplaysCount);
planeSupportedDisplays = SDL_malloc(sizeof(VkDisplayKHR) * planeSupportedDisplaysCount);
planeSupportedDisplays = (VkDisplayKHR *)SDL_malloc(sizeof(VkDisplayKHR) * planeSupportedDisplaysCount);
if (!planeSupportedDisplays) {
SDL_free(displayPlaneProperties);
goto error;

View File

@ -27,7 +27,7 @@
#if SDL_HAVE_YUV
static SDL_bool IsPlanar2x2Format(Uint32 format);
static SDL_bool IsPlanar2x2Format(SDL_PixelFormatEnum format);
#endif
/*
@ -36,7 +36,7 @@ static SDL_bool IsPlanar2x2Format(Uint32 format);
*
* return 0 on success, -1 on error
*/
int SDL_CalculateYUVSize(Uint32 format, int w, int h, size_t *size, size_t *pitch)
int SDL_CalculateYUVSize(SDL_PixelFormatEnum format, int w, int h, size_t *size, size_t *pitch)
{
#if SDL_HAVE_YUV
int sz_plane = 0, sz_plane_chroma = 0, sz_plane_packed = 0;
@ -187,7 +187,7 @@ static int GetYUVConversionType(SDL_Colorspace colorspace, YCbCrType *yuv_type)
return SDL_SetError("Unsupported YUV colorspace");
}
static SDL_bool IsPlanar2x2Format(Uint32 format)
static SDL_bool IsPlanar2x2Format(SDL_PixelFormatEnum format)
{
return format == SDL_PIXELFORMAT_YV12 || format == SDL_PIXELFORMAT_IYUV || format == SDL_PIXELFORMAT_NV12 || format == SDL_PIXELFORMAT_NV21 || format == SDL_PIXELFORMAT_P010;
}
@ -197,7 +197,7 @@ static SDL_bool IsPacked4Format(Uint32 format)
return format == SDL_PIXELFORMAT_YUY2 || format == SDL_PIXELFORMAT_UYVY || format == SDL_PIXELFORMAT_YVYU;
}
static int GetYUVPlanes(int width, int height, Uint32 format, const void *yuv, int yuv_pitch,
static int GetYUVPlanes(int width, int height, SDL_PixelFormatEnum format, const void *yuv, int yuv_pitch,
const Uint8 **y, const Uint8 **u, const Uint8 **v, Uint32 *y_stride, Uint32 *uv_stride)
{
const Uint8 *planes[3] = { NULL, NULL, NULL };
@ -304,7 +304,7 @@ static int GetYUVPlanes(int width, int height, Uint32 format, const void *yuv, i
#ifdef SDL_SSE2_INTRINSICS
static SDL_bool SDL_TARGETING("sse2") yuv_rgb_sse(
Uint32 src_format, Uint32 dst_format,
SDL_PixelFormatEnum src_format, SDL_PixelFormatEnum dst_format,
Uint32 width, Uint32 height,
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
Uint8 *rgb, Uint32 rgb_stride,
@ -411,7 +411,7 @@ static SDL_bool SDL_TARGETING("sse2") yuv_rgb_sse(
}
#else
static SDL_bool yuv_rgb_sse(
Uint32 src_format, Uint32 dst_format,
SDL_PixelFormatEnum src_format, SDL_PixelFormatEnum dst_format,
Uint32 width, Uint32 height,
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
Uint8 *rgb, Uint32 rgb_stride,
@ -423,7 +423,7 @@ static SDL_bool yuv_rgb_sse(
#ifdef SDL_LSX_INTRINSICS
static SDL_bool yuv_rgb_lsx(
Uint32 src_format, Uint32 dst_format,
SDL_PixelFormatEnum src_format, SDL_PixelFormatEnum dst_format,
Uint32 width, Uint32 height,
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
Uint8 *rgb, Uint32 rgb_stride,
@ -463,7 +463,7 @@ static SDL_bool yuv_rgb_lsx(
}
#else
static SDL_bool yuv_rgb_lsx(
Uint32 src_format, Uint32 dst_format,
SDL_PixelFormatEnum src_format, SDL_PixelFormatEnum dst_format,
Uint32 width, Uint32 height,
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
Uint8 *rgb, Uint32 rgb_stride,
@ -474,7 +474,7 @@ static SDL_bool yuv_rgb_lsx(
#endif
static SDL_bool yuv_rgb_std(
Uint32 src_format, Uint32 dst_format,
SDL_PixelFormatEnum src_format, SDL_PixelFormatEnum dst_format,
Uint32 width, Uint32 height,
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
Uint8 *rgb, Uint32 rgb_stride,
@ -579,14 +579,16 @@ static SDL_bool yuv_rgb_std(
case SDL_PIXELFORMAT_XBGR2101010:
yuvp010_xbgr2101010_std(width, height, (const uint16_t *)y, (const uint16_t *)u, (const uint16_t *)v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
return SDL_TRUE;
default:
break;
}
}
return SDL_FALSE;
}
int SDL_ConvertPixels_YUV_to_RGB(int width, int height,
Uint32 src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch,
Uint32 dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch)
SDL_PixelFormatEnum src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch,
SDL_PixelFormatEnum dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch)
{
const Uint8 *y = NULL;
const Uint8 *u = NULL;
@ -707,7 +709,7 @@ static struct RGB2YUVFactors RGB2YUVFactorTables[] = {
},
};
static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch, YCbCrType yuv_type)
static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch, YCbCrType yuv_type)
{
const int src_pitch_x_2 = src_pitch * 2;
const int height_half = height / 2;
@ -998,7 +1000,7 @@ static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *
return 0;
}
static int SDL_ConvertPixels_XBGR2101010_to_P010(int width, int height, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch, YCbCrType yuv_type)
static int SDL_ConvertPixels_XBGR2101010_to_P010(int width, int height, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch, YCbCrType yuv_type)
{
const int src_pitch_x_2 = src_pitch * 2;
const int height_half = height / 2;
@ -1121,8 +1123,8 @@ static int SDL_ConvertPixels_XBGR2101010_to_P010(int width, int height, const vo
}
int SDL_ConvertPixels_RGB_to_YUV(int width, int height,
Uint32 src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch,
Uint32 dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch)
SDL_PixelFormatEnum src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch,
SDL_PixelFormatEnum dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch)
{
YCbCrType yuv_type = YCBCR_601_LIMITED;
@ -1208,7 +1210,7 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height,
}
}
static int SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, Uint32 format,
static int SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, SDL_PixelFormatEnum format,
const void *src, int src_pitch, void *dst, int dst_pitch)
{
int i;
@ -1285,8 +1287,8 @@ static int SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src
if (src == dst) {
int UVpitch = (dst_pitch + 1) / 2;
Uint8 *tmp;
Uint8 *row1 = dst;
Uint8 *row2 = (Uint8 *)dst + UVheight * UVpitch;
Uint8 *row1 = (Uint8 *)dst;
Uint8 *row2 = row1 + UVheight * UVpitch;
/* Allocate a temporary row for the swap */
tmp = (Uint8 *)SDL_malloc(UVwidth);
@ -1675,8 +1677,8 @@ static int SDL_ConvertPixels_SwapNV(int width, int height, const void *src, int
}
static int SDL_ConvertPixels_Planar2x2_to_Planar2x2(int width, int height,
Uint32 src_format, const void *src, int src_pitch,
Uint32 dst_format, void *dst, int dst_pitch)
SDL_PixelFormatEnum src_format, const void *src, int src_pitch,
SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch)
{
if (src != dst) {
/* Copy Y plane */
@ -2233,8 +2235,8 @@ static int SDL_ConvertPixels_YVYU_to_UYVY(int width, int height, const void *src
}
static int SDL_ConvertPixels_Packed4_to_Packed4(int width, int height,
Uint32 src_format, const void *src, int src_pitch,
Uint32 dst_format, void *dst, int dst_pitch)
SDL_PixelFormatEnum src_format, const void *src, int src_pitch,
SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch)
{
switch (src_format) {
case SDL_PIXELFORMAT_YUY2:
@ -2275,8 +2277,8 @@ static int SDL_ConvertPixels_Packed4_to_Packed4(int width, int height,
}
static int SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height,
Uint32 src_format, const void *src, int src_pitch,
Uint32 dst_format, void *dst, int dst_pitch)
SDL_PixelFormatEnum src_format, const void *src, int src_pitch,
SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch)
{
int x, y;
const Uint8 *srcY1, *srcY2, *srcU, *srcV;
@ -2417,8 +2419,8 @@ static int SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height,
}
static int SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height,
Uint32 src_format, const void *src, int src_pitch,
Uint32 dst_format, void *dst, int dst_pitch)
SDL_PixelFormatEnum src_format, const void *src, int src_pitch,
SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch)
{
int x, y;
const Uint8 *srcY1, *srcY2, *srcU1, *srcU2, *srcV1, *srcV2;
@ -2550,8 +2552,8 @@ static int SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height,
#endif /* SDL_HAVE_YUV */
int SDL_ConvertPixels_YUV_to_YUV(int width, int height,
Uint32 src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch,
Uint32 dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch)
SDL_PixelFormatEnum src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch,
SDL_PixelFormatEnum dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch)
{
#if SDL_HAVE_YUV
if (src_colorspace != dst_colorspace) {

View File

@ -26,11 +26,11 @@
/* YUV conversion functions */
extern int SDL_ConvertPixels_YUV_to_RGB(int width, int height, Uint32 src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, Uint32 dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
extern int SDL_ConvertPixels_RGB_to_YUV(int width, int height, Uint32 src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, Uint32 dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
extern int SDL_ConvertPixels_YUV_to_YUV(int width, int height, Uint32 src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, Uint32 dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
extern int SDL_ConvertPixels_YUV_to_RGB(int width, int height, SDL_PixelFormatEnum src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
extern int SDL_ConvertPixels_RGB_to_YUV(int width, int height, SDL_PixelFormatEnum src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
extern int SDL_ConvertPixels_YUV_to_YUV(int width, int height, SDL_PixelFormatEnum src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
extern int SDL_CalculateYUVSize(Uint32 format, int w, int h, size_t *size, size_t *pitch);
extern int SDL_CalculateYUVSize(SDL_PixelFormatEnum format, int w, int h, size_t *size, size_t *pitch);
#endif /* SDL_yuv_c_h_ */

View File

@ -29,10 +29,10 @@
#define DUMMY_SURFACE "SDL.internal.window.surface"
int SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
int SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
{
SDL_Surface *surface;
const Uint32 surface_format = SDL_PIXELFORMAT_XRGB8888;
const SDL_PixelFormatEnum surface_format = SDL_PIXELFORMAT_XRGB8888;
int w, h;
/* Create a new framebuffer */

View File

@ -24,7 +24,7 @@
#include "SDL_internal.h"
extern int SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch);
extern int SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
extern int SDL_DUMMY_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
extern void SDL_DUMMY_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);

View File

@ -27,10 +27,10 @@
#include <emscripten/threading.h>
int Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
int Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
{
SDL_Surface *surface;
const Uint32 surface_format = SDL_PIXELFORMAT_XBGR8888;
const SDL_PixelFormatEnum surface_format = SDL_PIXELFORMAT_XBGR8888;
int w, h;
/* Free the old framebuffer surface */

View File

@ -23,7 +23,7 @@
#ifndef SDL_emscriptenframebuffer_h_
#define SDL_emscriptenframebuffer_h_
extern int Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch);
extern int Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
extern int Emscripten_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
extern void Emscripten_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);

View File

@ -44,7 +44,7 @@ static SDL_INLINE SDL_BLooper *_GetBeLooper() {
}
int HAIKU_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window,
Uint32 * format,
SDL_PixelFormatEnum * format,
void ** pixels, int *pitch) {
SDL_BWin *bwin = _ToBeWin(window);
BScreen bscreen;

View File

@ -31,7 +31,7 @@ extern "C" {
#include "../SDL_sysvideo.h"
extern int HAIKU_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window,
Uint32 *format,
SDL_PixelFormatEnum *format,
void **pixels, int *pitch);
extern int HAIKU_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window,
const SDL_Rect *rects, int numrects);

View File

@ -132,7 +132,7 @@ void _SpoutModeData(display_mode *bmode) {
int32 HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace)
SDL_PixelFormatEnum HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace)
{
switch (colorspace) {
case B_CMAP8:
@ -162,7 +162,7 @@ int32 HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace)
/* May never get here, but safer and needed to shut up compiler */
SDL_SetError("Invalid color space");
return 0;
return SDL_PIXELFORMAT_UNKNOWN;
}
static void _BDisplayModeToSdlDisplayMode(display_mode *bmode, SDL_DisplayMode *mode) {

View File

@ -28,7 +28,7 @@ extern "C" {
#include "../SDL_sysvideo.h"
extern int32 HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace);
extern SDL_PixelFormatEnum HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace);
extern int HAIKU_InitModes(SDL_VideoDevice *_this);
extern int HAIKU_QuitModes(SDL_VideoDevice *_this);

View File

@ -40,7 +40,7 @@ static int GetSourceOffset(int x, int y, int source_width);
static void FlushN3DSBuffer(const void *buffer, u32 bufsize, gfxScreen_t screen);
int SDL_N3DS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
int SDL_N3DS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
{
SDL_Surface *framebuffer;
int w, h;

View File

@ -24,7 +24,7 @@
#include "SDL_internal.h"
int SDL_N3DS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch);
int SDL_N3DS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
int SDL_N3DS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
void SDL_N3DS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);

View File

@ -44,11 +44,11 @@ void DrawBackground(SDL_VideoDevice *_this);
void DirectDraw(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects, TUint16 *screenBuffer);
void RedrawWindowL(SDL_VideoDevice *_this);
int SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
int SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
{
SDL_VideoData *phdata = _this->driverdata;
SDL_Surface *surface;
const Uint32 surface_format = SDL_PIXELFORMAT_RGB444;
const SDL_PixelFormatEnum surface_format = SDL_PIXELFORMAT_RGB444;
int w, h;
/* Free the old framebuffer surface */

View File

@ -21,7 +21,7 @@
#include "SDL_internal.h"
extern int SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch);
extern int SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
extern int SDL_NGAGE_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
extern void SDL_NGAGE_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);

View File

@ -29,10 +29,10 @@
#define OFFSCREEN_SURFACE "SDL.internal.window.surface"
int SDL_OFFSCREEN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
int SDL_OFFSCREEN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
{
SDL_Surface *surface;
const Uint32 surface_format = SDL_PIXELFORMAT_XRGB8888;
const SDL_PixelFormatEnum surface_format = SDL_PIXELFORMAT_XRGB8888;
int w, h;
/* Create a new framebuffer */

View File

@ -20,6 +20,6 @@
*/
#include "SDL_internal.h"
extern int SDL_OFFSCREEN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch);
extern int SDL_OFFSCREEN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
extern int SDL_OFFSCREEN_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
extern void SDL_OFFSCREEN_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);

View File

@ -147,7 +147,7 @@ fail:
* @param[out] pitch Holds the number of bytes per line
* @return 0 if successful, -1 on error
*/
static int createWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * format,
static int createWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window, SDL_PixelFormatEnum * format,
void ** pixels, int *pitch)
{
window_impl_t *impl = (window_impl_t *)window->driverdata;

View File

@ -30,7 +30,7 @@
#include <kernel.h>
#include <swis.h>
int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
{
SDL_WindowData *driverdata = window->driverdata;
const char *sprite_name = "display";

View File

@ -24,7 +24,7 @@
#include "SDL_internal.h"
extern int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch);
extern int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
extern int RISCOS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
extern void RISCOS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);

View File

@ -63,7 +63,7 @@ void vita_gpu_free(SceUID uid)
sceKernelFreeMemBlock(uid);
}
int VITA_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
int VITA_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
{
SDL_WindowData *data = window->driverdata;
SceDisplayFrameBuf framebuf;

View File

@ -20,6 +20,6 @@
*/
#include "SDL_internal.h"
extern int VITA_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch);
extern int VITA_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
extern int VITA_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
extern void VITA_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);

View File

@ -1881,7 +1881,7 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst)
}
SDL_Appname = WIN_UTF8ToString(name);
SDL_Appstyle = style;
SDL_Instance = hInst ? hInst : GetModuleHandle(NULL);
SDL_Instance = hInst ? (HINSTANCE)hInst : GetModuleHandle(NULL);
/* Register the application class */
wcex.cbSize = sizeof(WNDCLASSEX);

View File

@ -24,7 +24,7 @@
#include "SDL_windowsvideo.h"
int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
{
SDL_WindowData *data = window->driverdata;
SDL_bool isstack;

View File

@ -20,6 +20,6 @@
*/
#include "SDL_internal.h"
extern int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch);
extern int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
extern int WIN_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
extern void WIN_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);

View File

@ -1411,8 +1411,8 @@ static SDL_bool UILess_SetupSinks(SDL_VideoData *videodata)
return SDL_FALSE;
}
videodata->ime_uielemsink = SDL_malloc(sizeof(TSFSink));
videodata->ime_ippasink = SDL_malloc(sizeof(TSFSink));
videodata->ime_uielemsink = (TSFSink *)SDL_malloc(sizeof(TSFSink));
videodata->ime_ippasink = (TSFSink *)SDL_malloc(sizeof(TSFSink));
videodata->ime_uielemsink->lpVtbl = vtUIElementSink;
videodata->ime_uielemsink->refcount = 1;

View File

@ -232,7 +232,7 @@ typedef struct
typedef struct
{
DLGTEMPLATEEX *lpDialog;
Uint8 *data;
void *data;
size_t size;
size_t used;
WORD numbuttons;
@ -373,7 +373,7 @@ static SDL_bool AddDialogData(WIN_DialogData *dialog, const void *data, size_t s
return SDL_FALSE;
}
SDL_memcpy(dialog->data + dialog->used, data, size);
SDL_memcpy((Uint8 *)dialog->data + dialog->used, data, size);
dialog->used += size;
return SDL_TRUE;
@ -650,7 +650,7 @@ static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src)
*dstlen = srclen + ampcount + extraspace;
SDL_free(*dst);
*dst = NULL;
newdst = SDL_malloc(*dstlen);
newdst = (char *)SDL_malloc(*dstlen);
if (!newdst) {
return NULL;
}
@ -974,7 +974,7 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
TaskConfig.pszContent = wmessage;
TaskConfig.cButtons = messageboxdata->numbuttons;
pButtons = SDL_malloc(sizeof(TASKDIALOG_BUTTON) * messageboxdata->numbuttons);
pButtons = (TASKDIALOG_BUTTON *)SDL_malloc(sizeof(TASKDIALOG_BUTTON) * messageboxdata->numbuttons);
TaskConfig.nDefaultButton = 0;
nCancelButton = 0;
for (i = 0; i < messageboxdata->numbuttons; i++) {

View File

@ -750,7 +750,7 @@ static void WIN_LogMonitor(SDL_VideoDevice *_this, HMONITOR mon)
int WIN_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
{
SDL_DisplayData *displaydata = display->driverdata;
SDL_DisplayModeData *data = mode->driverdata;
SDL_DisplayModeData *data = (SDL_DisplayModeData *)mode->driverdata;
LONG status;
#ifdef DEBUG_MODES

View File

@ -178,7 +178,7 @@ done:
static SDL_Cursor *WIN_CreateDefaultCursor()
{
SDL_Cursor *cursor = SDL_calloc(1, sizeof(*cursor));
SDL_Cursor *cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor));
if (cursor) {
cursor->driverdata = LoadCursor(NULL, IDC_ARROW);
}
@ -263,7 +263,7 @@ static HBITMAP CreateMaskBitmap(SDL_Surface *surface, SDL_bool is_monochrome)
return NULL;
}
dst = pixels;
dst = (Uint8 *)pixels;
/* Make the mask completely transparent. */
SDL_memset(dst, 0xff, size);
@ -327,7 +327,7 @@ static SDL_Cursor *WIN_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y)
return NULL;
}
cursor = SDL_calloc(1, sizeof(*cursor));
cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor));
if (cursor) {
cursor->driverdata = hcursor;
} else {
@ -419,7 +419,7 @@ static SDL_Cursor *WIN_CreateSystemCursor(SDL_SystemCursor id)
break;
}
cursor = SDL_calloc(1, sizeof(*cursor));
cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor));
if (cursor) {
HCURSOR hcursor;

View File

@ -220,7 +220,7 @@ SDL_FunctionPointer WIN_GL_GetProcAddress(SDL_VideoDevice *_this, const char *pr
func = (SDL_FunctionPointer)_this->gl_data->wglGetProcAddress(proc);
if (!func) {
/* This is probably a normal GL function */
func = (SDL_FunctionPointer)GetProcAddress(_this->gl_config.dll_handle, proc);
func = (SDL_FunctionPointer)GetProcAddress((HMODULE)_this->gl_config.dll_handle, proc);
}
return func;
}

View File

@ -241,7 +241,7 @@ int WINRT_VideoInit(SDL_VideoDevice *_this)
return 0;
}
extern "C" Uint32 D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat);
extern "C" SDL_PixelFormatEnum D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat);
static void WINRT_DXGIModeToSDLDisplayMode(const DXGI_MODE_DESC *dxgiMode, SDL_DisplayMode *sdlMode)
{
@ -298,7 +298,7 @@ static int WINRT_AddDisplaysForOutput(SDL_VideoDevice *_this, IDXGIAdapter1 *dxg
display.name = SDL_strdup("Windows Simulator / Terminal Services Display");
mode.w = (dxgiOutputDesc.DesktopCoordinates.right - dxgiOutputDesc.DesktopCoordinates.left);
mode.h = (dxgiOutputDesc.DesktopCoordinates.bottom - dxgiOutputDesc.DesktopCoordinates.top);
mode.format = DXGI_FORMAT_B8G8R8A8_UNORM;
mode.format = D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM);
display.desktop_mode = mode;
} else if (FAILED(hr)) {
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIOutput::FindClosestMatchingMode failed", hr);
@ -411,7 +411,7 @@ static int WINRT_AddDisplaysForAdapter(SDL_VideoDevice *_this, IDXGIFactory2 *dx
mode.h = (int)SDL_floorf(coreWin->Bounds.Height);
#endif
mode.pixel_density = WINRT_DISPLAY_PROPERTY(LogicalDpi) / 96.0f;
mode.format = DXGI_FORMAT_B8G8R8A8_UNORM;
mode.format = D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM);
display.desktop_mode = mode;
bool error = (SDL_AddVideoDisplay(&display, SDL_FALSE) == 0);

View File

@ -47,7 +47,7 @@ static SDL_bool have_mitshm(Display *dpy)
#endif /* !NO_SHARED_MEMORY */
int X11_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format,
int X11_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format,
void **pixels, int *pitch)
{
SDL_WindowData *data = window->driverdata;

View File

@ -25,7 +25,7 @@
#include "SDL_internal.h"
extern int X11_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window,
Uint32 *format,
SDL_PixelFormatEnum *format,
void **pixels, int *pitch);
extern int X11_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window,
const SDL_Rect *rects, int numrects);

View File

@ -294,7 +294,7 @@ int X11_GetVisualInfoFromVisual(Display *display, Visual *visual, XVisualInfo *v
return -1;
}
Uint32 X11_GetPixelFormatFromVisualInfo(Display *display, XVisualInfo *vinfo)
SDL_PixelFormatEnum X11_GetPixelFormatFromVisualInfo(Display *display, XVisualInfo *vinfo)
{
if (vinfo->class == DirectColor || vinfo->class == TrueColor) {
int bpp;

View File

@ -56,10 +56,8 @@ extern int X11_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display,
extern void X11_QuitModes(SDL_VideoDevice *_this);
/* Some utility functions for working with visuals */
extern int X11_GetVisualInfoFromVisual(Display *display, Visual *visual,
XVisualInfo *vinfo);
extern Uint32 X11_GetPixelFormatFromVisualInfo(Display *display,
XVisualInfo *vinfo);
extern int X11_GetVisualInfoFromVisual(Display *display, Visual *visual, XVisualInfo *vinfo);
extern SDL_PixelFormatEnum X11_GetPixelFormatFromVisualInfo(Display *display, XVisualInfo *vinfo);
extern int X11_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display, SDL_Rect *rect);
extern int X11_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display, SDL_Rect *rect);

View File

@ -310,7 +310,7 @@ int main(int argc, char *argv[])
mode = SDL_GetCurrentDisplayMode(SDL_GetPrimaryDisplay());
if (mode) {
SDL_Log("Screen BPP : %" SDL_PRIu32 "\n", SDL_BITSPERPIXEL(mode->format));
SDL_Log("Screen BPP : %d\n", SDL_BITSPERPIXEL(mode->format));
}
LogSwapInterval();

View File

@ -1101,7 +1101,7 @@ int main(int argc, char **argv)
mode = SDL_GetCurrentDisplayMode(SDL_GetPrimaryDisplay());
if (mode) {
SDL_Log("Screen BPP : %" SDL_PRIu32 "\n", SDL_BITSPERPIXEL(mode->format));
SDL_Log("Screen BPP : %d\n", SDL_BITSPERPIXEL(mode->format));
}
SDL_GetWindowSize(state->windows[0], &dw, &dh);
SDL_Log("Window Size : %d,%d\n", dw, dh);