Commit 7f4f3792 authored by Sam Lantinga's avatar Sam Lantinga

Refactored to use render_loadTestFace()

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404186
parent 86dbbd0d
...@@ -543,7 +543,6 @@ static int render_testBlit (void) ...@@ -543,7 +543,6 @@ static int render_testBlit (void)
{ {
int ret; int ret;
SDL_Rect rect; SDL_Rect rect;
SDL_Surface *face;
SDL_TextureID tface; SDL_TextureID tface;
int i, j, ni, nj; int i, j, ni, nj;
...@@ -556,34 +555,15 @@ static int render_testBlit (void) ...@@ -556,34 +555,15 @@ static int render_testBlit (void)
return 0; return 0;
/* Create face surface. */ /* Create face surface. */
face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, tface = render_loadTestFace();
img_face.width, img_face.height, 32, img_face.width*4, if (SDL_ATassert( "render_loadTestFace()", tface != 0))
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
return -1;
tface = SDL_CreateTextureFromSurface( 0, face );
if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
return -1; return -1;
/* Constant values. */ /* Constant values. */
rect.w = face->w; rect.w = img_face.width;
rect.h = face->h; rect.h = img_face.height;
ni = SCREEN_W - face->w; ni = SCREEN_W - img_face.width;
nj = SCREEN_H - face->h; nj = SCREEN_H - img_face.height;
/* Clean up. */
SDL_FreeSurface( face );
/* Loop blit. */ /* Loop blit. */
for (j=0; j <= nj; j+=4) { for (j=0; j <= nj; j+=4) {
...@@ -615,7 +595,6 @@ static int render_testBlitColour (void) ...@@ -615,7 +595,6 @@ static int render_testBlitColour (void)
{ {
int ret; int ret;
SDL_Rect rect; SDL_Rect rect;
SDL_Surface *face;
SDL_TextureID tface; SDL_TextureID tface;
int i, j, ni, nj; int i, j, ni, nj;
...@@ -628,34 +607,15 @@ static int render_testBlitColour (void) ...@@ -628,34 +607,15 @@ static int render_testBlitColour (void)
return 0; return 0;
/* Create face surface. */ /* Create face surface. */
face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, tface = render_loadTestFace();
img_face.width, img_face.height, 32, img_face.width*4, if (SDL_ATassert( "render_loadTestFace()", tface != 0))
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
return -1;
tface = SDL_CreateTextureFromSurface( 0, face );
if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
return -1; return -1;
/* Constant values. */ /* Constant values. */
rect.w = face->w; rect.w = img_face.width;
rect.h = face->h; rect.h = img_face.height;
ni = SCREEN_W - face->w; ni = SCREEN_W - img_face.width;
nj = SCREEN_H - face->h; nj = SCREEN_H - img_face.height;
/* Clean up. */
SDL_FreeSurface( face );
/* Test blitting with colour mod. */ /* Test blitting with colour mod. */
for (j=0; j <= nj; j+=4) { for (j=0; j <= nj; j+=4) {
...@@ -693,7 +653,6 @@ static int render_testBlitAlpha (void) ...@@ -693,7 +653,6 @@ static int render_testBlitAlpha (void)
{ {
int ret; int ret;
SDL_Rect rect; SDL_Rect rect;
SDL_Surface *face;
SDL_TextureID tface; SDL_TextureID tface;
int i, j, ni, nj; int i, j, ni, nj;
...@@ -706,34 +665,15 @@ static int render_testBlitAlpha (void) ...@@ -706,34 +665,15 @@ static int render_testBlitAlpha (void)
return 0; return 0;
/* Create face surface. */ /* Create face surface. */
face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, tface = render_loadTestFace();
img_face.width, img_face.height, 32, img_face.width*4, if (SDL_ATassert( "render_loadTestFace()", tface != 0))
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
return -1;
tface = SDL_CreateTextureFromSurface( 0, face );
if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
return -1; return -1;
/* Constant values. */ /* Constant values. */
rect.w = face->w; rect.w = img_face.width;
rect.h = face->h; rect.h = img_face.height;
ni = SCREEN_W - face->w; ni = SCREEN_W - img_face.width;
nj = SCREEN_H - face->h; nj = SCREEN_H - img_face.height;
/* Clean up. */
SDL_FreeSurface( face );
/* Clear surface. */ /* Clear surface. */
if (render_clearScreen()) if (render_clearScreen())
...@@ -817,7 +757,6 @@ static int render_testBlitBlend (void) ...@@ -817,7 +757,6 @@ static int render_testBlitBlend (void)
{ {
int ret; int ret;
SDL_Rect rect; SDL_Rect rect;
SDL_Surface *face;
SDL_TextureID tface; SDL_TextureID tface;
int i, j, ni, nj; int i, j, ni, nj;
int mode; int mode;
...@@ -831,24 +770,8 @@ static int render_testBlitBlend (void) ...@@ -831,24 +770,8 @@ static int render_testBlitBlend (void)
return 0; return 0;
/* Create face surface. */ /* Create face surface. */
face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, tface = render_loadTestFace();
img_face.width, img_face.height, 32, img_face.width*4, if (SDL_ATassert( "render_loadTestFace()", tface != 0))
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
return -1;
tface = SDL_CreateTextureFromSurface( 0, face );
if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
return -1; return -1;
/* Steps to take. */ /* Steps to take. */
...@@ -856,11 +779,8 @@ static int render_testBlitBlend (void) ...@@ -856,11 +779,8 @@ static int render_testBlitBlend (void)
nj = SCREEN_H - FACE_H; nj = SCREEN_H - FACE_H;
/* Constant values. */ /* Constant values. */
rect.w = face->w; rect.w = img_face.width;
rect.h = face->h; rect.h = img_face.height;
/* Clean up. */
SDL_FreeSurface( face );
/* Set alpha mod. */ /* Set alpha mod. */
ret = SDL_SetRenderDrawColor( 255, 255, 255, 100 ); ret = SDL_SetRenderDrawColor( 255, 255, 255, 100 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment