diff options
Diffstat (limited to 'source/blender/editors')
4 files changed, 73 insertions, 115 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 37bb75a5efd..b3682681fd7 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -611,21 +611,18 @@ void set_special_seq_update(int val) else special_seq_update= 0; } -// XXX todo: remove special offset code for image-buf calculations... -void draw_image_seq(Scene *scene, ARegion *ar, SpaceSeq *sseq) +void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq) { extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); struct ImBuf *ibuf; - int x1, y1, rectx, recty; + struct View2D *v2d = &ar->v2d; + int rectx, recty; int free_ibuf = 0; static int recursive= 0; - float zoom; - float zoomx, zoomy; float render_size = 0.0; float proxy_size = 100.0; - - glClearColor(0.0, 0.0, 0.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); + GLuint texid; + GLuint last_texid; render_size = sseq->render_size; if (render_size == 0) { @@ -637,14 +634,21 @@ void draw_image_seq(Scene *scene, ARegion *ar, SpaceSeq *sseq) return; } - rectx= (render_size*scene->r.xsch)/100; - recty= (render_size*scene->r.ysch)/100; + rectx= (render_size*(float)scene->r.xsch)/100.0f+0.5f; + recty= (render_size*(float)scene->r.ysch)/100.0f+0.5f; + + /* XXX TODO: take color from theme */ + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + UI_view2d_totRect_set(v2d, rectx, recty); + 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 { @@ -708,34 +712,37 @@ void draw_image_seq(Scene *scene, ARegion *ar, SpaceSeq *sseq) IMB_rect_from_float(ibuf); } - /* needed for gla draw */ - glaDefine2DArea(&ar->winrct); - - zoom= SEQ_ZOOM_FAC(sseq->zoom); - if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { - zoom /= proxy_size / 100.0; - zoomx = zoom * ((float)scene->r.xasp / (float)scene->r.yasp); - zoomy = zoom; - } else { - zoomx = zoomy = zoom; - } + /* setting up the view - actual drawing starts here */ + UI_view2d_view_ortho(C, v2d); - /* calc location */ - x1= (ar->winx-zoomx*ibuf->x)/2 + sseq->xof; - y1= (ar->winy-zoomy*ibuf->y)/2 + sseq->yof; - - glPixelZoom(zoomx, zoomy); - - glaDrawPixelsSafe(x1, y1, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); - - glPixelZoom(1.0, 1.0); + last_texid= glaGetOneInteger(GL_TEXTURE_2D); + glEnable(GL_TEXTURE_2D); + glGenTextures(1, (GLuint *)&texid); + + glBindTexture(GL_TEXTURE_2D, texid); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + glBegin(GL_QUADS); + 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( ); + glBindTexture(GL_TEXTURE_2D, last_texid); + 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; - float x2 = x1 + ibuf->x * zoomx; - float y2 = y1 + ibuf->y * zoomy; + 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; @@ -769,82 +776,9 @@ void draw_image_seq(Scene *scene, ARegion *ar, SpaceSeq *sseq) // if (sseq->flag & SEQ_DRAW_GPENCIL) // XXX draw_gpencil_2dview(sa, 0); - /* ortho at pixel level sa */ -// XXX myortho2(-0.375, sa->winx-0.375, -0.375, sa->winy-0.375); - -} - -// XXX part of wacko image-drawing system... -void seq_reset_imageofs(SpaceSeq *sseq) -{ - sseq->xof = sseq->yof = sseq->zoom = 0; -} - - -#if 0 -/* XXX - these should really be made to use View2D instead of so wacko private system - Aligorith */ - -void seq_viewzoom(SpaceSeq *sseq, unsigned short event, int invert) -{ - - if(event==PAD1) - sseq->zoom= 1.0; - else if(event==PAD2) - sseq->zoom= (invert)? 2.0: 0.5; - else if(event==PAD4) - sseq->zoom= (invert)? 4.0: 0.25; - else if(event==PAD8) - sseq->zoom= (invert)? 8.0: 0.125; - - /* ensure pixel exact locations for draw */ - sseq->xof= (int)sseq->xof; - sseq->yof= (int)sseq->yof; -} - -void seq_viewmove(Scene *scene, ARegion *ar, SpaceSeq *sseq) -{ - short mval[2], mvalo[2]; - short rectx, recty, xmin, xmax, ymin, ymax, pad; - int oldcursor; - Window *win; - - sa = sseq->area; - rectx= (scene->r.size*scene->r.xsch)/100; - recty= (scene->r.size*scene->r.ysch)/100; - - pad = 10; - xmin = -(ar->winx/2) - rectx/2 + pad; - xmax = ar->winx/2 + rectx/2 - pad; - ymin = -(ar->winy/2) - recty/2 + pad; - ymax = ar->winy/2 + recty/2 - pad; - - getmouseco_sc(mvalo); - - oldcursor=get_cursor(); - win=winlay_get_active_window(); - - SetBlenderCursor(BC_NSEW_SCROLLCURSOR); - - while(get_mbut()&(L_MOUSE|M_MOUSE)) { - - getmouseco_sc(mval); - - if(mvalo[0]!=mval[0] || mvalo[1]!=mval[1]) { - - sseq->xof -= (mvalo[0]-mval[0]); - sseq->yof -= (mvalo[1]-mval[1]); - - /* prevent dragging image outside of the window and losing it! */ - CLAMP(sseq->xof, xmin, xmax); - CLAMP(sseq->yof, ymin, ymax); - - mvalo[0]= mval[0]; - mvalo[1]= mval[1]; - - } - } + /* ortho at pixel level */ + UI_view2d_view_restore(C); } -#endif void drawprefetchseqspace(Scene *scene, ARegion *ar, SpaceSeq *sseq) { diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index bd1db4c29b6..fb8f3b37683 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2226,13 +2226,17 @@ void SEQUENCER_OT_view_all(wmOperatorType *ot) static int sequencer_view_all_preview_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); - //bScreen *sc= CTX_wm_screen(C); + bScreen *sc= CTX_wm_screen(C); ScrArea *area= CTX_wm_area(C); ARegion *ar= CTX_wm_region(C); SpaceSeq *sseq= area->spacedata.first; - //View2D *v2d= UI_view2d_fromcontext(C); - + View2D *v2d= UI_view2d_fromcontext(C); + v2d->cur= v2d->tot; + UI_view2d_curRect_validate(v2d); + UI_view2d_sync(sc, area, v2d, V2D_LOCK_COPY); + +#if 0 /* Like zooming on an image view */ float zoomX, zoomY; int width, height, imgwidth, imgheight; @@ -2261,6 +2265,7 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *op) else { sseq->zoom= 1.0f; } +#endif ED_area_tag_redraw(CTX_wm_area(C)); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index cf598bfb613..40e9a37f8b6 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -48,7 +48,7 @@ struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa); /* sequencer_draw.c */ void draw_timeline_seq(const struct bContext *C, struct ARegion *ar); -void draw_image_seq(struct Scene *scene, struct ARegion *ar, struct SpaceSeq *sseq); +void draw_image_seq(const struct bContext* C, struct Scene *scene,struct ARegion *ar, struct SpaceSeq *sseq); void seq_reset_imageofs(struct SpaceSeq *sseq); diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index d2b13ac7912..99492272340 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -131,6 +131,7 @@ void ED_sequencer_update_view(bContext *C, int view) if (ar_preview->flag & RGN_FLAG_HIDDEN) { ar_preview->flag &= ~RGN_FLAG_HIDDEN; ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; + ar_preview->v2d.cur = ar_preview->v2d.tot; } ar_main->alignment= RGN_ALIGN_NONE; ar_preview->alignment= RGN_ALIGN_NONE; @@ -143,6 +144,7 @@ void ED_sequencer_update_view(bContext *C, int view) if (ar_preview->flag & RGN_FLAG_HIDDEN) { ar_preview->flag &= ~RGN_FLAG_HIDDEN; ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; + ar_preview->v2d.cur = ar_preview->v2d.tot; } ar_main->alignment= RGN_ALIGN_NONE; ar_preview->alignment= RGN_ALIGN_TOP; @@ -184,11 +186,28 @@ static SpaceLink *sequencer_new(const bContext *C) ar->flag = RGN_FLAG_HIDDEN; /* preview area */ + /* NOTE: if you change values here, also change them in sequencer_init_preview_region */ ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer"); BLI_addtail(&sseq->regionbase, ar); ar->regiontype= RGN_TYPE_PREVIEW; ar->alignment= RGN_ALIGN_TOP; ar->flag |= RGN_FLAG_HIDDEN; + /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */ + ar->v2d.keepzoom= V2D_KEEPASPECT | V2D_KEEPZOOM; + ar->v2d.minzoom= 0.00001f; + ar->v2d.maxzoom= 100000.0f; + ar->v2d.tot.xmin= -960.0f; /* 1920 width centered */ + ar->v2d.tot.ymin= -540.0f; /* 1080 height centered */ + ar->v2d.tot.xmax= 960.0f; + ar->v2d.tot.ymax= 540.0f; + ar->v2d.min[0]= 0.0f; + ar->v2d.min[1]= 0.0f; + ar->v2d.max[0]= 12000.0f; + ar->v2d.max[1]= 12000.0f; + ar->v2d.cur= ar->v2d.tot; + ar->v2d.align= V2D_ALIGN_FREE; + ar->v2d.keeptot= V2D_KEEPTOT_FREE; + /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for sequencer"); @@ -358,8 +377,8 @@ static void sequencer_main_area_listener(ARegion *ar, wmNotifier *wmn) static void sequencer_preview_area_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - - UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); + + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); keymap= WM_keymap_find(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -377,7 +396,7 @@ static void sequencer_preview_area_draw(const bContext *C, ARegion *ar) /* XXX temp fix for wrong setting in sseq->mainb */ if (sseq->mainb == SEQ_DRAW_SEQUENCE) sseq->mainb = SEQ_DRAW_IMG_IMBUF; - draw_image_seq(scene, ar, sseq); + draw_image_seq(C, scene, ar, sseq); } static void sequencer_preview_area_listener(ARegion *ar, wmNotifier *wmn) |