mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-22 06:41:08 +00:00
Remove dependency with Allegro library in algofill.cpp
This commit is contained in:
parent
cab6ecbfda
commit
817fac5e6f
@ -14,31 +14,30 @@
|
|||||||
#include "raster/image.h"
|
#include "raster/image.h"
|
||||||
#include "raster/primitives.h"
|
#include "raster/primitives.h"
|
||||||
|
|
||||||
#include <allegro.h>
|
#include <climits>
|
||||||
#include <allegro/internal/aintern.h>
|
#include <cmath>
|
||||||
#include <limits.h>
|
#include <vector>
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
namespace raster {
|
namespace raster {
|
||||||
|
|
||||||
typedef struct FLOODED_LINE /* store segments which have been flooded */
|
struct FLOODED_LINE { // store segments which have been flooded
|
||||||
{
|
short flags; // status of the segment
|
||||||
short flags; /* status of the segment */
|
short lpos, rpos; // left and right ends of segment
|
||||||
short lpos, rpos; /* left and right ends of segment */
|
short y; // y coordinate of the segment
|
||||||
short y; /* y coordinate of the segment */
|
int next; // linked list if several per line
|
||||||
int next; /* linked list if several per line */
|
};
|
||||||
} FLOODED_LINE;
|
|
||||||
|
|
||||||
/* Note: a 'short' is not sufficient for 'next' above in some corner cases. */
|
/* Note: a 'short' is not sufficient for 'next' above in some corner cases. */
|
||||||
|
|
||||||
|
|
||||||
|
static std::vector<FLOODED_LINE> flood_buf;
|
||||||
static int flood_count; /* number of flooded segments */
|
static int flood_count; /* number of flooded segments */
|
||||||
|
|
||||||
#define FLOOD_IN_USE 1
|
#define FLOOD_IN_USE 1
|
||||||
#define FLOOD_TODO_ABOVE 2
|
#define FLOOD_TODO_ABOVE 2
|
||||||
#define FLOOD_TODO_BELOW 4
|
#define FLOOD_TODO_BELOW 4
|
||||||
|
|
||||||
#define FLOOD_LINE(c) (((FLOODED_LINE *)_scratch_mem) + c)
|
#define FLOOD_LINE(c) (&flood_buf[c])
|
||||||
|
|
||||||
static inline bool color_equal_32(color_t c1, color_t c2, int tolerance)
|
static inline bool color_equal_32(color_t c1, color_t c2, int tolerance)
|
||||||
{
|
{
|
||||||
@ -232,7 +231,7 @@ static int flooder(Image *image, int x, int y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
p->next = c = flood_count++;
|
p->next = c = flood_count++;
|
||||||
_grow_scratch_mem(sizeof(FLOODED_LINE) * flood_count);
|
flood_buf.resize(flood_count);
|
||||||
p = FLOOD_LINE(c);
|
p = FLOOD_LINE(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,9 +340,9 @@ void algo_floodfill(Image* image, int x, int y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* set up the list of flooded segments */
|
/* set up the list of flooded segments */
|
||||||
_grow_scratch_mem(sizeof(FLOODED_LINE) * image->height());
|
flood_buf.resize(image->height());
|
||||||
flood_count = image->height();
|
flood_count = image->height();
|
||||||
FLOODED_LINE* p = (FLOODED_LINE*)_scratch_mem;
|
FLOODED_LINE* p = (FLOODED_LINE*)&flood_buf[0];
|
||||||
for (int c=0; c<flood_count; c++) {
|
for (int c=0; c<flood_count; c++) {
|
||||||
p[c].flags = 0;
|
p[c].flags = 0;
|
||||||
p[c].lpos = SHRT_MAX;
|
p[c].lpos = SHRT_MAX;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user