diff options
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_draw.c')
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_draw.c | 226 |
1 files changed, 132 insertions, 94 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index b63c46cba01..27eb28bec8f 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -50,6 +50,7 @@ #include "BKE_main.h" #include "BKE_sequencer.h" #include "BKE_sound.h" +#include "BKE_scene.h" #include "IMB_colormanagement.h" #include "IMB_imbuf.h" @@ -62,6 +63,7 @@ #include "ED_markers.h" #include "ED_mask.h" #include "ED_sequencer.h" +#include "ED_screen.h" #include "ED_space_api.h" #include "UI_interface.h" @@ -424,12 +426,12 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla size_t numstr_len; if (direction == SEQ_LEFTHANDLE) { - numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%d", seq->startdisp); + numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", seq->startdisp); x1 = rx1; y1 -= 0.45f; } else { - numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%d", seq->enddisp - 1); + numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", seq->enddisp - 1); x1 = x2 - handsize_clamped * 0.75f; y1 = y2 + 0.05f; } @@ -860,7 +862,7 @@ void ED_sequencer_special_preview_clear(void) sequencer_special_update_set(NULL); } -ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int cfra, int frame_ofs) +ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int cfra, int frame_ofs, const char *viewname) { SeqRenderData context; ImBuf *ibuf; @@ -888,6 +890,7 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int bmain->eval_ctx, bmain, scene, rectx, recty, proxy_size, &context); + context.view_id = BKE_scene_multiview_view_id_get(&scene->r, viewname); /* sequencer could start rendering, in this case we need to be sure it wouldn't be canceled * by Esc pressed somewhere in the past @@ -978,6 +981,76 @@ static void sequencer_display_size(Scene *scene, SpaceSeq *sseq, float r_viewrec } } +static void sequencer_draw_gpencil(const bContext *C) +{ + /* draw grease-pencil (image aligned) */ + ED_gpencil_draw_2dimage(C); + + /* ortho at pixel level */ + UI_view2d_view_restore(C); + + /* draw grease-pencil (screen aligned) */ + ED_gpencil_draw_view2d(C, 0); +} + +/* draws content borders plus safety borders if needed */ +static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, const Scene *scene) +{ + float x1 = v2d->tot.xmin; + float y1 = v2d->tot.ymin; + float x2 = v2d->tot.xmax; + float y2 = v2d->tot.ymax; + + /* border */ + setlinestyle(3); + + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 1.0, 0); + + glBegin(GL_LINE_LOOP); + glVertex2f(x1 - 0.5f, y1 - 0.5f); + glVertex2f(x1 - 0.5f, y2 + 0.5f); + glVertex2f(x2 + 0.5f, y2 + 0.5f); + glVertex2f(x2 + 0.5f, y1 - 0.5f); + glEnd(); + + /* safety border */ + if (sseq->flag & SEQ_SHOW_SAFE_MARGINS) { + UI_draw_safe_areas( + x1, x2, y1, y2, + scene->safe_areas.title, + scene->safe_areas.action); + + if (sseq->flag & SEQ_SHOW_SAFE_CENTER) { + UI_draw_safe_areas( + x1, x2, y1, y2, + scene->safe_areas.title_center, + scene->safe_areas.action_center); + } + } + + setlinestyle(0); +} + +/* draws checkerboard background for transparent content */ +static void sequencer_draw_background(const SpaceSeq *sseq, View2D *v2d, const float viewrect[2]) +{ + /* setting up the view */ + UI_view2d_totRect_set(v2d, viewrect[0] + 0.5f, viewrect[1] + 0.5f); + UI_view2d_curRect_validate(v2d); + UI_view2d_view_ortho(v2d); + + /* only draw alpha for main buffer */ + if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { + if (sseq->flag & SEQ_USE_ALPHA) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + fdrawcheckerboard(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax); + glColor4f(1.0, 1.0, 1.0, 1.0); + } + } +} + void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs, bool draw_overlay, bool draw_backdrop) { struct Main *bmain = CTX_data_main(C); @@ -994,6 +1067,9 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq const bool is_imbuf = ED_space_sequencer_check_show_imbuf(sseq); int format, type; bool glsl_used = false; + const bool draw_gpencil = ((sseq->flag & SEQ_SHOW_GPENCIL) && sseq->gpd); + const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; + bool draw_metadata = false; if (G.is_rendering == false && (scene->r.seq_flag & R_SEQ_GL_PREV) == 0) { /* stop all running jobs, except screen one. currently previews frustrate Render @@ -1015,6 +1091,9 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq glClear(GL_COLOR_BUFFER_BIT); } + /* without this colors can flicker from previous opengl state */ + glColor4ub(255, 255, 255, 255); + /* only initialize the preview if a render is in progress */ if (G.is_rendering) return; @@ -1023,17 +1102,27 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq return; } - ibuf = sequencer_ibuf_get(bmain, scene, sseq, cfra, frame_ofs); - - if (ibuf == NULL) - return; + /* for now we only support Left/Right */ + ibuf = sequencer_ibuf_get(bmain, scene, sseq, cfra, frame_ofs, names[sseq->multiview_eye]); + + if ((ibuf == NULL) || + (ibuf->rect == NULL && ibuf->rect_float == NULL)) + { + /* gpencil can also be drawn without a valid imbuf */ + if (draw_gpencil && is_imbuf) { + sequencer_display_size(scene, sseq, viewrect); + + sequencer_draw_background(sseq, v2d, viewrect); + sequencer_draw_borders(sseq, v2d, scene); - if (ibuf->rect == NULL && ibuf->rect_float == NULL) + sequencer_draw_gpencil(C); + } return; + } sequencer_display_size(scene, sseq, viewrect); - if (sseq->mainb != SEQ_DRAW_IMG_IMBUF || sseq->zebra != 0) { + if (!draw_backdrop && (sseq->mainb != SEQ_DRAW_IMG_IMBUF || sseq->zebra != 0)) { SequencerScopes *scopes = &sseq->scopes; sequencer_check_scopes(scopes, ibuf); @@ -1079,36 +1168,23 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq /* future files may have new scopes we don't catch above */ if (scope) { scopes->reference_ibuf = ibuf; - viewrect[0] = scope->x; - viewrect[1] = scope->y; + if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { + /* scopes drawn in image preview use viewrect from orig ibuf - currently that's only zebra */ + } + else { + viewrect[0] = scope->x; + viewrect[1] = scope->y; + } } else { scopes->reference_ibuf = NULL; } } - /* without this colors can flicker from previous opengl state */ - glColor4ub(255, 255, 255, 255); - if (!draw_backdrop) { - UI_view2d_totRect_set(v2d, viewrect[0] + 0.5f, viewrect[1] + 0.5f); - UI_view2d_curRect_validate(v2d); - - /* setting up the view - actual drawing starts here */ - UI_view2d_view_ortho(v2d); - - /* only draw alpha for main buffer */ - if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { - if (sseq->flag & SEQ_USE_ALPHA) { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - fdrawcheckerboard(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax); - glColor4f(1.0, 1.0, 1.0, 1.0); - } - } + sequencer_draw_background(sseq, v2d, viewrect); } - + if (scope) { IMB_freeImBuf(ibuf); ibuf = scope; @@ -1229,10 +1305,12 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq } } else if (draw_backdrop) { - float aspect = BLI_rcti_size_x(&ar->winrct) / (float)BLI_rcti_size_y(&ar->winrct); + float aspect; float image_aspect = viewrect[0] / viewrect[1]; float imagex, imagey; - + + aspect = BLI_rcti_size_x(&ar->winrct) / (float)BLI_rcti_size_y(&ar->winrct); + if (aspect >= image_aspect) { imagex = image_aspect / aspect; imagey = 1.0f; @@ -1241,28 +1319,22 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq imagex = 1.0f; imagey = aspect / image_aspect; } - + glTexCoord2f(0.0f, 0.0f); glVertex2f(-imagex, -imagey); glTexCoord2f(0.0f, 1.0f); glVertex2f(-imagex, imagey); glTexCoord2f(1.0f, 1.0f); glVertex2f(imagex, imagey); glTexCoord2f(1.0f, 0.0f); glVertex2f(imagex, -imagey); } else { + draw_metadata = ((sseq->flag & SEQ_SHOW_METADATA) != 0); + glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin); glTexCoord2f(0.0f, 1.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymax); glTexCoord2f(1.0f, 1.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymax); glTexCoord2f(1.0f, 0.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymin); } glEnd(); - - if (draw_backdrop) { - glPopMatrix(); - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - - } - + glBindTexture(GL_TEXTURE_2D, last_texid); glDisable(GL_TEXTURE_2D); if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA) @@ -1277,63 +1349,29 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq if (!scope) IMB_freeImBuf(ibuf); - + + if (draw_metadata) { + ED_region_image_metadata_draw(0.0, 0.0, ibuf, v2d->tot, 1.0, 1.0); + } + if (draw_backdrop) { + glPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); return; } - - if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { - - float x1 = v2d->tot.xmin; - float y1 = v2d->tot.ymin; - float x2 = v2d->tot.xmax; - float y2 = v2d->tot.ymax; - - /* border */ - setlinestyle(3); - - UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 1.0, 0); - - glBegin(GL_LINE_LOOP); - glVertex2f(x1 - 0.5f, y1 - 0.5f); - glVertex2f(x1 - 0.5f, y2 + 0.5f); - glVertex2f(x2 + 0.5f, y2 + 0.5f); - glVertex2f(x2 + 0.5f, y1 - 0.5f); - glEnd(); - - /* safety border */ - if (sseq->flag & SEQ_SHOW_SAFE_MARGINS) { - UI_draw_safe_areas( - x1, x2, y1, y2, - scene->safe_areas.title, - scene->safe_areas.action); - - if (sseq->flag & SEQ_SHOW_SAFE_CENTER) { - UI_draw_safe_areas( - x1, x2, y1, y2, - scene->safe_areas.title_center, - scene->safe_areas.action_center); - } - } - setlinestyle(0); + if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { + sequencer_draw_borders(sseq, v2d, scene); } - - if (sseq->flag & SEQ_SHOW_GPENCIL) { - if (is_imbuf) { - /* draw grease-pencil (image aligned) */ - ED_gpencil_draw_2dimage(C); - } + + if (draw_gpencil && is_imbuf) { + sequencer_draw_gpencil(C); } - - /* ortho at pixel level */ - UI_view2d_view_restore(C); - - if (sseq->flag & SEQ_SHOW_GPENCIL) { - if (is_imbuf) { - /* draw grease-pencil (screen aligned) */ - ED_gpencil_draw_view2d(C, 0); - } + else { + /* ortho at pixel level */ + UI_view2d_view_restore(C); } |