diff options
Diffstat (limited to 'contrib/SDL-3.2.8/src/video/dummy')
| -rw-r--r-- | contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents.c | 38 | ||||
| -rw-r--r-- | contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents_c.h | 31 | ||||
| -rw-r--r-- | contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer.c | 78 | ||||
| -rw-r--r-- | contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer_c.h | 31 | ||||
| -rw-r--r-- | contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.c | 182 | ||||
| -rw-r--r-- | contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.h | 28 |
6 files changed, 388 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents.c b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents.c new file mode 100644 index 0000000..2a7cdd4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents.c | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
| 4 | |||
| 5 | This software is provided 'as-is', without any express or implied | ||
| 6 | warranty. In no event will the authors be held liable for any damages | ||
| 7 | arising from the use of this software. | ||
| 8 | |||
| 9 | Permission is granted to anyone to use this software for any purpose, | ||
| 10 | including commercial applications, and to alter it and redistribute it | ||
| 11 | freely, subject to the following restrictions: | ||
| 12 | |||
| 13 | 1. The origin of this software must not be misrepresented; you must not | ||
| 14 | claim that you wrote the original software. If you use this software | ||
| 15 | in a product, an acknowledgment in the product documentation would be | ||
| 16 | appreciated but is not required. | ||
| 17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
| 18 | misrepresented as being the original software. | ||
| 19 | 3. This notice may not be removed or altered from any source distribution. | ||
| 20 | */ | ||
| 21 | #include "SDL_internal.h" | ||
| 22 | |||
| 23 | #ifdef SDL_VIDEO_DRIVER_DUMMY | ||
| 24 | |||
| 25 | /* Being a null driver, there's no event stream. We just define stubs for | ||
| 26 | most of the API. */ | ||
| 27 | |||
| 28 | #include "../../events/SDL_events_c.h" | ||
| 29 | |||
| 30 | #include "SDL_nullvideo.h" | ||
| 31 | #include "SDL_nullevents_c.h" | ||
| 32 | |||
| 33 | void DUMMY_PumpEvents(SDL_VideoDevice *_this) | ||
| 34 | { | ||
| 35 | // do nothing. | ||
| 36 | } | ||
| 37 | |||
| 38 | #endif // SDL_VIDEO_DRIVER_DUMMY | ||
diff --git a/contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents_c.h b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents_c.h new file mode 100644 index 0000000..8baed95 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents_c.h | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
| 4 | |||
| 5 | This software is provided 'as-is', without any express or implied | ||
| 6 | warranty. In no event will the authors be held liable for any damages | ||
| 7 | arising from the use of this software. | ||
| 8 | |||
| 9 | Permission is granted to anyone to use this software for any purpose, | ||
| 10 | including commercial applications, and to alter it and redistribute it | ||
| 11 | freely, subject to the following restrictions: | ||
| 12 | |||
| 13 | 1. The origin of this software must not be misrepresented; you must not | ||
| 14 | claim that you wrote the original software. If you use this software | ||
| 15 | in a product, an acknowledgment in the product documentation would be | ||
| 16 | appreciated but is not required. | ||
| 17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
| 18 | misrepresented as being the original software. | ||
| 19 | 3. This notice may not be removed or altered from any source distribution. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #ifndef SDL_nullevents_c_h_ | ||
| 23 | #define SDL_nullevents_c_h_ | ||
| 24 | |||
| 25 | #include "SDL_internal.h" | ||
| 26 | |||
| 27 | #include "SDL_nullvideo.h" | ||
| 28 | |||
| 29 | extern void DUMMY_PumpEvents(SDL_VideoDevice *_this); | ||
| 30 | |||
| 31 | #endif // SDL_nullevents_c_h_ | ||
diff --git a/contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer.c b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer.c new file mode 100644 index 0000000..f37510c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer.c | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
| 4 | |||
| 5 | This software is provided 'as-is', without any express or implied | ||
| 6 | warranty. In no event will the authors be held liable for any damages | ||
| 7 | arising from the use of this software. | ||
| 8 | |||
| 9 | Permission is granted to anyone to use this software for any purpose, | ||
| 10 | including commercial applications, and to alter it and redistribute it | ||
| 11 | freely, subject to the following restrictions: | ||
| 12 | |||
| 13 | 1. The origin of this software must not be misrepresented; you must not | ||
| 14 | claim that you wrote the original software. If you use this software | ||
| 15 | in a product, an acknowledgment in the product documentation would be | ||
| 16 | appreciated but is not required. | ||
| 17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
| 18 | misrepresented as being the original software. | ||
| 19 | 3. This notice may not be removed or altered from any source distribution. | ||
| 20 | */ | ||
| 21 | #include "SDL_internal.h" | ||
| 22 | |||
| 23 | #ifdef SDL_VIDEO_DRIVER_DUMMY | ||
| 24 | |||
| 25 | #include "../SDL_sysvideo.h" | ||
| 26 | #include "../../SDL_properties_c.h" | ||
| 27 | #include "SDL_nullframebuffer_c.h" | ||
| 28 | |||
| 29 | #define DUMMY_SURFACE "SDL.internal.window.surface" | ||
| 30 | |||
| 31 | |||
| 32 | bool SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch) | ||
| 33 | { | ||
| 34 | SDL_Surface *surface; | ||
| 35 | const SDL_PixelFormat surface_format = SDL_PIXELFORMAT_XRGB8888; | ||
| 36 | int w, h; | ||
| 37 | |||
| 38 | // Create a new framebuffer | ||
| 39 | SDL_GetWindowSizeInPixels(window, &w, &h); | ||
| 40 | surface = SDL_CreateSurface(w, h, surface_format); | ||
| 41 | if (!surface) { | ||
| 42 | return false; | ||
| 43 | } | ||
| 44 | |||
| 45 | // Save the info and return! | ||
| 46 | SDL_SetSurfaceProperty(SDL_GetWindowProperties(window), DUMMY_SURFACE, surface); | ||
| 47 | *format = surface_format; | ||
| 48 | *pixels = surface->pixels; | ||
| 49 | *pitch = surface->pitch; | ||
| 50 | return true; | ||
| 51 | } | ||
| 52 | |||
| 53 | bool SDL_DUMMY_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects) | ||
| 54 | { | ||
| 55 | static int frame_number; | ||
| 56 | SDL_Surface *surface; | ||
| 57 | |||
| 58 | surface = (SDL_Surface *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), DUMMY_SURFACE, NULL); | ||
| 59 | if (!surface) { | ||
| 60 | return SDL_SetError("Couldn't find dummy surface for window"); | ||
| 61 | } | ||
| 62 | |||
| 63 | // Send the data to the display | ||
| 64 | if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DUMMY_SAVE_FRAMES, false)) { | ||
| 65 | char file[128]; | ||
| 66 | (void)SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIu32 "-%8.8d.bmp", | ||
| 67 | SDL_GetWindowID(window), ++frame_number); | ||
| 68 | SDL_SaveBMP(surface, file); | ||
| 69 | } | ||
| 70 | return true; | ||
| 71 | } | ||
| 72 | |||
| 73 | void SDL_DUMMY_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) | ||
| 74 | { | ||
| 75 | SDL_ClearProperty(SDL_GetWindowProperties(window), DUMMY_SURFACE); | ||
| 76 | } | ||
| 77 | |||
| 78 | #endif // SDL_VIDEO_DRIVER_DUMMY | ||
diff --git a/contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer_c.h b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer_c.h new file mode 100644 index 0000000..819b841 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer_c.h | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
| 4 | |||
| 5 | This software is provided 'as-is', without any express or implied | ||
| 6 | warranty. In no event will the authors be held liable for any damages | ||
| 7 | arising from the use of this software. | ||
| 8 | |||
| 9 | Permission is granted to anyone to use this software for any purpose, | ||
| 10 | including commercial applications, and to alter it and redistribute it | ||
| 11 | freely, subject to the following restrictions: | ||
| 12 | |||
| 13 | 1. The origin of this software must not be misrepresented; you must not | ||
| 14 | claim that you wrote the original software. If you use this software | ||
| 15 | in a product, an acknowledgment in the product documentation would be | ||
| 16 | appreciated but is not required. | ||
| 17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
| 18 | misrepresented as being the original software. | ||
| 19 | 3. This notice may not be removed or altered from any source distribution. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #ifndef SDL_nullframebuffer_c_h_ | ||
| 23 | #define SDL_nullframebuffer_c_h_ | ||
| 24 | |||
| 25 | #include "SDL_internal.h" | ||
| 26 | |||
| 27 | extern bool SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch); | ||
| 28 | extern bool SDL_DUMMY_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); | ||
| 29 | extern void SDL_DUMMY_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 30 | |||
| 31 | #endif // SDL_nullframebuffer_c_h_ | ||
diff --git a/contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.c b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.c new file mode 100644 index 0000000..7be4ae1 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.c | |||
| @@ -0,0 +1,182 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
| 4 | |||
| 5 | This software is provided 'as-is', without any express or implied | ||
| 6 | warranty. In no event will the authors be held liable for any damages | ||
| 7 | arising from the use of this software. | ||
| 8 | |||
| 9 | Permission is granted to anyone to use this software for any purpose, | ||
| 10 | including commercial applications, and to alter it and redistribute it | ||
| 11 | freely, subject to the following restrictions: | ||
| 12 | |||
| 13 | 1. The origin of this software must not be misrepresented; you must not | ||
| 14 | claim that you wrote the original software. If you use this software | ||
| 15 | in a product, an acknowledgment in the product documentation would be | ||
| 16 | appreciated but is not required. | ||
| 17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
| 18 | misrepresented as being the original software. | ||
| 19 | 3. This notice may not be removed or altered from any source distribution. | ||
| 20 | */ | ||
| 21 | #include "SDL_internal.h" | ||
| 22 | |||
| 23 | #ifdef SDL_VIDEO_DRIVER_DUMMY | ||
| 24 | |||
| 25 | /* Dummy SDL video driver implementation; this is just enough to make an | ||
| 26 | * SDL-based application THINK it's got a working video driver, for | ||
| 27 | * applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it, | ||
| 28 | * and also for use as a collection of stubs when porting SDL to a new | ||
| 29 | * platform for which you haven't yet written a valid video driver. | ||
| 30 | * | ||
| 31 | * This is also a great way to determine bottlenecks: if you think that SDL | ||
| 32 | * is a performance problem for a given platform, enable this driver, and | ||
| 33 | * then see if your application runs faster without video overhead. | ||
| 34 | * | ||
| 35 | * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion | ||
| 36 | * of this was cut-and-pasted from Stephane Peter's work in the AAlib | ||
| 37 | * SDL video driver. Renamed to "DUMMY" by Sam Lantinga. | ||
| 38 | */ | ||
| 39 | |||
| 40 | #include "../SDL_sysvideo.h" | ||
| 41 | #include "../SDL_pixels_c.h" | ||
| 42 | #include "../../events/SDL_events_c.h" | ||
| 43 | #ifdef SDL_INPUT_LINUXEV | ||
| 44 | #include "../../core/linux/SDL_evdev.h" | ||
| 45 | #endif | ||
| 46 | |||
| 47 | #include "SDL_nullvideo.h" | ||
| 48 | #include "SDL_nullevents_c.h" | ||
| 49 | #include "SDL_nullframebuffer_c.h" | ||
| 50 | |||
| 51 | #define DUMMYVID_DRIVER_NAME "dummy" | ||
| 52 | #define DUMMYVID_DRIVER_EVDEV_NAME "evdev" | ||
| 53 | |||
| 54 | // Initialization/Query functions | ||
| 55 | static bool DUMMY_VideoInit(SDL_VideoDevice *_this); | ||
| 56 | static void DUMMY_VideoQuit(SDL_VideoDevice *_this); | ||
| 57 | |||
| 58 | static bool DUMMY_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) | ||
| 59 | { | ||
| 60 | SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, window->pending.x, window->pending.y); | ||
| 61 | return true; | ||
| 62 | } | ||
| 63 | |||
| 64 | static void DUMMY_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) | ||
| 65 | { | ||
| 66 | SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, window->pending.w, window->pending.h); | ||
| 67 | } | ||
| 68 | |||
| 69 | // DUMMY driver bootstrap functions | ||
| 70 | |||
| 71 | static bool DUMMY_Available(const char *enable_hint) | ||
| 72 | { | ||
| 73 | const char *hint = SDL_GetHint(SDL_HINT_VIDEO_DRIVER); | ||
| 74 | if (hint) { | ||
| 75 | if (SDL_strcmp(hint, enable_hint) == 0) { | ||
| 76 | return true; | ||
| 77 | } | ||
| 78 | } | ||
| 79 | return false; | ||
| 80 | } | ||
| 81 | |||
| 82 | static void DUMMY_DeleteDevice(SDL_VideoDevice *device) | ||
| 83 | { | ||
| 84 | SDL_free(device); | ||
| 85 | } | ||
| 86 | |||
| 87 | static SDL_VideoDevice *DUMMY_InternalCreateDevice(const char *enable_hint) | ||
| 88 | { | ||
| 89 | SDL_VideoDevice *device; | ||
| 90 | |||
| 91 | if (!DUMMY_Available(enable_hint)) { | ||
| 92 | return NULL; | ||
| 93 | } | ||
| 94 | |||
| 95 | // Initialize all variables that we clean on shutdown | ||
| 96 | device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); | ||
| 97 | if (!device) { | ||
| 98 | return NULL; | ||
| 99 | } | ||
| 100 | device->is_dummy = true; | ||
| 101 | |||
| 102 | // Set the function pointers | ||
| 103 | device->VideoInit = DUMMY_VideoInit; | ||
| 104 | device->VideoQuit = DUMMY_VideoQuit; | ||
| 105 | device->PumpEvents = DUMMY_PumpEvents; | ||
| 106 | device->SetWindowSize = DUMMY_SetWindowSize; | ||
| 107 | device->SetWindowPosition = DUMMY_SetWindowPosition; | ||
| 108 | device->CreateWindowFramebuffer = SDL_DUMMY_CreateWindowFramebuffer; | ||
| 109 | device->UpdateWindowFramebuffer = SDL_DUMMY_UpdateWindowFramebuffer; | ||
| 110 | device->DestroyWindowFramebuffer = SDL_DUMMY_DestroyWindowFramebuffer; | ||
| 111 | device->free = DUMMY_DeleteDevice; | ||
| 112 | |||
| 113 | return device; | ||
| 114 | } | ||
| 115 | |||
| 116 | static SDL_VideoDevice *DUMMY_CreateDevice(void) | ||
| 117 | { | ||
| 118 | return DUMMY_InternalCreateDevice(DUMMYVID_DRIVER_NAME); | ||
| 119 | } | ||
| 120 | |||
| 121 | VideoBootStrap DUMMY_bootstrap = { | ||
| 122 | DUMMYVID_DRIVER_NAME, "SDL dummy video driver", | ||
| 123 | DUMMY_CreateDevice, | ||
| 124 | NULL, // no ShowMessageBox implementation | ||
| 125 | false | ||
| 126 | }; | ||
| 127 | |||
| 128 | #ifdef SDL_INPUT_LINUXEV | ||
| 129 | |||
| 130 | static void DUMMY_EVDEV_Poll(SDL_VideoDevice *_this) | ||
| 131 | { | ||
| 132 | (void)_this; | ||
| 133 | SDL_EVDEV_Poll(); | ||
| 134 | } | ||
| 135 | |||
| 136 | static SDL_VideoDevice *DUMMY_EVDEV_CreateDevice(void) | ||
| 137 | { | ||
| 138 | SDL_VideoDevice *device = DUMMY_InternalCreateDevice(DUMMYVID_DRIVER_EVDEV_NAME); | ||
| 139 | if (device) { | ||
| 140 | device->PumpEvents = DUMMY_EVDEV_Poll; | ||
| 141 | } | ||
| 142 | return device; | ||
| 143 | } | ||
| 144 | |||
| 145 | VideoBootStrap DUMMY_evdev_bootstrap = { | ||
| 146 | DUMMYVID_DRIVER_EVDEV_NAME, "SDL dummy video driver with evdev", | ||
| 147 | DUMMY_EVDEV_CreateDevice, | ||
| 148 | NULL, // no ShowMessageBox implementation | ||
| 149 | false | ||
| 150 | }; | ||
| 151 | |||
| 152 | #endif // SDL_INPUT_LINUXEV | ||
| 153 | |||
| 154 | bool DUMMY_VideoInit(SDL_VideoDevice *_this) | ||
| 155 | { | ||
| 156 | SDL_DisplayMode mode; | ||
| 157 | |||
| 158 | // Use a fake 32-bpp desktop mode | ||
| 159 | SDL_zero(mode); | ||
| 160 | mode.format = SDL_PIXELFORMAT_XRGB8888; | ||
| 161 | mode.w = 1024; | ||
| 162 | mode.h = 768; | ||
| 163 | if (SDL_AddBasicVideoDisplay(&mode) == 0) { | ||
| 164 | return false; | ||
| 165 | } | ||
| 166 | |||
| 167 | #ifdef SDL_INPUT_LINUXEV | ||
| 168 | SDL_EVDEV_Init(); | ||
| 169 | #endif | ||
| 170 | |||
| 171 | // We're done! | ||
| 172 | return true; | ||
| 173 | } | ||
| 174 | |||
| 175 | void DUMMY_VideoQuit(SDL_VideoDevice *_this) | ||
| 176 | { | ||
| 177 | #ifdef SDL_INPUT_LINUXEV | ||
| 178 | SDL_EVDEV_Quit(); | ||
| 179 | #endif | ||
| 180 | } | ||
| 181 | |||
| 182 | #endif // SDL_VIDEO_DRIVER_DUMMY | ||
diff --git a/contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.h b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.h new file mode 100644 index 0000000..8a43794 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.h | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
| 4 | |||
| 5 | This software is provided 'as-is', without any express or implied | ||
| 6 | warranty. In no event will the authors be held liable for any damages | ||
| 7 | arising from the use of this software. | ||
| 8 | |||
| 9 | Permission is granted to anyone to use this software for any purpose, | ||
| 10 | including commercial applications, and to alter it and redistribute it | ||
| 11 | freely, subject to the following restrictions: | ||
| 12 | |||
| 13 | 1. The origin of this software must not be misrepresented; you must not | ||
| 14 | claim that you wrote the original software. If you use this software | ||
| 15 | in a product, an acknowledgment in the product documentation would be | ||
| 16 | appreciated but is not required. | ||
| 17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
| 18 | misrepresented as being the original software. | ||
| 19 | 3. This notice may not be removed or altered from any source distribution. | ||
| 20 | */ | ||
| 21 | #include "SDL_internal.h" | ||
| 22 | |||
| 23 | #ifndef SDL_nullvideo_h_ | ||
| 24 | #define SDL_nullvideo_h_ | ||
| 25 | |||
| 26 | #include "../SDL_sysvideo.h" | ||
| 27 | |||
| 28 | #endif // SDL_nullvideo_h_ | ||
