early-access version 2281

This commit is contained in:
pineappleEA
2021-12-07 02:20:09 +01:00
parent c2ae6d480a
commit c4fa174d53
591 changed files with 36978 additions and 18653 deletions

View File

@@ -104,7 +104,7 @@ void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,
/* Log pass message */
SDLTest_AssertsPassed++;
SDLTest_Log(SDLTEST_ASSERT_CHECK_FORMAT, logMessage, "Pass");
SDLTest_Log(SDLTEST_ASSERT_CHECK_FORMAT, logMessage, "Passed");
}
/*

View File

@@ -37,7 +37,8 @@ static const char *video_usage[] = {
"[--scale N]", "[--depth N]", "[--refresh R]", "[--vsync]", "[--noframe]",
"[--resizable]", "[--minimize]", "[--maximize]", "[--grab]", "[--keyboard-grab]",
"[--shown]", "[--hidden]", "[--input-focus]", "[--mouse-focus]",
"[--flash-on-focus-loss]", "[--allow-highdpi]", "[--usable-bounds]"
"[--flash-on-focus-loss]", "[--allow-highdpi]", "[--confine-cursor X,Y,W,H]",
"[--usable-bounds]"
};
static const char *audio_usage[] = {
@@ -296,6 +297,34 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index)
state->window_y = SDL_atoi(y);
return 2;
}
if (SDL_strcasecmp(argv[index], "--confine-cursor") == 0) {
char *x, *y, *w, *h;
++index;
if (!argv[index]) {
return -1;
}
x = argv[index];
y = argv[index];
#define SEARCHARG(dim) \
while (*dim && *dim != ',') { \
++dim; \
} \
if (!*dim) { \
return -1; \
} \
*dim++ = '\0';
SEARCHARG(y)
w = y;
SEARCHARG(w)
h = w;
SEARCHARG(h)
#undef SEARCHARG
state->confine.x = SDL_atoi(x);
state->confine.y = SDL_atoi(y);
state->confine.w = SDL_atoi(w);
state->confine.h = SDL_atoi(h);
return 2;
}
if (SDL_strcasecmp(argv[index], "--usable-bounds") == 0) {
/* !!! FIXME: this is a bit of a hack, but I don't want to add a
!!! FIXME: flag to the public structure in 2.0.x */
@@ -1289,6 +1318,10 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
SDL_ShowWindow(state->windows[i]);
if (!SDL_RectEmpty(&state->confine)) {
SDL_SetWindowMouseRect(state->windows[i], &state->confine);
}
if (!state->skip_renderer
&& (state->renderdriver
|| !(state->window_flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_VULKAN | SDL_WINDOW_METAL)))) {
@@ -1440,10 +1473,18 @@ SDLTest_PrintEvent(SDL_Event * event)
switch (event->type) {
case SDL_DISPLAYEVENT:
switch (event->display.event) {
case SDL_DISPLAYEVENT_CONNECTED:
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " connected",
event->display.display);
break;
case SDL_DISPLAYEVENT_ORIENTATION:
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " changed orientation to %s",
event->display.display, DisplayOrientationName(event->display.data1));
break;
case SDL_DISPLAYEVENT_DISCONNECTED:
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " disconnected",
event->display.display);
break;
default:
SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " got unknown event 0x%4.4x",
event->display.display, event->display.event);
@@ -2019,6 +2060,20 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done)
SDL_SetRelativeMouseMode(!SDL_GetRelativeMouseMode() ? SDL_TRUE : SDL_FALSE);
}
break;
case SDLK_t:
if (withControl) {
/* Ctrl-T toggle topmost mode */
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
if (window) {
Uint32 flags = SDL_GetWindowFlags(window);
if (flags & SDL_WINDOW_ALWAYS_ON_TOP) {
SDL_SetWindowAlwaysOnTop(window, SDL_FALSE);
} else {
SDL_SetWindowAlwaysOnTop(window, SDL_TRUE);
}
}
}
break;
case SDLK_z:
if (withControl) {
/* Ctrl-Z minimize */
@@ -2178,7 +2233,7 @@ SDLTest_CommonQuit(SDLTest_CommonState * state)
}
void
SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window)
SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window, int * usedHeight)
{
char text[1024];
int textY = 0;
@@ -2187,11 +2242,37 @@ SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window)
SDL_Rect rect;
SDL_DisplayMode mode;
float ddpi, hdpi, vdpi;
float scaleX, scaleY;
Uint32 flags;
const int windowDisplayIndex = SDL_GetWindowDisplayIndex(window);
SDL_RendererInfo info;
/* Video */
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
SDLTest_DrawString(renderer, 0, textY, "-- Video --");
textY += lineHeight;
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
SDL_snprintf(text, sizeof(text), "SDL_GetCurrentVideoDriver: %s", SDL_GetCurrentVideoDriver());
SDLTest_DrawString(renderer, 0, textY, text);
textY += lineHeight;
/* Renderer */
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
SDLTest_DrawString(renderer, 0, textY, "-- Renderer --");
textY += lineHeight;
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
if (0 == SDL_GetRendererInfo(renderer, &info)) {
SDL_snprintf(text, sizeof(text), "SDL_GetRendererInfo: name: %s", info.name);
SDLTest_DrawString(renderer, 0, textY, text);
textY += lineHeight;
}
if (0 == SDL_GetRendererOutputSize(renderer, &w, &h)) {
SDL_snprintf(text, sizeof(text), "SDL_GetRendererOutputSize: %dx%d", w, h);
SDLTest_DrawString(renderer, 0, textY, text);
@@ -2204,11 +2285,25 @@ SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window)
SDLTest_DrawString(renderer, 0, textY, text);
textY += lineHeight;
SDL_RenderGetScale(renderer, &scaleX, &scaleY);
SDL_snprintf(text, sizeof(text), "SDL_RenderGetScale: %f,%f",
scaleX, scaleY);
SDLTest_DrawString(renderer, 0, textY, text);
textY += lineHeight;
SDL_RenderGetLogicalSize(renderer, &w, &h);
SDL_snprintf(text, sizeof(text), "SDL_RenderGetLogicalSize: %dx%d", w, h);
SDLTest_DrawString(renderer, 0, textY, text);
textY += lineHeight;
/* Window */
SDLTest_DrawString(renderer, 0, textY, "----");
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
SDLTest_DrawString(renderer, 0, textY, "-- Window --");
textY += lineHeight;
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
SDL_GetWindowPosition(window, &x, &y);
SDL_snprintf(text, sizeof(text), "SDL_GetWindowPosition: %d,%d", x, y);
SDLTest_DrawString(renderer, 0, textY, text);
@@ -2224,11 +2319,21 @@ SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window)
SDLTest_DrawString(renderer, 0, textY, text);
textY += lineHeight;
if (0 == SDL_GetWindowDisplayMode(window, &mode)) {
SDL_snprintf(text, sizeof(text), "SDL_GetWindowDisplayMode: %dx%d@%dHz (%s)",
mode.w, mode.h, mode.refresh_rate, SDL_GetPixelFormatName(mode.format));
SDLTest_DrawString(renderer, 0, textY, text);
textY += lineHeight;
}
/* Display */
SDLTest_DrawString(renderer, 0, textY, "----");
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
SDLTest_DrawString(renderer, 0, textY, "-- Display --");
textY += lineHeight;
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
SDL_snprintf(text, sizeof(text), "SDL_GetWindowDisplayIndex: %d", windowDisplayIndex);
SDLTest_DrawString(renderer, 0, textY, text);
textY += lineHeight;
@@ -2272,9 +2377,12 @@ SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window)
/* Mouse */
SDLTest_DrawString(renderer, 0, textY, "----");
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
SDLTest_DrawString(renderer, 0, textY, "-- Mouse --");
textY += lineHeight;
SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255);
flags = SDL_GetMouseState(&x, &y);
SDL_snprintf(text, sizeof(text), "SDL_GetMouseState: %d,%d ", x, y);
SDLTest_PrintButtonMask(text, sizeof(text), flags);
@@ -2286,6 +2394,10 @@ SDLTest_CommonDrawWindowInfo(SDL_Renderer * renderer, SDL_Window * window)
SDLTest_PrintButtonMask(text, sizeof(text), flags);
SDLTest_DrawString(renderer, 0, textY, text);
textY += lineHeight;
if (usedHeight) {
*usedHeight = textY;
}
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -3109,10 +3109,16 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = {
/* ---- Character */
struct SDLTest_CharTextureCache {
SDL_Renderer* renderer;
SDL_Texture* charTextureCache[256];
struct SDLTest_CharTextureCache* next;
};
/*!
\brief Global cache for 8x8 pixel font textures created at runtime.
\brief List of per-renderer caches for 8x8 pixel font textures created at runtime.
*/
static SDL_Texture *SDLTest_CharTextureCache[256];
static struct SDLTest_CharTextureCache *SDLTest_CharTextureCacheList;
int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
{
@@ -3131,6 +3137,7 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
SDL_Surface *character;
Uint32 ci;
Uint8 r, g, b, a;
struct SDLTest_CharTextureCache *cache;
/*
* Setup source rectangle
@@ -3151,10 +3158,25 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
/* Character index in cache */
ci = (unsigned char)c;
/* Search for this renderer's cache */
for (cache = SDLTest_CharTextureCacheList; cache != NULL; cache = cache->next) {
if (cache->renderer == renderer) {
break;
}
}
/* Allocate a new cache for this renderer if needed */
if (cache == NULL) {
cache = (struct SDLTest_CharTextureCache*)SDL_calloc(1, sizeof(struct SDLTest_CharTextureCache));
cache->renderer = renderer;
cache->next = SDLTest_CharTextureCacheList;
SDLTest_CharTextureCacheList = cache;
}
/*
* Create new charWidth x charHeight bitmap surface if not already present.
*/
if (SDLTest_CharTextureCache[ci] == NULL) {
if (cache->charTextureCache[ci] == NULL) {
/*
* Redraw character into surface
*/
@@ -3191,14 +3213,15 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
linepos += pitch;
}
/* Convert temp surface into texture */
SDLTest_CharTextureCache[ci] = SDL_CreateTextureFromSurface(renderer, character);
cache->charTextureCache[ci] = SDL_CreateTextureFromSurface(renderer, character);
SDL_FreeSurface(character);
/*
* Check pointer
*/
if (SDLTest_CharTextureCache[ci] == NULL) {
if (cache->charTextureCache[ci] == NULL) {
return (-1);
}
}
@@ -3208,13 +3231,13 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
*/
result = 0;
result |= SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a);
result |= SDL_SetTextureColorMod(SDLTest_CharTextureCache[ci], r, g, b);
result |= SDL_SetTextureAlphaMod(SDLTest_CharTextureCache[ci], a);
result |= SDL_SetTextureColorMod(cache->charTextureCache[ci], r, g, b);
result |= SDL_SetTextureAlphaMod(cache->charTextureCache[ci], a);
/*
* Draw texture onto destination
*/
result |= SDL_RenderCopy(renderer, SDLTest_CharTextureCache[ci], &srect, &drect);
result |= SDL_RenderCopy(renderer, cache->charTextureCache[ci], &srect, &drect);
return (result);
}
@@ -3239,12 +3262,23 @@ int SDLTest_DrawString(SDL_Renderer * renderer, int x, int y, const char *s)
void SDLTest_CleanupTextDrawing(void)
{
unsigned int i;
for (i = 0; i < SDL_arraysize(SDLTest_CharTextureCache); ++i) {
if (SDLTest_CharTextureCache[i]) {
SDL_DestroyTexture(SDLTest_CharTextureCache[i]);
SDLTest_CharTextureCache[i] = NULL;
struct SDLTest_CharTextureCache* cache, *next;
cache = SDLTest_CharTextureCacheList;
do {
for (i = 0; i < SDL_arraysize(cache->charTextureCache); ++i) {
if (cache->charTextureCache[i]) {
SDL_DestroyTexture(cache->charTextureCache[i]);
cache->charTextureCache[i] = NULL;
}
}
}
next = cache->next;
SDL_free(cache);
cache = next;
} while (cache);
SDLTest_CharTextureCacheList = NULL;
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -98,7 +98,7 @@ SDLTest_GenerateRunSeed(const int length)
*
*/
static Uint64
SDLTest_GenerateExecKey(const char *runSeed, char *suiteName, char *testName, int iteration)
SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName, const char *testName, int iteration)
{
SDLTest_Md5Context md5Context;
Uint64 *keys;
@@ -240,7 +240,7 @@ SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, const SDLTest_TestCaseRef
return TEST_RESULT_SETUP_FAILURE;
}
if (!testCase->enabled && forceTestRun == SDL_FALSE)
if (!testCase->enabled && forceTestRun == SDL_FALSE)
{
SDLTest_Log(SDLTEST_FINAL_RESULT_FORMAT, "Test", testCase->name, "Skipped (Disabled)");
return TEST_RESULT_SKIPPED;
@@ -316,7 +316,7 @@ SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, const SDLTest_TestCaseRef
}
/* Prints summary of all suites/tests contained in the given reference */
#if 0
#if 0
static void SDLTest_LogTestSuiteSummary(SDLTest_TestSuiteReference *testSuites)
{
int suiteCounter;
@@ -377,8 +377,8 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
SDLTest_TestSuiteReference *testSuite;
const SDLTest_TestCaseReference *testCase;
const char *runSeed = NULL;
char *currentSuiteName;
char *currentTestName;
const char *currentSuiteName;
const char *currentTestName;
Uint64 execKey;
float runStartSeconds;
float suiteStartSeconds;
@@ -388,10 +388,10 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
float testEndSeconds;
float runtime;
int suiteFilter = 0;
char *suiteFilterName = NULL;
const char *suiteFilterName = NULL;
int testFilter = 0;
char *testFilterName = NULL;
SDL_bool forceTestRun = SDL_FALSE;
const char *testFilterName = NULL;
SDL_bool forceTestRun = SDL_FALSE;
int testResult = 0;
int runResult = 0;
int totalTestFailedCount = 0;
@@ -419,7 +419,6 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
runSeed = userRunSeed;
}
/* Reset per-run counters */
totalTestFailedCount = 0;
totalTestPassedCount = 0;
@@ -431,7 +430,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
/* Log run with fuzzer parameters */
SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed);
/* Count the total number of tests */
/* Count the total number of tests */
suiteCounter = 0;
while (testSuites[suiteCounter]) {
testSuite = testSuites[suiteCounter];
@@ -440,17 +439,17 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
while (testSuite->testCases[testCounter])
{
testCounter++;
totalNumberOfTests++;
}
}
totalNumberOfTests++;
}
}
/* Pre-allocate an array for tracking failed tests (potentially all test cases) */
failedTests = (const SDLTest_TestCaseReference **)SDL_malloc(totalNumberOfTests * sizeof(SDLTest_TestCaseReference *));
if (failedTests == NULL) {
SDLTest_LogError("Unable to allocate cache for failed tests");
SDL_Error(SDL_ENOMEM);
/* Pre-allocate an array for tracking failed tests (potentially all test cases) */
failedTests = (const SDLTest_TestCaseReference **)SDL_malloc(totalNumberOfTests * sizeof(SDLTest_TestCaseReference *));
if (failedTests == NULL) {
SDLTest_LogError("Unable to allocate cache for failed tests");
SDL_Error(SDL_ENOMEM);
return -1;
}
}
/* Initialize filtering */
if (filter != NULL && filter[0] != '\0') {
@@ -542,7 +541,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
/* Override 'disabled' flag if we specified a test filter (i.e. force run for debugging) */
if (testFilter == 1 && !testCase->enabled) {
SDLTest_Log("Force run of disabled test since test filter was set");
forceTestRun = SDL_TRUE;
forceTestRun = SDL_TRUE;
}
/* Take time - test start */
@@ -571,7 +570,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
}
SDLTest_Log("Test Iteration %i: execKey %" SDL_PRIu64, iterationCounter, execKey);
testResult = SDLTest_RunTest(testSuite, testCase, execKey, forceTestRun);
testResult = SDLTest_RunTest(testSuite, testCase, execKey, forceTestRun);
if (testResult == TEST_RESULT_PASSED) {
testPassedCount++;

View File

@@ -26,6 +26,7 @@
#include "SDL_test_memory.h"
#ifdef HAVE_LIBUNWIND_H
#define UNW_LOCAL_ONLY
#include <libunwind.h>
#endif
@@ -103,13 +104,13 @@ static void SDL_TrackAllocation(void *mem, size_t size)
stack_index = 0;
while (unw_step(&cursor) > 0) {
unw_word_t offset, pc;
char sym[256];
char sym[236];
unw_get_reg(&cursor, UNW_REG_IP, &pc);
entry->stack[stack_index] = pc;
if (unw_get_proc_name(&cursor, sym, sizeof(sym), &offset) == 0) {
snprintf(entry->stack_names[stack_index], sizeof(entry->stack_names[stack_index]), "%s+0x%llx", sym, (unsigned long long)offset);
SDL_snprintf(entry->stack_names[stack_index], sizeof(entry->stack_names[stack_index]), "%s+0x%llx", sym, (unsigned long long)offset);
}
++stack_index;

View File

@@ -83,7 +83,8 @@ unsigned int SDLTest_Random(SDLTest_RandomContext * rndContext)
if (rndContext==NULL) return -1;
xh = rndContext->x >> 16, xl = rndContext->x & 65535;
xh = rndContext->x >> 16;
xl = rndContext->x & 65535;
rndContext->x = rndContext->x * rndContext->a + rndContext->c;
rndContext->c =
xh * rndContext->ah + ((xh * rndContext->al) >> 16) +