Welcome to mirror list, hosted at ThFree Co, Russian Federation.

lineart_intern.h « lineart « intern « gpencil_modifiers « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 65ba3a003f11a50b21cc96d1b9e14920f5c16914 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* SPDX-License-Identifier: GPL-2.0-or-later
 * Copyright 2019 Blender Foundation. All rights reserved. */

/** \file
 * \ingroup editors
 */

#pragma once

#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_threads.h"

#include "DNA_lineart_types.h"

#include <math.h>
#include <string.h>

struct LineartEdge;
struct LineartRenderBuffer;
struct LineartStaticMemPool;
struct LineartStaticMemPoolNode;

void *lineart_list_append_pointer_pool(ListBase *list,
                                       struct LineartStaticMemPool *smp,
                                       void *data);
void *lineart_list_append_pointer_pool_sized(ListBase *list,
                                             struct LineartStaticMemPool *smp,
                                             void *data,
                                             int size);
void *lineart_list_append_pointer_pool_thread(ListBase *list,
                                              struct LineartStaticMemPool *smp,
                                              void *data);
void *lineart_list_append_pointer_pool_sized_thread(ListBase *list,
                                                    LineartStaticMemPool *smp,
                                                    void *data,
                                                    int size);
void *list_push_pointer_static(ListBase *list, struct LineartStaticMemPool *smp, void *p);
void *list_push_pointer_static_sized(ListBase *list,
                                     struct LineartStaticMemPool *smp,
                                     void *p,
                                     int size);

void *lineart_list_pop_pointer_no_free(ListBase *list);
void lineart_list_remove_pointer_item_no_free(ListBase *list, LinkData *lip);

struct LineartStaticMemPoolNode *lineart_mem_new_static_pool(struct LineartStaticMemPool *smp,
                                                             size_t size);
void *lineart_mem_acquire(struct LineartStaticMemPool *smp, size_t size);
void *lineart_mem_acquire_thread(struct LineartStaticMemPool *smp, size_t size);
void lineart_mem_destroy(struct LineartStaticMemPool *smp);

void lineart_prepend_edge_direct(void **list_head, void *node);
void lineart_prepend_pool(LinkNode **first, struct LineartStaticMemPool *smp, void *link);

void lineart_matrix_ortho_44d(double (*mProjection)[4],
                              double xMin,
                              double xMax,
                              double yMin,
                              double yMax,
                              double zMin,
                              double zMax);
void lineart_matrix_perspective_44d(
    double (*mProjection)[4], double fFov_rad, double fAspect, double zMin, double zMax);

int lineart_count_intersection_segment_count(struct LineartRenderBuffer *rb);

void lineart_count_and_print_render_buffer_memory(struct LineartRenderBuffer *rb);

#define LRT_ITER_ALL_LINES_BEGIN \
  { \
    LineartEdge *e; \
    for (int __i = 0; __i < rb->pending_edges.next; __i++) { \
      e = rb->pending_edges.array[__i];

#define LRT_ITER_ALL_LINES_NEXT ; /* Doesn't do anything now with new array setup. */

#define LRT_ITER_ALL_LINES_END \
  LRT_ITER_ALL_LINES_NEXT \
  } \
  }

#define LRT_BOUND_AREA_CROSSES(b1, b2) \
  ((b1)[0] < (b2)[1] && (b1)[1] > (b2)[0] && (b1)[3] < (b2)[2] && (b1)[2] > (b2)[3])

/* Initial bounding area row/column count, setting 10 is tested to be realitvely optimal for the
 * performance under current CAS algorithm. */
#define LRT_BA_ROWS 10

#ifdef __cplusplus
extern "C" {
#endif

void lineart_sort_adjacent_items(LineartAdjacentEdge *ai, int length);

#ifdef __cplusplus
}
#endif

#ifndef __cplusplus /* Compatibility code for atomics, only for C. */

#  if defined __has_include /* Try to use C11 atomics support. */
#    if __has_include(<stdatomic.h>)
#      include <stdatomic.h>
#      define lineart_atomic_load(p) atomic_load((volatile size_t *)p)
#      define lineart_atomic_store(p, d) atomic_store((volatile size_t *)p, (size_t)d)
#    endif
#  endif

#  ifdef _MSC_VER /* Atomics walkaround for windows. */
#    define WIN32_LEAN_AND_MEAN
#    include <windows.h>
#    define lineart_atomic_load(p) (MemoryBarrier(), *(p))
#    define lineart_atomic_store(p, d) \
      do { \
        *(p) = (d); \
        MemoryBarrier(); \
      } while (0)
#  endif

#  if !defined lineart_atomic_load /* Fallback */
#    include "atomic_ops.h"
#    define lineart_atomic_load(p) atomic_add_and_fetch_z((size_t *)p, 0)
#    define lineart_atomic_store(p, d) atomic_add_and_fetch_z((size_t *)p, (size_t)d)
#  endif

#endif /* !__cplusplus */