changeset 3738:c875baafce36 gsoc2009_unit_tests

Changed placeholder for SDL_ReadPixels.
author Edgar Simo <bobbens@gmail.com>
date Sun, 02 Aug 2009 15:41:49 +0000
parents 9689eaa6d2e3
children 651b261e591d
files test/automated/render/render.c
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/test/automated/render/render.c	Sun Aug 02 09:37:14 2009 +0000
+++ b/test/automated/render/render.c	Sun Aug 02 15:41:49 2009 +0000
@@ -56,7 +56,6 @@
 {
    (void) msg;
    (void) s;
-#if 0
    int ret;
    void *pix;
    SDL_Surface *testsur;
@@ -67,9 +66,26 @@
       return 1;
 
    /* Read pixels. */
+#if 0
    ret = SDL_RenderReadPixels( NULL, pix, 80*4 );
    if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) )
       return 1;
+#else
+   int i, j;
+   Uint8 *buf = pix;
+   const Uint8 *read_pix;
+   Uint8 *write_pix;
+   for (j=0; j<s->height; j++) {
+      for (i=0; i<s->width; i++) {
+         read_pix  = &s->pixel_data[ (j*80 + i) * s->bytes_per_pixel ];
+         write_pix = &buf[ (j*80 + i) * 4 ];
+         write_pix[0] = read_pix[0];
+         write_pix[1] = read_pix[1];
+         write_pix[2] = read_pix[2];
+         write_pix[3] = SDL_ALPHA_OPAQUE;
+      }
+   }
+#endif
 
    /* Create surface. */
    testsur = SDL_CreateRGBSurfaceFrom( pix, 80, 60, 32, 80*4,
@@ -85,7 +101,6 @@
    /* Clean up. */
    SDL_FreeSurface( testsur );
    free(pix);
-#endif
 
    return 0;
 }