diff options
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_draw.c')
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_draw.c | 127 |
1 files changed, 61 insertions, 66 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 4f52a17f623..afd8895edd9 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -39,12 +39,11 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_userdef_types.h" +#include "DNA_sound_types.h" #include "BKE_context.h" #include "BKE_global.h" -#include "BKE_plugin_types.h" #include "BKE_sequencer.h" -#include "BKE_scene.h" #include "BKE_utildefines.h" #include "BKE_sound.h" @@ -168,7 +167,7 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, char *col) } } -static void drawseqwave(Sequence *seq, float x1, float y1, float x2, float y2, float stepsize) +static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x2, float y2, float stepsize) { /* x1 is the starting x value to draw the wave, @@ -184,7 +183,9 @@ static void drawseqwave(Sequence *seq, float x1, float y1, float x2, float y2, f float* samples = MEM_mallocN(length * sizeof(float) * 2, "seqwave_samples"); if(!samples) return; - if(sound_read_sound_buffer(seq->sound, samples, length) != length) + if(sound_read_sound_buffer(seq->sound, samples, length, + (seq->startofs + seq->anim_startofs)/FPS, + (seq->startofs + seq->anim_startofs + seq->enddisp - seq->startdisp)/FPS) != length) { MEM_freeN(samples); return; @@ -381,6 +382,8 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, SpaceSeq *sseq, Seque pixely = (v2d->cur.ymax - v2d->cur.ymin)/(v2d->mask.ymax - v2d->mask.ymin); + if(pixely <= 0) return; /* can happen when the view is split/resized */ + blendcol[0] = blendcol[1] = blendcol[2] = 120; if(seq->startofs) { @@ -588,7 +591,7 @@ static void draw_shadedstrip(Sequence *seq, char *col, float x1, float y1, float } /* -Draw a sequence strip, bounds check alredy made +Draw a sequence strip, bounds check already made ARegion is currently only used to get the windows width in pixels so wave file sample drawing precision is zoom adjusted */ @@ -634,7 +637,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence * x2= seq->enddisp; /* draw sound wave */ - if(seq->type == SEQ_SOUND) drawseqwave(seq, x1, y1, x2, y2, (ar->v2d.cur.xmax - ar->v2d.cur.xmin)/ar->winx); + if(seq->type == SEQ_SOUND) drawseqwave(scene, seq, x1, y1, x2, y2, (ar->v2d.cur.xmax - ar->v2d.cur.xmin)/ar->winx); get_seq_color3ubv(scene, seq, col); if (G.moving && (seq->flag & SELECT)) { @@ -692,12 +695,12 @@ void set_special_seq_update(int val) void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs) { extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); - struct ImBuf *ibuf; + struct Main *bmain= CTX_data_main(C); + struct ImBuf *ibuf = 0; + struct ImBuf *scope = 0; struct View2D *v2d = &ar->v2d; int rectx, recty; float viewrectx, viewrecty; - int free_ibuf = 0; - static int recursive= 0; float render_size = 0.0; float proxy_size = 100.0; GLuint texid; @@ -737,33 +740,12 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq UI_view2d_totRect_set(v2d, viewrectx + 0.5f, viewrecty + 0.5f); UI_view2d_curRect_validate(v2d); - /* BIG PROBLEM: the give_ibuf_seq() can call a rendering, which in turn calls redraws... - this shouldn't belong in a window drawing.... - So: solve this once event based. - Now we check for recursion, space type and active area again (ton) */ - - if(recursive) - return; - else { - recursive= 1; - if (special_seq_update) { - ibuf= give_ibuf_seq_direct(scene, rectx, recty, cfra + frame_ofs, proxy_size, special_seq_update); - } - else if (!U.prefetchframes) { // XXX || (G.f & G_PLAYANIM) == 0) { - ibuf= (ImBuf *)give_ibuf_seq(scene, rectx, recty, cfra + frame_ofs, sseq->chanshown, proxy_size); - } - else { - ibuf= (ImBuf *)give_ibuf_seq_threaded(scene, rectx, recty, cfra + frame_ofs, sseq->chanshown, proxy_size); - } - recursive= 0; - - /* XXX HURMF! the give_ibuf_seq can call image display in this window */ -// if(sa->spacetype!=SPACE_SEQ) -// return; -// if(sa!=curarea) { -// areawinset(sa->win); -// } - } + if (special_seq_update) + ibuf= give_ibuf_seq_direct(bmain, scene, rectx, recty, cfra + frame_ofs, proxy_size, special_seq_update); + else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) { + ibuf= (ImBuf *)give_ibuf_seq(bmain, scene, rectx, recty, cfra + frame_ofs, sseq->chanshown, proxy_size); + else + ibuf= (ImBuf *)give_ibuf_seq_threaded(bmain, scene, rectx, recty, cfra + frame_ofs, sseq->chanshown, proxy_size); if(ibuf==NULL) return; @@ -774,28 +756,29 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq switch(sseq->mainb) { case SEQ_DRAW_IMG_IMBUF: if (sseq->zebra != 0) { - ibuf = make_zebra_view_from_ibuf(ibuf, sseq->zebra); - free_ibuf = 1; + scope = make_zebra_view_from_ibuf(ibuf, sseq->zebra); } break; case SEQ_DRAW_IMG_WAVEFORM: if ((sseq->flag & SEQ_DRAW_COLOR_SEPERATED) != 0) { - ibuf = make_sep_waveform_view_from_ibuf(ibuf); + scope = make_sep_waveform_view_from_ibuf(ibuf); } else { - ibuf = make_waveform_view_from_ibuf(ibuf); + scope = make_waveform_view_from_ibuf(ibuf); } - free_ibuf = 1; break; case SEQ_DRAW_IMG_VECTORSCOPE: - ibuf = make_vectorscope_view_from_ibuf(ibuf); - free_ibuf = 1; + scope = make_vectorscope_view_from_ibuf(ibuf); break; case SEQ_DRAW_IMG_HISTOGRAM: - ibuf = make_histogram_view_from_ibuf(ibuf); - free_ibuf = 1; + scope = make_histogram_view_from_ibuf(ibuf); break; } + if (scope) { + IMB_freeImBuf(ibuf); + ibuf = scope; + } + if(ibuf->rect_float && ibuf->rect==NULL) { IMB_rect_from_float(ibuf); } @@ -838,42 +821,54 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq glDisable(GL_TEXTURE_2D); glDeleteTextures(1, &texid); - /* safety border */ - if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && - (sseq->flag & SEQ_DRAW_SAFE_MARGINS) != 0) { - float fac= 0.1; + 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; - - float a= fac*(x2-x1); - x1+= a; - x2-= a; - - a= fac*(y2-y1); - y1+= a; - y2-= a; - - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + + /* border */ setlinestyle(3); UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 1.0, 0); - - uiSetRoundBox(15); - gl_round_box(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); + + glBegin(GL_LINE_LOOP); + glVertex2f(x1-0.5, y1-0.5); + glVertex2f(x1-0.5, y2+0.5); + glVertex2f(x2+0.5, y2+0.5); + glVertex2f(x2+0.5, y1-0.5); + glEnd(); + + /* safety border */ + if ((sseq->flag & SEQ_DRAW_SAFE_MARGINS) != 0) { + float fac= 0.1; + + float a= fac*(x2-x1); + x1+= a; + x2-= a; + + a= fac*(y2-y1); + y1+= a; + y2-= a; + + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + + uiSetRoundBox(15); + gl_round_box(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); + + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + + } setlinestyle(0); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } /* draw grease-pencil (image aligned) */ // if (sseq->flag & SEQ_DRAW_GPENCIL) // XXX draw_gpencil_2dimage(sa, ibuf); - if (free_ibuf) { - IMB_freeImBuf(ibuf); - } + IMB_freeImBuf(ibuf); /* draw grease-pencil (screen aligned) */ // if (sseq->flag & SEQ_DRAW_GPENCIL) |