Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mask/mask_draw.c
| Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| #include "GPU_shader.h" | #include "GPU_shader.h" | ||||
| #include "GPU_matrix.h" | #include "GPU_matrix.h" | ||||
| #include "GPU_state.h" | #include "GPU_state.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "DEG_depsgraph_query.h" | |||||
| #include "mask_intern.h" /* own include */ | #include "mask_intern.h" /* own include */ | ||||
| static void mask_spline_color_get(MaskLayer *masklay, | static void mask_spline_color_get(MaskLayer *masklay, | ||||
| MaskSpline *spline, | MaskSpline *spline, | ||||
| const bool is_sel, | const bool is_sel, | ||||
| unsigned char r_rgb[4]) | unsigned char r_rgb[4]) | ||||
| { | { | ||||
| if (is_sel) { | if (is_sel) { | ||||
| ▲ Show 20 Lines • Show All 604 Lines • ▼ Show 20 Lines | static float *mask_rasterize(Mask *mask, const int width, const int height) | ||||
| BKE_maskrasterize_handle_free(handle); | BKE_maskrasterize_handle_free(handle); | ||||
| return buffer; | return buffer; | ||||
| } | } | ||||
| /* sets up the opengl context. | /* sets up the opengl context. | ||||
| * width, height are to match the values from ED_mask_get_size() */ | * width, height are to match the values from ED_mask_get_size() */ | ||||
| void ED_mask_draw_region( | void ED_mask_draw_region( | ||||
| Mask *mask, | Depsgraph *depsgraph, | ||||
| Mask *mask_, | |||||
| ARegion *ar, | ARegion *ar, | ||||
| const char draw_flag, | const char draw_flag, | ||||
| const char draw_type, | const char draw_type, | ||||
| const char overlay_mode, | const char overlay_mode, | ||||
| /* convert directly into aspect corrected vars */ | /* convert directly into aspect corrected vars */ | ||||
| const int width_i, | const int width_i, | ||||
| const int height_i, | const int height_i, | ||||
| const float aspx, | const float aspx, | ||||
| const float aspy, | const float aspy, | ||||
| const bool do_scale_applied, | const bool do_scale_applied, | ||||
| const bool do_draw_cb, | const bool do_draw_cb, | ||||
| /* optional - only used by clip */ | /* optional - only used by clip */ | ||||
| float stabmat[4][4], | float stabmat[4][4], | ||||
| /* optional - only used when do_post_draw is set or called from clip editor */ | /* optional - only used when do_post_draw is set or called from clip editor */ | ||||
| const bContext *C) | const bContext *C) | ||||
| { | { | ||||
| struct View2D *v2d = &ar->v2d; | struct View2D *v2d = &ar->v2d; | ||||
| Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_->id); | |||||
| /* aspect always scales vertically in movie and image spaces */ | /* aspect always scales vertically in movie and image spaces */ | ||||
| const float width = width_i, height = (float)height_i * (aspy / aspx); | const float width = width_i, height = (float)height_i * (aspy / aspx); | ||||
| int x, y; | int x, y; | ||||
| /* int w, h; */ | /* int w, h; */ | ||||
| float zoomx, zoomy; | float zoomx, zoomy; | ||||
| Show All 29 Lines | void ED_mask_draw_region( | ||||
| } | } | ||||
| else { /* (width > height) */ | else { /* (width > height) */ | ||||
| xofs = 0.0f; | xofs = 0.0f; | ||||
| yofs = ((width - height) / -2.0f) * zoomy; | yofs = ((width - height) / -2.0f) * zoomy; | ||||
| } | } | ||||
| if (draw_flag & MASK_DRAWFLAG_OVERLAY) { | if (draw_flag & MASK_DRAWFLAG_OVERLAY) { | ||||
| float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; | float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; | ||||
| float *buffer = mask_rasterize(mask, width, height); | float *buffer = mask_rasterize(mask_eval, width, height); | ||||
| if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) { | if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) { | ||||
| /* More blending types could be supported in the future. */ | /* More blending types could be supported in the future. */ | ||||
| GPU_blend(true); | GPU_blend(true); | ||||
| GPU_blend_set_func(GPU_DST_COLOR, GPU_ZERO); | GPU_blend_set_func(GPU_DST_COLOR, GPU_ZERO); | ||||
| } | } | ||||
| GPU_matrix_push(); | GPU_matrix_push(); | ||||
| Show All 27 Lines | void ED_mask_draw_region( | ||||
| } | } | ||||
| GPU_matrix_scale_2f(maxdim, maxdim); | GPU_matrix_scale_2f(maxdim, maxdim); | ||||
| if (do_draw_cb) { | if (do_draw_cb) { | ||||
| ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); | ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); | ||||
| } | } | ||||
| /* draw! */ | /* draw! */ | ||||
| draw_masklays(C, mask, draw_flag, draw_type, width, height); | draw_masklays(C, mask_eval, draw_flag, draw_type, width, height); | ||||
| if (do_draw_cb) { | if (do_draw_cb) { | ||||
| ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); | ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); | ||||
| } | } | ||||
| GPU_matrix_pop(); | GPU_matrix_pop(); | ||||
| } | } | ||||
| Show All 33 Lines | |||||