int j;
int active = plugin->config.active;
+ int op = plugin->config.op;
int use_mask = plugin->config.use_mask;
int capture_mask = plugin->config.capture_mask;
int invert_selection = plugin->config.invert_selection;
int byte_advance=0;
int have_alpha=1;
-#define SPLIT 128
+#define SPLIT 256
int tasks = engine->get_total_packages()*16;
int taski,rowi,coli;
/* selection modification according to config */
if(use_mask && have_alpha){
- if(!have_selection){
- /* selection consists only of mask */
- selection_test=0.;
- for(j = 0; j < todo; j++)
- selection_test += selection[j] = Avec[j];
- have_selection=1;
- }else{
- if(invert_selection){
- if(selection_test < SELECT_THRESH){
- /* fully selected after invert, clip to mask */
- selection_test=0.f;
- for(j = 0; j < todo; j++)
- selection_test += selection[j] = Avec[j];
- }else if (selection_test >= todo-SELECT_THRESH){
- /* fully deselected after invert */
- selection_test=0.;
+ if(!op){
+ if(!have_selection){
+ /* selection consists only of mask */
+ selection_test=0.;
+ for(j = 0; j < todo; j++)
+ selection_test += selection[j] = Avec[j];
+ have_selection=1;
+ }else{
+ if(invert_selection){
+ if(selection_test < SELECT_THRESH){
+ /* fully selected after invert, clip to mask */
+ selection_test=0.f;
+ for(j = 0; j < todo; j++)
+ selection_test += selection[j] = Avec[j];
+ }else{
+ /* partial selection after invert, clip to mask */
+ selection_test=0.f;
+ for(j = 0; j < todo; j++)
+ selection_test += selection[j] = Avec[j]*(1.f-selection[j]);
+ }
}else{
- /* partial selection after invert, clip to mask */
- selection_test=0.f;
- for(j = 0; j < todo; j++)
- selection_test += selection[j] = Avec[j]*(1.f-selection[j]);
+ if(selection_test < SELECT_THRESH){
+ /* fully deselected */
+ }else if(selection_test >= todo-SELECT_THRESH){
+ /* fully selected, clip to mask */
+ selection_test=0.f;
+ for(j = 0; j < todo; j++)
+ selection_test += selection[j] = Avec[j];
+ }else{
+ /* partial selection, clip to mask */
+ selection_test=0.f;
+ for(j = 0; j < todo; j++)
+ selection_test += selection[j] *= Avec[j];
+ }
}
+ }
+ }else{
+ if(!have_selection){
+ for(j = 0; j < todo; j++) selection[j] = 1;
}else{
- if(selection_test < SELECT_THRESH){
- /* fully deselected */
- }else if (selection_test >= todo-SELECT_THRESH){
- /* fully selected, clip to mask */
- selection_test=0.f;
- for(j = 0; j < todo; j++)
- selection_test += selection[j] = Avec[j];
+ if(invert_selection){
+ if(selection_test < SELECT_THRESH){
+ /* fully selected after invert */
+ for(j = 0; j < todo; j++) selection[j] = 1;
+ }else{
+ /* partial selection after invert, clip to mask */
+ selection_test=0.f;
+ for(j = 0; j < todo; j++)
+ selection_test += selection[j] =
+ Avec[j]+(1.f-selection[j])-Avec[j]*(1.f-selection[j]);
+ }
}else{
- /* partial selection, clip to mask */
- selection_test=0.f;
- for(j = 0; j < todo; j++)
- selection_test += selection[j] *= Avec[j];
+ if(selection_test < SELECT_THRESH){
+ /* fully deselected, clip to mask */
+ selection_test=0.f;
+ for(j = 0; j < todo; j++)
+ selection_test += selection[j] = Avec[j];
+ }else if(selection_test >= todo-SELECT_THRESH){
+ /* fully selected */
+ }else{
+ /* partial selection, clip to mask */
+ selection_test=0.f;
+ for(j = 0; j < todo; j++)
+ selection_test += selection[j] =
+ selection[j]+Avec[j]-selection[j]*Avec[j];
+ }
}
}
}
- if(selection_test < SELECT_THRESH){
+
+ if(!use_mask && !invert_selection && selection_test < SELECT_THRESH){
/* skip processing this fragment */
/* we're using a mask; if the mask is set to capture, we
need to restore alpha before skipping */
}
}
}
-
+ float *s = have_selection?selection:0;
/* re-layer back into pipeline color format */
switch(frame->get_color_model()) {
case BC_RGB888:
- RGB_to_rgb8(Rvec,Gvec,Bvec,have_selection?selection:0,1.f,row_fragment,todo,3);
+ RGB_to_rgb8(Rvec,Gvec,Bvec,s,1.f,row_fragment,todo,3);
break;
case BC_RGBA8888:
- RGB_to_rgb8(Rvec,Gvec,Bvec,have_selection?selection:0,1.f,row_fragment,todo,4);
+ RGB_to_rgb8(Rvec,Gvec,Bvec,s,1.f,row_fragment,todo,4);
break;
case BC_RGB_FLOAT:
- RGB_to_rgbF(Rvec,Gvec,Bvec,have_selection?selection:0,1.f,(float *)row_fragment,todo,3);
+ RGB_to_rgbF(Rvec,Gvec,Bvec,s,1.f,(float *)row_fragment,todo,3);
break;
case BC_RGBA_FLOAT:
- RGB_to_rgbF(Rvec,Gvec,Bvec,have_selection?selection:0,1.f,(float *)row_fragment,todo,4);
+ RGB_to_rgbF(Rvec,Gvec,Bvec,s,1.f,(float *)row_fragment,todo,4);
break;
case BC_YUV888:
- RGB_to_yuv8(Rvec,Gvec,Bvec,have_selection?selection:0,1.f,row_fragment,todo,3);
+ RGB_to_yuv8(Rvec,Gvec,Bvec,s,1.f,row_fragment,todo,3);
break;
case BC_YUVA8888:
- RGB_to_yuv8(Rvec,Gvec,Bvec,have_selection?selection:0,1.f,row_fragment,todo,4);
+ RGB_to_yuv8(Rvec,Gvec,Bvec,s,1.f,row_fragment,todo,4);
break;
}
}
- if(active || show_ants || (use_mask && capture_mask)){
-
- if(use_mask && capture_mask){
+ if(active || show_ants || use_mask || capture_mask){
+ if(capture_mask){
switch(frame->get_color_model()) {
case BC_RGBA8888:
- if( have_selection && Aal < 1.f )
- Aal_to_alp8(selection,Aal,row_fragment,todo,4);
- else
- unmask_rgba8(row_fragment,todo);
+ unmask_rgba8(row_fragment,todo);
break;
case BC_RGBA_FLOAT:
- if( have_selection && Aal < 1.f )
- Aal_to_alpF(selection,Aal,(float *)row_fragment,todo,4);
- else
- unmask_rgbaF((float *)row_fragment,todo);
+ unmask_rgbaF((float *)row_fragment,todo);
break;
case BC_YUVA8888:
- if( have_selection && Aal < 1.f )
- Aal_to_alp8(selection,Aal,row_fragment,todo,4);
- else
- unmask_yuva8(row_fragment,todo);
+ unmask_yuva8(row_fragment,todo);
+ break;
+ }
+ }
+ else if(use_mask){
+ float *s = !show_ants&&have_selection?selection:0;
+ switch(frame->get_color_model()) {
+ case BC_RGBA8888:
+ case BC_YUVA8888:
+ Aal_to_alp8(s,Aal,row_fragment,todo,4);
+ break;
+ case BC_RGBA_FLOAT:
+ Aal_to_alpF(s,Aal,(float *)row_fragment,todo,4);
break;
}
}
#include "bluebananawindow.h"
#include "keys.h"
#include "language.h"
+#include "plugin.h"
#include "brender.h"
#include "bluebananacolor.c"
};
+// -------------------------------------------- Op --------------------------------------------
+class BluebananaOp : public BC_CheckBox {
+public:
+ BluebananaOp(BluebananaMain *plugin, BluebananaWindow *gui)
+ : BC_CheckBox(-1, -1, &plugin->config.op, ""){
+ this->plugin = plugin;
+ this->gui = gui;
+ }
+ virtual int handle_event() {
+ if(plugin->config.op != get_value()){
+ plugin->config.op = get_value();
+ gui->enter_config_change();
+ gui->commit_config_change();
+ }
+ return 1;
+ }
+ void update (){
+ if(plugin->config.op != get_value()){
+ this->BC_CheckBox::update(plugin->config.op,1);
+ }
+ };
+ BluebananaMain *plugin;
+ BluebananaWindow *gui;
+};
+
// -------------------------------------------- Mark --------------------------------------------
class BluebananaMark : public BC_CheckBox {
public:
/* window headline */
{
- BC_Title *l = new BC_Title(xmargin,y,_("Color Selection"));
+ BC_Title *l = new BC_Title(xmargin,y,_("Combine Selection"));
BC_Title *l2 = new BC_Title(-1,-1,_(" Mark Selected Areas"));
add_subwindow(mark = new BluebananaMark(plugin,this));
add_subwindow(l);
add_subwindow(l2);
padx = l->get_h()*column_padding;
- label_x = xmargin + l->get_w();
-
- int x0 = get_w()-xmargin-mark->get_w();
- mark->reposition_window(x0,y-(mark->get_h()-l->get_h())/2);
- x0 -= padx+l2->get_w();
- l2->reposition_window(x0,y);
- x0-=padx;
+ add_subwindow(op = new BluebananaOp(plugin,this));
+ int x0 = xmargin + l->get_w() + padx;
+ op->reposition_window(x0,y-(op->get_h()-l->get_h())/2);
+ x0 += op->get_w() + padx;
+ int x1 = get_w()-xmargin-mark->get_w();
+ mark->reposition_window(x1,y-(mark->get_h()-l->get_h())/2);
+ x1 -= padx+l2->get_w();
+ l2->reposition_window(x1,y);
+ x1-=padx;
set_color(get_resources()->default_text_color);
- draw_line(label_x+padx, (int)(y+l->get_h()*.5), x0, (int)(y+l->get_h()*.5));
+ int y0 = y+l->get_h()*.5;
+ draw_line(x0,y0, x1,y0);
y += l->get_h()*(row_padding+1.);
}
+ label_x = xmargin + 100 + padx;
const char *labels[12]={_("hue"),_("saturation"),_("value"),_("fill"),_("red"),_("green"),_("blue"),_("hue"),_("saturation"),_("value"),_("fade"),_("alpha")};
for(i=0;i<12;i++){
add_subwindow(slider_labels[i] = new BC_Title(-1,-1,labels[i]));
int BluebananaWindow::repeat_event(int64_t d){
if(d==97){
- if(config_consume==config_produce)
+ if(config_consume!=config_produce)
flush_config_change();
- config_consume=config_produce;
}
+ if(!plugin->server->plugin->on) return 0;
if(d==207){
/* if background render is active and we're showing the zebra, mark