test/testautomation_render.c
changeset 7176 66cf9f85494e
parent 7172 b3569dff1c6e
child 7191 75360622e65f
equal deleted inserted replaced
7175:45276691c8c8 7176:66cf9f85494e
   111    SDL_Rect rect;
   111    SDL_Rect rect;
   112    SDL_Surface *referenceSurface = NULL;
   112    SDL_Surface *referenceSurface = NULL;
   113    int checkFailCount1;
   113    int checkFailCount1;
   114    int checkFailCount2;
   114    int checkFailCount2;
   115 
   115 
   116    /* Need drawcolour or just skip test. */
   116    /* Need drawcolor or just skip test. */
   117    SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor");
   117    SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor");
   118 
   118 
   119    /* Draw a rectangle. */
   119    /* Draw a rectangle. */
   120    rect.x = 40;
   120    rect.x = 40;
   121    rect.y = 0;
   121    rect.y = 0;
   214    SDL_Surface *referenceSurface = NULL;
   214    SDL_Surface *referenceSurface = NULL;
   215    int checkFailCount1;
   215    int checkFailCount1;
   216    int checkFailCount2;
   216    int checkFailCount2;
   217    int checkFailCount3;
   217    int checkFailCount3;
   218 
   218 
   219    /* Need drawcolour and blendmode or just skip test. */
   219    /* Need drawcolor and blendmode or just skip test. */
   220    SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor");
   220    SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor");
   221    SDLTest_AssertCheck(_hasBlendModes(), "_hasBlendModes");
   221    SDLTest_AssertCheck(_hasBlendModes(), "_hasBlendModes");
   222 
   222 
   223    /* Create some rectangles for each blend mode. */
   223    /* Create some rectangles for each blend mode. */
   224    ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0 );
   224    ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0 );
   361    int taccess, tw, th;
   361    int taccess, tw, th;
   362    int i, j, ni, nj;
   362    int i, j, ni, nj;
   363    int checkFailCount1;
   363    int checkFailCount1;
   364 
   364 
   365 
   365 
   366    /* Need drawcolour or just skip test. */
   366    /* Need drawcolor or just skip test. */
   367    SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor)");
   367    SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor)");
   368 
   368 
   369    /* Create face surface. */
   369    /* Create face surface. */
   370    tface = _loadTestFace();
   370    tface = _loadTestFace();
   371    SDLTest_AssertCheck(tface != NULL,  "Verify _loadTestFace() result");
   371    SDLTest_AssertCheck(tface != NULL,  "Verify _loadTestFace() result");
   408    return TEST_COMPLETED;
   408    return TEST_COMPLETED;
   409 }
   409 }
   410 
   410 
   411 
   411 
   412 /**
   412 /**
   413  * @brief Blits doing colour tests.
   413  * @brief Blits doing color tests.
   414  *
   414  *
   415  * \sa
   415  * \sa
   416  * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod
   416  * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod
   417  * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy
   417  * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy
   418  * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
   418  * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
   443    rect.w = tw;
   443    rect.w = tw;
   444    rect.h = th;
   444    rect.h = th;
   445    ni     = TESTRENDER_SCREEN_W - tw;
   445    ni     = TESTRENDER_SCREEN_W - tw;
   446    nj     = TESTRENDER_SCREEN_H - th;
   446    nj     = TESTRENDER_SCREEN_H - th;
   447 
   447 
   448    /* Test blitting with colour mod. */
   448    /* Test blitting with color mod. */
   449    checkFailCount1 = 0;
   449    checkFailCount1 = 0;
   450    checkFailCount2 = 0;
   450    checkFailCount2 = 0;
   451    for (j=0; j <= nj; j+=4) {
   451    for (j=0; j <= nj; j+=4) {
   452       for (i=0; i <= ni; i+=4) {
   452       for (i=0; i <= ni; i+=4) {
   453          /* Set colour mod. */
   453          /* Set color mod. */
   454          ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j );
   454          ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j );
   455          if (ret != 0) checkFailCount1++;
   455          if (ret != 0) checkFailCount1++;
   456 
   456 
   457          /* Blitting. */
   457          /* Blitting. */
   458          rect.x = i;
   458          rect.x = i;
   696    checkFailCount3 = 0;
   696    checkFailCount3 = 0;
   697    checkFailCount4 = 0;
   697    checkFailCount4 = 0;
   698    for (j=0; j <= nj; j+=4) {
   698    for (j=0; j <= nj; j+=4) {
   699       for (i=0; i <= ni; i+=4) {
   699       for (i=0; i <= ni; i+=4) {
   700 
   700 
   701          /* Set colour mod. */
   701          /* Set color mod. */
   702          ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j );
   702          ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j );
   703          if (ret != 0) checkFailCount1++;
   703          if (ret != 0) checkFailCount1++;
   704 
   704 
   705          /* Set alpha mod. */
   705          /* Set alpha mod. */
   706          ret = SDL_SetTextureAlphaMod( tface, (100/ni)*i );
   706          ret = SDL_SetTextureAlphaMod( tface, (100/ni)*i );
   750 {
   750 {
   751    return (code == 0);
   751    return (code == 0);
   752 }
   752 }
   753 
   753 
   754 /**
   754 /**
   755  * @brief Test to see if we can vary the draw colour. Helper function.
   755  * @brief Test to see if we can vary the draw color. Helper function.
   756  *
   756  *
   757  * \sa
   757  * \sa
   758  * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor
   758  * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor
   759  * http://wiki.libsdl.org/moin.cgi/SDL_GetRenderDrawColor
   759  * http://wiki.libsdl.org/moin.cgi/SDL_GetRenderDrawColor
   760  */
   760  */
   764    int ret, fail;
   764    int ret, fail;
   765    Uint8 r, g, b, a;
   765    Uint8 r, g, b, a;
   766 
   766 
   767    fail = 0;
   767    fail = 0;
   768 
   768 
   769    /* Set colour. */
   769    /* Set color. */
   770    ret = SDL_SetRenderDrawColor(renderer, 100, 100, 100, 100 );
   770    ret = SDL_SetRenderDrawColor(renderer, 100, 100, 100, 100 );
   771    if (!_isSupported(ret))
   771    if (!_isSupported(ret))
   772       fail = 1;
   772       fail = 1;
   773    ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a );
   773    ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a );
   774    if (!_isSupported(ret))
   774    if (!_isSupported(ret))
   873    return tface;
   873    return tface;
   874 }
   874 }
   875 
   875 
   876 
   876 
   877 /**
   877 /**
   878  * @brief Test to see if can set texture colour mode. Helper function.
   878  * @brief Test to see if can set texture color mode. Helper function.
   879  *
   879  *
   880  * \sa
   880  * \sa
   881  * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod
   881  * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod
   882  * http://wiki.libsdl.org/moin.cgi/SDL_GetTextureColorMod
   882  * http://wiki.libsdl.org/moin.cgi/SDL_GetTextureColorMod
   883  * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
   883  * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
  1014 static int
  1014 static int
  1015 _clearScreen(void)
  1015 _clearScreen(void)
  1016 {
  1016 {
  1017    int ret;
  1017    int ret;
  1018 
  1018 
  1019    /* Set colour. */
  1019    /* Set color. */
  1020    ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE );
  1020    ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE );
  1021    SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
  1021    SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
  1022 
  1022 
  1023    /* Clear screen. */
  1023    /* Clear screen. */
  1024    ret = SDL_RenderFillRect(renderer, NULL );
  1024    ret = SDL_RenderFillRect(renderer, NULL );