Mercurial > sdl-ios-xcode
comparison src/video/SDL_shape.c @ 4785:ef8b32ef9793
Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
author | Eli Gottlieb <eligottlieb@gmail.com> |
---|---|
date | Tue, 06 Jul 2010 22:05:22 -0400 |
parents | b6930aefd008 |
children | 175da36d1342 |
comparison
equal
deleted
inserted
replaced
4784:2878650e0dc9 | 4785:ef8b32ef9793 |
---|---|
43 else | 43 else |
44 return window->shaper != NULL; | 44 return window->shaper != NULL; |
45 } | 45 } |
46 | 46 |
47 /* REQUIRES that bitmap point to a w-by-h bitmap with 1bpp. */ | 47 /* REQUIRES that bitmap point to a w-by-h bitmap with 1bpp. */ |
48 void SDL_CalculateShapeBitmap(Uint8 alphacutoff,SDL_Surface *shape,Uint8* bitmap) { | 48 void SDL_CalculateShapeBitmap(Uint8 alphacutoff,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb,Uint8 value) { |
49 if(SDL_MUSTLOCK(shape)) | 49 if(SDL_MUSTLOCK(shape)) |
50 SDL_LockSurface(shape); | 50 SDL_LockSurface(shape); |
51 int x = 0,y = 0; | 51 int x = 0,y = 0; |
52 for(x = 0;x<shape->w;x++) | 52 for(x = 0;x<shape->w;x++) |
53 for(y = 0;y<shape->h;y++) { | 53 for(y = 0;y<shape->h;y++) { |
54 void* pixel = shape->pixels + (y*shape->pitch) + (x*shape->format->BytesPerPixel); | 54 void* pixel = shape->pixels + (y*shape->pitch) + (x*shape->format->BytesPerPixel); |
55 Uint8 alpha = 0; | 55 Uint8 alpha = 0; |
56 SDL_GetRGBA(*(Uint32*)pixel,shape->format,NULL,NULL,NULL,&alpha); | 56 SDL_GetRGBA(*(Uint32*)pixel,shape->format,NULL,NULL,NULL,&alpha); |
57 Uint32 bitmap_pixel = y*shape->w + x; | 57 Uint32 bitmap_pixel = y*shape->w + x; |
58 bitmap[bitmap_pixel / 8] |= (alpha >= alphacutoff ? 1 : 0) << (8 - (bitmap_pixel % 8)); | 58 bitmap[bitmap_pixel / ppb] |= (alpha >= alphacutoff ? value : 0) << ((ppb - 1) - (bitmap_pixel % ppb)); |
59 } | 59 } |
60 if(SDL_MUSTLOCK(shape)) | 60 if(SDL_MUSTLOCK(shape)) |
61 SDL_UnlockSurface(shape); | 61 SDL_UnlockSurface(shape); |
62 } | 62 } |
63 | 63 |
79 window->shaper->alphacutoff = shapeMode->parameters.binarizationCutoff; | 79 window->shaper->alphacutoff = shapeMode->parameters.binarizationCutoff; |
80 break; | 80 break; |
81 } | 81 } |
82 } | 82 } |
83 } | 83 } |
84 //TODO: Platform-specific implementations of SetWindowShape. X11 is in-progress. | 84 //TODO: Platform-specific implementations of SetWindowShape. X11 is finished. Win32 is in progress. |
85 int result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shapeMode); | 85 int result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shapeMode); |
86 window->shaper->hasshape = SDL_TRUE; | 86 window->shaper->hasshape = SDL_TRUE; |
87 if(window->shaper->usershownflag & SDL_WINDOW_SHOWN == SDL_WINDOW_SHOWN) { | 87 if(window->shaper->usershownflag & SDL_WINDOW_SHOWN == SDL_WINDOW_SHOWN) { |
88 SDL_ShowWindow(window); | 88 SDL_ShowWindow(window); |
89 window->shaper->usershownflag &= !SDL_WINDOW_SHOWN; | 89 window->shaper->usershownflag &= !SDL_WINDOW_SHOWN; |