48 r_rgb[0] = r_rgb[1] = r_rgb[2] = 255;
52 r_rgb[1] = r_rgb[2] = 0;
57 r_rgb[1] = r_rgb[2] = 0;
70 r_rgb[0] = r_rgb[2] = 0;
74 r_rgb[0] = r_rgb[2] = 0;
91 const float handle_size,
92 const float point_pos[2],
93 const float handle_pos[2])
99 handle_type = bezt->
h1;
102 handle_type = bezt->
h2;
111 const uchar rgb_gray[4] = {0x60, 0x60, 0x60, 0xff};
125 switch (handle_type) {
150 float point_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
174 const char draw_type)
176 const bool is_spline_sel = (spline->flag &
SELECT) &&
182 bool undistort =
false;
184 int tot_feather_point;
185 float(*feather_points)[2], (*fp)[2];
186 float min[2], max[2];
188 if (!spline->tot_point) {
209 for (
int i = 0; i < spline->tot_point; i++) {
214 for (
int j = 0; j <= point->tot_uw; j++) {
215 float feather_point[2];
228 sel = (point->uw[j - 1].flag &
SELECT) != 0;
258 for (
int i = 0; i < spline->tot_point; i++) {
284 float handle_left[2], handle_right[2];
325 float x = (
min[0] + max[0]) * 0.5f;
326 float y = (
min[1] + max[1]) * 0.5f;
352 r_rgb[0] =
uchar((
int(rgb[0]) + 128) / 2);
353 r_rgb[1] =
uchar((
int(rgb[1]) + 128) / 2);
354 r_rgb[2] =
uchar((
int(rgb[2]) + 128) / 2);
358 *(
uint *)r_rgb = *(
const uint *)rgb;
364 const float (*points)[2],
368 for (
uint i = 0; i < vertex_len; i++) {
376 float (*orig_points)[2],
378 const bool is_feather,
379 const bool is_active,
380 const uchar rgb_spline[4],
381 const char draw_type)
385 const uchar rgb_black[4] = {0x00, 0x00, 0x00, 0xff};
388 float(*points)[2] = orig_points;
394 points = MEM_cnew_array<float[2]>(tot_point,
"undistorthed mask curve");
396 for (
int i = 0; i < tot_point; i++) {
434 rgb_tmp[0] = rgb_tmp[1] = rgb_tmp[2] = 0;
437 rgb_tmp[0] = rgb_tmp[1] = rgb_tmp[2] = 255;
448 rgb_tmp[0] =
uchar((
short(rgb_tmp[0]) +
short(rgb_spline[0])) / 2);
449 rgb_tmp[1] =
uchar((
short(rgb_tmp[1]) +
short(rgb_spline[1])) / 2);
450 rgb_tmp[2] =
uchar((
short(rgb_tmp[2]) +
short(rgb_spline[2])) / 2);
470 float viewport_size[4];
492 if (points != orig_points) {
500 const char draw_type,
501 const bool is_active,
510 const bool is_spline_sel = (spline->flag &
SELECT) &&
515 float(*diff_points)[2];
517 uint tot_feather_point;
518 float(*feather_points)[2];
529 spline, resol, (is_fill !=
false), &tot_feather_point);
534 C, spline, feather_points, tot_feather_point,
true, is_active, rgb_tmp, draw_type);
537 const float *fp = &diff_points[0][0];
538 float *fp_feather = &feather_points[0][0];
540 BLI_assert(tot_diff_point == tot_feather_point);
542 for (
int i = 0; i < tot_diff_point; i++, fp += 2, fp_feather += 2) {
550 C, spline, feather_points, tot_feather_point,
true, is_active, rgb_tmp, draw_type);
558 C, spline, diff_points, tot_diff_point,
false, is_active, rgb_tmp, draw_type);
566 const char draw_type,
569 const bool is_active)
584 spline->points_deform =
nullptr;
587 spline->points_deform = back;
593 const bContext *C,
Mask *mask,
const char draw_type,
const int width,
const int height)
601 const bool is_active = (i == mask->masklay_act);
615 if (active !=
nullptr) {
626 float *buffer = MEM_cnew_array<float>(height * width,
"rasterized mask buffer");
644 const char draw_flag,
645 const char draw_type,
647 const float blend_factor,
653 const bool do_scale_applied,
654 const bool do_draw_cb,
660 View2D *v2d = ®ion->v2d;
664 const float width = width_i, height =
float(height_i) * (aspy / aspx);
683 if (do_scale_applied) {
692 maxdim =
max_ff(width, height);
693 if (width == height) {
696 else if (width < height) {
697 xofs = ((height - width) / -2.0f) * zoomx;
702 yofs = ((width - height) / -2.0f) * zoomy;
706 float buf_col[4] = {1.0f, 0.0f, 0.0f, 0.0f};
727 const float blend_col[4] = {0.0f, 0.0f, 0.0f, blend_factor};
730 &
state, 0.0f, 0.0f, width, height,
GPU_R16F,
false, buffer, 1.0f, 1.0f, blend_col);
734 &
state, 0.0f, 0.0f, width, height,
GPU_R16F,
false, buffer, 1.0f, 1.0f,
nullptr);
772 Mask *mask,
ARegion *region,
const int cfra,
const int sfra,
const int efra)
774 const float framelen = region->winx /
float(efra - sfra + 1);
777 if (mask_layer ==
nullptr) {
782 if (num_lines == 0) {
788 const int region_bottom = rect_visible->
ymin;
799 int frame = mask_layer_shape->frame;
802 int height = (frame == cfra) ? 22 : 10;
803 int x = (frame - sfra) * framelen;
void immDrawPixelsTexTiled(IMMDrawPixelsTexState *state, float x, float y, int img_w, int img_h, eGPUTextureFormat gpu_format, bool use_filter, const void *rect, float xzoom, float yzoom, const float color[4])
IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin)
SpaceClip * CTX_wm_space_clip(const bContext *C)
int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, int height)
#define MASKPOINT_ISSEL_ANY(p)
float(* BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, unsigned int resol, unsigned int *r_tot_diff_point))[2]
void BKE_maskrasterize_handle_free(MaskRasterHandle *mr_handle)
unsigned int BKE_mask_spline_feather_resolution(struct MaskSpline *spline, int width, int height)
@ MASK_WHICH_HANDLE_RIGHT
@ MASK_WHICH_HANDLE_STICK
MaskRasterHandle * BKE_maskrasterize_handle_new(void)
#define MASKPOINT_ISSEL_KNOT(p)
void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mask, int width, int height, bool do_aspect_correct, bool do_mask_aa, bool do_feather)
void BKE_mask_coord_to_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2])
void BKE_mask_point_handle(const struct MaskSplinePoint *point, eMaskWhichHandle which_handle, float r_handle[2])
#define MASKPOINT_ISSEL_HANDLE(point, which_handle)
float(* BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2]
eMaskhandleMode BKE_mask_point_handles_mode_get(const struct MaskSplinePoint *point)
void BKE_mask_coord_from_movieclip(struct MovieClip *clip, struct MovieClipUser *user, float r_co[2], const float co[2])
float(* BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, unsigned int resol, bool do_feather_isect, unsigned int *r_tot_feather_point))[2]
struct MaskLayer * BKE_mask_layer_active(struct Mask *mask)
void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle, unsigned int width, unsigned int height, float *buffer)
Rasterize a buffer from a single mask (threaded execution).
struct MaskSplinePoint * BKE_mask_spline_point_array(struct MaskSpline *spline)
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE float max_ff(float a, float b)
MINLINE int max_ii(int a, int b)
void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
MINLINE void copy_v2_v2(float r[2], const float a[2])
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
#define INIT_MINMAX2(min, max)
ID * DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
@ MASK_OVERLAY_ALPHACHANNEL
@ MCLIP_PROXY_RENDER_UNDISTORT
Object is a sort of wrapper for general info.
void ED_clip_point_undistorted_pos(const SpaceClip *sc, const float co[2], float r_co[2])
const rcti * ED_region_visible_rect(ARegion *region)
void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type)
#define REGION_DRAW_POST_VIEW
#define REGION_DRAW_PRE_VIEW
void GPU_matrix_scale_2f(float x, float y)
#define GPU_matrix_mul(x)
void GPU_matrix_translate_2f(float x, float y)
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
void GPU_shader_uniform_float_ex(GPUShader *shader, int location, int length, int array_size, const float *value)
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
@ GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR
@ GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA
void GPU_program_point_size(bool enable)
void GPU_blend(eGPUBlend blend)
void GPU_line_width(float width)
void GPU_line_smooth(bool enable)
void GPU_viewport_size_get_f(float coords[4])
Read Guarded memory(de)allocation.
void UI_GetThemeColor3fv(int colorid, float col[3])
@ TH_HANDLE_VERTEX_SELECT
float UI_GetThemeValuef(int colorid)
void UI_view2d_view_to_region(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
const Depsgraph * depsgraph
draw_view in_light_buf[] float
void MEM_freeN(void *vmemh)
void ED_mask_draw_frames(Mask *mask, ARegion *region, const int cfra, const int sfra, const int efra)
static void mask_color_active_tint(uchar r_rgb[4], const uchar rgb[4], const bool is_active)
static void draw_mask_layers(const bContext *C, Mask *mask, const char draw_type, const int width, const int height)
void ED_mask_draw_region(Depsgraph *depsgraph, Mask *mask_, ARegion *region, const char draw_flag, const char draw_type, const eMaskOverlayMode overlay_mode, const float blend_factor, const int width_i, const int height_i, const float aspx, const float aspy, const bool do_scale_applied, const bool do_draw_cb, float stabmat[4][4], const bContext *C)
static void mask_draw_array(uint pos, GPUPrimType prim_type, const float(*points)[2], uint vertex_len)
static void mask_spline_feather_color_get(MaskLayer *, MaskSpline *, const bool is_sel, uchar r_rgb[4])
static void mask_point_undistort_pos(SpaceClip *sc, float r_co[2], const float co[2])
static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float(*orig_points)[2], int tot_point, const bool is_feather, const bool is_active, const uchar rgb_spline[4], const char draw_type)
static void draw_spline_points(const bContext *C, MaskLayer *mask_layer, MaskSpline *spline, const char draw_type)
static void draw_layer_splines(const bContext *C, MaskLayer *layer, const char draw_type, const int width, const int height, const bool is_active)
static float * mask_rasterize(Mask *mask, const int width, const int height)
static void draw_spline_curve(const bContext *C, MaskLayer *mask_layer, MaskSpline *spline, const char draw_type, const bool is_active, const int width, const int height)
static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoint *point, const eMaskWhichHandle which_handle, const int draw_type, const float handle_size, const float point_pos[2], const float handle_pos[2])
static void mask_spline_color_get(MaskLayer *mask_layer, MaskSpline *spline, const bool is_sel, uchar r_rgb[4])
struct MaskSplinePoint * act_point
struct MaskSpline * act_spline
struct MovieClipUser user