test/test-automation/testsurface/testsurface.c
author Markus Kauppila <markus.kauppila@gmail.com>
Tue, 12 Jul 2011 23:53:57 +0300
changeset 5757 a97102f40230
parent 5756 3581346510f3
child 5760 735407c0bda3
permissions -rw-r--r--
Plain logger logs the used command line options.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     1
/**
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     2
 * Original code: automated SDL surface test written by Edgar Simo "bobbens"
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     3
 */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     4
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     5
#include <stdio.h>
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     6
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     7
#include <SDL/SDL.h>
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     8
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     9
#include "../SDL_test.h"
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    10
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    11
#include <sys/stat.h>
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    12
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    13
/* Test case references */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    14
static const TestCaseReference test1 =
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    15
		(TestCaseReference){ "surface_testLoad", "Tests sprite loading.", TEST_ENABLED, 0, 0};
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    16
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    17
static const TestCaseReference test2 =
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    18
		(TestCaseReference){ "surface_testBlit", "Tests some blitting routines.", TEST_ENABLED, 0, 0};
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    19
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    20
static const TestCaseReference test3 =
5757
a97102f40230 Plain logger logs the used command line options.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5756
diff changeset
    21
		(TestCaseReference){ "surface_testBlitBlendNone", "Tests blitting routines with none blending.", TEST_ENABLED, 0, 0};
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    22
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
    23
static const TestCaseReference test4 =
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
    24
		(TestCaseReference){ "surface_testLoadFailure", "Tests sprite loading. A failure case.", TEST_ENABLED, 0, 0};
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
    25
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    26
static const TestCaseReference test5 =
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    27
		(TestCaseReference){ "surface_testConversion", "Tests sprite conversion.", TEST_ENABLED, 0, 0};
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    28
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    29
static const TestCaseReference test6 =
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    30
		(TestCaseReference){ "surface_testBlitColorMod", "Tests some blitting routines with color mod.", TEST_ENABLED, 0, 0};
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    31
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    32
static const TestCaseReference test7 =
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    33
		(TestCaseReference){ "surface_testBlitAlphaMod", "Tests some blitting routines with alpha mod.", TEST_ENABLED, 0, 0};
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    34
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    35
static const TestCaseReference test8 =
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    36
		(TestCaseReference){ "surface_testBlitBlendLoop", "Test blittin routines with blending", TEST_ENABLED, 0, 0};
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    37
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    38
static const TestCaseReference test9 =
5757
a97102f40230 Plain logger logs the used command line options.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5756
diff changeset
    39
		(TestCaseReference){ "surface_testBlitBlendBlend", "Tests blitting routines with blend blending.", TEST_ENABLED, 0, 0};
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    40
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    41
static const TestCaseReference test10 =
5757
a97102f40230 Plain logger logs the used command line options.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5756
diff changeset
    42
		(TestCaseReference){ "surface_testBlitBlendAdd", "Tests blitting routines with add blending.", TEST_ENABLED, 0, 0};
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    43
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    44
static const TestCaseReference test11 =
5757
a97102f40230 Plain logger logs the used command line options.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5756
diff changeset
    45
		(TestCaseReference){ "surface_testBlitBlendMod", "Tests blitting routines with modblending.", TEST_ENABLED, 0, 0};
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    46
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    47
/* Test suite */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    48
extern const TestCaseReference *testSuite[] =  {
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    49
	&test1, &test2, &test3, &test4, &test5,
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
    50
	&test6, &test7, &test8, &test9, &test10, &test11, NULL
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    51
};
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    52
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    53
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    54
TestCaseReference **QueryTestSuite() {
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    55
	return (TestCaseReference **)testSuite;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    56
}
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    57
5755
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    58
/* Function prototypes */
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    59
SDL_Surface *_CreateTestSurface();
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    60
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    61
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    62
/* Create test fixture */
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    63
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    64
static SDL_Surface *testsur = NULL;
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    65
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    66
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    67
void
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    68
SetUp(void *arg)
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    69
{
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    70
	int ret = SDL_Init(SDL_INIT_VIDEO);
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    71
	AssertTrue(ret == 0, "SDL_Init(SDL_INIT_VIDEO)");
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    72
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    73
	testsur = _CreateTestSurface();
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    74
	AssertTrue(testsur != NULL, "SDL_Init(SDL_INIT_VIDEO)");
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    75
}
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    76
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    77
void
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    78
TearDown(void *arg)
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    79
{
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    80
	SDL_FreeSurface( testsur );
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    81
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    82
	SDL_Quit();
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    83
}
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    84
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
    85
