diff options
author | Matt Ebb <matt@mke3.net> | 2010-04-06 06:05:54 +0400 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-04-06 06:05:54 +0400 |
commit | bfe248b3d629d28fed3798e9f6a42bccb5d40f9e (patch) | |
tree | d4b75ad54067d790cdabaa7e843624b1d423a5af /source/blender/editors/space_image | |
parent | ea7fdb55a3e8f088161b218b96220c1cba9380a1 (diff) |
Patch [#21750] Add luma waveform and vectorscope to image view
by Xavier Thomas
This adds the waveform monitor and vectorscope to the image editor 'scopes'
region, bringing it inline (plus a bit more) with sequence editor functionality,
and a big step closer to the end goal of unifying the display code for image/
comp/sequence editor. It's non-intrusive, using the same code paths as
the histogram.
There's still room for more tweaks - I modified the original patch, changing
the openGL immediate mode drawing of the waveform display to vertex arrays for
speed optimisation. Xavier can look at doing this for the vectorscope now too.
Thanks very much Xavier!
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 25 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 41 |
2 files changed, 38 insertions, 28 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index c9daeb09f25..55e6ac356c6 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -177,7 +177,7 @@ static void view_pan_exit(bContext *C, wmOperator *op, int cancel) if(cancel) { sima->xof= vpd->xof; sima->yof= vpd->yof; - ED_area_tag_redraw(CTX_wm_area(C)); + ED_region_tag_redraw(CTX_wm_region(C)); } WM_cursor_restore(CTX_wm_window(C)); @@ -193,7 +193,7 @@ static int view_pan_exec(bContext *C, wmOperator *op) sima->xof += offset[0]; sima->yof += offset[1]; - ED_area_tag_redraw(CTX_wm_area(C)); + ED_region_tag_redraw(CTX_wm_region(C)); /* XXX notifier? */ #if 0 @@ -309,7 +309,7 @@ static void view_zoom_exit(bContext *C, wmOperator *op, int cancel) if(cancel) { sima->zoom= vpd->zoom; - ED_area_tag_redraw(CTX_wm_area(C)); + ED_region_tag_redraw(CTX_wm_region(C)); } WM_cursor_restore(CTX_wm_window(C)); @@ -323,7 +323,7 @@ static int view_zoom_exec(bContext *C, wmOperator *op) sima_zoom_set_factor(sima, ar, RNA_float_get(op->ptr, "factor")); - ED_area_tag_redraw(CTX_wm_area(C)); + ED_region_tag_redraw(CTX_wm_region(C)); /* XXX notifier? */ #if 0 @@ -347,7 +347,7 @@ static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event) factor= 1.0 + (event->x-event->prevx+event->y-event->prevy)/300.0f; RNA_float_set(op->ptr, "factor", factor); sima_zoom_set(sima, ar, sima->zoom*factor); - ED_area_tag_redraw(CTX_wm_area(C)); + ED_region_tag_redraw(CTX_wm_region(C)); return OPERATOR_FINISHED; } @@ -369,7 +369,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) factor= 1.0 + (vpd->x-event->x+vpd->y-event->y)/300.0f; RNA_float_set(op->ptr, "factor", factor); sima_zoom_set(sima, ar, vpd->zoom*factor); - ED_area_tag_redraw(CTX_wm_area(C)); + ED_region_tag_redraw(CTX_wm_region(C)); break; case MIDDLEMOUSE: case LEFTMOUSE: @@ -452,7 +452,7 @@ static int view_all_exec(bContext *C, wmOperator *op) sima->xof= sima->yof= 0.0f; - ED_area_tag_redraw(CTX_wm_area(C)); + ED_region_tag_redraw(CTX_wm_region(C)); return OPERATOR_FINISHED; } @@ -504,7 +504,7 @@ static int view_selected_exec(bContext *C, wmOperator *op) if(size<=0.01) size= 0.01; sima_zoom_set(sima, ar, 0.7/size); - ED_area_tag_redraw(CTX_wm_area(C)); + ED_region_tag_redraw(CTX_wm_region(C)); return OPERATOR_FINISHED; } @@ -529,7 +529,7 @@ static int view_zoom_in_exec(bContext *C, wmOperator *op) sima_zoom_set_factor(sima, ar, 1.25f); - ED_area_tag_redraw(CTX_wm_area(C)); + ED_region_tag_redraw(CTX_wm_region(C)); return OPERATOR_FINISHED; } @@ -552,7 +552,7 @@ static int view_zoom_out_exec(bContext *C, wmOperator *op) sima_zoom_set_factor(sima, ar, 0.8f); - ED_area_tag_redraw(CTX_wm_area(C)); + ED_region_tag_redraw(CTX_wm_region(C)); return OPERATOR_FINISHED; } @@ -590,7 +590,7 @@ static int view_zoom_ratio_exec(bContext *C, wmOperator *op) } #endif - ED_area_tag_redraw(CTX_wm_area(C)); + ED_region_tag_redraw(CTX_wm_region(C)); return OPERATOR_FINISHED; } @@ -1688,16 +1688,17 @@ static int sample_line_exec(bContext *C, wmOperator *op) hist->data_r[i] = fp[0]; hist->data_g[i] = fp[1]; hist->data_b[i] = fp[2]; + hist->data_luma[i] = (0.299f*fp[0] + 0.587f*fp[1] + 0.114f*fp[2]); } else if (ibuf->rect) { cp= (unsigned char *)(ibuf->rect + y*ibuf->x + x); hist->data_r[i] = (float)cp[0]/255.0f; hist->data_g[i] = (float)cp[1]/255.0f; hist->data_b[i] = (float)cp[2]/255.0f; + hist->data_luma[i] = (0.299f*cp[0] + 0.587f*cp[1] + 0.114f*cp[2])/255; } } } - hist->ok=1; ED_space_image_release_buffer(sima, lock); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 0eb377450e9..45903c8079d 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -47,6 +47,7 @@ #include "BKE_screen.h" #include "BKE_utildefines.h" +#include "IMB_imbuf.h" #include "IMB_imbuf_types.h" #include "ED_mesh.h" @@ -98,6 +99,7 @@ void ED_space_image_set(bContext *C, SpaceImage *sima, Scene *scene, Object *obe WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); ED_area_tag_redraw(CTX_wm_area(C)); + } } @@ -289,21 +291,21 @@ int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit) } - -static void image_histogram_tag_refresh(ScrArea *sa) +static void image_scopes_tag_refresh(ScrArea *sa) { SpaceImage *sima= (SpaceImage *)sa->spacedata.first; ARegion *ar; - + /* only while histogram is visible */ for (ar=sa->regionbase.first; ar; ar=ar->next) { if (ar->regiontype == RGN_TYPE_PREVIEW && ar->flag & RGN_FLAG_HIDDEN) return; } - - sima->hist.ok=0; + + sima->scopes.ok=0; } + /* ******************** manage regions ********************* */ ARegion *image_has_buttons_region(ScrArea *sa) @@ -356,8 +358,8 @@ ARegion *image_has_scope_region(ScrArea *sa) arnew->alignment= RGN_ALIGN_RIGHT; arnew->flag = RGN_FLAG_HIDDEN; - - image_histogram_tag_refresh(sa); + + image_scopes_tag_refresh(sa); return arnew; } @@ -400,6 +402,13 @@ static SpaceLink *image_new(const bContext *C) ar->regiontype= RGN_TYPE_PREVIEW; ar->alignment= RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; + + simage->scopes.accuracy=30.0; + simage->scopes.hist.mode=HISTO_MODE_RGB; + simage->scopes.wavefrm_alpha=0.3; + simage->scopes.vecscope_alpha=0.3; + simage->scopes.wavefrm_height= 100; + simage->scopes.hist.height= 100; /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for image"); @@ -417,9 +426,7 @@ static void image_free(SpaceLink *sl) if(simage->cumap) curvemapping_free(simage->cumap); -// if(simage->gpd) -// XXX free_gpencil_data(simage->gpd); - + scopes_free(&simage->scopes); } @@ -590,7 +597,7 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) case NC_SCENE: switch(wmn->data) { case ND_FRAME: - image_histogram_tag_refresh(sa); + image_scopes_tag_refresh(sa); ED_area_tag_refresh(sa); ED_area_tag_redraw(sa); break; @@ -598,7 +605,7 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) case ND_RENDER_RESULT: case ND_COMPO_RESULT: if (ED_space_image_show_render(sima)) - image_histogram_tag_refresh(sa); + image_scopes_tag_refresh(sa); ED_area_tag_refresh(sa); ED_area_tag_redraw(sa); break; @@ -606,14 +613,14 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_IMAGE: if (wmn->reference == sima->image || !wmn->reference) { - image_histogram_tag_refresh(sa); + image_scopes_tag_refresh(sa); ED_area_tag_refresh(sa); ED_area_tag_redraw(sa); } break; case NC_SPACE: if(wmn->data == ND_SPACE_IMAGE) { - image_histogram_tag_refresh(sa); + image_scopes_tag_refresh(sa); ED_area_tag_redraw(sa); } break; @@ -837,10 +844,12 @@ static void image_scope_area_init(wmWindowManager *wm, ARegion *ar) static void image_scope_area_draw(const bContext *C, ARegion *ar) { SpaceImage *sima= CTX_wm_space_image(C); + Scene *scene= CTX_data_scene(C); void *lock; ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock); - if(ibuf) - histogram_update(&sima->hist, ibuf); + if(ibuf) { + scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT ); + } ED_space_image_release_buffer(sima, lock); ED_region_panels(C, ar, 1, NULL, -1); |