From 8509e94d3ad69aaa2bb3b14c5669ea9d596e3fd0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 24 Jul 2012 19:29:24 +0000 Subject: initial commit for supporting masks in the image view, currently active seq strip is used as the mask source. also unify mask drawing code for clip/sequencer/image --- .../editors/space_sequencer/sequencer_draw.c | 67 ++++------------------ 1 file changed, 11 insertions(+), 56 deletions(-) (limited to 'source/blender/editors/space_sequencer') diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 09bfa384db0..ac2f8a7a34c 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -798,61 +798,6 @@ static void UNUSED_FUNCTION(set_special_seq_update) (int val) else special_seq_update = NULL; } -static void sequencer_main_area_draw_mask(const bContext *C, Scene *scene, ARegion *ar) -{ - Mask *mask = BKE_sequencer_mask_get(scene); - - if (mask) { - struct View2D *v2d = &ar->v2d; - - int x, y; - int width, height; - float zoomx, zoomy; - - /* frame image */ - float maxdim; - float xofs, yofs; - - /* find window pixel coordinates of origin */ - UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); - - width = v2d->tot.xmax - v2d->tot.xmin; - height = v2d->tot.ymax - v2d->tot.ymin; - - zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)); - zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)); - - x += v2d->tot.xmin * zoomx; - y += v2d->tot.ymin * zoomy; - - /* frame the image */ - maxdim = maxf(width, height); - if (width == height) { - xofs = yofs = 0; - } - else if (width < height) { - xofs = ((height - width) / -2.0f) * zoomx; - yofs = 0.0f; - } - else { /* (width > height) */ - xofs = 0.0f; - yofs = ((width - height) / -2.0f) * zoomy; - } - - /* apply transformation so mask editing tools will assume drawing from the origin in normalized space */ - glPushMatrix(); - glTranslatef(x + xofs, y + yofs, 0); - glScalef(maxdim * zoomx, maxdim * zoomy, 0); - - ED_mask_draw((bContext *)C, 0, 0); // sc->mask_draw_flag, sc->mask_draw_type - - ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); - - glPopMatrix(); - } -} - - void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs) { struct Main *bmain = CTX_data_main(C); @@ -1047,7 +992,17 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq //if (sc->mode == SC_MODE_MASKEDIT) { if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { - sequencer_main_area_draw_mask(C, scene, ar); + Mask *mask = BKE_sequencer_mask_get(scene); + + if (mask) { + int width, height; + ED_mask_size(C, &width, &height); + ED_mask_draw_region(mask, ar, + 0, 0, /* TODO */ + width, height, + FALSE, TRUE, + NULL, C); + } } } -- cgit v1.2.3