/* Helper functions for the test cases */
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
    86
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
    87
#define TEST_SURFACE_WIDTH 80
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
    88
#define TEST_SURFACE_HEIGHT 60
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    89
5755
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
    90
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    91
/*!
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    92
 * Creates test surface
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    93
 */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    94
SDL_Surface *
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
    95
_CreateTestSurface()
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
    96
{
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
    97
	SDL_Surface *testsur = NULL;
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    98
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    99
	/* Create the test surface. */
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   100
	testsur = SDL_CreateRGBSurface( 0,
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   101
			TEST_SURFACE_WIDTH, TEST_SURFACE_HEIGHT, 32,
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   102
			RMASK, GMASK, BMASK, AMASK );
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   103
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   104
	if(testsur->w != TEST_SURFACE_WIDTH) {
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   105
		AssertFail("Test surface width doesn't match");
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   106
	}
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   107
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   108
	if(testsur->h != TEST_SURFACE_HEIGHT) {
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   109
		AssertFail("Test surface height doesn't match");
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   110
	}
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   111
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   112
	AssertTrue(testsur != NULL, "SDL_CreateRGBSurface");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   113
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   114
	return testsur;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   115
}
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   116
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   117
/*!
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   118
 * Create test surface from in-memory image
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   119
 */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   120
