Made texture size and format public in the API

Also added refcount to textures so they can be retained by application code.
This commit is contained in:
Sam Lantinga 2024-09-30 20:40:54 -07:00
parent 5136b30652
commit 1f3a0d12e6
8 changed files with 76 additions and 66 deletions

View file

@ -239,8 +239,7 @@ static int SDLCALL render_testBlit(void *arg)
SDL_FRect rect;
SDL_Texture *tface;
SDL_Surface *referenceSurface = NULL;
float tw, th;
float i, j, ni, nj;
int i, j, ni, nj;
int checkFailCount1;
/* Clear surface. */
@ -257,19 +256,18 @@ static int SDLCALL render_testBlit(void *arg)
}
/* Constant values. */
CHECK_FUNC(SDL_GetTextureSize, (tface, &tw, &th))
rect.w = tw;
rect.h = th;
ni = TESTRENDER_SCREEN_W - tw;
nj = TESTRENDER_SCREEN_H - th;
rect.w = (float)tface->w;
rect.h = (float)tface->h;
ni = TESTRENDER_SCREEN_W - tface->w;
nj = TESTRENDER_SCREEN_H - tface->h;
/* Loop blit. */
checkFailCount1 = 0;
for (j = 0; j <= nj; j += 4) {
for (i = 0; i <= ni; i += 4) {
/* Blitting. */
rect.x = i;
rect.y = j;
rect.x = (float)i;
rect.y = (float)j;
ret = SDL_RenderTexture(renderer, tface, NULL, &rect);
if (!ret) {
checkFailCount1++;
@ -631,7 +629,6 @@ static int SDLCALL render_testBlitColor(void *arg)
SDL_FRect rect;
SDL_Texture *tface;
SDL_Surface *referenceSurface = NULL;
float tw, th;
int i, j, ni, nj;
int checkFailCount1;
int checkFailCount2;
@ -647,11 +644,10 @@ static int SDLCALL render_testBlitColor(void *arg)
}
/* Constant values. */
CHECK_FUNC(SDL_GetTextureSize, (tface, &tw, &th))
rect.w = tw;
rect.h = th;
ni = TESTRENDER_SCREEN_W - (int)tw;
nj = TESTRENDER_SCREEN_H - (int)th;
rect.w = (float)tface->w;
rect.h = (float)tface->h;
ni = TESTRENDER_SCREEN_W - tface->w;
nj = TESTRENDER_SCREEN_H - tface->h;
/* Test blitting with color mod. */
checkFailCount1 = 0;
@ -1423,7 +1419,6 @@ static int SDLCALL render_testUVWrapping(void *arg)
SDL_Vertex vertices[6];
SDL_Vertex *verts = vertices;
SDL_FColor color = { 1.0f, 1.0f, 1.0f, 1.0f };
float tw, th;
SDL_FRect rect;
float min_U = -0.5f;
float max_U = 1.5f;
@ -1442,11 +1437,10 @@ static int SDLCALL render_testUVWrapping(void *arg)
return TEST_ABORTED;
}
CHECK_FUNC(SDL_GetTextureSize, (tface, &tw, &th))
rect.w = tw * 2;
rect.h = th * 2;
rect.x = (TESTRENDER_SCREEN_W - rect.w) / 2;
rect.y = (TESTRENDER_SCREEN_H - rect.h) / 2;
rect.w = (float)tface->w * 2;
rect.h = (float)tface->h * 2;
rect.x = (float)(TESTRENDER_SCREEN_W - rect.w) / 2;
rect.y = (float)(TESTRENDER_SCREEN_H - rect.h) / 2;
/*
* 0--1