13 const unsigned int *limask,
14 const unsigned int *lomask,
30 if ((!limask[
x - rw] && lomask[
x - rw]) || (!limask[
x + 1] && lomask[
x + 1])) {
48 if ((!limask[
x - rw] && lomask[
x - rw]) || (!limask[
x - 1] && lomask[
x - 1])) {
66 if ((!limask[
x + rw] && lomask[
x + rw]) || (!limask[
x + 1] && lomask[
x + 1])) {
84 if ((!limask[
x + rw] && lomask[
x + rw]) || (!limask[
x - 1] && lomask[
x - 1])) {
98 for (
x =
t - 1;
x >= (
t - rw) + 2;
x--) {
103 if ((!limask[
x - 1] && lomask[
x - 1]) || (!limask[
x + 1] && lomask[
x + 1])) {
111 else if (lomask[
x]) {
118 for (
x = rw - 2;
x;
x--) {
123 if ((!limask[
x - 1] && lomask[
x - 1]) || (!limask[
x + 1] && lomask[
x + 1])) {
131 else if (lomask[
x]) {
137 for (
x =
t - (rw << 1) + 1;
x >= rw;
x -= rw) {
142 if ((!limask[
x - rw] && lomask[
x - rw]) || (!limask[
x + rw] && lomask[
x + rw])) {
150 else if (lomask[
x]) {
157 for (
x =
t - rw;
x > rw;
x -= rw) {
162 if ((!limask[
x - rw] && lomask[
x - rw]) || (!limask[
x + rw] && lomask[
x + rw])) {
170 else if (lomask[
x]) {
183 const unsigned int *limask,
184 const unsigned int *lomask,
190 unsigned int isz = 0;
191 unsigned int osz = 0;
192 unsigned int gsz = 0;
200 if ((!limask[
x - rw] && lomask[
x - rw]) || (!limask[
x + 1] && lomask[
x + 1])) {
208 else if (lomask[
x]) {
209 if (!lomask[
x - rw] ||
225 if ((!limask[
x - rw] && lomask[
x - rw]) || (!limask[
x - 1] && lomask[
x - 1])) {
233 else if (lomask[
x]) {
234 if (!lomask[
x - rw] ||
250 if ((!limask[
x + rw] && lomask[
x + rw]) || (!limask[
x + 1] && lomask[
x + 1])) {
258 else if (lomask[
x]) {
259 if (!lomask[
x + rw] ||
275 if ((!limask[
x + rw] && lomask[
x + rw]) || (!limask[
x - 1] && lomask[
x - 1])) {
283 else if (lomask[
x]) {
284 if (!lomask[
x + rw] ||
295 for (
x =
t - 1;
x >= (
t - rw) + 2;
x--) {
300 if ((!limask[
x - 1] && lomask[
x - 1]) || (!limask[
x + 1] && lomask[
x + 1])) {
308 else if (lomask[
x]) {
309 if (!lomask[
x - 1] ||
322 for (
x = rw - 2;
x;
x--) {
327 if ((!limask[
x - 1] && lomask[
x - 1]) || (!limask[
x + 1] && lomask[
x + 1])) {
335 else if (lomask[
x]) {
336 if (!lomask[
x - 1] ||
348 for (
x =
t - (rw << 1) + 1;
x >= rw;
x -= rw) {
353 if ((!limask[
x - rw] && lomask[
x - rw]) || (!limask[
x + rw] && lomask[
x + rw])) {
361 else if (lomask[
x]) {
362 if (!lomask[
x - rw] ||
375 for (
x =
t - rw;
x > rw;
x -= rw) {
380 if ((!limask[
x - rw] && lomask[
x - rw]) || (!limask[
x + rw] && lomask[
x + rw])) {
388 else if (lomask[
x]) {
389 if (!lomask[
x - rw] ||
408 const unsigned int *limask,
409 const unsigned int *lomask,
415 unsigned int isz = 0;
416 unsigned int osz = 0;
417 unsigned int gsz = 0;
424 if (!limask[
x - rw] || !limask[
x + 1]) {
432 else if (lomask[
x]) {
441 if (!limask[
x - rw] || !limask[
x - 1]) {
449 else if (lomask[
x]) {
458 if (!limask[
x + rw] || !limask[
x + 1]) {
466 else if (lomask[
x]) {
475 if (!limask[
x + rw] || !limask[
x - 1]) {
483 else if (lomask[
x]) {
489 for (
x =
t - 1;
x >= (
t - rw) + 2;
x--) {
493 if (!limask[
x - 1] || !limask[
x + 1]) {
501 else if (lomask[
x]) {
508 for (
x = rw - 2;
x;
x--) {
512 if (!limask[
x - 1] || !limask[
x + 1]) {
520 else if (lomask[
x]) {
526 for (
x =
t - (rw << 1) + 1;
x >= rw;
x -= rw) {
530 if (!limask[
x - rw] || !limask[
x + rw]) {
538 else if (lomask[
x]) {
545 for (
x =
t - rw;
x > rw;
x -= rw) {
549 if (!limask[
x - rw] || !limask[
x + rw]) {
557 else if (lomask[
x]) {
570 const unsigned int *limask,
571 const unsigned int *lomask,
577 unsigned int isz = 0;
578 unsigned int osz = 0;
579 unsigned int gsz = 0;
586 if (!limask[
x - rw] || !limask[
x + 1]) {
594 else if (lomask[
x]) {
595 if (!lomask[
x - rw] ||
610 if (!limask[
x - rw] || !limask[
x - 1]) {
618 else if (lomask[
x]) {
619 if (!lomask[
x - rw] ||
634 if (!limask[
x + rw] || !limask[
x + 1]) {
642 else if (lomask[
x]) {
643 if (!lomask[
x + rw] ||
658 if (!limask[
x + rw] || !limask[
x - 1]) {
666 else if (lomask[
x]) {
667 if (!lomask[
x + rw] ||
678 for (
x =
t - 1;
x >= (
t - rw) + 2;
x--) {
682 if (!limask[
x - 1] || !limask[
x + 1]) {
690 else if (lomask[
x]) {
691 if (!lomask[
x - 1] ||
704 for (
x = rw - 2;
x;
x--) {
708 if (!limask[
x - 1] || !limask[
x + 1]) {
716 else if (lomask[
x]) {
717 if (!lomask[
x - 1] ||
729 for (
x =
t - (rw << 1) + 1;
x >= rw;
x -= rw) {
733 if (!limask[
x - rw] || !limask[
x + rw]) {
741 else if (lomask[
x]) {
742 if (!lomask[
x - rw] ||
755 for (
x =
t - rw;
x > rw;
x -= rw) {
759 if (!limask[
x - rw] || !limask[
x + rw]) {
767 else if (lomask[
x]) {
768 if (!lomask[
x - rw] ||
787 const unsigned int *limask,
788 const unsigned int *lomask,
805 for (
x = (
t - rw) + 1, dx =
x - (rw - 2); dx > rw;
x -= rw, dx -= rw) {
807 pix_prevRow =
a + rw;
808 pix_nextRow =
a - rw;
820 if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) ||
821 (!lomask[pix_prevCol] && !limask[pix_prevCol]) ||
822 (!lomask[pix_nextRow] && !limask[pix_nextRow]) ||
823 (!lomask[pix_prevRow] && !limask[pix_prevRow])) {
834 if (!limask[pix_nextCol] || !limask[pix_prevCol] || !limask[pix_nextRow] ||
835 !limask[pix_prevRow]) {
858 const unsigned int *limask,
859 const unsigned int *lomask,
875 for (
x = (
t - rw) + 1, dx =
x - (rw - 2); dx > rw;
x -= rw, dx -= rw) {
877 pix_prevRow =
a + rw;
878 pix_nextRow =
a - rw;
890 if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) ||
891 (!lomask[pix_prevCol] && !limask[pix_prevCol]) ||
892 (!lomask[pix_nextRow] && !limask[pix_nextRow]) ||
893 (!lomask[pix_prevRow] && !limask[pix_prevRow])) {
904 if ((!limask[pix_nextCol] && lomask[pix_nextCol]) ||
905 (!limask[pix_prevCol] && lomask[pix_prevCol]) ||
906 (!limask[pix_nextRow] && lomask[pix_nextRow]) ||
907 (!limask[pix_prevRow] && lomask[pix_prevRow])) {
930 const unsigned int *lres,
932 unsigned short *gbuf,
933 unsigned int *inner_edge_offset,
934 unsigned int *outer_edge_offset,
944 unsigned int gradient_fill_offset;
947 unsigned int inner_accum = 0;
949 unsigned int outer_accum = 0;
951 unsigned int gradient_accum = 0;
1018 gradient_fill_offset = 0;
1019 *inner_edge_offset = gradient_fill_offset + gsz;
1020 *outer_edge_offset = (*inner_edge_offset) + isz;
1023 gradient_accum = gradient_fill_offset;
1024 inner_accum = *inner_edge_offset;
1025 outer_accum = *outer_edge_offset;
1027 for (
x = 0, dmin = 0;
x <
t;
x += rw, dmin++) {
1028 for (rsl = 0; rsl < rw; rsl++) {
1031 ud = gradient_accum << 1;
1036 else if (lres[
a] == 3) {
1037 ud = outer_accum << 1;
1043 else if (lres[
a] == 4) {
1044 ud = inner_accum << 1;
1056 const unsigned short *gbuf,
1060 unsigned int inner_edge_offset,
1061 unsigned int outer_edge_offset)
1068 const float rsopf = 1.5f;
1070 unsigned int gradient_fill_offset;
1138 for (
x = gsz - 1;
x >= 0;
x--) {
1139 gradient_fill_offset =
x << 1;
1140 t = gbuf[gradient_fill_offset];
1141 fsz = gbuf[gradient_fill_offset + 1];
1143 for (
a = outer_edge_offset + osz - 1;
a >= outer_edge_offset;
1147 dx = fsz - gbuf[ud + 1];
1148 ud = dx * dx + dy * dy;
1153 odist = (
float)(dmin);
1155 rsl = *(
unsigned int *)&odist;
1156 rsl = 0x5f3759df - (rsl >> 1);
1157 odist = *(
float *)&rsl;
1158 odist = odist * (rsopf - (rsf * odist *
1161 for (
a = inner_edge_offset + isz - 1;
a >= inner_edge_offset;
1165 dx = fsz - gbuf[ud + 1];
1166 ud = dx * dx + dy * dy;
1174 idist = (
float)(dmin);
1176 rsl = *(
unsigned int *)&idist;
1179 rsl = 0x5f3759df - (rsl >> 1);
1180 idist = *(
float *)&rsl;
1181 idist = idist * (rsopf - (rsf * idist * idist));
1189 res[gbuf[gradient_fill_offset + 1] + (gbuf[gradient_fill_offset] * rw)] =
1190 (idist / (idist + odist));
1199 unsigned int *limask;
1200 unsigned int *lomask;
1206 unsigned int isz = 0;
1207 unsigned int osz = 0;
1208 unsigned int gsz = 0;
1209 unsigned int rsize[3];
1210 unsigned int inner_edge_offset =
1212 unsigned int outer_edge_offset =
1215 unsigned short *gbuf;
1226 lres = (
unsigned int *)res;
1227 limask = (
unsigned int *)imask;
1228 lomask = (
unsigned int *)omask;
1255 if (adjacent_only_) {
1292 fsz = gsz + isz + osz;
1294 gbuf = (
unsigned short *)
MEM_callocN(
sizeof(
unsigned short) * fsz * 2,
"DEM");
1297 t, rw, lres, res, gbuf, &inner_edge_offset, &outer_edge_offset, isz, gsz);
1310 input_inner_mask_ =
nullptr;
1311 input_outer_mask_ =
nullptr;
1312 adjacent_only_ =
false;
1313 keep_inside_ =
false;
1315 is_output_rendered_ =
false;
1321 if (cached_instance_ ==
nullptr) {
1338 cached_instance_ =
nullptr;
1343 if (cached_instance_) {
1344 return cached_instance_;
1348 if (cached_instance_ ==
nullptr) {
1356 cached_instance_ =
data;
1359 return cached_instance_;
1365 output[0] =
buffer[index];
1370 input_inner_mask_ =
nullptr;
1371 input_outer_mask_ =
nullptr;
1373 if (cached_instance_) {
1375 cached_instance_ =
nullptr;
1390 if (!is_output_rendered_) {
1404 is_output_rendered_ =
true;
1406 if (inner_mask != input_inner_mask) {
1409 if (outer_mask != input_outer_mask) {
typedef float(TangentPoint)[2]
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
void update_memory_buffer(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
DoubleEdgeMaskOperation()
void execute_pixel(float output[4], int x, int y, void *data) override
void init_execution() override
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override
Get input operation area being read by this operation on rendering given output area.
void deinit_execution() override
void do_double_edge_mask(float *imask, float *omask, float *res)
void * initialize_tile_data(rcti *rect) override
bool determine_depending_area_of_interest(rcti *input, ReadBufferOperation *read_operation, rcti *output) override
a MemoryBuffer contains access to the data of a chunk
MemoryBuffer * inflate() const
bool is_a_single_elem() const
float * get_buffer()
get the data of this MemoryBuffer
unsigned int get_height() const
void add_output_socket(DataType datatype)
SocketReader * get_input_socket_reader(unsigned int index)
unsigned int get_width() const
NodeOperationFlags flags_
const rcti & get_canvas() const
virtual bool determine_depending_area_of_interest(rcti *input, ReadBufferOperation *read_operation, rcti *output)
void add_input_socket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
virtual void * initialize_tile_data(rcti *)
ccl_global float * buffer
ccl_global KernelShaderEvalInput ccl_global float * output
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
static void do_createEdgeLocationBuffer(unsigned int t, unsigned int rw, const unsigned int *lres, float *res, unsigned short *gbuf, unsigned int *inner_edge_offset, unsigned int *outer_edge_offset, unsigned int isz, unsigned int gsz)
static void area(int d1, int d2, int e1, int e2, float weights[2])
static void do_adjacentKeepBorders(unsigned int t, unsigned int rw, const unsigned int *limask, const unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize)
static void do_fillGradientBuffer(unsigned int rw, float *res, const unsigned short *gbuf, unsigned int isz, unsigned int osz, unsigned int gsz, unsigned int inner_edge_offset, unsigned int outer_edge_offset)
static void do_allEdgeDetection(unsigned int t, unsigned int rw, const unsigned int *limask, const unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize, unsigned int in_isz, unsigned int in_osz, unsigned int in_gsz)
static void do_allBleedBorders(unsigned int t, unsigned int rw, const unsigned int *limask, const unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize)
static void do_adjacentEdgeDetection(unsigned int t, unsigned int rw, const unsigned int *limask, const unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize, unsigned int in_isz, unsigned int in_osz, unsigned int in_gsz)
static void do_allKeepBorders(unsigned int t, unsigned int rw, const unsigned int *limask, const unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize)
static void do_adjacentBleedBorders(unsigned int t, unsigned int rw, const unsigned int *limask, const unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize)
static bNodeSocketTemplate inputs[]