Merge branch 'master' into sdl2.0

This commit is contained in:
Pere Pujal i Carabantes 2021-11-16 20:16:33 +01:00
commit 6b167caa74
5 changed files with 44 additions and 24 deletions

View file

@ -0,0 +1,2 @@
rotate
spacing=10

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

@ -8,7 +8,7 @@ http://www.tuxpaint.org/
$Id$ $Id$
2021.November.8 (0.9.27) 2021.November.15 (0.9.27)
* New Magic Tools: * New Magic Tools:
---------------- ----------------
* "Lightning" - Draws a bolt of lightning striking between * "Lightning" - Draws a bolt of lightning striking between
@ -66,6 +66,8 @@ $Id$
arrow which can rotate at any angle, using the new arrow which can rotate at any angle, using the new
"rotational" brush feature. "rotational" brush feature.
* Added "rotating dash" brush.
* Small icons appear on brush selection buttons denoting * Small icons appear on brush selection buttons denoting
when the brush is animated and/or directional. when the brush is animated and/or directional.
(Closes https://sourceforge.net/p/tuxpaint/bugs/183/) (Closes https://sourceforge.net/p/tuxpaint/bugs/183/)
@ -192,6 +194,11 @@ $Id$
(e.g., when returning from the "Open" dialog). (e.g., when returning from the "Open" dialog).
(Closes https://sourceforge.net/p/tuxpaint/feature-requests/186/) (Closes https://sourceforge.net/p/tuxpaint/feature-requests/186/)
* 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)
* Ports & Building * Ports & Building
---------------- ----------------
* Fix compilation error on Linux with HOST environment variable set. * Fix compilation error on Linux with HOST environment variable set.

View file

@ -27,7 +27,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
Last updated: October 24, 2021 Last updated: November 15, 2021
$Id$ $Id$
*/ */
@ -64,7 +64,7 @@
double colors_close(SDL_Surface * canvas, Uint32 c1, Uint32 c2); double colors_close(SDL_Surface * canvas, Uint32 c1, Uint32 c2);
Uint32 blend(SDL_Surface * canvas, Uint32 draw_colr, Uint32 old_colr, double pct); Uint32 blend(SDL_Surface * canvas, Uint32 draw_colr, Uint32 old_colr, double pct);
void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, 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 simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, 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 draw_brush_fill_single(SDL_Surface * canvas, int x, int y, Uint32 draw_color, Uint8 * touched); 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_Texture * texture, SDL_Renderer * renderer, 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) { void simulate_flood_fill(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, 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, texture, renderer, last, canvas, x, y, cur_colr, old_colr, x1, y1, x2, y2, touched, 0); simulate_flood_fill_outside_check(screen, texture, renderer, last, canvas, x, y, cur_colr, old_colr, x1, y1, x2, y2, touched, 0, 0);
} }
void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, 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 simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, 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)
{ {
int fillL, fillR, narrowFillL, narrowFillR, i, outside; int fillL, fillR, narrowFillL, narrowFillR, i, outside;
double in_line, closeness; double in_line, closeness;
@ -144,6 +144,10 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Texture * textu
Uint32 px_colr; Uint32 px_colr;
Uint8 touch_byt; 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 */ /* "Same" color? No need to fill */
if (!would_flood_fill(canvas, cur_colr, old_colr)) if (!would_flood_fill(canvas, cur_colr, old_colr))
@ -313,7 +317,7 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Texture * textu
) )
) )
{ {
simulate_flood_fill_outside_check(screen, texture, renderer, last, canvas, i, y - 1, cur_colr, old_colr, x1, y1, x2, y2, touched, y_outside + 1); simulate_flood_fill_outside_check(screen, texture, renderer, last, canvas, i, y - 1, cur_colr, old_colr, x1, y1, x2, y2, touched, y_outside + 1, cnt + 1);
} }
px_colr = getpixels[last->format->BytesPerPixel] (last, i, y + 1); px_colr = getpixels[last->format->BytesPerPixel] (last, i, y + 1);
@ -325,7 +329,7 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Texture * textu
) )
) )
{ {
simulate_flood_fill_outside_check(screen, texture, renderer, last, canvas, i, y + 1, cur_colr, old_colr, x1, y1, x2, y2, touched, y_outside + 1); simulate_flood_fill_outside_check(screen, texture, renderer, last, canvas, i, y + 1, cur_colr, old_colr, x1, y1, x2, y2, touched, y_outside + 1, cnt + 1);
} }
} }
} }

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
June 14, 2002 - November 8, 2021 June 14, 2002 - November 15, 2021
*/ */
#include "platform.h" #include "platform.h"
@ -2071,7 +2071,7 @@ SDL_Joystick *joystick;
static void mainloop(void); static void mainloop(void);
static void brush_draw(int x1, int y1, int x2, int y2, int update); static void brush_draw(int x1, int y1, int x2, int y2, int update);
static void blit_brush(int x, int y, int direction, int rotation, int * w, int * h); static void blit_brush(int x, int y, int direction, double rotation, int * w, int * h);
static void stamp_draw(int x, int y); static void stamp_draw(int x, int y);
static void rec_undo_buffer(void); static void rec_undo_buffer(void);
@ -6307,10 +6307,11 @@ static void draw_blinking_cursor(void)
*/ */
static void brush_draw(int x1, int y1, int x2, int y2, int update) static void brush_draw(int x1, int y1, int x2, int y2, int update)
{ {
int dx, dy, y, frame_w, w, h; int dx, dy, y, frame_w, w, h, sz;
int orig_x1, orig_y1, orig_x2, orig_y2, tmp; int orig_x1, orig_y1, orig_x2, orig_y2, tmp;
int direction, r; int direction;
float m, b; float m, b;
double r;
orig_x1 = x1; orig_x1 = x1;
orig_y1 = y1; orig_y1 = y1;
@ -6331,22 +6332,22 @@ static void brush_draw(int x1, int y1, int x2, int y2, int update)
direction = BRUSH_DIRECTION_NONE; direction = BRUSH_DIRECTION_NONE;
r = 0; r = -1.0;
if (brushes_directional[cur_brush] || brushes_rotate[cur_brush]) if (brushes_directional[cur_brush] || brushes_rotate[cur_brush])
{ {
r = brush_rotation(x1, y1, x2, y2); r = brush_rotation(x1, y1, x2, y2);
if (brushes_directional[cur_brush]) if (brushes_directional[cur_brush])
{ {
r = r + 22; r = r + 22.0;
if (r < 0) if (r < 0.0)
r = r + 360; r = r + 360.0;
if (x1 != x2 || y1 != y2) if (x1 != x2 || y1 != y2)
direction = (r / 45); direction = (r / 45.0);
} }
else else
{ {
r = 270 - r; r = 270.0 - r;
} }
} }
@ -6414,19 +6415,25 @@ static void brush_draw(int x1, int y1, int x2, int y2, int update)
if (update) if (update)
{ {
update_canvas(orig_x1 - (w >> 1), orig_y1 - (h >> 1), orig_x2 + (w >> 1), orig_y2 + (h >> 1)); sz = max(w,h);
update_canvas(orig_x1 - sz, orig_y1 - sz, orig_x2 + sz, orig_y2 + sz);
} }
} }
/** /**
* Reset the brush counter, such that the next * Reset the brush counter, such that the next attempt to draw something
* attempt to draw something is guaranteed to * is either (a) guaranteed to do so, regardless of the brush's spacing
* do so, regardless of the brushe's spacing. * (for non-rotational brushes), or (b) requires the user to have moved
* far enough to get a good idea of the angle they're drawing
* (for rotational brushes).
*/ */
void reset_brush_counter(void) void reset_brush_counter(void)
{ {
brush_counter = 999; if (img_cur_brush_rotate)
brush_counter = 0;
else
brush_counter = 999;
} }
@ -6442,7 +6449,7 @@ void reset_brush_counter(void)
* @param direction BRUSH_DIRECTION_... being drawn (for compass direction brushes) * @param direction BRUSH_DIRECTION_... being drawn (for compass direction brushes)
* @param rotation angle being drawn (for brushes which may rotate at any angle (0-360 degrees)) * @param rotation angle being drawn (for brushes which may rotate at any angle (0-360 degrees))
*/ */
static void blit_brush(int x, int y, int direction, int rotation, int * w, int * h) static void blit_brush(int x, int y, int direction, double rotation, int * w, int * h)
{ {
SDL_Rect src, dest; SDL_Rect src, dest;
@ -6515,7 +6522,7 @@ static void blit_brush(int x, int y, int direction, int rotation, int * w, int *
src.w = img_cur_brush_w; src.w = img_cur_brush_w;
src.h = img_cur_brush_h; src.h = img_cur_brush_h;
if (img_cur_brush_rotate) if (img_cur_brush_rotate && rotation != -1.0 /* only if we're moving */)
{ {
SDL_Surface * rotated_brush; SDL_Surface * rotated_brush;