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

@ -27,7 +27,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
Last updated: October 24, 2021
Last updated: November 15, 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_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);
@ -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) {
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;
double in_line, closeness;
@ -144,6 +144,10 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Texture * textu
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))
@ -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);
@ -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
(See COPYING.txt)
June 14, 2002 - November 8, 2021
June 14, 2002 - November 15, 2021
*/
#include "platform.h"
@ -2071,7 +2071,7 @@ SDL_Joystick *joystick;
static void mainloop(void);
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 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)
{
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 direction, r;
int direction;
float m, b;
double r;
orig_x1 = x1;
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;
r = 0;
r = -1.0;
if (brushes_directional[cur_brush] || brushes_rotate[cur_brush])
{
r = brush_rotation(x1, y1, x2, y2);
if (brushes_directional[cur_brush])
{
r = r + 22;
if (r < 0)
r = r + 360;
r = r + 22.0;
if (r < 0.0)
r = r + 360.0;
if (x1 != x2 || y1 != y2)
direction = (r / 45);
direction = (r / 45.0);
}
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)
{
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
* attempt to draw something is guaranteed to
* do so, regardless of the brushe's spacing.
* Reset the brush counter, such that the next attempt to draw something
* is either (a) guaranteed to do so, regardless of the brush'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)
{
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 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;
@ -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.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;