Blender  V3.3
gpencil_trace.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2020 Blender Foundation. All rights reserved. */
3 
8 #pragma once
9 
10 /* internal exports only */
11 struct FILE;
12 struct ImBuf;
13 struct Main;
14 struct Object;
15 struct bGPDframe;
16 
17 #include "potracelib.h"
18 
19 /* Potrace macros for writing individual bitmap pixels. */
20 #define BM_WORDSIZE ((int)sizeof(potrace_word))
21 #define BM_WORDBITS (8 * BM_WORDSIZE)
22 #define BM_HIBIT (((potrace_word)1) << (BM_WORDBITS - 1))
23 #define BM_ALLBITS (~(potrace_word)0)
24 
25 #define bm_scanline(bm, y) ((bm)->map + (y) * (bm)->dy)
26 #define bm_index(bm, x, y) (&bm_scanline(bm, y)[(x) / BM_WORDBITS])
27 #define bm_mask(x) (BM_HIBIT >> ((x) & (BM_WORDBITS - 1)))
28 #define bm_range(x, a) ((int)(x) >= 0 && (int)(x) < (a))
29 #define bm_safe(bm, x, y) (bm_range(x, (bm)->w) && bm_range(y, (bm)->h))
30 
31 #define BM_UGET(bm, x, y) ((*bm_index(bm, x, y) & bm_mask(x)) != 0)
32 #define BM_USET(bm, x, y) (*bm_index(bm, x, y) |= bm_mask(x))
33 #define BM_UCLR(bm, x, y) (*bm_index(bm, x, y) &= ~bm_mask(x))
34 #define BM_UINV(bm, x, y) (*bm_index(bm, x, y) ^= bm_mask(x))
35 #define BM_UPUT(bm, x, y, b) ((b) ? BM_USET(bm, x, y) : BM_UCLR(bm, x, y))
36 #define BM_GET(bm, x, y) (bm_safe(bm, x, y) ? BM_UGET(bm, x, y) : 0)
37 #define BM_SET(bm, x, y) (bm_safe(bm, x, y) ? BM_USET(bm, x, y) : 0)
38 #define BM_CLR(bm, x, y) (bm_safe(bm, x, y) ? BM_UCLR(bm, x, y) : 0)
39 #define BM_INV(bm, x, y) (bm_safe(bm, x, y) ? BM_UINV(bm, x, y) : 0)
40 #define BM_PUT(bm, x, y, b) (bm_safe(bm, x, y) ? BM_UPUT(bm, x, y, b) : 0)
41 
42 /* Trace modes */
43 #define GPENCIL_TRACE_MODE_SINGLE 0
44 #define GPENCIL_TRACE_MODE_SEQUENCE 1
45 
51 void ED_gpencil_trace_bitmap_print(FILE *f, const potrace_bitmap_t *bm);
52 
59 potrace_bitmap_t *ED_gpencil_trace_bitmap_new(int32_t w, int32_t h);
64 void ED_gpencil_trace_bitmap_free(const potrace_bitmap_t *bm);
69 void ED_gpencil_trace_bitmap_invert(const potrace_bitmap_t *bm);
70 
76 void ED_gpencil_trace_image_to_bitmap(struct ImBuf *ibuf,
77  const potrace_bitmap_t *bm,
78  float threshold);
79 
88 void ED_gpencil_trace_data_to_strokes(struct Main *bmain,
89  potrace_state_t *st,
90  struct Object *ob,
91  struct bGPDframe *gpf,
92  int32_t offset[2],
93  float scale,
94  float sample,
95  int32_t resolution,
96  int32_t thickness);
ATTR_WARN_UNUSED_RESULT BMesh * bm
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
void ED_gpencil_trace_bitmap_print(FILE *f, const potrace_bitmap_t *bm)
void ED_gpencil_trace_data_to_strokes(struct Main *bmain, potrace_state_t *st, struct Object *ob, struct bGPDframe *gpf, int32_t offset[2], float scale, float sample, int32_t resolution, int32_t thickness)
void ED_gpencil_trace_bitmap_free(const potrace_bitmap_t *bm)
void ED_gpencil_trace_image_to_bitmap(struct ImBuf *ibuf, const potrace_bitmap_t *bm, float threshold)
void ED_gpencil_trace_bitmap_invert(const potrace_bitmap_t *bm)
potrace_bitmap_t * ED_gpencil_trace_bitmap_new(int32_t w, int32_t h)
ccl_gpu_kernel_postfix ccl_global float int int int int float threshold
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
signed int int32_t
Definition: stdint.h:77
Definition: BKE_main.h:121