Added a function to clean up test text drawing
parent
ca15c7d67f
commit
b0b3da7702
|
@ -50,7 +50,7 @@ extern "C" {
|
||||||
*
|
*
|
||||||
* \returns Returns 0 on success, -1 on failure.
|
* \returns Returns 0 on success, -1 on failure.
|
||||||
*/
|
*/
|
||||||
int SDLTest_DrawCharacter( SDL_Renderer *renderer, int x, int y, char c );
|
int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Draw a string in the currently set font.
|
* \brief Draw a string in the currently set font.
|
||||||
|
@ -62,9 +62,14 @@ int SDLTest_DrawCharacter( SDL_Renderer *renderer, int x, int y, char c );
|
||||||
*
|
*
|
||||||
* \returns Returns 0 on success, -1 on failure.
|
* \returns Returns 0 on success, -1 on failure.
|
||||||
*/
|
*/
|
||||||
int SDLTest_DrawString( SDL_Renderer * renderer, int x, int y, const char *s );
|
int SDLTest_DrawString(SDL_Renderer *renderer, int x, int y, const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Cleanup textures used by font drawing functions.
|
||||||
|
*/
|
||||||
|
void SDLTest_CleanupTextDrawing(SDL_Renderer *renderer);
|
||||||
|
|
||||||
/* Ends C function definitions when using C++ */
|
/* Ends C function definitions when using C++ */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,3 +148,5 @@ int SDLTest_AssertSummaryToTestResult()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -113,3 +113,5 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface,
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -164,3 +164,5 @@ int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -3116,9 +3116,9 @@ static SDL_Texture *SDLTest_CharTextureCache[256];
|
||||||
|
|
||||||
int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
|
int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
|
||||||
{
|
{
|
||||||
const Uint32 charWidth = FONT_CHARACTER_SIZE;
|
const Uint32 charWidth = FONT_CHARACTER_SIZE;
|
||||||
const Uint32 charHeight = FONT_CHARACTER_SIZE;
|
const Uint32 charHeight = FONT_CHARACTER_SIZE;
|
||||||
const Uint32 charSize = FONT_CHARACTER_SIZE;
|
const Uint32 charSize = FONT_CHARACTER_SIZE;
|
||||||
SDL_Rect srect;
|
SDL_Rect srect;
|
||||||
SDL_Rect drect;
|
SDL_Rect drect;
|
||||||
int result;
|
int result;
|
||||||
|
@ -3133,16 +3133,16 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
|
||||||
Uint8 r, g, b, a;
|
Uint8 r, g, b, a;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup source rectangle
|
* Setup source rectangle
|
||||||
*/
|
*/
|
||||||
srect.x = 0;
|
srect.x = 0;
|
||||||
srect.y = 0;
|
srect.y = 0;
|
||||||
srect.w = charWidth;
|
srect.w = charWidth;
|
||||||
srect.h = charHeight;
|
srect.h = charHeight;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup destination rectangle
|
* Setup destination rectangle
|
||||||
*/
|
*/
|
||||||
drect.x = x;
|
drect.x = x;
|
||||||
drect.y = y;
|
drect.y = y;
|
||||||
drect.w = charWidth;
|
drect.w = charWidth;
|
||||||
|
@ -3152,12 +3152,12 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
|
||||||
ci = (unsigned char)c;
|
ci = (unsigned char)c;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create new charWidth x charHeight bitmap surface if not already present.
|
* Create new charWidth x charHeight bitmap surface if not already present.
|
||||||
*/
|
*/
|
||||||
if (SDLTest_CharTextureCache[ci] == NULL) {
|
if (SDLTest_CharTextureCache[ci] == NULL) {
|
||||||
/*
|
/*
|
||||||
* Redraw character into surface
|
* Redraw character into surface
|
||||||
*/
|
*/
|
||||||
character = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
character = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
||||||
charWidth, charHeight, 32,
|
charWidth, charHeight, 32,
|
||||||
0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
|
0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
|
||||||
|
@ -3170,8 +3170,8 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
|
||||||
pitch = character->pitch;
|
pitch = character->pitch;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Drawing loop
|
* Drawing loop
|
||||||
*/
|
*/
|
||||||
patt = 0;
|
patt = 0;
|
||||||
for (iy = 0; iy < charWidth; iy++) {
|
for (iy = 0; iy < charWidth; iy++) {
|
||||||
mask = 0x00;
|
mask = 0x00;
|
||||||
|
@ -3196,24 +3196,24 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
|
||||||
SDL_FreeSurface(character);
|
SDL_FreeSurface(character);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check pointer
|
* Check pointer
|
||||||
*/
|
*/
|
||||||
if (SDLTest_CharTextureCache[ci] == NULL) {
|
if (SDLTest_CharTextureCache[ci] == NULL) {
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set color
|
* Set color
|
||||||
*/
|
*/
|
||||||
result = 0;
|
result = 0;
|
||||||
result |= SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a);
|
result |= SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a);
|
||||||
result |= SDL_SetTextureColorMod(SDLTest_CharTextureCache[ci], r, g, b);
|
result |= SDL_SetTextureColorMod(SDLTest_CharTextureCache[ci], r, g, b);
|
||||||
result |= SDL_SetTextureAlphaMod(SDLTest_CharTextureCache[ci], a);
|
result |= SDL_SetTextureAlphaMod(SDLTest_CharTextureCache[ci], a);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Draw texture onto destination
|
* Draw texture onto destination
|
||||||
*/
|
*/
|
||||||
result |= SDL_RenderCopy(renderer, SDLTest_CharTextureCache[ci], &srect, &drect);
|
result |= SDL_RenderCopy(renderer, SDLTest_CharTextureCache[ci], &srect, &drect);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
|
@ -3221,7 +3221,7 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
|
||||||
|
|
||||||
int SDLTest_DrawString(SDL_Renderer * renderer, int x, int y, const char *s)
|
int SDLTest_DrawString(SDL_Renderer * renderer, int x, int y, const char *s)
|
||||||
{
|
{
|
||||||
const Uint32 charWidth = FONT_CHARACTER_SIZE;
|
const Uint32 charWidth = FONT_CHARACTER_SIZE;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
int curx = x;
|
int curx = x;
|
||||||
int cury = y;
|
int cury = y;
|
||||||
|
@ -3236,3 +3236,15 @@ int SDLTest_DrawString(SDL_Renderer * renderer, int x, int y, const char *s)
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDLTest_CleanupTextDrawing(SDL_Renderer *renderer)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < SDL_ARRAYSIZE(SDLTest_CharTextureCache); ++i) {
|
||||||
|
if (SDLTest_CharTextureCache[i]) {
|
||||||
|
SDL_TextureDestroy(SDLTest_CharTextureCache[i]);
|
||||||
|
SDLTest_CharTextureCache[i] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -524,3 +524,5 @@ SDLTest_RandomAsciiStringOfSize(int size)
|
||||||
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -676,3 +676,5 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
|
||||||
SDLTest_Log("Exit code: %d", runResult);
|
SDLTest_Log("Exit code: %d", runResult);
|
||||||
return runResult;
|
return runResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -1555,3 +1555,5 @@ SDL_Surface *SDLTest_ImageBlitAlpha()
|
||||||
);
|
);
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -2841,3 +2841,5 @@ SDL_Surface *SDLTest_ImageBlitBlendAll()
|
||||||
);
|
);
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -244,3 +244,4 @@ SDL_Surface *SDLTest_ImageFace()
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -510,3 +510,5 @@ SDL_Surface *SDLTest_ImagePrimitives()
|
||||||
);
|
);
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -692,3 +692,5 @@ SDL_Surface *SDLTest_ImagePrimitivesBlend()
|
||||||
);
|
);
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -114,3 +114,5 @@ void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
/* Log with timestamp and newline */
|
/* Log with timestamp and newline */
|
||||||
SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_ERROR, "%s: %s", SDLTest_TimestampToString(time(0)), logMessage);
|
SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_ERROR, "%s: %s", SDLTest_TimestampToString(time(0)), logMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -334,3 +334,5 @@ static void SDLTest_Md5Transform(MD5UINT4 * buf, MD5UINT4 * in)
|
||||||
buf[2] += c;
|
buf[2] += c;
|
||||||
buf[3] += d;
|
buf[3] += d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -92,3 +92,5 @@ unsigned int SDLTest_Random(SDLTest_RandomContext * rndContext)
|
||||||
rndContext->c++;
|
rndContext->c++;
|
||||||
return (rndContext->x);
|
return (rndContext->x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
Loading…
Reference in New Issue