SDL_Surface *
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   121
_createTestSurfaceFromMemory()
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   122
{
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   123
	SDL_Surface *face = NULL;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   124
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   125
	/* Create face surface. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   126
	face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   127
		  img_face.width, img_face.height, 32, img_face.width*4,
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   128
	#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   129
		  0xff000000, /* Red bit mask. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   130
		  0x00ff0000, /* Green bit mask. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   131
		  0x0000ff00, /* Blue bit mask. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   132
		  0x000000ff /* Alpha bit mask. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   133
	#else
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   134
		  0x000000ff, /* Red bit mask. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   135
		  0x0000ff00, /* Green bit mask. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   136
		  0x00ff0000, /* Blue bit mask. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   137
		  0xff000000 /* Alpha bit mask. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   138
	#endif
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   139
		  );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   140
	AssertTrue(face != NULL, "SDL_CreateRGBSurfaceFrom");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   141
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   142
	return face;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   143
}
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   144
5751
cbb921210496 Bunch of little fixes.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5750
diff changeset
   145
/**
cbb921210496 Bunch of little fixes.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5750
diff changeset
   146
 * @brief Tests a blend mode.
cbb921210496 Bunch of little fixes.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5750
diff changeset
   147
 */
5755
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
   148
void _testBlitBlendMode(SDL_Surface *testsur, SDL_Surface *face, int mode)
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   149
{
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   150
	int ret;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   151
	int i, j, ni, nj;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   152
	SDL_Rect rect;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   153
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   154
	AssertTrue(testsur != NULL, "testsur != NULL");
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   155
	AssertTrue(face != NULL, "face != NULL");
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   156
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   157
	/* Clear surface. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   158
	ret = SDL_FillRect( testsur, NULL,
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   159
		 SDL_MapRGB( testsur->format, 0, 0, 0 ) );
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   160
	 AssertTrue(ret != 0, "SDL_FillRect");
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   161
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   162
	/* Steps to take. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   163
	ni     = testsur->w - face->w;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   164
	nj     = testsur->h - face->h;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   165
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   166
	/* Constant values. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   167
	rect.w = face->w;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   168
	rect.h = face->h;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   169
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   170
	/* Test blend mode. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   171
	for (j=0; j <= nj; j+=4) {
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   172
	  for (i=0; i <= ni; i+=4) {
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   173
		 /* Set blend mode. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   174
		 ret = SDL_SetSurfaceBlendMode( face, mode );
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   175
		 AssertTrue(ret != 0, "SDL_SetSurfaceBlendMode");
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   176
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   177
		 /* Blitting. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   178
		 rect.x = i;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   179
		 rect.y = j;
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   180
		 // TODO Add pixel level validation, SDL_BlitSurface might be no-op
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   181
		 ret = SDL_BlitSurface( face, NULL, testsur, &rect );
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   182
		 AssertTrue(ret != 0, "SDL_BlitSurface");	  }
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   183
	}
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   184
}
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   185
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   186
int
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   187
_AssertFileExist(const char *filename)
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   188
{
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   189
	struct stat st;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   190
	int ret = stat(filename, &st);
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   191
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   192
	AssertTrue(ret == 0, "Does file %s exist", filename);
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   193
}
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   194
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   195
/* Test case functions */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   196
/**
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   197
 * @brief Tests sprite loading
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   198
 */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   199
void surface_testLoad(void *arg)
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   200
{
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   201
	int ret;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   202
    SDL_Surface *face, *rface;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   203
5755
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
   204
    /* Clear surface. */
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   205
    /*
5755
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5753
diff changeset
   206
    ret = SDL_FillRect( testsur, NULL,
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   207
         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   208
	AssertTrue(ret == 0,  "SDL_FillRect");
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   209
	*/
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   210
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   211
   /* Create the blit surface. */
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   212
	const char *filename = "icon.bmp";
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   213
	_AssertFileExist(filename);
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   214
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   215
	face = SDL_LoadBMP(filename);
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   216
	AssertTrue(face != NULL, "SDL_CreateLoadBmp");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   217
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   218
	AssertTrue(face->w == 32, "testing icon width");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   219
	AssertTrue(face->h == 32, "testing icon height");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   220
}
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   221
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   222
/*!
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   223
 *  Tests sprite conversion.
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   224
 */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   225
void surface_testConversion(void *arg)
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   226
{
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   227
	SDL_Surface *rface = NULL, *face = NULL;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   228
	int ret = 0;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   229
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   230
	const char *filename = "icon.bmp";
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   231
	_AssertFileExist(filename);
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   232
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   233
	face = SDL_LoadBMP(filename);
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   234
	AssertTrue(face != NULL, "SDL_CreateLoadBmp");
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   235
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   236
	/* Set transparent pixel as the pixel at (0,0) */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   237
	if (face->format->palette) {
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   238
	  ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels);
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   239
	  AssertTrue(ret == 0, "SDL_SetColorKey");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   240
	}
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   241
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   242
	/* Convert to 32 bit to compare. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   243
	rface = SDL_ConvertSurface( face, testsur->format, 0 );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   244
	AssertTrue(rface != NULL, "SDL_ConvertSurface");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   245
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   246
	/* See if it's the same. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   247
	AssertTrue(surface_compare( rface, &img_face, 0 ) == 0,
5752
528866846266 Updated assert messages in surface test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
   248
		   "Comparing primitives output.");
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   249
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   250
	/* Clean up. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   251
	SDL_FreeSurface( rface );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   252
	SDL_FreeSurface( face );
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   253
}
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   254
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   255
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   256
/**
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   257
 * @brief Tests sprite loading. A failure case.
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   258
 */
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   259
void surface_testLoadFailure(void *arg)
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   260
{
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   261
	SDL_Surface *face = SDL_LoadBMP("nonexistant.bmp");
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   262
	AssertTrue(face == NULL, "SDL_CreateLoadBmp");
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   263
}
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   264
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   265
/**
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   266
 * @brief Tests some blitting routines.
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   267
 */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   268
void surface_testBlit(void *arg)
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   269
{
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   270
   int ret;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   271
   SDL_Rect rect;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   272
   SDL_Surface *face;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   273
   int i, j, ni, nj;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   274
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   275
   /* Clear surface. */
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   276
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   277
   ret = SDL_FillRect( testsur, NULL,
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   278
         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   279
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   280
   AssertTrue(ret == 0, "SDL_FillRect");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   281
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   282
   face = _createTestSurfaceFromMemory();
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   283
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   284
   /* Constant values. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   285
   rect.w = face->w;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   286
   rect.h = face->h;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   287
   ni     = testsur->w - face->w;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   288
   nj     = testsur->h - face->h;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   289
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   290
   /* Loop blit. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   291
   for (j=0; j <= nj; j+=4) {
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   292
      for (i=0; i <= ni; i+=4) {
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   293
         /* Blitting. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   294
         rect.x = i;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   295
         rect.y = j;
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   296
         // TODO Add pixel level validation, SDL_BlitSurface might be no-op
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   297
         ret = SDL_BlitSurface( face, NULL, testsur, &rect );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   298
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   299
         AssertTrue(ret == 0, "SDL_BlitSurface");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   300
      }
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   301
   }
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   302
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   303
   /* See if it's the same. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   304
   AssertTrue(surface_compare( testsur, &img_blit, 0 ) == 0,
5752
528866846266 Updated assert messages in surface test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
   305
		   "Comparing blitting output (normal blit).");
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   306
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   307
   /* Clean up. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   308
   SDL_FreeSurface( face );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   309
}
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   310
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   311
/**
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   312
 * @brief Tests some blitting routines with color mod
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   313
 */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   314
void surface_testBlitColorMod(void *arg)
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   315
{
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   316
   int ret;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   317
   SDL_Rect rect;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   318
   SDL_Surface *face;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   319
   int i, j, ni, nj;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   320
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   321
   /* Clear surface. */
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   322
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   323
   ret = SDL_FillRect( testsur, NULL,
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   324
         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   325
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   326
   AssertTrue(ret == 0, "SDL_FillRect");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   327
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   328
   face = _createTestSurfaceFromMemory();
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   329
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   330
   /* Constant values. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   331
   rect.w = face->w;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   332
   rect.h = face->h;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   333
   ni     = testsur->w - face->w;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   334
   nj     = testsur->h - face->h;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   335
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   336
   /* Clear surface. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   337
    ret = SDL_FillRect( testsur, NULL,
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   338
          SDL_MapRGB( testsur->format, 0, 0, 0 ) );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   339
    AssertTrue(ret == 0, "SDL_FillRect");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   340
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   341
    /* Test blitting with colour mod. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   342
    for (j=0; j <= nj; j+=4) {
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   343
       for (i=0; i <= ni; i+=4) {
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   344
          /* Set colour mod. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   345
          ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   346
          AssertTrue(ret == 0, "SDL_SetSurfaceColorMod");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   347
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   348
          /* Blitting. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   349
          rect.x = i;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   350
          rect.y = j;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   351
          // TODO Add pixel level validation, SDL_BlitSurface might be no-op
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   352
          ret = SDL_BlitSurface( face, NULL, testsur, &rect );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   353
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   354
          AssertTrue(ret == 0, "SDL_BlitSurface");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   355
       }
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   356
    }
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   357
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   358
    /* See if it's the same. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   359
    AssertTrue(surface_compare( testsur, &img_blitColour, 0 ) == 0,
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   360
 		   "Comparing blitting output (using SDL_SetSurfaceColorMod).");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   361
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   362
   /* Clean up. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   363
   SDL_FreeSurface( face );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   364
}
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   365
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   366
/**
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   367
 * @brief Tests some blitting routines with alpha mod
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   368
 */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   369
void surface_testBlitAlphaMod(void *arg)
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   370
{
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   371
   int ret;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   372
   SDL_Rect rect;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   373
   SDL_Surface *face;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   374
   int i, j, ni, nj;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   375
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   376
   /* Clear surface. */
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   377
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   378
   ret = SDL_FillRect( testsur, NULL,
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   379
         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   380
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   381
   AssertTrue(ret == 0, "SDL_FillRect");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   382
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   383
   face = _createTestSurfaceFromMemory();
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   384
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   385
   /* Constant values. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   386
   rect.w = face->w;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   387
   rect.h = face->h;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   388
   ni     = testsur->w - face->w;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   389
   nj     = testsur->h - face->h;
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   390
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   391
   /* Clear surface. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   392
   ret = SDL_FillRect( testsur, NULL,
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   393
         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   394
   AssertTrue(ret == 0, "SDL_FillRect");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   395
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   396
   /* Restore colour. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   397
   ret = SDL_SetSurfaceColorMod( face, 255, 255, 255 );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   398
   AssertTrue(ret == 0, "SDL_SetSurfaceColorMod");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   399
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   400
   /* Test blitting with colour mod. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   401
   for (j=0; j <= nj; j+=4) {
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   402
      for (i=0; i <= ni; i+=4) {
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   403
         /* Set alpha mod. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   404
         ret = SDL_SetSurfaceAlphaMod( face, (255/ni)*i );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   405
         AssertTrue(ret == 0, "SDL_SetSurfaceAlphaMod");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   406
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   407
         /* Blitting. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   408
         rect.x = i;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   409
         rect.y = j;
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   410
         // TODO Add pixel level validation, SDL_BlitSurface might be no-op
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   411
         ret = SDL_BlitSurface( face, NULL, testsur, &rect );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   412
         AssertTrue(ret == 0, "SDL_BlitSurface");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   413
      }
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   414
   }
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   415
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   416
   /* See if it's the same. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   417
   AssertTrue(surface_compare( testsur, &img_blitAlpha, 0 ) == 0,
5752
528866846266 Updated assert messages in surface test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
   418
		   "Comparing blitting output (using SDL_SetSurfaceAlphaMod).");
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   419
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   420
   /* Clean up. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   421
   SDL_FreeSurface( face );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   422
}
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   423
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   424
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   425
/**
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   426
 * @brief Tests some more blitting routines.
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   427
 */
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   428
void surface_testBlitBlendNone(void *arg)
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   429
{
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   430
   int ret;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   431
   SDL_Rect rect;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   432
   SDL_Surface *face;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   433
   int i, j, ni, nj;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   434
   int mode;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   435
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   436
   /* Clear surface. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   437
   ret = SDL_FillRect( testsur, NULL,
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   438
         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   439
   AssertTrue(ret == 0, "SDL_FillRect");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   440
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   441
   face = _createTestSurfaceFromMemory();
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   442
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   443
   /* Set alpha mod. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   444
   // TODO alpha value could be generated by fuzzer
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   445
   ret = SDL_SetSurfaceAlphaMod( face, 100 );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   446
   AssertTrue(ret == 0, "SDL_SetSurfaceAlphaMod");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   447
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   448
   /* Steps to take. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   449
   ni     = testsur->w - face->w;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   450
   nj     = testsur->h - face->h;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   451
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   452
   AssertTrue(ni != 0, "ni != 0");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   453
   AssertTrue(nj != 0, "nj != 0");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   454
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   455
   /* Constant values. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   456
   rect.w = face->w;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   457
   rect.h = face->h;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   458
   /* Test None. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   459
  _testBlitBlendMode( testsur, face, SDL_BLENDMODE_NONE );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   460
   AssertTrue(surface_compare( testsur, &img_blendNone, 0 ) == 0,
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   461
   		   "Comparing blitting blending output (using SDL_BLENDMODE_NONE).");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   462
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   463
   /* Test Blend. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   464
   _testBlitBlendMode( testsur, face, SDL_BLENDMODE_BLEND );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   465
   AssertTrue(surface_compare( testsur, &img_blendBlend, 0 ) == 0,
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   466
   		   "Comparing blitting blending output (using SDL_BLENDMODE_BLEND).");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   467
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   468
   /* Test Add. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   469
   _testBlitBlendMode( testsur, face, SDL_BLENDMODE_ADD );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   470
   AssertTrue(surface_compare( testsur, &img_blendAdd, 0 ) == 0,
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   471
   		      "Comparing blitting blending output (using SDL_BLENDMODE_ADD).");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   472
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   473
   /* Test Mod. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   474
   _testBlitBlendMode( testsur, face, SDL_BLENDMODE_MOD );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   475
   AssertTrue(surface_compare( testsur, &img_blendMod, 0 ) == 0,
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   476
   		      "Comparing blitting blending output not the same (using SDL_BLENDMODE_MOD).");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   477
}
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   478
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   479
/**
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   480
 * @brief Tests some more blitting routines.
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   481
 */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   482
void surface_testBlitBlendBlend(void *arg)
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   483
{
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   484
   int ret;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   485
   SDL_Rect rect;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   486
   SDL_Surface *face;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   487
   int i, j, ni, nj;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   488
   int mode;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   489
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   490
   /* Clear surface. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   491
   ret = SDL_FillRect( testsur, NULL,
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   492
         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   493
   AssertTrue(ret == 0, "SDL_FillRect");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   494
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   495
   face = _createTestSurfaceFromMemory();
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   496
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   497
   /* Set alpha mod. */
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   498
   // TODO alpha value could be generated by fuzzer
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   499
   ret = SDL_SetSurfaceAlphaMod( face, 100 );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   500
   AssertTrue(ret == 0, "SDL_SetSurfaceAlphaMod");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   501
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   502
   /* Steps to take. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   503
   ni     = testsur->w - face->w;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   504
   nj     = testsur->h - face->h;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   505
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   506
   AssertTrue(ni != 0, "ni != 0");
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   507
   AssertTrue(nj != 0, "nj != 0");
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   508
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   509
   /* Constant values. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   510
   rect.w = face->w;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   511
   rect.h = face->h;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   512
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   513
   /* Test Blend. */
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   514
   _testBlitBlendMode( testsur, face, SDL_BLENDMODE_BLEND );
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   515
   AssertTrue(surface_compare( testsur, &img_blendBlend, 0 ) == 0,
5752
528866846266 Updated assert messages in surface test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
   516
   		   "Comparing blitting blending output (using SDL_BLENDMODE_BLEND).");
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   517
}
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   518
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   519
/**
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   520
 * @brief Tests some more blitting routines.
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   521
 */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   522
void surface_testBlitBlendAdd(void *arg)
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   523
{
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   524
   int ret;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   525
   SDL_Rect rect;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   526
   SDL_Surface *face;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   527
   int i, j, ni, nj;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   528
   int mode;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   529
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   530
   /* Clear surface. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   531
   ret = SDL_FillRect( testsur, NULL,
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   532
         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   533
   AssertTrue(ret == 0, "SDL_FillRect");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   534
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   535
   face = _createTestSurfaceFromMemory();
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   536
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   537
   /* Set alpha mod. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   538
   // TODO alpha value could be generated by fuzzer
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   539
   ret = SDL_SetSurfaceAlphaMod( face, 100 );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   540
   AssertTrue(ret == 0, "SDL_SetSurfaceAlphaMod");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   541
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   542
   /* Steps to take. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   543
   ni     = testsur->w - face->w;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   544
   nj     = testsur->h - face->h;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   545
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   546
   AssertTrue(ni != 0, "ni != 0");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   547
   AssertTrue(nj != 0, "nj != 0");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   548
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   549
   /* Constant values. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   550
   rect.w = face->w;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   551
   rect.h = face->h;
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   552
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   553
   /* Test Add. */
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   554
   _testBlitBlendMode( testsur, face, SDL_BLENDMODE_ADD );
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   555
   AssertTrue(surface_compare( testsur, &img_blendAdd, 0 ) == 0,
5752
528866846266 Updated assert messages in surface test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
   556
   		      "Comparing blitting blending output (using SDL_BLENDMODE_ADD).");
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   557
}
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   558
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   559
/**
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   560
 * @brief Tests some more blitting routines.
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   561
 */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   562
void surface_testBlitBlendMod(void *arg)
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   563
{
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   564
   int ret;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   565
   SDL_Rect rect;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   566
   SDL_Surface *face;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   567
   int i, j, ni, nj;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   568
   int mode;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   569
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   570
   /* Clear surface. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   571
   ret = SDL_FillRect( testsur, NULL,
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   572
         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   573
   AssertTrue(ret == 0, "SDL_FillRect");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   574
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   575
   face = _createTestSurfaceFromMemory();
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   576
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   577
   /* Set alpha mod. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   578
   // TODO alpha value could be generated by fuzzer
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   579
   ret = SDL_SetSurfaceAlphaMod( face, 100 );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   580
   AssertTrue(ret == 0, "SDL_SetSurfaceAlphaMod");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   581
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   582
   /* Steps to take. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   583
   ni     = testsur->w - face->w;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   584
   nj     = testsur->h - face->h;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   585
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   586
   AssertTrue(ni != 0, "ni != 0");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   587
   AssertTrue(nj != 0, "nj != 0");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   588
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   589
   /* Constant values. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   590
   rect.w = face->w;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   591
   rect.h = face->h;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   592
   /* Test None. */
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   593
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   594
   /* Test Mod. */
5753
5e8c5282cac0 Fixes based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5752
diff changeset
   595
   _testBlitBlendMode( testsur, face, SDL_BLENDMODE_MOD );
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   596
   AssertTrue(surface_compare( testsur, &img_blendMod, 0 ) == 0,
5756
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   597
   		      "Comparing blitting blending output (using SDL_BLENDMODE_MOD).");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   598
}
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   599
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   600
/**
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   601
 * @brief Tests some more blitting routines with loop
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   602
 */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   603
void surface_testBlitBlendLoop(void *arg) {
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   604
	int ret;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   605
	SDL_Rect rect;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   606
	SDL_Surface *face;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   607
	int i, j, ni, nj;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   608
	int mode;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   609
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   610
	/* Clear surface. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   611
	ret = SDL_FillRect( testsur, NULL,
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   612
		 SDL_MapRGB( testsur->format, 0, 0, 0 ) );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   613
	AssertTrue(ret == 0, "SDL_FillRect");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   614
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   615
	face = _createTestSurfaceFromMemory();
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   616
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   617
	/* Set alpha mod. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   618
	// TODO alpha value could be generated by fuzzer
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   619
	ret = SDL_SetSurfaceAlphaMod( face, 100 );
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   620
	AssertTrue(ret == 0, "SDL_SetSurfaceAlphaMod");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   621
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   622
	/* Steps to take. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   623
	ni     = testsur->w - face->w;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   624
	nj     = testsur->h - face->h;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   625
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   626
	AssertTrue(ni != 0, "ni != 0");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   627
	AssertTrue(nj != 0, "nj != 0");
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   628
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   629
	/* Constant values. */
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   630
	rect.w = face->w;
3581346510f3 Breaking tests in surface to several smaller tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5755
diff changeset
   631
	rect.h = face->h;
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   632
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   633
   /* Clear surface. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   634
   ret = SDL_FillRect( testsur, NULL,
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   635
         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   636
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   637
   AssertTrue(ret == 0, "SDL_FillRect");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   638
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   639
   /* Loop blit. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   640
   for (j=0; j <= nj; j+=4) {
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   641
      for (i=0; i <= ni; i+=4) {
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   642
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   643
         /* Set colour mod. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   644
         ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   645
         AssertTrue(ret == 0, "SDL_SetSurfaceColorMod");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   646
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   647
         /* Set alpha mod. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   648
         ret = SDL_SetSurfaceAlphaMod( face, (100/ni)*i );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   649
         AssertTrue(ret == 0, "SDL_SetSurfaceAlphaMod");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   650
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   651
         /* Crazy blending mode magic. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   652
         mode = (i/4*j/4) % 4;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   653
         if (mode==0) mode = SDL_BLENDMODE_NONE;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   654
         else if (mode==1) mode = SDL_BLENDMODE_BLEND;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   655
         else if (mode==2) mode = SDL_BLENDMODE_ADD;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   656
         else if (mode==3) mode = SDL_BLENDMODE_MOD;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   657
         ret = SDL_SetSurfaceBlendMode( face, mode );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   658
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   659
         AssertTrue(ret == 0, "SDL_SetSurfaceBlendMode");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   660
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   661
         /* Blitting. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   662
         rect.x = i;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   663
         rect.y = j;
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   664
         ret = SDL_BlitSurface( face, NULL, testsur, &rect );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   665
         AssertTrue(ret == 0, "SDL_BlitSurface");
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   666
      }
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   667
   }
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   668
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   669
   /* Check to see if matches. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   670
   AssertTrue(surface_compare( testsur, &img_blendAll, 0 ) == 0,
5752
528866846266 Updated assert messages in surface test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
   671
		      "Surface comparison (surface_compare).");
5750
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   672
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   673
   /* Clean up. */
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   674
   SDL_FreeSurface( face );
337982ee35ac Ported surface tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   675
}