SDL_DrawLines: minor simpification:

- scale is  1.0f, don't need to multiply
- typo in error message
- remap SDL_DrawLines to SDL_DrawLinesF
This commit is contained in:
Sylvain 2021-12-07 10:44:12 +01:00
parent a0818a63e3
commit 6dafc85017
No known key found for this signature in database
GPG key ID: 5F87E02E5BC0939E

View file

@ -2940,31 +2940,29 @@ SDL_RenderDrawLines(SDL_Renderer * renderer,
if (!fpoints) { if (!fpoints) {
return SDL_OutOfMemory(); return SDL_OutOfMemory();
} }
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i) {
fpoints[i].x = points[i].x * renderer->scale.x; fpoints[i].x = points[i].x;
fpoints[i].y = points[i].y * renderer->scale.y; fpoints[i].y = points[i].y;
} }
retval = QueueCmdDrawLines(renderer, fpoints, count); retval = SDL_RenderDrawLinesF(renderer, fpoints, count);
SDL_small_free(fpoints, isstack); SDL_small_free(fpoints, isstack);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); return retval;
} }
int int
SDL_RenderDrawLinesF(SDL_Renderer * renderer, SDL_RenderDrawLinesF(SDL_Renderer * renderer,
const SDL_FPoint * points, int count) const SDL_FPoint * points, int count)
{ {
SDL_FPoint *fpoints;
int i;
int retval; int retval;
SDL_bool isstack;
CHECK_RENDERER_MAGIC(renderer, -1); CHECK_RENDERER_MAGIC(renderer, -1);
if (!points) { if (!points) {
return SDL_SetError("SDL_RenderDrawLines(): Passed NULL points"); return SDL_SetError("SDL_RenderDrawLinesF(): Passed NULL points");
} }
if (count < 2) { if (count < 2) {
return 0; return 0;
@ -2981,18 +2979,7 @@ SDL_RenderDrawLinesF(SDL_Renderer * renderer,
return RenderDrawLinesWithRectsF(renderer, points, count); return RenderDrawLinesWithRectsF(renderer, points, count);
} }
fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack); retval = QueueCmdDrawLines(renderer, points, count);
if (!fpoints) {
return SDL_OutOfMemory();
}
for (i = 0; i < count; ++i) {
fpoints[i].x = points[i].x * renderer->scale.x;
fpoints[i].y = points[i].y * renderer->scale.y;
}
retval = QueueCmdDrawLines(renderer, fpoints, count);
SDL_small_free(fpoints, isstack);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
} }