# HG changeset patch # User Eli Gottlieb # Date 1279082968 14400 # Node ID 6f0bc179771ca65d0c2727364cc3dc86989c8a28 # Parent e562160a873f15c44816ece3a9c40755a31abe6b Numerous bug fixes that keep testeyes from crashing and dying. diff -r e562160a873f -r 6f0bc179771c src/video/SDL_shape.c --- a/src/video/SDL_shape.c Tue Jul 13 02:43:49 2010 -0400 +++ b/src/video/SDL_shape.c Wed Jul 14 00:49:28 2010 -0400 @@ -48,7 +48,7 @@ void SDL_CalculateShapeBitmap(Uint8 alphacutoff,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb,Uint8 value) { int x = 0; int y = 0; - Uint8 alpha = 0; + Uint8 r = 0,g = 0,b = 0,alpha = 0; Uint8* pixel; Uint32 bitmap_pixel; if(SDL_MUSTLOCK(shape)) @@ -57,7 +57,7 @@ for(y = 0;yh;y++) { pixel = shape->pixels + (y*shape->pitch) + (x*shape->format->BytesPerPixel); alpha = 0; - SDL_GetRGBA(*(Uint32*)pixel,shape->format,NULL,NULL,NULL,&alpha); + SDL_GetRGBA(*(Uint32*)pixel,shape->format,&r,&g,&b,&alpha); Uint32 bitmap_pixel = y*shape->w + x; bitmap[bitmap_pixel / ppb] |= (alpha >= alphacutoff ? value : 0) << ((ppb - 1) - (bitmap_pixel % ppb)); } diff -r e562160a873f -r 6f0bc179771c src/video/x11/SDL_x11shape.c --- a/src/video/x11/SDL_x11shape.c Tue Jul 13 02:43:49 2010 -0400 +++ b/src/video/x11/SDL_x11shape.c Wed Jul 14 00:49:28 2010 -0400 @@ -34,7 +34,10 @@ result->window = window; result->alphacutoff = 0; result->usershownflag = 0; - result->driverdata = malloc(sizeof(SDL_ShapeData)); + SDL_ShapeData* data = malloc(sizeof(SDL_ShapeData)); + result->driverdata = data; + data->bitmapsize = 0; + data->bitmap = NULL; window->shaper = result; int resized_properly = X11_ResizeWindowShape(window); assert(resized_properly == 0); diff -r e562160a873f -r 6f0bc179771c test/testeyes.c --- a/test/testeyes.c Tue Jul 13 02:43:49 2010 -0400 +++ b/test/testeyes.c Wed Jul 14 00:49:28 2010 -0400 @@ -143,31 +143,47 @@ exit(-3); } - SDL_Color bnw_palette[2] = {{0,0,0,255},{255,255,255,255}}; - SDL_Texture *eyes_texture = SDL_CreateTexture(SDL_PIXELFORMAT_INDEX1LSB,SDL_TEXTUREACCESS_STREAMING,eyes_width,eyes_height); + int bpp = 0; + Uint32 r = 0,g = 0,b = 0,a = 0; + SDL_PixelFormatEnumToMasks(SDL_PIXELFORMAT_ARGB4444,&bpp,&r,&g,&b,&a); + SDL_Surface *eyes = SDL_CreateRGBSurface(0,eyes_width,eyes_height,bpp,r,g,b,a); + if(eyes == NULL) { + SDL_DestroyRenderer(window); + SDL_DestroyWindow(window); + SDL_VideoQuit(); + printf("Could not create eyes surface.\n"); + exit(-4); + } + + void *pixels = NULL; + int pitch = 0; + SDL_Rect rect = {0,0,eyes_width,eyes_height}; + if(SDL_MUSTLOCK(eyes)) + SDL_LockSurface(eyes); + pixels = eyes->pixels; + pitch = eyes->pitch; + for(int y=0;yformat,brightness,brightness,brightness,255); + } + if(SDL_MUSTLOCK(eyes)) + SDL_UnlockSurface(eyes); + SDL_Texture *eyes_texture = SDL_CreateTextureFromSurface(SDL_PIXELFORMAT_ARGB4444,eyes); if(eyes_texture == NULL) { + SDL_FreeSurface(eyes); SDL_DestroyRenderer(window); SDL_DestroyWindow(window); SDL_VideoQuit(); printf("Could not create eyes texture.\n"); - exit(-4); + exit(-5); } - SDL_SetTexturePalette(eyes_texture,bnw_palette,0,2); - - void *pixels = NULL; - int pitch = 0; - SDL_Rect rect = {0,0,eyes_width,eyes_height}; - SDL_LockTexture(eyes_texture,&rect,1,&pixels,&pitch); - for(int row = 0;rowpixels; + pitch = mask->pitch; for(int y=0;y