Added a function to clean up test text drawing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
diff --git a/include/SDL_test_font.h b/include/SDL_test_font.h
index 4927629..434e808 100644
--- a/include/SDL_test_font.h
+++ b/include/SDL_test_font.h
@@ -50,7 +50,7 @@ extern "C" {
*
* \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.
@@ -62,9 +62,14 @@ int SDLTest_DrawCharacter( SDL_Renderer *renderer, int x, int y, char c );
*
* \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++ */
#ifdef __cplusplus
}
diff --git a/src/test/SDL_test_assert.c b/src/test/SDL_test_assert.c
index f41f620..5362201 100644
--- a/src/test/SDL_test_assert.c
+++ b/src/test/SDL_test_assert.c
@@ -148,3 +148,5 @@ int SDLTest_AssertSummaryToTestResult()
}
}
}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/test/SDL_test_compare.c b/src/test/SDL_test_compare.c
index bd13670..af1b102 100644
--- a/src/test/SDL_test_compare.c
+++ b/src/test/SDL_test_compare.c
@@ -113,3 +113,5 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface,
return ret;
}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/test/SDL_test_crc32.c b/src/test/SDL_test_crc32.c
index a6ef959..a8878ea 100644
--- a/src/test/SDL_test_crc32.c
+++ b/src/test/SDL_test_crc32.c
@@ -164,3 +164,5 @@ int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext)
return 0;
}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/test/SDL_test_font.c b/src/test/SDL_test_font.c
index f608986..21c6220 100644
--- a/src/test/SDL_test_font.c
+++ b/src/test/SDL_test_font.c
@@ -3116,9 +3116,9 @@ static SDL_Texture *SDLTest_CharTextureCache[256];
int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
{
- const Uint32 charWidth = FONT_CHARACTER_SIZE;
- const Uint32 charHeight = FONT_CHARACTER_SIZE;
- const Uint32 charSize = FONT_CHARACTER_SIZE;
+ const Uint32 charWidth = FONT_CHARACTER_SIZE;
+ const Uint32 charHeight = FONT_CHARACTER_SIZE;
+ const Uint32 charSize = FONT_CHARACTER_SIZE;
SDL_Rect srect;
SDL_Rect drect;
int result;
@@ -3133,16 +3133,16 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
Uint8 r, g, b, a;
/*
- * Setup source rectangle
- */
+ * Setup source rectangle
+ */
srect.x = 0;
srect.y = 0;
srect.w = charWidth;
srect.h = charHeight;
/*
- * Setup destination rectangle
- */
+ * Setup destination rectangle
+ */
drect.x = x;
drect.y = y;
drect.w = charWidth;
@@ -3152,12 +3152,12 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, 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) {
/*
- * Redraw character into surface
- */
+ * Redraw character into surface
+ */
character = SDL_CreateRGBSurface(SDL_SWSURFACE,
charWidth, charHeight, 32,
0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
@@ -3170,8 +3170,8 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
pitch = character->pitch;
/*
- * Drawing loop
- */
+ * Drawing loop
+ */
patt = 0;
for (iy = 0; iy < charWidth; iy++) {
mask = 0x00;
@@ -3196,24 +3196,24 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
SDL_FreeSurface(character);
/*
- * Check pointer
- */
+ * Check pointer
+ */
if (SDLTest_CharTextureCache[ci] == NULL) {
return (-1);
}
}
/*
- * Set color
- */
+ * Set color
+ */
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);
/*
- * Draw texture onto destination
- */
+ * Draw texture onto destination
+ */
result |= SDL_RenderCopy(renderer, SDLTest_CharTextureCache[ci], &srect, &drect);
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)
{
- const Uint32 charWidth = FONT_CHARACTER_SIZE;
+ const Uint32 charWidth = FONT_CHARACTER_SIZE;
int result = 0;
int curx = x;
int cury = y;
@@ -3236,3 +3236,15 @@ int SDLTest_DrawString(SDL_Renderer * renderer, int x, int y, const char *s)
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: */
diff --git a/src/test/SDL_test_fuzzer.c b/src/test/SDL_test_fuzzer.c
index e6ae988..4b38100 100644
--- a/src/test/SDL_test_fuzzer.c
+++ b/src/test/SDL_test_fuzzer.c
@@ -524,3 +524,5 @@ SDLTest_RandomAsciiStringOfSize(int size)
return string;
}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c
index 5374190..f4d557b 100644
--- a/src/test/SDL_test_harness.c
+++ b/src/test/SDL_test_harness.c
@@ -676,3 +676,5 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
SDLTest_Log("Exit code: %d", runResult);
return runResult;
}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/test/SDL_test_imageBlit.c b/src/test/SDL_test_imageBlit.c
index 0b452fd..8906763 100644
--- a/src/test/SDL_test_imageBlit.c
+++ b/src/test/SDL_test_imageBlit.c
@@ -1555,3 +1555,5 @@ SDL_Surface *SDLTest_ImageBlitAlpha()
);
return surface;
}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/test/SDL_test_imageBlitBlend.c b/src/test/SDL_test_imageBlitBlend.c
index e8135a7..657ab8a 100644
--- a/src/test/SDL_test_imageBlitBlend.c
+++ b/src/test/SDL_test_imageBlitBlend.c
@@ -2841,3 +2841,5 @@ SDL_Surface *SDLTest_ImageBlitBlendAll()
);
return surface;
}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/test/SDL_test_imageFace.c b/src/test/SDL_test_imageFace.c
index ea81ab4..b633e97 100644
--- a/src/test/SDL_test_imageFace.c
+++ b/src/test/SDL_test_imageFace.c
@@ -244,3 +244,4 @@ SDL_Surface *SDLTest_ImageFace()
return surface;
}
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/test/SDL_test_imagePrimitives.c b/src/test/SDL_test_imagePrimitives.c
index f1e9a17..0b7e510 100644
--- a/src/test/SDL_test_imagePrimitives.c
+++ b/src/test/SDL_test_imagePrimitives.c
@@ -510,3 +510,5 @@ SDL_Surface *SDLTest_ImagePrimitives()
);
return surface;
}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/test/SDL_test_imagePrimitivesBlend.c b/src/test/SDL_test_imagePrimitivesBlend.c
index 121d24c..32cc234 100644
--- a/src/test/SDL_test_imagePrimitivesBlend.c
+++ b/src/test/SDL_test_imagePrimitivesBlend.c
@@ -692,3 +692,5 @@ SDL_Surface *SDLTest_ImagePrimitivesBlend()
);
return surface;
}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/test/SDL_test_log.c b/src/test/SDL_test_log.c
index 9a9ce66..4495411 100644
--- a/src/test/SDL_test_log.c
+++ b/src/test/SDL_test_log.c
@@ -114,3 +114,5 @@ void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
/* Log with timestamp and newline */
SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_ERROR, "%s: %s", SDLTest_TimestampToString(time(0)), logMessage);
}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/test/SDL_test_md5.c b/src/test/SDL_test_md5.c
index fb31901..73da473 100644
--- a/src/test/SDL_test_md5.c
+++ b/src/test/SDL_test_md5.c
@@ -334,3 +334,5 @@ static void SDLTest_Md5Transform(MD5UINT4 * buf, MD5UINT4 * in)
buf[2] += c;
buf[3] += d;
}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/test/SDL_test_random.c b/src/test/SDL_test_random.c
index 25840c6..68f60a6 100644
--- a/src/test/SDL_test_random.c
+++ b/src/test/SDL_test_random.c
@@ -92,3 +92,5 @@ unsigned int SDLTest_Random(SDLTest_RandomContext * rndContext)
rndContext->c++;
return (rndContext->x);
}
+
+/* vi: set ts=4 sw=4 expandtab: */