diff options
author | Tianwei Shen <shentianweipku@gmail.com> | 2016-08-06 14:07:11 +0300 |
---|---|---|
committer | Tianwei Shen <shentianweipku@gmail.com> | 2016-08-06 14:07:11 +0300 |
commit | ab73d3ab27747271af9d7f500c3054334f9cfd00 (patch) | |
tree | 1617174d0434008a54572b7833df4c944c221445 /source/blender/editors/space_clip | |
parent | 496830a2a31f698725b46f6e1aa15b02d364c981 (diff) |
make the witness clip context shown right
- duplicate code in clip_draw_secondary_clip and clip_draw_main
- selecting in a sub-region is a problem
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r-- | source/blender/editors/space_clip/clip_draw.c | 51 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_editor.c | 34 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 48 |
3 files changed, 81 insertions, 52 deletions
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index f59df488683..4294a1740bd 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -325,6 +325,49 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, glDisable(GL_BLEND); } +static void draw_movieclip_secondary_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, ImBuf *ibuf, + int width, int height, float zoomx, float zoomy) +{ + MovieClip *clip = ED_space_clip_get_secondary_clip(sc); + int filter = GL_LINEAR; + int x, y; + + /* find window pixel coordinates of origin */ + UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); + + /* checkerboard for case alpha */ + if (ibuf->planes == 32) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + fdrawcheckerboard(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y); + } + + /* non-scaled proxy shouldn't use filtering */ + if ((clip->flag & MCLIP_USE_PROXY) == 0 || + ELEM(sc->user.render_size, MCLIP_PROXY_RENDER_SIZE_FULL, MCLIP_PROXY_RENDER_SIZE_100)) + { + filter = GL_NEAREST; + } + + /* set zoom */ + glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y); + + glaDrawImBuf_glsl_ctx(C, ibuf, x, y, filter); + /* reset zoom */ + glPixelZoom(1.0f, 1.0f); + + + if (sc->flag & SC_SHOW_METADATA) { + rctf frame; + BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y); + ED_region_image_metadata_draw(x, y, ibuf, &frame, zoomx * width / ibuf->x, zoomy * height / ibuf->y); + } + + if (ibuf->planes == 32) + glDisable(GL_BLEND); +} + static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int height, float zoomx, float zoomy) { int x, y; @@ -1775,8 +1818,8 @@ void clip_draw_secondary_clip(const bContext *C, SpaceClip *sc, ARegion *ar) float smat[4][4], ismat[4][4]; if ((sc->flag & SC_MUTE_FOOTAGE) == 0) { - ibuf = ED_space_clip_get_stable_buffer(sc, sc->loc, - &sc->scale, &sc->angle); + ibuf = ED_space_clip_get_secondary_stable_buffer(sc, sc->loc, + &sc->scale, &sc->angle); } if (ibuf != NULL && width != ibuf->x) @@ -1795,7 +1838,7 @@ void clip_draw_secondary_clip(const bContext *C, SpaceClip *sc, ARegion *ar) mul_m4_series(sc->unistabmat, smat, sc->stabmat, ismat); } else if ((sc->flag & SC_MUTE_FOOTAGE) == 0) { - ibuf = ED_space_clip_get_buffer(sc); + ibuf = ED_space_clip_secondary_get_buffer(sc); zero_v2(sc->loc); sc->scale = 1.0f; @@ -1804,7 +1847,7 @@ void clip_draw_secondary_clip(const bContext *C, SpaceClip *sc, ARegion *ar) } if (ibuf) { - draw_movieclip_buffer(C, sc, ar, ibuf, width, height, zoomx, zoomy); + draw_movieclip_secondary_buffer(C, sc, ar, ibuf, width, height, zoomx, zoomy); IMB_freeImBuf(ibuf); } else if (sc->flag & SC_MUTE_FOOTAGE) { diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 6a56ed12583..b8aa1264632 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -254,6 +254,23 @@ ImBuf *ED_space_clip_get_buffer(SpaceClip *sc) return NULL; } +ImBuf *ED_space_clip_secondary_get_buffer(SpaceClip *sc) +{ + if (sc->secondary_clip) { + ImBuf *ibuf; + + ibuf = BKE_movieclip_get_postprocessed_ibuf(sc->secondary_clip, &sc->user, sc->postproc_flag); + + if (ibuf && (ibuf->rect || ibuf->rect_float)) + return ibuf; + + if (ibuf) + IMB_freeImBuf(ibuf); + } + + return NULL; +} + ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale, float *angle) { if (sc->clip) { @@ -271,6 +288,23 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale return NULL; } +ImBuf *ED_space_clip_get_secondary_stable_buffer(SpaceClip *sc, float loc[2], float *scale, float *angle) +{ + if (sc->secondary_clip) { + ImBuf *ibuf; + + ibuf = BKE_movieclip_get_stable_ibuf(sc->secondary_clip, &sc->user, loc, scale, angle, sc->postproc_flag); + + if (ibuf && (ibuf->rect || ibuf->rect_float)) + return ibuf; + + if (ibuf) + IMB_freeImBuf(ibuf); + } + + return NULL; +} + /* Returns color in the display space, matching ED_space_image_color_sample(). */ bool ED_space_clip_color_sample(Scene *scene, SpaceClip *sc, ARegion *ar, int mval[2], float r_col[3]) { diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index d6fa84892cf..e3525dfee88 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1150,54 +1150,6 @@ static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar) ar->v2d.cur.ymax /= h; } -/* sets up the fields of the View2D from zoom and offset for secondary clip in correspondence mode*/ -static void movieclip_secondary_clip_set_view2d(const bContext *C, ARegion *ar) -{ - SpaceClip *sc = CTX_wm_space_clip(C); - RegionSpaceClip *rsc = (RegionSpaceClip*) ar->regiondata; - float x1, y1, w, h, aspx, aspy; - int width, height, winx, winy; - - ED_space_clip_get_size(sc, &width, &height); - ED_space_clip_get_aspect(sc, &aspx, &aspy); - - w = width * aspx; - h = height * aspy; - - winx = BLI_rcti_size_x(&ar->winrct) + 1; - winy = BLI_rcti_size_y(&ar->winrct) + 1; - - ar->v2d.tot.xmin = 0; - ar->v2d.tot.ymin = 0; - ar->v2d.tot.xmax = w; - ar->v2d.tot.ymax = h; - - ar->v2d.mask.xmin = ar->v2d.mask.ymin = 0; - ar->v2d.mask.xmax = winx; - ar->v2d.mask.ymax = winy; - - /* which part of the image space do we see? */ - x1 = ar->winrct.xmin + (winx - rsc->zoom * w) / 2.0f; - y1 = ar->winrct.ymin + (winy - rsc->zoom * h) / 2.0f; - - x1 -= rsc->zoom * rsc->xof; - y1 -= rsc->zoom * rsc->yof; - - /* relative display right */ - ar->v2d.cur.xmin = (ar->winrct.xmin - (float)x1) / rsc->zoom; - ar->v2d.cur.xmax = ar->v2d.cur.xmin + ((float)winx / rsc->zoom); - - /* relative display left */ - ar->v2d.cur.ymin = (ar->winrct.ymin - (float)y1) / rsc->zoom; - ar->v2d.cur.ymax = ar->v2d.cur.ymin + ((float)winy / rsc->zoom); - - /* normalize 0.0..1.0 */ - ar->v2d.cur.xmin /= w; - ar->v2d.cur.xmax /= w; - ar->v2d.cur.ymin /= h; - ar->v2d.cur.ymax /= h; -} - /* add handlers, stuff you only do once or on area/region changes */ static void clip_main_region_init(wmWindowManager *wm, ARegion *ar) { |