Added a function to clean up test text drawing
authorSam Lantinga <slouken@libsdl.org>
Fri, 08 Sep 2017 04:14:05 -0700
changeset 114659843b1895c45
parent 11464 5af6d801e51f
child 11466 b24819a2250b
Added a function to clean up test text drawing
include/SDL_test_font.h
src/test/SDL_test_assert.c
src/test/SDL_test_compare.c
src/test/SDL_test_crc32.c
src/test/SDL_test_font.c
src/test/SDL_test_fuzzer.c
src/test/SDL_test_harness.c
src/test/SDL_test_imageBlit.c
src/test/SDL_test_imageBlitBlend.c
src/test/SDL_test_imageFace.c
src/test/SDL_test_imagePrimitives.c
src/test/SDL_test_imagePrimitivesBlend.c
src/test/SDL_test_log.c
src/test/SDL_test_md5.c
src/test/SDL_test_random.c
     1.1 --- a/include/SDL_test_font.h	Thu Sep 07 10:56:08 2017 -0400
     1.2 +++ b/include/SDL_test_font.h	Fri Sep 08 04:14:05 2017 -0700
     1.3 @@ -50,7 +50,7 @@
     1.4   *
     1.5   *  \returns Returns 0 on success, -1 on failure.
     1.6   */
     1.7 -int SDLTest_DrawCharacter( SDL_Renderer *renderer, int x, int y, char c );
     1.8 +int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c);
     1.9  
    1.10  /**
    1.11   *  \brief Draw a string in the currently set font.
    1.12 @@ -62,9 +62,14 @@
    1.13   *
    1.14   *  \returns Returns 0 on success, -1 on failure.
    1.15   */
    1.16 -int SDLTest_DrawString( SDL_Renderer * renderer, int x, int y, const char *s );
    1.17 +int SDLTest_DrawString(SDL_Renderer *renderer, int x, int y, const char *s);
    1.18  
    1.19  
    1.20 +/**
    1.21 + *  \brief Cleanup textures used by font drawing functions.
    1.22 + */
    1.23 +void SDLTest_CleanupTextDrawing(SDL_Renderer *renderer);
    1.24 +
    1.25  /* Ends C function definitions when using C++ */
    1.26  #ifdef __cplusplus
    1.27  }
     2.1 --- a/src/test/SDL_test_assert.c	Thu Sep 07 10:56:08 2017 -0400
     2.2 +++ b/src/test/SDL_test_assert.c	Fri Sep 08 04:14:05 2017 -0700
     2.3 @@ -148,3 +148,5 @@
     2.4          }
     2.5      }
     2.6  }
     2.7 +
     2.8 +/* vi: set ts=4 sw=4 expandtab: */
     3.1 --- a/src/test/SDL_test_compare.c	Thu Sep 07 10:56:08 2017 -0400
     3.2 +++ b/src/test/SDL_test_compare.c	Fri Sep 08 04:14:05 2017 -0700
     3.3 @@ -113,3 +113,5 @@
     3.4  
     3.5     return ret;
     3.6  }
     3.7 +
     3.8 +/* vi: set ts=4 sw=4 expandtab: */
     4.1 --- a/src/test/SDL_test_crc32.c	Thu Sep 07 10:56:08 2017 -0400
     4.2 +++ b/src/test/SDL_test_crc32.c	Fri Sep 08 04:14:05 2017 -0700
     4.3 @@ -164,3 +164,5 @@
     4.4  
     4.5    return 0;
     4.6  }
     4.7 +
     4.8 +/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/test/SDL_test_font.c	Thu Sep 07 10:56:08 2017 -0400
     5.2 +++ b/src/test/SDL_test_font.c	Fri Sep 08 04:14:05 2017 -0700
     5.3 @@ -3116,9 +3116,9 @@
     5.4  
     5.5  int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c)
     5.6  {
     5.7 -	const Uint32 charWidth = FONT_CHARACTER_SIZE;
     5.8 -	const Uint32 charHeight = FONT_CHARACTER_SIZE;
     5.9 -	const Uint32 charSize = FONT_CHARACTER_SIZE;
    5.10 +    const Uint32 charWidth = FONT_CHARACTER_SIZE;
    5.11 +    const Uint32 charHeight = FONT_CHARACTER_SIZE;
    5.12 +    const Uint32 charSize = FONT_CHARACTER_SIZE;
    5.13      SDL_Rect srect;
    5.14      SDL_Rect drect;
    5.15      int result;
    5.16 @@ -3133,16 +3133,16 @@
    5.17      Uint8 r, g, b, a;
    5.18  
    5.19      /*
    5.20 -    * Setup source rectangle
    5.21 -    */
    5.22 +     * Setup source rectangle
    5.23 +     */
    5.24      srect.x = 0;
    5.25      srect.y = 0;
    5.26      srect.w = charWidth;
    5.27      srect.h = charHeight;
    5.28  
    5.29      /*
    5.30 -    * Setup destination rectangle
    5.31 -    */
    5.32 +     * Setup destination rectangle
    5.33 +     */
    5.34      drect.x = x;
    5.35      drect.y = y;
    5.36      drect.w = charWidth;
    5.37 @@ -3152,12 +3152,12 @@
    5.38      ci = (unsigned char)c;
    5.39  
    5.40      /*
    5.41 -    * Create new charWidth x charHeight bitmap surface if not already present.
    5.42 -    */
    5.43 +     * Create new charWidth x charHeight bitmap surface if not already present.
    5.44 +     */
    5.45      if (SDLTest_CharTextureCache[ci] == NULL) {
    5.46          /*
    5.47 -        * Redraw character into surface
    5.48 -        */
    5.49 +         * Redraw character into surface
    5.50 +         */
    5.51          character = SDL_CreateRGBSurface(SDL_SWSURFACE,
    5.52              charWidth, charHeight, 32,
    5.53              0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
    5.54 @@ -3170,8 +3170,8 @@
    5.55          pitch = character->pitch;
    5.56  
    5.57          /*
    5.58 -        * Drawing loop
    5.59 -        */
    5.60 +         * Drawing loop
    5.61 +         */
    5.62          patt = 0;
    5.63          for (iy = 0; iy < charWidth; iy++) {
    5.64              mask = 0x00;
    5.65 @@ -3196,24 +3196,24 @@
    5.66          SDL_FreeSurface(character);
    5.67  
    5.68          /*
    5.69 -        * Check pointer
    5.70 -        */
    5.71 +         * Check pointer
    5.72 +         */
    5.73          if (SDLTest_CharTextureCache[ci] == NULL) {
    5.74              return (-1);
    5.75          }
    5.76      }
    5.77  
    5.78      /*
    5.79 -    * Set color
    5.80 -    */
    5.81 +     * Set color
    5.82 +     */
    5.83      result = 0;
    5.84      result |= SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a);
    5.85      result |= SDL_SetTextureColorMod(SDLTest_CharTextureCache[ci], r, g, b);
    5.86      result |= SDL_SetTextureAlphaMod(SDLTest_CharTextureCache[ci], a);
    5.87  
    5.88      /*
    5.89 -    * Draw texture onto destination
    5.90 -    */
    5.91 +     * Draw texture onto destination
    5.92 +     */
    5.93      result |= SDL_RenderCopy(renderer, SDLTest_CharTextureCache[ci], &srect, &drect);
    5.94  
    5.95      return (result);
    5.96 @@ -3221,7 +3221,7 @@
    5.97  
    5.98  int SDLTest_DrawString(SDL_Renderer * renderer, int x, int y, const char *s)
    5.99  {
   5.100 -	const Uint32 charWidth = FONT_CHARACTER_SIZE;
   5.101 +    const Uint32 charWidth = FONT_CHARACTER_SIZE;
   5.102      int result = 0;
   5.103      int curx = x;
   5.104      int cury = y;
   5.105 @@ -3236,3 +3236,15 @@
   5.106      return (result);
   5.107  }
   5.108  
   5.109 +void SDLTest_CleanupTextDrawing(SDL_Renderer *renderer)
   5.110 +{
   5.111 +    int i;
   5.112 +    for (i = 0; i < SDL_ARRAYSIZE(SDLTest_CharTextureCache); ++i) {
   5.113 +        if (SDLTest_CharTextureCache[i]) {
   5.114 +            SDL_TextureDestroy(SDLTest_CharTextureCache[i]);
   5.115 +            SDLTest_CharTextureCache[i] = NULL;
   5.116 +        }
   5.117 +    }
   5.118 +}
   5.119 +
   5.120 +/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/test/SDL_test_fuzzer.c	Thu Sep 07 10:56:08 2017 -0400
     6.2 +++ b/src/test/SDL_test_fuzzer.c	Fri Sep 08 04:14:05 2017 -0700
     6.3 @@ -524,3 +524,5 @@
     6.4  
     6.5      return string;
     6.6  }
     6.7 +
     6.8 +/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/test/SDL_test_harness.c	Thu Sep 07 10:56:08 2017 -0400
     7.2 +++ b/src/test/SDL_test_harness.c	Fri Sep 08 04:14:05 2017 -0700
     7.3 @@ -676,3 +676,5 @@
     7.4      SDLTest_Log("Exit code: %d", runResult);
     7.5      return runResult;
     7.6  }
     7.7 +
     7.8 +/* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/test/SDL_test_imageBlit.c	Thu Sep 07 10:56:08 2017 -0400
     8.2 +++ b/src/test/SDL_test_imageBlit.c	Fri Sep 08 04:14:05 2017 -0700
     8.3 @@ -1555,3 +1555,5 @@
     8.4           );
     8.5     return surface;
     8.6  }
     8.7 +
     8.8 +/* vi: set ts=4 sw=4 expandtab: */
     9.1 --- a/src/test/SDL_test_imageBlitBlend.c	Thu Sep 07 10:56:08 2017 -0400
     9.2 +++ b/src/test/SDL_test_imageBlitBlend.c	Fri Sep 08 04:14:05 2017 -0700
     9.3 @@ -2841,3 +2841,5 @@
     9.4           );
     9.5     return surface;
     9.6  }
     9.7 +
     9.8 +/* vi: set ts=4 sw=4 expandtab: */
    10.1 --- a/src/test/SDL_test_imageFace.c	Thu Sep 07 10:56:08 2017 -0400
    10.2 +++ b/src/test/SDL_test_imageFace.c	Fri Sep 08 04:14:05 2017 -0700
    10.3 @@ -244,3 +244,4 @@
    10.4     return surface;
    10.5  }
    10.6  
    10.7 +/* vi: set ts=4 sw=4 expandtab: */
    11.1 --- a/src/test/SDL_test_imagePrimitives.c	Thu Sep 07 10:56:08 2017 -0400
    11.2 +++ b/src/test/SDL_test_imagePrimitives.c	Fri Sep 08 04:14:05 2017 -0700
    11.3 @@ -510,3 +510,5 @@
    11.4           );
    11.5     return surface;
    11.6  }
    11.7 +
    11.8 +/* vi: set ts=4 sw=4 expandtab: */
    12.1 --- a/src/test/SDL_test_imagePrimitivesBlend.c	Thu Sep 07 10:56:08 2017 -0400
    12.2 +++ b/src/test/SDL_test_imagePrimitivesBlend.c	Fri Sep 08 04:14:05 2017 -0700
    12.3 @@ -692,3 +692,5 @@
    12.4           );
    12.5     return surface;
    12.6  }
    12.7 +
    12.8 +/* vi: set ts=4 sw=4 expandtab: */
    13.1 --- a/src/test/SDL_test_log.c	Thu Sep 07 10:56:08 2017 -0400
    13.2 +++ b/src/test/SDL_test_log.c	Fri Sep 08 04:14:05 2017 -0700
    13.3 @@ -114,3 +114,5 @@
    13.4      /* Log with timestamp and newline */
    13.5      SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_ERROR, "%s: %s", SDLTest_TimestampToString(time(0)), logMessage);
    13.6  }
    13.7 +
    13.8 +/* vi: set ts=4 sw=4 expandtab: */
    14.1 --- a/src/test/SDL_test_md5.c	Thu Sep 07 10:56:08 2017 -0400
    14.2 +++ b/src/test/SDL_test_md5.c	Fri Sep 08 04:14:05 2017 -0700
    14.3 @@ -334,3 +334,5 @@
    14.4    buf[2] += c;
    14.5    buf[3] += d;
    14.6  }
    14.7 +
    14.8 +/* vi: set ts=4 sw=4 expandtab: */
    15.1 --- a/src/test/SDL_test_random.c	Thu Sep 07 10:56:08 2017 -0400
    15.2 +++ b/src/test/SDL_test_random.c	Fri Sep 08 04:14:05 2017 -0700
    15.3 @@ -92,3 +92,5 @@
    15.4      rndContext->c++;
    15.5    return (rndContext->x);
    15.6  }
    15.7 +
    15.8 +/* vi: set ts=4 sw=4 expandtab: */