comparison test/automated/surface/surface.c @ 3723:1496cdbb6055 gsoc2009_unit_tests

* Added mixture of blending modes test.
author Edgar Simo <bobbens@gmail.com>
date Thu, 09 Jul 2009 15:01:38 +0000
parents d8772964e402
children 48e2b67bb2de
comparison
equal deleted inserted replaced
3722:d8772964e402 3723:1496cdbb6055
544 SDL_MapRGB( testsur->format, 0, 0, 0 ) ); 544 SDL_MapRGB( testsur->format, 0, 0, 0 ) );
545 if (SDL_ATassert( "SDL_FillRect", ret == 0)) 545 if (SDL_ATassert( "SDL_FillRect", ret == 0))
546 return; 546 return;
547 547
548 /* Loop blit. */ 548 /* Loop blit. */
549 for (j=0; j <= testsur->h - face->h; j+=4) { 549 for (j=0; j <= nj; j+=4) {
550 for (i=0; i <= testsur->w - face->w; i+=4) { 550 for (i=0; i <= ni; i+=4) {
551 551
552 /* Set colour mod. */ 552 /* Set colour mod. */
553 ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j ); 553 ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j );
554 if (SDL_ATassert( "SDL_SetSurfaceColorMod", ret == 0)) 554 if (SDL_ATassert( "SDL_SetSurfaceColorMod", ret == 0))
555 return; 555 return;
556 556
557 /* Set alpha mod. */ 557 /* Set alpha mod. */
558 ret = SDL_SetSurfaceAlphaMod( face, (255/ni)*i ); 558 ret = SDL_SetSurfaceAlphaMod( face, (100/ni)*i );
559 if (SDL_ATassert( "SDL_SetSurfaceAlphaMod", ret == 0)) 559 if (SDL_ATassert( "SDL_SetSurfaceAlphaMod", ret == 0))
560 return; 560 return;
561 561
562 /* Crazy blending mode magic. */ 562 /* Crazy blending mode magic. */
563 mode = (i*j)%5; 563 mode = (i/4*j/4) % 4;
564 if (mode==0) mode = SDL_BLENDMODE_NONE; 564 if (mode==0) mode = SDL_BLENDMODE_MASK;
565 else if (mode==1) mode = SDL_BLENDMODE_MASK; 565 else if (mode==1) mode = SDL_BLENDMODE_BLEND;
566 else if (mode==2) mode = SDL_BLENDMODE_BLEND; 566 else if (mode==2) mode = SDL_BLENDMODE_ADD;
567 else if (mode==3) mode = SDL_BLENDMODE_ADD; 567 else if (mode==3) mode = SDL_BLENDMODE_MOD;
568 else if (mode==4) mode = SDL_BLENDMODE_MOD;
569 ret = SDL_SetSurfaceBlendMode( face, mode ); 568 ret = SDL_SetSurfaceBlendMode( face, mode );
570 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0)) 569 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
571 return; 570 return;
572 571
573 /* Blitting. */ 572 /* Blitting. */
577 if (SDL_ATassert( "SDL_BlitSurface", ret == 0)) 576 if (SDL_ATassert( "SDL_BlitSurface", ret == 0))
578 return; 577 return;
579 } 578 }
580 } 579 }
581 580
582 SDL_SaveBMP( testsur, "blit.bmp" ); 581 /* Check to see if matches. */
582 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLEND_*).",
583 surface_compare( testsur, &img_blendAll )==0 ))
584 return;
583 585
584 /* Clean up. */ 586 /* Clean up. */
585 SDL_FreeSurface( face ); 587 SDL_FreeSurface( face );
586 SDL_FreeSurface( testsur ); 588 SDL_FreeSurface( testsur );
587 589