comparison src/video/SDL_shape.c @ 4850:14870d46ee2d

Mostly seem to have fixed SDL_CalculateShapeTree. Mostly. There still seem to be some rendering artifacts, stepping effects, and such on Windows -- which indicates subtle logic errors in SDL_CalculateShapeTree(). Oh well, back into the salt mine.
author egottlieb
date Sat, 14 Aug 2010 20:29:51 -0400
parents 0b918c186938
children 5624fb0190b5
comparison
equal deleted inserted replaced
4849:0b918c186938 4850:14870d46ee2d
154 case(ShapeModeReverseBinarizeAlpha): 154 case(ShapeModeReverseBinarizeAlpha):
155 pixel_opaque = (a <= mode.parameters.binarizationCutoff ? SDL_TRUE : SDL_FALSE); 155 pixel_opaque = (a <= mode.parameters.binarizationCutoff ? SDL_TRUE : SDL_FALSE);
156 break; 156 break;
157 case(ShapeModeColorKey): 157 case(ShapeModeColorKey):
158 key = mode.parameters.colorKey; 158 key = mode.parameters.colorKey;
159 pixel_opaque = ((key.r == r && key.g == g && key.b == b) ? SDL_TRUE : SDL_FALSE); 159 pixel_opaque = ((key.r != r || key.g != g || key.b != b) ? SDL_TRUE : SDL_FALSE);
160 break; 160 break;
161 } 161 }
162 if(last_opaque == -1) 162 if(last_opaque == -1)
163 last_opaque = pixel_opaque; 163 last_opaque = pixel_opaque;
164 if(last_opaque != pixel_opaque) { 164 if(last_opaque != pixel_opaque) {
168 next.h = dimensions.h / 2; 168 next.h = dimensions.h / 2;
169 //These will change from recursion to recursion. 169 //These will change from recursion to recursion.
170 next.x = dimensions.x; 170 next.x = dimensions.x;
171 next.y = dimensions.y; 171 next.y = dimensions.y;
172 result->data.children.upleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); 172 result->data.children.upleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
173 next.x = dimensions.w / 2; 173 next.x += next.w;
174 //Unneeded: next.y = dimensions.y; 174 //Unneeded: next.y = dimensions.y;
175 result->data.children.upright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); 175 result->data.children.upright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
176 next.x = dimensions.x; 176 next.x = dimensions.x;
177 next.y = dimensions.h / 2; 177 next.y += next.h;
178 result->data.children.downleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); 178 result->data.children.downleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
179 next.x = dimensions.w / 2; 179 next.x += next.w;
180 //Unneeded: next.y = dimensions.h / 2 + 1; 180 //Unneeded: next.y = dimensions.y + dimensions.h /2;
181 result->data.children.downright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); 181 result->data.children.downright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
182 return result; 182 return result;
183 } 183 }
184 } 184 }
185 //If we never recursed, all the pixels in this quadrant have the same "value". 185 //If we never recursed, all the pixels in this quadrant have the same "value".
212 else 212 else
213 function(tree,closure); 213 function(tree,closure);
214 } 214 }
215 215
216 void 216 void
217 SDL_FreeShapeTree(SDL_ShapeTree** shapeTree) { 217 SDL_FreeShapeTree(SDL_ShapeTree** shape_tree) {
218 if((*shapeTree)->kind == QuadShape) { 218 if((*shape_tree)->kind == QuadShape) {
219 SDL_FreeShapeTree((SDL_ShapeTree **)&(*shapeTree)->data.children.upleft); 219 SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.upleft);
220 SDL_FreeShapeTree((SDL_ShapeTree **)&(*shapeTree)->data.children.upright); 220 SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.upright);
221 SDL_FreeShapeTree((SDL_ShapeTree **)&(*shapeTree)->data.children.downleft); 221 SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.downleft);
222 SDL_FreeShapeTree((SDL_ShapeTree **)&(*shapeTree)->data.children.downright); 222 SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.downright);
223 } 223 }
224 SDL_free(*shapeTree); 224 SDL_free(*shape_tree);
225 *shapeTree = NULL; 225 *shape_tree = NULL;
226 } 226 }
227 227
228 int 228 int
229 SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { 229 SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
230 int result; 230 int result;
238 if(shape_mode != NULL) 238 if(shape_mode != NULL)
239 window->shaper->mode = *shape_mode; 239 window->shaper->mode = *shape_mode;
240 result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shape_mode); 240 result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shape_mode);
241 window->shaper->hasshape = SDL_TRUE; 241 window->shaper->hasshape = SDL_TRUE;
242 if((window->shaper->usershownflag & SDL_WINDOW_SHOWN) == SDL_WINDOW_SHOWN) { 242 if((window->shaper->usershownflag & SDL_WINDOW_SHOWN) == SDL_WINDOW_SHOWN) {
243 SDL_SetWindowPosition(window,window->x,window->y);
244 SDL_ShowWindow(window); 243 SDL_ShowWindow(window);
245 window->shaper->usershownflag &= !SDL_WINDOW_SHOWN; 244 window->shaper->usershownflag &= !SDL_WINDOW_SHOWN;
246 } 245 }
247 return result; 246 return result;
248 } 247 }