Mercurial > sdl-ios-xcode
comparison test/automated/render/render.c @ 3445:de72b49bb695
Refactored to use render_loadTestFace()
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 18 Nov 2009 07:34:05 +0000 |
parents | 50fca98abc24 |
children | 7bd010656baf |
comparison
equal
deleted
inserted
replaced
3444:50fca98abc24 | 3445:de72b49bb695 |
---|---|
541 */ | 541 */ |
542 static int render_testBlit (void) | 542 static int render_testBlit (void) |
543 { | 543 { |
544 int ret; | 544 int ret; |
545 SDL_Rect rect; | 545 SDL_Rect rect; |
546 SDL_Surface *face; | |
547 SDL_TextureID tface; | 546 SDL_TextureID tface; |
548 int i, j, ni, nj; | 547 int i, j, ni, nj; |
549 | 548 |
550 /* Clear surface. */ | 549 /* Clear surface. */ |
551 if (render_clearScreen()) | 550 if (render_clearScreen()) |
554 /* Need drawcolour or just skip test. */ | 553 /* Need drawcolour or just skip test. */ |
555 if (!render_hasDrawColor()) | 554 if (!render_hasDrawColor()) |
556 return 0; | 555 return 0; |
557 | 556 |
558 /* Create face surface. */ | 557 /* Create face surface. */ |
559 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, | 558 tface = render_loadTestFace(); |
560 img_face.width, img_face.height, 32, img_face.width*4, | 559 if (SDL_ATassert( "render_loadTestFace()", tface != 0)) |
561 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) | |
562 0xff000000, /* Red bit mask. */ | |
563 0x00ff0000, /* Green bit mask. */ | |
564 0x0000ff00, /* Blue bit mask. */ | |
565 0x000000ff /* Alpha bit mask. */ | |
566 #else | |
567 0x000000ff, /* Red bit mask. */ | |
568 0x0000ff00, /* Green bit mask. */ | |
569 0x00ff0000, /* Blue bit mask. */ | |
570 0xff000000 /* Alpha bit mask. */ | |
571 #endif | |
572 ); | |
573 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL)) | |
574 return -1; | |
575 tface = SDL_CreateTextureFromSurface( 0, face ); | |
576 if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0)) | |
577 return -1; | 560 return -1; |
578 | 561 |
579 /* Constant values. */ | 562 /* Constant values. */ |
580 rect.w = face->w; | 563 rect.w = img_face.width; |
581 rect.h = face->h; | 564 rect.h = img_face.height; |
582 ni = SCREEN_W - face->w; | 565 ni = SCREEN_W - img_face.width; |
583 nj = SCREEN_H - face->h; | 566 nj = SCREEN_H - img_face.height; |
584 | |
585 /* Clean up. */ | |
586 SDL_FreeSurface( face ); | |
587 | 567 |
588 /* Loop blit. */ | 568 /* Loop blit. */ |
589 for (j=0; j <= nj; j+=4) { | 569 for (j=0; j <= nj; j+=4) { |
590 for (i=0; i <= ni; i+=4) { | 570 for (i=0; i <= ni; i+=4) { |
591 /* Blitting. */ | 571 /* Blitting. */ |
613 */ | 593 */ |
614 static int render_testBlitColour (void) | 594 static int render_testBlitColour (void) |
615 { | 595 { |
616 int ret; | 596 int ret; |
617 SDL_Rect rect; | 597 SDL_Rect rect; |
618 SDL_Surface *face; | |
619 SDL_TextureID tface; | 598 SDL_TextureID tface; |
620 int i, j, ni, nj; | 599 int i, j, ni, nj; |
621 | 600 |
622 /* Clear surface. */ | 601 /* Clear surface. */ |
623 if (render_clearScreen()) | 602 if (render_clearScreen()) |
626 /* Need drawcolour or just skip test. */ | 605 /* Need drawcolour or just skip test. */ |
627 if (!render_hasTexColor()) | 606 if (!render_hasTexColor()) |
628 return 0; | 607 return 0; |
629 | 608 |
630 /* Create face surface. */ | 609 /* Create face surface. */ |
631 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, | 610 tface = render_loadTestFace(); |
632 img_face.width, img_face.height, 32, img_face.width*4, | 611 if (SDL_ATassert( "render_loadTestFace()", tface != 0)) |
633 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) | |
634 0xff000000, /* Red bit mask. */ | |
635 0x00ff0000, /* Green bit mask. */ | |
636 0x0000ff00, /* Blue bit mask. */ | |
637 0x000000ff /* Alpha bit mask. */ | |
638 #else | |
639 0x000000ff, /* Red bit mask. */ | |
640 0x0000ff00, /* Green bit mask. */ | |
641 0x00ff0000, /* Blue bit mask. */ | |
642 0xff000000 /* Alpha bit mask. */ | |
643 #endif | |
644 ); | |
645 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL)) | |
646 return -1; | |
647 tface = SDL_CreateTextureFromSurface( 0, face ); | |
648 if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0)) | |
649 return -1; | 612 return -1; |
650 | 613 |
651 /* Constant values. */ | 614 /* Constant values. */ |
652 rect.w = face->w; | 615 rect.w = img_face.width; |
653 rect.h = face->h; | 616 rect.h = img_face.height; |
654 ni = SCREEN_W - face->w; | 617 ni = SCREEN_W - img_face.width; |
655 nj = SCREEN_H - face->h; | 618 nj = SCREEN_H - img_face.height; |
656 | |
657 /* Clean up. */ | |
658 SDL_FreeSurface( face ); | |
659 | 619 |
660 /* Test blitting with colour mod. */ | 620 /* Test blitting with colour mod. */ |
661 for (j=0; j <= nj; j+=4) { | 621 for (j=0; j <= nj; j+=4) { |
662 for (i=0; i <= ni; i+=4) { | 622 for (i=0; i <= ni; i+=4) { |
663 /* Set colour mod. */ | 623 /* Set colour mod. */ |
691 */ | 651 */ |
692 static int render_testBlitAlpha (void) | 652 static int render_testBlitAlpha (void) |
693 { | 653 { |
694 int ret; | 654 int ret; |
695 SDL_Rect rect; | 655 SDL_Rect rect; |
696 SDL_Surface *face; | |
697 SDL_TextureID tface; | 656 SDL_TextureID tface; |
698 int i, j, ni, nj; | 657 int i, j, ni, nj; |
699 | 658 |
700 /* Clear surface. */ | 659 /* Clear surface. */ |
701 if (render_clearScreen()) | 660 if (render_clearScreen()) |
704 /* Need alpha or just skip test. */ | 663 /* Need alpha or just skip test. */ |
705 if (!render_hasTexAlpha()) | 664 if (!render_hasTexAlpha()) |
706 return 0; | 665 return 0; |
707 | 666 |
708 /* Create face surface. */ | 667 /* Create face surface. */ |
709 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, | 668 tface = render_loadTestFace(); |
710 img_face.width, img_face.height, 32, img_face.width*4, | 669 if (SDL_ATassert( "render_loadTestFace()", tface != 0)) |
711 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) | |
712 0xff000000, /* Red bit mask. */ | |
713 0x00ff0000, /* Green bit mask. */ | |
714 0x0000ff00, /* Blue bit mask. */ | |
715 0x000000ff /* Alpha bit mask. */ | |
716 #else | |
717 0x000000ff, /* Red bit mask. */ | |
718 0x0000ff00, /* Green bit mask. */ | |
719 0x00ff0000, /* Blue bit mask. */ | |
720 0xff000000 /* Alpha bit mask. */ | |
721 #endif | |
722 ); | |
723 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL)) | |
724 return -1; | |
725 tface = SDL_CreateTextureFromSurface( 0, face ); | |
726 if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0)) | |
727 return -1; | 670 return -1; |
728 | 671 |
729 /* Constant values. */ | 672 /* Constant values. */ |
730 rect.w = face->w; | 673 rect.w = img_face.width; |
731 rect.h = face->h; | 674 rect.h = img_face.height; |
732 ni = SCREEN_W - face->w; | 675 ni = SCREEN_W - img_face.width; |
733 nj = SCREEN_H - face->h; | 676 nj = SCREEN_H - img_face.height; |
734 | |
735 /* Clean up. */ | |
736 SDL_FreeSurface( face ); | |
737 | 677 |
738 /* Clear surface. */ | 678 /* Clear surface. */ |
739 if (render_clearScreen()) | 679 if (render_clearScreen()) |
740 return -1; | 680 return -1; |
741 | 681 |
815 */ | 755 */ |
816 static int render_testBlitBlend (void) | 756 static int render_testBlitBlend (void) |
817 { | 757 { |
818 int ret; | 758 int ret; |
819 SDL_Rect rect; | 759 SDL_Rect rect; |
820 SDL_Surface *face; | |
821 SDL_TextureID tface; | 760 SDL_TextureID tface; |
822 int i, j, ni, nj; | 761 int i, j, ni, nj; |
823 int mode; | 762 int mode; |
824 | 763 |
825 /* Clear surface. */ | 764 /* Clear surface. */ |
829 /* Need drawcolour and blendmode or just skip test. */ | 768 /* Need drawcolour and blendmode or just skip test. */ |
830 if (!render_hasBlendModes() || !render_hasTexColor() || !render_hasTexAlpha()) | 769 if (!render_hasBlendModes() || !render_hasTexColor() || !render_hasTexAlpha()) |
831 return 0; | 770 return 0; |
832 | 771 |
833 /* Create face surface. */ | 772 /* Create face surface. */ |
834 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, | 773 tface = render_loadTestFace(); |
835 img_face.width, img_face.height, 32, img_face.width*4, | 774 if (SDL_ATassert( "render_loadTestFace()", tface != 0)) |
836 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) | |
837 0xff000000, /* Red bit mask. */ | |
838 0x00ff0000, /* Green bit mask. */ | |
839 0x0000ff00, /* Blue bit mask. */ | |
840 0x000000ff /* Alpha bit mask. */ | |
841 #else | |
842 0x000000ff, /* Red bit mask. */ | |
843 0x0000ff00, /* Green bit mask. */ | |
844 0x00ff0000, /* Blue bit mask. */ | |
845 0xff000000 /* Alpha bit mask. */ | |
846 #endif | |
847 ); | |
848 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL)) | |
849 return -1; | |
850 tface = SDL_CreateTextureFromSurface( 0, face ); | |
851 if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0)) | |
852 return -1; | 775 return -1; |
853 | 776 |
854 /* Steps to take. */ | 777 /* Steps to take. */ |
855 ni = SCREEN_W - FACE_W; | 778 ni = SCREEN_W - FACE_W; |
856 nj = SCREEN_H - FACE_H; | 779 nj = SCREEN_H - FACE_H; |
857 | 780 |
858 /* Constant values. */ | 781 /* Constant values. */ |
859 rect.w = face->w; | 782 rect.w = img_face.width; |
860 rect.h = face->h; | 783 rect.h = img_face.height; |
861 | |
862 /* Clean up. */ | |
863 SDL_FreeSurface( face ); | |
864 | 784 |
865 /* Set alpha mod. */ | 785 /* Set alpha mod. */ |
866 ret = SDL_SetRenderDrawColor( 255, 255, 255, 100 ); | 786 ret = SDL_SetRenderDrawColor( 255, 255, 255, 100 ); |
867 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) | 787 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0)) |
868 return -1; | 788 return -1; |