Revert Fill stack explosion prevention
Not the way to do it.
This commit is contained in:
parent
af8fd5b8a1
commit
fcf1f66a03
2 changed files with 8 additions and 13 deletions
|
|
@ -8,7 +8,7 @@ http://www.tuxpaint.org/
|
|||
|
||||
$Id$
|
||||
|
||||
2021.November.15 (0.9.27)
|
||||
2021.November.16 (0.9.27)
|
||||
* New Magic Tools:
|
||||
----------------
|
||||
* "Lightning" - Draws a bolt of lightning striking between
|
||||
|
|
@ -194,7 +194,7 @@ $Id$
|
|||
(e.g., when returning from the "Open" dialog).
|
||||
(Closes https://sourceforge.net/p/tuxpaint/feature-requests/186/)
|
||||
|
||||
* Attempt to void crashing (by blowing up the stack) when doing
|
||||
* WIP - Attempt to void crashing (by blowing up the stack) when doing
|
||||
a flood-fill of a complicated shape on a large canvas
|
||||
(e.g., `tuxpaint --3000x2000` with `starters/mosaic.svg`).
|
||||
(h/t Yang for reporting, and Pere for confirming)
|
||||
|
|
|
|||
17
src/fill.c
17
src/fill.c
|
|
@ -27,7 +27,7 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: November 15, 2021
|
||||
Last updated: November 16, 2021
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
double colors_close(SDL_Surface * canvas, Uint32 c1, Uint32 c2);
|
||||
Uint32 blend(SDL_Surface * canvas, Uint32 draw_colr, Uint32 old_colr, double pct);
|
||||
void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Surface * last, SDL_Surface * canvas, int x, int y, Uint32 cur_colr, Uint32 old_colr, int * x1, int * y1, int * x2, int * y2, Uint8 * touched, int y_outside, Uint32 cnt);
|
||||
void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Surface * last, SDL_Surface * canvas, int x, int y, Uint32 cur_colr, Uint32 old_colr, int * x1, int * y1, int * x2, int * y2, Uint8 * touched, int y_outside);
|
||||
void draw_brush_fill_single(SDL_Surface * canvas, int x, int y, Uint32 draw_color, Uint8 * touched);
|
||||
|
||||
|
||||
|
|
@ -133,10 +133,10 @@ Uint32 blend(SDL_Surface * canvas, Uint32 draw_colr, Uint32 old_colr, double pct
|
|||
}
|
||||
|
||||
void simulate_flood_fill(SDL_Surface * screen, SDL_Surface * last, SDL_Surface * canvas, int x, int y, Uint32 cur_colr, Uint32 old_colr, int * x1, int * y1, int * x2, int * y2, Uint8 * touched) {
|
||||
simulate_flood_fill_outside_check(screen, last, canvas, x, y, cur_colr, old_colr, x1, y1, x2, y2, touched, 0, 0);
|
||||
simulate_flood_fill_outside_check(screen, last, canvas, x, y, cur_colr, old_colr, x1, y1, x2, y2, touched, 0);
|
||||
}
|
||||
|
||||
void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Surface * last, SDL_Surface * canvas, int x, int y, Uint32 cur_colr, Uint32 old_colr, int * x1, int * y1, int * x2, int * y2, Uint8 * touched, int y_outside, Uint32 cnt)
|
||||
void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Surface * last, SDL_Surface * canvas, int x, int y, Uint32 cur_colr, Uint32 old_colr, int * x1, int * y1, int * x2, int * y2, Uint8 * touched, int y_outside)
|
||||
{
|
||||
int fillL, fillR, narrowFillL, narrowFillR, i, outside;
|
||||
double in_line, closeness;
|
||||
|
|
@ -144,11 +144,6 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Surface * last,
|
|||
Uint32 px_colr;
|
||||
Uint8 touch_byt;
|
||||
|
||||
/* Don't blow up the stack! */
|
||||
/* FIXME: Would be better to do this a more reliable way */
|
||||
if (cnt >= 20000)
|
||||
return;
|
||||
|
||||
/* "Same" color? No need to fill */
|
||||
if (!would_flood_fill(canvas, cur_colr, old_colr))
|
||||
return;
|
||||
|
|
@ -317,7 +312,7 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Surface * last,
|
|||
)
|
||||
)
|
||||
{
|
||||
simulate_flood_fill_outside_check(screen, last, canvas, i, y - 1, cur_colr, old_colr, x1, y1, x2, y2, touched, y_outside + 1, cnt + 1);
|
||||
simulate_flood_fill_outside_check(screen, last, canvas, i, y - 1, cur_colr, old_colr, x1, y1, x2, y2, touched, y_outside + 1);
|
||||
}
|
||||
|
||||
px_colr = getpixels[last->format->BytesPerPixel] (last, i, y + 1);
|
||||
|
|
@ -329,7 +324,7 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Surface * last,
|
|||
)
|
||||
)
|
||||
{
|
||||
simulate_flood_fill_outside_check(screen, last, canvas, i, y + 1, cur_colr, old_colr, x1, y1, x2, y2, touched, y_outside + 1, cnt + 1);
|
||||
simulate_flood_fill_outside_check(screen, last, canvas, i, y + 1, cur_colr, old_colr, x1, y1, x2, y2, touched, y_outside + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue