Merging r49659 through r49666 from trunk into soc-2011-tomato
This commit is contained in:
@@ -115,6 +115,7 @@ class NODE_MT_view(Menu):
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("node.view_selected")
|
||||
layout.operator("node.view_all")
|
||||
|
||||
if context.space_data.show_backdrop:
|
||||
|
||||
@@ -1577,12 +1577,12 @@ static void make_cb_table_float(float lift, float gain, float gamma,
|
||||
}
|
||||
}
|
||||
|
||||
static void color_balance_byte_byte(Sequence *seq, ImBuf *ibuf, float mul)
|
||||
static void color_balance_byte_byte(Sequence *seq, unsigned char *rect, int width, int height, float mul)
|
||||
{
|
||||
unsigned char cb_tab[3][256];
|
||||
int c;
|
||||
unsigned char *p = (unsigned char *) ibuf->rect;
|
||||
unsigned char *e = p + ibuf->x * 4 * ibuf->y;
|
||||
unsigned char *p = rect;
|
||||
unsigned char *e = p + width * 4 * height;
|
||||
|
||||
StripColorBalance cb = calc_cb(seq->strip->color_balance);
|
||||
|
||||
@@ -1600,18 +1600,16 @@ static void color_balance_byte_byte(Sequence *seq, ImBuf *ibuf, float mul)
|
||||
}
|
||||
}
|
||||
|
||||
static void color_balance_byte_float(Sequence *seq, ImBuf *ibuf, float mul)
|
||||
static void color_balance_byte_float(Sequence *seq, unsigned char *rect, float *rect_float, int width, int height, float mul)
|
||||
{
|
||||
float cb_tab[4][256];
|
||||
int c, i;
|
||||
unsigned char *p = (unsigned char *) ibuf->rect;
|
||||
unsigned char *e = p + ibuf->x * 4 * ibuf->y;
|
||||
unsigned char *p = rect;
|
||||
unsigned char *e = p + width * 4 * height;
|
||||
float *o;
|
||||
StripColorBalance cb;
|
||||
|
||||
imb_addrectfloatImBuf(ibuf);
|
||||
|
||||
o = ibuf->rect_float;
|
||||
o = rect_float;
|
||||
|
||||
cb = calc_cb(seq->strip->color_balance);
|
||||
|
||||
@@ -1633,10 +1631,10 @@ static void color_balance_byte_float(Sequence *seq, ImBuf *ibuf, float mul)
|
||||
}
|
||||
}
|
||||
|
||||
static void color_balance_float_float(Sequence *seq, ImBuf *ibuf, float mul)
|
||||
static void color_balance_float_float(Sequence *seq, float *rect_float, int width, int height, float mul)
|
||||
{
|
||||
float *p = ibuf->rect_float;
|
||||
float *e = ibuf->rect_float + ibuf->x * 4 * ibuf->y;
|
||||
float *p = rect_float;
|
||||
float *e = rect_float + width * 4 * height;
|
||||
StripColorBalance cb = calc_cb(seq->strip->color_balance);
|
||||
|
||||
while (p < e) {
|
||||
@@ -1648,19 +1646,99 @@ static void color_balance_float_float(Sequence *seq, ImBuf *ibuf, float mul)
|
||||
}
|
||||
}
|
||||
|
||||
static void color_balance(Sequence *seq, ImBuf *ibuf, float mul)
|
||||
typedef struct ColorBalanceInitData {
|
||||
Sequence *seq;
|
||||
ImBuf *ibuf;
|
||||
float mul;
|
||||
} ColorBalanceInitData;
|
||||
|
||||
typedef struct ColorBalanceThread {
|
||||
Sequence *seq;
|
||||
float mul;
|
||||
|
||||
int width, height;
|
||||
|
||||
unsigned char *rect;
|
||||
float *rect_float;
|
||||
} ColorBalanceThread;
|
||||
|
||||
static void color_balance_init_handle(void *handle_v, int start_line, int tot_line, void *init_data_v)
|
||||
{
|
||||
if (ibuf->rect_float) {
|
||||
color_balance_float_float(seq, ibuf, mul);
|
||||
ColorBalanceThread *handle = (ColorBalanceThread *) handle_v;
|
||||
ColorBalanceInitData *init_data = (ColorBalanceInitData *) init_data_v;
|
||||
ImBuf *ibuf = init_data->ibuf;
|
||||
|
||||
int offset = 4 * start_line * ibuf->x;
|
||||
|
||||
memset(handle, 0, sizeof(ColorBalanceThread));
|
||||
|
||||
handle->seq = init_data->seq;
|
||||
handle->mul = init_data->mul;
|
||||
handle->width = ibuf->x;
|
||||
handle->height = tot_line;
|
||||
|
||||
if (ibuf->rect)
|
||||
handle->rect = (unsigned char *) ibuf->rect + offset;
|
||||
|
||||
if (ibuf->rect_float)
|
||||
handle->rect_float = ibuf->rect_float + offset;
|
||||
}
|
||||
|
||||
static void *color_balance_do_thread(void *thread_data_v)
|
||||
{
|
||||
ColorBalanceThread *thread_data = (ColorBalanceThread *) thread_data_v;
|
||||
Sequence *seq = thread_data->seq;
|
||||
int width = thread_data->width, height = thread_data->height;
|
||||
unsigned char *rect = thread_data->rect;
|
||||
float *rect_float = thread_data->rect_float;
|
||||
float mul = thread_data->mul;
|
||||
|
||||
if (rect_float) {
|
||||
color_balance_float_float(seq, rect_float, width, height, mul);
|
||||
}
|
||||
else if (seq->flag & SEQ_MAKE_FLOAT) {
|
||||
color_balance_byte_float(seq, ibuf, mul);
|
||||
color_balance_byte_float(seq, rect, rect_float, width, height, mul);
|
||||
}
|
||||
else {
|
||||
color_balance_byte_byte(seq, ibuf, mul);
|
||||
color_balance_byte_byte(seq, rect, width, height, mul);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void color_balance(Sequence *seq, ImBuf *ibuf, float mul)
|
||||
{
|
||||
if (!ibuf->rect_float && seq->flag & SEQ_MAKE_FLOAT)
|
||||
imb_addrectfloatImBuf(ibuf);
|
||||
|
||||
if (BLI_thread_is_main()) {
|
||||
/* color balance could have been called from prefetching job which
|
||||
* is already multithreaded, so doing threading here makes no sense
|
||||
*/
|
||||
ColorBalanceInitData init_data;
|
||||
|
||||
init_data.seq = seq;
|
||||
init_data.ibuf = ibuf;
|
||||
init_data.mul = mul;
|
||||
|
||||
IMB_processor_apply_threaded(ibuf->y, sizeof(ColorBalanceThread), &init_data,
|
||||
color_balance_init_handle, color_balance_do_thread);
|
||||
|
||||
}
|
||||
else {
|
||||
ColorBalanceThread handle;
|
||||
|
||||
handle.seq = seq;
|
||||
handle.mul = mul;
|
||||
handle.width = ibuf->x;
|
||||
handle.height = ibuf->y;
|
||||
handle.rect = (unsigned char *)ibuf->rect;
|
||||
handle.rect_float = ibuf->rect_float;
|
||||
|
||||
color_balance_do_thread(&handle);
|
||||
} }
|
||||
|
||||
|
||||
/*
|
||||
* input preprocessing for SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP and SEQ_TYPE_SCENE
|
||||
*
|
||||
|
||||
@@ -113,6 +113,7 @@ void NODE_OT_select_same_type_prev(wmOperatorType *ot);
|
||||
|
||||
/* node_view.c */
|
||||
void NODE_OT_view_all(struct wmOperatorType *ot);
|
||||
void NODE_OT_view_selected(struct wmOperatorType *ot);
|
||||
|
||||
void NODE_OT_backimage_move(struct wmOperatorType *ot);
|
||||
void NODE_OT_backimage_zoom(struct wmOperatorType *ot);
|
||||
|
||||
@@ -60,6 +60,7 @@ void node_operatortypes(void)
|
||||
WM_operatortype_append(NODE_OT_select_same_type_prev);
|
||||
|
||||
WM_operatortype_append(NODE_OT_view_all);
|
||||
WM_operatortype_append(NODE_OT_view_selected);
|
||||
|
||||
WM_operatortype_append(NODE_OT_mute_toggle);
|
||||
WM_operatortype_append(NODE_OT_hide_toggle);
|
||||
@@ -255,6 +256,7 @@ void node_keymap(struct wmKeyConfig *keyconf)
|
||||
WM_keymap_add_item(keymap, "NODE_OT_show_cyclic_dependencies", CKEY, KM_PRESS, 0, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "NODE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "NODE_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "NODE_OT_select_border", BKEY, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(kmi->ptr, "tweak", FALSE);
|
||||
|
||||
@@ -60,54 +60,52 @@
|
||||
|
||||
/* **************** View All Operator ************** */
|
||||
|
||||
static void snode_home(ScrArea *UNUSED(sa), ARegion *ar, SpaceNode *snode)
|
||||
static int snode_home(ScrArea *UNUSED(sa), ARegion *ar, SpaceNode *snode, const int node_flag)
|
||||
{
|
||||
bNode *node;
|
||||
rctf *cur;
|
||||
rctf cur_new;
|
||||
float oldwidth, oldheight, width, height;
|
||||
int first = 1;
|
||||
int change = FALSE;
|
||||
|
||||
cur = &ar->v2d.cur;
|
||||
|
||||
oldwidth = cur->xmax - cur->xmin;
|
||||
oldheight = cur->ymax - cur->ymin;
|
||||
|
||||
cur->xmin = cur->ymin = 0.0f;
|
||||
cur->xmax = ar->winx;
|
||||
cur->ymax = ar->winy;
|
||||
|
||||
oldwidth = ar->v2d.cur.xmax - ar->v2d.cur.xmin;
|
||||
oldheight = ar->v2d.cur.ymax - ar->v2d.cur.ymin;
|
||||
|
||||
BLI_rctf_init_minmax(&cur_new);
|
||||
|
||||
if (snode->edittree) {
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
if (first) {
|
||||
first = 0;
|
||||
ar->v2d.cur = node->totr;
|
||||
}
|
||||
else {
|
||||
BLI_rctf_union(cur, &node->totr);
|
||||
if ((node->flag & node_flag) == node_flag) {
|
||||
BLI_rctf_union(&cur_new, &node->totr);
|
||||
change = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
snode->xof = 0;
|
||||
snode->yof = 0;
|
||||
width = cur->xmax - cur->xmin;
|
||||
height = cur->ymax - cur->ymin;
|
||||
|
||||
if (width > height) {
|
||||
float newheight;
|
||||
newheight = oldheight * width / oldwidth;
|
||||
cur->ymin = cur->ymin - newheight / 4;
|
||||
cur->ymax = cur->ymax + newheight / 4;
|
||||
}
|
||||
else {
|
||||
float newwidth;
|
||||
newwidth = oldwidth * height / oldheight;
|
||||
cur->xmin = cur->xmin - newwidth / 4;
|
||||
cur->xmax = cur->xmax + newwidth / 4;
|
||||
if (change) {
|
||||
snode->xof = 0;
|
||||
snode->yof = 0;
|
||||
width = cur_new.xmax - cur_new.xmin;
|
||||
height = cur_new.ymax - cur_new.ymin;
|
||||
|
||||
if (width > height) {
|
||||
float newheight;
|
||||
newheight = oldheight * width / oldwidth;
|
||||
cur_new.ymin = cur_new.ymin - newheight / 4;
|
||||
cur_new.ymax = cur_new.ymax + newheight / 4;
|
||||
}
|
||||
else {
|
||||
float newwidth;
|
||||
newwidth = oldwidth * height / oldheight;
|
||||
cur_new.xmin = cur_new.xmin - newwidth / 4;
|
||||
cur_new.xmax = cur_new.xmax + newwidth / 4;
|
||||
}
|
||||
|
||||
ar->v2d.tot = ar->v2d.cur = cur_new;
|
||||
UI_view2d_curRect_validate(&ar->v2d);
|
||||
}
|
||||
|
||||
ar->v2d.tot = ar->v2d.cur;
|
||||
UI_view2d_curRect_validate(&ar->v2d);
|
||||
return change;
|
||||
}
|
||||
|
||||
static int node_view_all_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
@@ -116,10 +114,14 @@ static int node_view_all_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
|
||||
snode_home(sa, ar, snode);
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
if (snode_home(sa, ar, snode, 0)) {
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
else {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
}
|
||||
|
||||
void NODE_OT_view_all(wmOperatorType *ot)
|
||||
@@ -137,6 +139,36 @@ void NODE_OT_view_all(wmOperatorType *ot)
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
static int node_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
|
||||
if (snode_home(sa, ar, snode, NODE_SELECT)) {
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
else {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
}
|
||||
|
||||
void NODE_OT_view_selected(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "View Selected";
|
||||
ot->idname = "NODE_OT_view_selected";
|
||||
ot->description = "Resize view so you can see selected nodes";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = node_view_selected_exec;
|
||||
ot->poll = ED_operator_node_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* **************** Backround Image Operators ************** */
|
||||
|
||||
|
||||
@@ -507,5 +507,11 @@ void imb_freemipmapImBuf(struct ImBuf *ibuf);
|
||||
short imb_addtilesImBuf(struct ImBuf *ibuf);
|
||||
void imb_freetilesImBuf(struct ImBuf *ibuf);
|
||||
|
||||
/* threaded processors */
|
||||
void IMB_processor_apply_threaded(int buffer_lines, int handle_size, void *init_customdata,
|
||||
void (init_handle) (void *handle, int start_line, int tot_line,
|
||||
void *customdata),
|
||||
void *(do_thread) (void *));
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -38,7 +38,11 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_listbase.h"
|
||||
|
||||
#include "IMB_imbuf_types.h"
|
||||
#include "IMB_imbuf.h"
|
||||
@@ -446,3 +450,49 @@ void neareast_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, i
|
||||
|
||||
neareast_interpolation_color(in, outI, outF, x, y);
|
||||
}
|
||||
|
||||
/*********************** Threaded image processing *************************/
|
||||
|
||||
void IMB_processor_apply_threaded(int buffer_lines, int handle_size, void *init_customdata,
|
||||
void (init_handle) (void *handle, int start_line, int tot_line,
|
||||
void *customdata),
|
||||
void *(do_thread) (void *))
|
||||
{
|
||||
void *handles;
|
||||
ListBase threads;
|
||||
|
||||
int i, tot_thread = BLI_system_thread_count();
|
||||
int start_line, tot_line;
|
||||
|
||||
handles = MEM_callocN(handle_size * tot_thread, "processor apply threaded handles");
|
||||
|
||||
if (tot_thread > 1)
|
||||
BLI_init_threads(&threads, do_thread, tot_thread);
|
||||
|
||||
start_line = 0;
|
||||
tot_line = ((float)(buffer_lines / tot_thread)) + 0.5f;
|
||||
|
||||
for (i = 0; i < tot_thread; i++) {
|
||||
int cur_tot_line;
|
||||
void *handle = ((char *) handles) + handle_size * i;
|
||||
|
||||
if (i < tot_thread - 1)
|
||||
cur_tot_line = tot_line;
|
||||
else
|
||||
cur_tot_line = buffer_lines - start_line;
|
||||
|
||||
init_handle(handle, start_line, cur_tot_line, init_customdata);
|
||||
|
||||
if (tot_thread > 1)
|
||||
BLI_insert_thread(&threads, handle);
|
||||
|
||||
start_line += tot_line;
|
||||
}
|
||||
|
||||
if (tot_thread > 1)
|
||||
BLI_end_threads(&threads);
|
||||
else
|
||||
do_thread(handles);
|
||||
|
||||
MEM_freeN(handles);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user