| 2443 | } |
| 2444 | |
| 2445 | static int |
| 2446 | RenderDrawLinesWithRects(SDL_Renderer * renderer, |
| 2447 | const SDL_Point * points, const int count) |
| 2448 | { |
| 2449 | SDL_FRect *frect; |
| 2450 | SDL_FRect *frects; |
| 2451 | SDL_FPoint fpoints[2]; |
| 2452 | int i, nrects = 0; |
| 2453 | int retval = 0; |
| 2454 | SDL_bool isstack; |
| 2455 | |
| 2456 | frects = SDL_small_alloc(SDL_FRect, count-1, &isstack); |
| 2457 | if (!frects) { |
| 2458 | return SDL_OutOfMemory(); |
| 2459 | } |
| 2460 | |
| 2461 | for (i = 0; i < count-1; ++i) { |
| 2462 | if (points[i].x == points[i+1].x) { |
| 2463 | const int minY = SDL_min(points[i].y, points[i+1].y); |
| 2464 | const int maxY = SDL_max(points[i].y, points[i+1].y); |
| 2465 | |
| 2466 | frect = &frects[nrects++]; |
| 2467 | frect->x = points[i].x * renderer->scale.x; |
| 2468 | frect->y = minY * renderer->scale.y; |
| 2469 | frect->w = renderer->scale.x; |
| 2470 | frect->h = (maxY - minY + 1) * renderer->scale.y; |
| 2471 | } else if (points[i].y == points[i+1].y) { |
| 2472 | const int minX = SDL_min(points[i].x, points[i+1].x); |
| 2473 | const int maxX = SDL_max(points[i].x, points[i+1].x); |
| 2474 | |
| 2475 | frect = &frects[nrects++]; |
| 2476 | frect->x = minX * renderer->scale.x; |
| 2477 | frect->y = points[i].y * renderer->scale.y; |
| 2478 | frect->w = (maxX - minX + 1) * renderer->scale.x; |
| 2479 | frect->h = renderer->scale.y; |
| 2480 | } else { |
| 2481 | /* FIXME: We can't use a rect for this line... */ |
| 2482 | fpoints[0].x = points[i].x * renderer->scale.x; |
| 2483 | fpoints[0].y = points[i].y * renderer->scale.y; |
| 2484 | fpoints[1].x = points[i+1].x * renderer->scale.x; |
| 2485 | fpoints[1].y = points[i+1].y * renderer->scale.y; |
| 2486 | retval += QueueCmdDrawLines(renderer, fpoints, 2); |
| 2487 | } |
| 2488 | } |
| 2489 | |
| 2490 | retval += QueueCmdFillRects(renderer, frects, nrects); |
| 2491 | |
| 2492 | SDL_small_free(frects, isstack); |
| 2493 | |
| 2494 | if (retval < 0) { |
| 2495 | retval = -1; |
| 2496 | } |
| 2497 | return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); |
| 2498 | } |
| 2499 | |
| 2500 | static int |
| 2501 | RenderDrawLinesWithRectsF(SDL_Renderer * renderer, |
no test coverage detected