# HG changeset patch # User Sam Lantinga # Date 1260772559 0 # Node ID 5f038ec1a1afaf9d81a1d459d0f35fd17c22bb9a # Parent 7184580ab75612ede306f91744c677c24c598336 Added a test to check the read/write pixels API diff -r 7184580ab756 -r 5f038ec1a1af test/automated/common/common.c --- a/test/automated/common/common.c Mon Dec 14 06:35:27 2009 +0000 +++ b/test/automated/common/common.c Mon Dec 14 06:35:59 2009 +0000 @@ -82,7 +82,6 @@ bpp = sur->format->BytesPerPixel; - /* Compare image - should be same format. */ if (bpp == 4) { for (j=0; jh; j++) { for (i=0; iw; i++) { diff -r 7184580ab756 -r 5f038ec1a1af test/automated/render/render.c --- a/test/automated/render/render.c Mon Dec 14 06:35:27 2009 +0000 +++ b/test/automated/render/render.c Mon Dec 14 06:35:59 2009 +0000 @@ -37,6 +37,7 @@ static int render_hasTexAlpha (void); static int render_clearScreen (void); /* Testcases. */ +static int render_testReadWrite (void); static int render_testPrimitives (void); static int render_testPrimitivesBlend (void); static int render_testBlit (void); @@ -363,6 +364,31 @@ /** + * @brief Test reading and writing framebuffer + */ +static int render_testReadWrite (void) +{ + int ret; + SDL_Rect rect; + + /* Write pixels. */ + rect.x = 0; + rect.y = 0; + rect.w = 80; + rect.h = 60; + ret = SDL_RenderWritePixels( &rect, SDL_PIXELFORMAT_RGB24, img_primitives.pixel_data, img_primitives.width*img_primitives.bytes_per_pixel ); + if (SDL_ATassert( "SDL_RenderWritePixels", ret==0) ) + return 1; + + /* See if it's the same. */ + if (render_compare( "Read/write output not the same.", &img_primitives, ALLOWABLE_ERROR_OPAQUE )) + return -1; + + return 0; +} + + +/** * @brief Tests the SDL primitives for rendering. */ static int render_testPrimitives (void) @@ -932,6 +958,9 @@ SDL_ATprintVerbose( 1, " Texture Alpha Mod supported\n" ); /* Software surface blitting. */ + ret = render_testReadWrite(); + if (ret) + return -1; ret = render_testPrimitives(); if (ret) return -1;