Update for SDL3 coding style (#6717)

I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594
This commit is contained in:
Sam Lantinga
2022-11-30 12:51:59 -08:00
committed by GitHub
parent 14b902faca
commit 5750bcb174
781 changed files with 51659 additions and 55763 deletions

View File

@@ -27,8 +27,7 @@
#include <emscripten/threading.h>
int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
{
SDL_Surface *surface;
const Uint32 surface_format = SDL_PIXELFORMAT_BGR888;
@@ -37,7 +36,7 @@ int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * form
Uint32 Rmask, Gmask, Bmask, Amask;
/* Free the old framebuffer surface */
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
surface = data->surface;
SDL_FreeSurface(surface);
@@ -58,11 +57,11 @@ int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * form
return 0;
}
int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects)
int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
{
SDL_Surface *surface;
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
surface = data->surface;
if (surface == NULL) {
return SDL_SetError("Couldn't find framebuffer surface for window");
@@ -70,6 +69,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rec
/* Send the data to the display */
/* *INDENT-OFF* */ /* clang-format off */
MAIN_THREAD_EM_ASM({
var w = $0;
var h = $1;
@@ -143,6 +143,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rec
SDL3.ctx.putImageData(SDL3.image, 0, 0);
}, surface->w, surface->h, surface->pixels, data->canvas_id);
/* *INDENT-ON* */ /* clang-format on */
if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, SDL_TRUE)) {
/* give back control to browser for screen refresh */
@@ -152,9 +153,9 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rec
return 0;
}
void Emscripten_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
void Emscripten_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_FreeSurface(data->surface);
data->surface = NULL;