diff options
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r-- | source/blender/editors/space_clip/clip_buttons.c | 7 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_dopesheet_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_draw.c | 33 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_editor.c | 43 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_graph_draw.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_graph_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 4 |
8 files changed, 59 insertions, 50 deletions
diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index e66faa88b93..969b0e25928 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -119,6 +119,8 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiTemplateID(layout, C, ptr, propname, NULL, "CLIP_OT_open", NULL); if (clip) { + uiLayout *col; + row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); uiDefBut(block, LABEL, 0, "File Path:", 0, 19, 145, 19, NULL, 0, 0, 0, 0, ""); @@ -129,6 +131,9 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiItemR(row, &clipptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "clip.reload"); + + col = uiLayoutColumn(layout, FALSE); + uiTemplateColorspaceSettings(col, &clipptr, "colorspace_settings"); } } @@ -169,7 +174,7 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname) scopes->track_preview_height = (scopes->track_preview_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->track_preview_height; - uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), + uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), scopes->track_preview_height, scopes, 0, 0, 0, 0, ""); } diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 5d890155e25..cc1b8d444bc 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -274,7 +274,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) dopesheet = &tracking->dopesheet; height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2); - if (height > BLI_RCT_SIZE_Y(&v2d->mask)) { + if (height > BLI_rcti_size_y(&v2d->mask)) { /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 2353f8f8c12..b22c9a60bdc 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -42,6 +42,7 @@ #include "BKE_tracking.h" #include "BKE_mask.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -246,14 +247,7 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar) ED_region_info_draw(ar, str, block, 0.6f); } -static void verify_buffer_float(ImBuf *ibuf) -{ - if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID))) { - IMB_rect_from_float(ibuf); - } -} - -static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, +static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, ImBuf *ibuf, int width, int height, float zoomx, float zoomy) { int x, y; @@ -267,13 +261,16 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, glRectf(x, y, x + zoomx * width, y + zoomy * height); } else { - verify_buffer_float(ibuf); + unsigned char *display_buffer; + void *cache_handle; + + display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); - if (ibuf->rect) { + if (display_buffer) { int need_fallback = 1; if (ED_space_clip_texture_buffer_supported(sc)) { - if (ED_space_clip_load_movieclip_buffer(sc, ibuf)) { + if (ED_space_clip_load_movieclip_buffer(sc, ibuf, display_buffer)) { glPushMatrix(); glTranslatef(x, y, 0.0f); glScalef(zoomx, zoomy, 1.0f); @@ -299,12 +296,14 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, /* set zoom */ glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y); - glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer); /* reset zoom */ glPixelZoom(1.0f, 1.0f); } } + + IMB_display_buffer_release(cache_handle); } /* draw boundary border for frame if stabilization is enabled */ @@ -958,12 +957,12 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra static void view2d_to_region_float(View2D *v2d, float x, float y, float *regionx, float *regiony) { /* express given coordinates as proportional values */ - x = -v2d->cur.xmin / BLI_RCT_SIZE_X(&v2d->cur); - y = -v2d->cur.ymin / BLI_RCT_SIZE_Y(&v2d->cur); + x = -v2d->cur.xmin / BLI_rctf_size_x(&v2d->cur); + y = -v2d->cur.ymin / BLI_rctf_size_y(&v2d->cur); /* convert proportional distances to screen coordinates */ - *regionx = v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask); - *regiony = v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask); + *regionx = v2d->mask.xmin + x * BLI_rcti_size_x(&v2d->mask); + *regiony = v2d->mask.ymin + y * BLI_rcti_size_y(&v2d->mask); } static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, @@ -1461,7 +1460,7 @@ void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar) } if (ibuf) { - draw_movieclip_buffer(sc, ar, ibuf, width, height, zoomx, zoomy); + draw_movieclip_buffer(C, sc, ar, ibuf, width, height, zoomx, zoomy); IMB_freeImBuf(ibuf); } else { diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 08ad6aac970..32f91671daf 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -149,8 +149,8 @@ void ED_space_clip_get_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoo ED_space_clip_get_size(sc, &width, &height); - *zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur) * width); - *zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur) * height); + *zoomx = (float)(BLI_rcti_size_x(&ar->winrct) + 1) / (BLI_rctf_size_x(&ar->v2d.cur) * width); + *zoomy = (float)(BLI_rcti_size_y(&ar->winrct) + 1) / (BLI_rctf_size_y(&ar->v2d.cur) * height); } void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy) @@ -277,13 +277,7 @@ int ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r_ if (ibuf->rect_float) { fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); - /* IB_PROFILE_NONE is default but infact its linear */ - if (ELEM(ibuf->profile, IB_PROFILE_LINEAR_RGB, IB_PROFILE_NONE)) { - linearrgb_to_srgb_v3_v3(r_col, fp); - } - else { - copy_v3_v3(r_col, fp); - } + linearrgb_to_srgb_v3_v3(r_col, fp); ret = TRUE; } else if (ibuf->rect) { @@ -394,8 +388,8 @@ int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit) ED_space_clip_get_aspect(sc, &aspx, &aspy); - width = BLI_RCT_SIZE_X(&ar->winrct) + 1; - height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; + width = BLI_rcti_size_x(&ar->winrct) + 1; + height = BLI_rcti_size_y(&ar->winrct) + 1; zoomx = (float)width / w / aspx; zoomy = (float)height / h / aspy; @@ -583,12 +577,15 @@ typedef struct SpaceClipDrawContext { GLuint texture; /* OGL texture ID */ short texture_allocated; /* flag if texture was allocated by glGenTextures */ struct ImBuf *texture_ibuf; /* image buffer for which texture was created */ + const unsigned char *display_buffer; /* display buffer for which texture was created */ int image_width, image_height; /* image width and height for which texture was created */ unsigned last_texture; /* ID of previously used texture, so it'll be restored after clip drawing */ /* fields to check if cache is still valid */ int framenr, start_frame, frame_offset; short render_size, render_flag; + + char colorspace[64]; } SpaceClipDrawContext; int ED_space_clip_texture_buffer_supported(SpaceClip *sc) @@ -613,7 +610,7 @@ int ED_space_clip_texture_buffer_supported(SpaceClip *sc) return context->buffers_supported; } -int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) +int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf, const unsigned char *display_buffer) { SpaceClipDrawContext *context = sc->draw_context; MovieClip *clip = ED_space_clip_get_clip(sc); @@ -625,12 +622,22 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) * assuming displaying happens of footage frames only on which painting doesn't heppen. * so not changed image buffer pointer means unchanged image content */ need_rebind |= context->texture_ibuf != ibuf; + need_rebind |= context->display_buffer != display_buffer; need_rebind |= context->framenr != sc->user.framenr; need_rebind |= context->render_size != sc->user.render_size; need_rebind |= context->render_flag != sc->user.render_flag; need_rebind |= context->start_frame != clip->start_frame; need_rebind |= context->frame_offset != clip->frame_offset; + if (!need_rebind) { + /* OCIO_TODO: not entirely nice, but currently it seems to be easiest way + * to deal with changing input color space settings + * pointer-based check could fail due to new buffers could be + * be allocated on on old memory + */ + need_rebind = strcmp(context->colorspace, clip->colorspace_settings.name) != 0; + } + if (need_rebind) { int width = ibuf->x, height = ibuf->y; int need_recreate = 0; @@ -670,16 +677,12 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) glBindTexture(GL_TEXTURE_2D, context->texture); } - if (ibuf->rect_float) { - if (ibuf->rect == NULL) - IMB_rect_from_float(ibuf); - } - - if (ibuf->rect) - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + if (display_buffer) + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer); /* store settings */ context->texture_allocated = 1; + context->display_buffer = display_buffer; context->texture_ibuf = ibuf; context->image_width = ibuf->x; context->image_height = ibuf->y; @@ -688,6 +691,8 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) context->render_flag = sc->user.render_flag; context->start_frame = clip->start_frame; context->frame_offset = clip->frame_offset; + + strcpy(context->colorspace, clip->colorspace_settings.name); } else { /* displaying exactly the same image which was loaded t oa texture, diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 91501971d9d..7b070fde6ba 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -94,7 +94,7 @@ static void tracking_segment_point_cb(void *UNUSED(userdata), MovieTrackingTrack glVertex2f(scene_framenr, val); } -void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord) +static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord) { static float colors[2][3] = {{1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}}; @@ -116,7 +116,7 @@ void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int co glBegin(GL_LINE_STRIP); } -void tracking_segment_end_cb(void *UNUSED(userdata)) +static void tracking_segment_end_cb(void *UNUSED(userdata)) { glEnd(); diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 71dcd326887..fa235bd2997 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -130,7 +130,7 @@ static void find_nearest_tracking_segment_cb(void *userdata, MovieTrackingTrack copy_v2_v2(data->prev_co, co); } -void find_nearest_tracking_segment_end_cb(void *userdata) +static void find_nearest_tracking_segment_end_cb(void *userdata) { MouseSelectUserData *data = userdata; @@ -580,11 +580,11 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op)) } /* we need an extra "buffer" factor on either side so that the endpoints are visible */ - extra = 0.01f * BLI_RCT_SIZE_X(&v2d->cur); + extra = 0.01f * BLI_rctf_size_x(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; - extra = 0.01f * BLI_RCT_SIZE_Y(&v2d->cur); + extra = 0.01f * BLI_rctf_size_y(&v2d->cur); v2d->cur.ymin -= extra; v2d->cur.ymax += extra; @@ -610,7 +610,7 @@ void CLIP_OT_graph_view_all(wmOperatorType *ot) void ED_clip_graph_center_current_frame(Scene *scene, ARegion *ar) { View2D *v2d = &ar->v2d; - float extra = BLI_RCT_SIZE_X(&v2d->cur) / 2.0f; + float extra = BLI_rctf_size_x(&v2d->cur) / 2.0f; /* set extents of view to start/end frames */ v2d->cur.xmin = (float)CFRA - extra; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index aa2cadbd2d3..5c338f3e6f1 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -90,9 +90,9 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2]) if ((width < 4) && (height < 4)) sc->zoom = oldzoom; - else if (BLI_RCT_SIZE_X(&ar->winrct) <= sc->zoom) + else if (BLI_rcti_size_x(&ar->winrct) <= sc->zoom) sc->zoom = oldzoom; - else if (BLI_RCT_SIZE_Y(&ar->winrct) <= sc->zoom) + else if (BLI_rcti_size_y(&ar->winrct) <= sc->zoom) sc->zoom = oldzoom; } @@ -726,8 +726,8 @@ static int view_all_exec(bContext *C, wmOperator *op) h = h * aspy; /* check if the image will fit in the image with zoom == 1 */ - width = BLI_RCT_SIZE_X(&ar->winrct) + 1; - height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; + width = BLI_rcti_size_x(&ar->winrct) + 1; + height = BLI_rcti_size_y(&ar->winrct) + 1; if (fit_view) { const int margin = 5; /* margin from border */ diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 7f43c404095..3f925df30c7 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1036,8 +1036,8 @@ static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar) if (clip) h *= clip->aspy / clip->aspx / clip->tracking.camera.pixel_aspect; - winx = BLI_RCT_SIZE_X(&ar->winrct) + 1; - winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1; + 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; |