removed internal blending modes

This commit is contained in:
itsmattkc
2019-03-10 09:03:08 +11:00
parent 8cf3bd46a1
commit 0e612e717d
13 changed files with 1190 additions and 1397 deletions
+58 -58
View File
@@ -34,79 +34,79 @@ QFile debug_file;
QTextStream debug_stream;
void open_debug_file() {
QDir debug_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
debug_dir.mkpath(".");
if (debug_dir.exists()) {
debug_file.setFileName(debug_dir.path() + "/debug_log");
if (debug_file.open(QFile::WriteOnly)) {
debug_stream.setDevice(&debug_file);
} else {
qWarning() << "Couldn't open debug log file, debug log will not be saved";
}
QDir debug_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
debug_dir.mkpath(".");
if (debug_dir.exists()) {
debug_file.setFileName(debug_dir.path() + "/debug_log");
if (debug_file.open(QFile::WriteOnly)) {
debug_stream.setDevice(&debug_file);
} else {
qWarning() << "Couldn't open debug log file, debug log will not be saved";
}
}
}
void close_debug_file()
{
if (debug_file.isOpen()) {
debug_file.close();
}
if (debug_file.isOpen()) {
debug_file.close();
}
}
void debug_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
debug_mutex.lock();
const QByteArray localMsg = msg.toLocal8Bit();
const QDateTime now = QDateTime::currentDateTime();
const QByteArray timeRepr(now.toString(Qt::ISODate).toLocal8Bit());
QString msgTag;
QString fontColor;
switch (type) {
case QtDebugMsg:
msgTag = "DEBUG";
fontColor = "grey";
break;
case QtInfoMsg:
msgTag = "INFO";
fontColor = "blue";
break;
case QtWarningMsg:
msgTag = "WARNING";
fontColor = "yellow";
break;
case QtCriticalMsg:
msgTag = "ERROR";
fontColor = "red";
break;
case QtFatalMsg:
msgTag = "FATAL";
fontColor = "red";
break;
default:
fprintf(stderr, "Unknown debug msg type");
fflush(stderr);
break;
}//switch
debug_mutex.lock();
const QByteArray localMsg = msg.toLocal8Bit();
const QDateTime now = QDateTime::currentDateTime();
const QByteArray timeRepr(now.toString(Qt::ISODate).toLocal8Bit());
QString msgTag;
QString fontColor;
switch (type) {
case QtDebugMsg:
msgTag = "DEBUG";
fontColor = "grey";
break;
case QtInfoMsg:
msgTag = "INFO";
fontColor = "blue";
break;
case QtWarningMsg:
msgTag = "WARNING";
fontColor = "yellow";
break;
case QtCriticalMsg:
msgTag = "ERROR";
fontColor = "red";
break;
case QtFatalMsg:
msgTag = "FATAL";
fontColor = "red";
break;
default:
fprintf(stderr, "Unknown debug msg type");
fflush(stderr);
break;
}//switch
/*fprintf(stderr, "%s [%s] %s (%s:%u, %s)\n", timeRepr.data(), msgTag.toLocal8Bit().constData(), localMsg.data(),
/*fprintf(stderr, "%s [%s] %s (%s:%u, %s)\n", timeRepr.data(), msgTag.toLocal8Bit().constData(), localMsg.data(),
context.file, context.line, context.function);*/
fprintf(stderr, "%s [%s] %s\n", timeRepr.data(), msgTag.toLocal8Bit().constData(), localMsg.data());
fprintf(stderr, "%s [%s] %s\n", timeRepr.data(), msgTag.toLocal8Bit().constData(), localMsg.data());
if (debug_file.isOpen()) {
debug_stream << QString("[%1] %2 (%3:%4, %5)\n")
.arg(msgTag, localMsg, context.file, QString::number(context.line), context.function);
}
debug_info.prepend(QString("<font color='%1'><b>[%2]</b> %3 (%4:%5, %6)</font><br>")
.arg(fontColor, msgTag, localMsg, context.file, QString::number(context.line), context.function));
fflush(stderr);
if (olive::DebugDialog != nullptr && olive::DebugDialog->isVisible()) {
QMetaObject::invokeMethod(olive::DebugDialog, "update_log", Qt::QueuedConnection);
}
debug_mutex.unlock();
if (debug_file.isOpen()) {
debug_stream << QString("[%1] %2 (%3:%4, %5)\n")
.arg(msgTag, localMsg, context.file, QString::number(context.line), context.function);
}
debug_info.prepend(QString("<font color='%1'><b>[%2]</b> %3 (%4:%5, %6)</font><br>")
.arg(fontColor, msgTag, localMsg, context.file, QString::number(context.line), context.function));
fflush(stderr);
if (olive::DebugDialog != nullptr && olive::DebugDialog->isVisible()) {
QMetaObject::invokeMethod(olive::DebugDialog, "update_log", Qt::QueuedConnection);
}
debug_mutex.unlock();
}
const QString &get_debug_str()
{
return debug_info;
return debug_info;
}
+5 -172
View File
@@ -1,176 +1,13 @@
#version 110
const int BLEND_MODE_ADD = 0;
const int BLEND_MODE_AVERAGE = 1;
const int BLEND_MODE_COLORBURN = 2;
const int BLEND_MODE_COLORDODGE = 3;
const int BLEND_MODE_DARKEN = 4;
const int BLEND_MODE_DIFFERENCE = 5;
const int BLEND_MODE_EXCLUSION = 6;
const int BLEND_MODE_GLOW = 7;
const int BLEND_MODE_HARDLIGHT = 8;
const int BLEND_MODE_HARDMIX = 9;
const int BLEND_MODE_LIGHTEN = 10;
const int BLEND_MODE_LINEARBURN = 11;
const int BLEND_MODE_LINEARDODGE = 12;
const int BLEND_MODE_LINEARLIGHT = 13;
const int BLEND_MODE_MULTIPLY = 14;
const int BLEND_MODE_NEGATION = 15;
const int BLEND_MODE_NORMAL = 16;
const int BLEND_MODE_OVERLAY = 17;
const int BLEND_MODE_PHOENIX = 18;
const int BLEND_MODE_PINLIGHT = 19;
const int BLEND_MODE_REFLECT = 20;
const int BLEND_MODE_SCREEN = 21;
const int BLEND_MODE_SOFTLIGHT = 22;
const int BLEND_MODE_SUBSTRACT = 23;
const int BLEND_MODE_SUBTRACT = 24;
const int BLEND_MODE_VIVIDLIGHT = 25;
/*
This main stump is combined with another shader loaded externally to produce a blending mode.
uniform sampler2D background;
uniform sampler2D foreground;
For a custom blend mode, the function blend() MUST be available, and use the following syntax:
uniform int blendmode;
uniform float opacity;
blend(vec3 base_color, vec3 blend_color, float opacity)
varying vec2 vTexCoord;
// adapted from https://github.com/jamieowen/glsl-blend
// and http://www.deepskycolors.com/archivo/2010/04/21/formulas-for-Photoshop-blending-modes.html
// float blending functions
float blend_color_burn(float base, float blend) {
return (blend==0.0)?blend:max((1.0-((1.0-base)/blend)),0.0);
}
float blend_color_dodge(float base, float blend) {
return (blend==1.0)?blend:min(base/(1.0-blend),1.0);
}
float blend_vivid_light(float base, float blend) {
return (blend<0.5)?blend_color_burn(base,(2.0*blend)):blend_color_dodge(base,(2.0*(blend-0.5)));
}
vec3 blend_vivid_light(vec3 base, vec3 blend) {
return vec3(blend_vivid_light(base.r,blend.r),blend_vivid_light(base.g,blend.g),blend_vivid_light(base.b,blend.b));
}
float blend_hard_mix(float base, float blend) {
return (blend_vivid_light(base,blend)<0.5)?0.0:1.0;
}
float blend_lighten(float base, float blend) {
return max(blend,base);
}
float blend_overlay(float base, float blend) {
return base<0.5?(2.0*base*blend):(1.0-2.0*(1.0-base)*(1.0-blend));
}
vec3 blend_overlay(vec3 base, vec3 blend) {
return vec3(blend_overlay(base.r,blend.r),blend_overlay(base.g,blend.g),blend_overlay(base.b,blend.b));
}
float blend_darken(float base, float blend) {
return min(blend, base);
}
float blend_linear_burn(float base, float blend) {
return max(base+blend-1.0,0.0);
}
vec3 blend_linear_burn(vec3 base, vec3 blend) {
return max(base+blend-vec3(1.0),vec3(0.0));
}
float blend_linear_dodge(float base, float blend) {
return min(base+blend,1.0);
}
vec3 blend_linear_dodge(vec3 base, vec3 blend) {
return min(base+blend,vec3(1.0));
}
float blend_linear_light(float base, float blend) {
return blend<0.5?blend_linear_burn(base,(2.0*blend)):blend_linear_dodge(base,(2.0*(blend-0.5)));
}
float blend_pin_light(float base, float blend) {
return (blend<0.5)?blend_darken(base,(2.0*blend)):blend_lighten(base,(2.0*(blend-0.5)));
}
float blend_reflect(float base, float blend) {
return (blend==1.0)?blend:min(base*base/(1.0-blend),1.0);
}
vec3 blend_reflect(vec3 base, vec3 blend) {
return vec3(blend_reflect(base.r,blend.r),blend_reflect(base.g,blend.g),blend_reflect(base.b,blend.b));
}
float blend_screen(float base, float blend) {
return 1.0-((1.0-base)*(1.0-blend));
}
float blend_substract(float base, float blend) {
return max(base+blend-1.0,0.0);
}
float blend_soft_light(float base, float blend) {
return (blend<0.5)?(2.0*base*blend+base*base*(1.0-2.0*blend)):(sqrt(base)*(2.0*blend-1.0)+2.0*base*(1.0-blend));
}
// RGB blending function, alpha is handled below
vec3 blend(vec3 base, vec3 blend) {
if (blendmode == BLEND_MODE_AVERAGE) {
return (base+blend)/2.0;
} else if (blendmode == BLEND_MODE_COLORBURN) {
return vec3(blend_color_burn(base.r, blend.r), blend_color_burn(base.g, blend.g), blend_color_burn(base.b, blend.b));
} else if (blendmode == BLEND_MODE_COLORDODGE) {
return vec3(blend_color_dodge(base.r, blend.r), blend_color_dodge(base.g, blend.g), blend_color_dodge(base.b, blend.b));
} else if (blendmode == BLEND_MODE_DARKEN) {
return vec3(blend_darken(base.r, blend.r), blend_darken(base.g, blend.g), blend_darken(base.b, blend.b));
} else if (blendmode == BLEND_MODE_DIFFERENCE) {
return abs(base-blend);
} else if (blendmode == BLEND_MODE_EXCLUSION) {
return base+blend-2.0*base*blend;
} else if (blendmode == BLEND_MODE_GLOW) {
return blend_reflect(blend, base);
} else if (blendmode == BLEND_MODE_HARDLIGHT) {
return blend_overlay(blend,base);
} else if (blendmode == BLEND_MODE_HARDMIX) {
return vec3(blend_hard_mix(base.r,blend.r),blend_hard_mix(base.g,blend.g),blend_hard_mix(base.b,blend.b));
} else if (blendmode == BLEND_MODE_LIGHTEN) {
return vec3(blend_lighten(base.r,blend.r),blend_lighten(base.g,blend.g),blend_lighten(base.b,blend.b));
} else if (blendmode == BLEND_MODE_LINEARBURN || blendmode == BLEND_MODE_SUBTRACT) {
return blend_linear_burn(base, blend);
} else if (blendmode == BLEND_MODE_LINEARDODGE || blendmode == BLEND_MODE_ADD) {
return blend_linear_dodge(base, blend);
} else if (blendmode == BLEND_MODE_LINEARLIGHT) {
return vec3(blend_linear_light(base.r,blend.r),blend_linear_light(base.g,blend.g),blend_linear_light(base.b,blend.b));
} else if (blendmode == BLEND_MODE_MULTIPLY) {
return (base * blend);
} else if (blendmode == BLEND_MODE_NEGATION) {
return vec3(1.0)-abs(vec3(1.0)-base-blend);
} else if (blendmode == BLEND_MODE_OVERLAY) {
return blend_overlay(base, blend);
} else if (blendmode == BLEND_MODE_PHOENIX) {
return min(base,blend)-max(base,blend)+vec3(1.0);
} else if (blendmode == BLEND_MODE_PINLIGHT) {
return vec3(blend_pin_light(base.r,blend.r),blend_pin_light(base.g,blend.g),blend_pin_light(base.b,blend.b));
} else if (blendmode == BLEND_MODE_REFLECT) {
return blend_reflect(base, blend);
} else if (blendmode == BLEND_MODE_SCREEN) {
return vec3(blend_screen(base.r,blend.r),blend_screen(base.g,blend.g),blend_screen(base.b,blend.b));
} else if (blendmode == BLEND_MODE_SUBSTRACT) {
return max(base+blend-vec3(1.0),vec3(0.0));
} else if (blendmode == BLEND_MODE_SOFTLIGHT) {
return vec3(blend_soft_light(base.r,blend.r),blend_soft_light(base.g,blend.g),blend_soft_light(base.b,blend.b));
} else if (blendmode == BLEND_MODE_VIVIDLIGHT) {
return vec3(blend_vivid_light(base.r,blend.r),blend_vivid_light(base.g,blend.g),blend_vivid_light(base.b,blend.b));
} else {
return blend;
}
}
*/
void main(void) {
vec4 bg_color = texture2D(background, vTexCoord);
@@ -179,9 +16,6 @@ void main(void) {
// blend textures together
vec3 composite = blend(bg_color.rgb, fg_color.rgb);
// add foreground and background alpha's together
// float alpha_opac = fg_color.a*opacity;
if (blendmode == BLEND_MODE_OVERLAY
|| blendmode == BLEND_MODE_LIGHTEN
|| blendmode == BLEND_MODE_SCREEN
@@ -198,7 +32,6 @@ void main(void) {
}
vec4 full_composite = vec4(composite + bg_color.rgb*(1.0-fg_color.a), bg_color.a + fg_color.a);
// vec4 full_composite = vec4(mix(bg_color.rgb, composite, alpha_opac), bg_color.a + alpha_opac);
full_composite = mix(bg_color, full_composite, opacity);
+157 -177
View File
@@ -44,230 +44,210 @@
#include "ui/viewerwidget.h"
TransformEffect::TransformEffect(Clip* c, const EffectMeta* em) : Effect(c, em) {
enable_coords = true;
enable_coords = true;
EffectRow* position_row = add_row(tr("Position"));
position_x = position_row->add_field(EFFECT_FIELD_DOUBLE, "posx"); // position X
position_y = position_row->add_field(EFFECT_FIELD_DOUBLE, "posy"); // position Y
EffectRow* position_row = add_row(tr("Position"));
position_x = position_row->add_field(EFFECT_FIELD_DOUBLE, "posx"); // position X
position_y = position_row->add_field(EFFECT_FIELD_DOUBLE, "posy"); // position Y
EffectRow* scale_row = add_row(tr("Scale"));
scale_x = scale_row->add_field(EFFECT_FIELD_DOUBLE, "scalex"); // scale X (and Y is uniform scale is selected)
scale_x->set_double_minimum_value(0);
scale_x->set_double_maximum_value(3000);
scale_y = scale_row->add_field(EFFECT_FIELD_DOUBLE, "scaley"); // scale Y (disabled if uniform scale is selected)
scale_y->set_double_minimum_value(0);
scale_y->set_double_maximum_value(3000);
EffectRow* scale_row = add_row(tr("Scale"));
scale_x = scale_row->add_field(EFFECT_FIELD_DOUBLE, "scalex"); // scale X (and Y is uniform scale is selected)
scale_x->set_double_minimum_value(0);
scale_x->set_double_maximum_value(3000);
scale_y = scale_row->add_field(EFFECT_FIELD_DOUBLE, "scaley"); // scale Y (disabled if uniform scale is selected)
scale_y->set_double_minimum_value(0);
scale_y->set_double_maximum_value(3000);
EffectRow* uniform_scale_row = add_row(tr("Uniform Scale"));
uniform_scale_field = uniform_scale_row->add_field(EFFECT_FIELD_BOOL, "uniformscale"); // uniform scale option
EffectRow* uniform_scale_row = add_row(tr("Uniform Scale"));
uniform_scale_field = uniform_scale_row->add_field(EFFECT_FIELD_BOOL, "uniformscale"); // uniform scale option
EffectRow* rotation_row = add_row(tr("Rotation"));
rotation = rotation_row->add_field(EFFECT_FIELD_DOUBLE, "rotation");
EffectRow* rotation_row = add_row(tr("Rotation"));
rotation = rotation_row->add_field(EFFECT_FIELD_DOUBLE, "rotation");
EffectRow* anchor_point_row = add_row(tr("Anchor Point"));
anchor_x_box = anchor_point_row->add_field(EFFECT_FIELD_DOUBLE, "anchorx"); // anchor point X
anchor_y_box = anchor_point_row->add_field(EFFECT_FIELD_DOUBLE, "anchory"); // anchor point Y
EffectRow* anchor_point_row = add_row(tr("Anchor Point"));
anchor_x_box = anchor_point_row->add_field(EFFECT_FIELD_DOUBLE, "anchorx"); // anchor point X
anchor_y_box = anchor_point_row->add_field(EFFECT_FIELD_DOUBLE, "anchory"); // anchor point Y
EffectRow* opacity_row = add_row(tr("Opacity"));
opacity = opacity_row->add_field(EFFECT_FIELD_DOUBLE, "opacity"); // opacity
opacity->set_double_minimum_value(0);
opacity->set_double_maximum_value(100);
EffectRow* opacity_row = add_row(tr("Opacity"));
opacity = opacity_row->add_field(EFFECT_FIELD_DOUBLE, "opacity"); // opacity
opacity->set_double_minimum_value(0);
opacity->set_double_maximum_value(100);
EffectRow* blend_mode_row = add_row(tr("Blend Mode"));
blend_mode_box = blend_mode_row->add_field(EFFECT_FIELD_COMBO, "blendmode", 2); // blend mode
blend_mode_box->add_combo_item(tr("Normal"), BLEND_MODE_NORMAL);
blend_mode_box->add_combo_item(tr("Darken"), BLEND_MODE_DARKEN);
blend_mode_box->add_combo_item(tr("Multiply"), BLEND_MODE_MULTIPLY);
blend_mode_box->add_combo_item(tr("Color Burn"), BLEND_MODE_COLORBURN);
blend_mode_box->add_combo_item(tr("Linear Burn"), BLEND_MODE_LINEARBURN);
blend_mode_box->add_combo_item(tr("Lighten"), BLEND_MODE_LIGHTEN);
blend_mode_box->add_combo_item(tr("Screen"), BLEND_MODE_SCREEN);
blend_mode_box->add_combo_item(tr("Color Dodge"), BLEND_MODE_COLORDODGE);
blend_mode_box->add_combo_item(tr("Linear Dodge (Add)"), BLEND_MODE_LINEARDODGE);
blend_mode_box->add_combo_item(tr("Overlay"), BLEND_MODE_OVERLAY);
blend_mode_box->add_combo_item(tr("Soft Light"), BLEND_MODE_SOFTLIGHT);
blend_mode_box->add_combo_item(tr("Hard Light"), BLEND_MODE_HARDLIGHT);
blend_mode_box->add_combo_item(tr("Vivid Light"), BLEND_MODE_VIVIDLIGHT);
blend_mode_box->add_combo_item(tr("Linear Light"), BLEND_MODE_LINEARLIGHT);
blend_mode_box->add_combo_item(tr("Pin Light"), BLEND_MODE_PINLIGHT);
blend_mode_box->add_combo_item(tr("Hard Mix"), BLEND_MODE_HARDMIX);
blend_mode_box->add_combo_item(tr("Difference"), BLEND_MODE_DIFFERENCE);
blend_mode_box->add_combo_item(tr("Exclusion"), BLEND_MODE_EXCLUSION);
blend_mode_box->add_combo_item(tr("Reflect"), BLEND_MODE_REFLECT);
// blend_mode_box->add_combo_item(tr("Subtract"), BLEND_MODE_SUBTRACT);
blend_mode_box->add_combo_item(tr("Substract"), BLEND_MODE_SUBSTRACT);
// blend_mode_box->add_combo_item(tr("Add"), BLEND_MODE_ADD);
blend_mode_box->add_combo_item(tr("Average"), BLEND_MODE_AVERAGE);
blend_mode_box->add_combo_item(tr("Glow"), BLEND_MODE_GLOW);
blend_mode_box->add_combo_item(tr("Negation"), BLEND_MODE_NEGATION);
blend_mode_box->add_combo_item(tr("Phoenix"), BLEND_MODE_PHOENIX);
EffectRow* blend_mode_row = add_row(tr("Blend Mode"));
blend_mode_box = blend_mode_row->add_field(EFFECT_FIELD_COMBO, "blendmode", 2); // blend mode
blend_mode_box->add_combo_item(tr("Normal"), -1);
// set up gizmos
top_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
top_left_gizmo->set_cursor(Qt::SizeFDiagCursor);
top_left_gizmo->x_field1 = scale_x;
// add loaded blending modes
for (int i=0;i<olive::blend_modes.size();i++) {
blend_mode_box->add_combo_item(olive::blend_modes.at(i).name, i);
}
top_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
top_center_gizmo->set_cursor(Qt::SizeVerCursor);
top_center_gizmo->y_field1 = scale_x;
// set up gizmos
top_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
top_left_gizmo->set_cursor(Qt::SizeFDiagCursor);
top_left_gizmo->x_field1 = scale_x;
top_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
top_right_gizmo->set_cursor(Qt::SizeBDiagCursor);
top_right_gizmo->x_field1 = scale_x;
top_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
top_center_gizmo->set_cursor(Qt::SizeVerCursor);
top_center_gizmo->y_field1 = scale_x;
bottom_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
bottom_left_gizmo->set_cursor(Qt::SizeBDiagCursor);
bottom_left_gizmo->x_field1 = scale_x;
top_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
top_right_gizmo->set_cursor(Qt::SizeBDiagCursor);
top_right_gizmo->x_field1 = scale_x;
bottom_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
bottom_center_gizmo->set_cursor(Qt::SizeVerCursor);
bottom_center_gizmo->y_field1 = scale_x;
bottom_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
bottom_left_gizmo->set_cursor(Qt::SizeBDiagCursor);
bottom_left_gizmo->x_field1 = scale_x;
bottom_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
bottom_right_gizmo->set_cursor(Qt::SizeFDiagCursor);
bottom_right_gizmo->x_field1 = scale_x;
bottom_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
bottom_center_gizmo->set_cursor(Qt::SizeVerCursor);
bottom_center_gizmo->y_field1 = scale_x;
left_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
left_center_gizmo->set_cursor(Qt::SizeHorCursor);
left_center_gizmo->x_field1 = scale_x;
bottom_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
bottom_right_gizmo->set_cursor(Qt::SizeFDiagCursor);
bottom_right_gizmo->x_field1 = scale_x;
right_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
right_center_gizmo->set_cursor(Qt::SizeHorCursor);
right_center_gizmo->x_field1 = scale_x;
left_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
left_center_gizmo->set_cursor(Qt::SizeHorCursor);
left_center_gizmo->x_field1 = scale_x;
anchor_gizmo = add_gizmo(GIZMO_TYPE_TARGET);
anchor_gizmo->set_cursor(Qt::SizeAllCursor);
anchor_gizmo->x_field1 = anchor_x_box;
anchor_gizmo->y_field1 = anchor_y_box;
anchor_gizmo->x_field2 = position_x;
anchor_gizmo->y_field2 = position_y;
right_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
right_center_gizmo->set_cursor(Qt::SizeHorCursor);
right_center_gizmo->x_field1 = scale_x;
rotate_gizmo = add_gizmo(GIZMO_TYPE_DOT);
rotate_gizmo->color = Qt::green;
rotate_gizmo->set_cursor(Qt::SizeAllCursor);
rotate_gizmo->x_field1 = rotation;
anchor_gizmo = add_gizmo(GIZMO_TYPE_TARGET);
anchor_gizmo->set_cursor(Qt::SizeAllCursor);
anchor_gizmo->x_field1 = anchor_x_box;
anchor_gizmo->y_field1 = anchor_y_box;
anchor_gizmo->x_field2 = position_x;
anchor_gizmo->y_field2 = position_y;
rect_gizmo = add_gizmo(GIZMO_TYPE_POLY);
rect_gizmo->x_field1 = position_x;
rect_gizmo->y_field1 = position_y;
rotate_gizmo = add_gizmo(GIZMO_TYPE_DOT);
rotate_gizmo->color = Qt::green;
rotate_gizmo->set_cursor(Qt::SizeAllCursor);
rotate_gizmo->x_field1 = rotation;
connect(uniform_scale_field, SIGNAL(toggled(bool)), this, SLOT(toggle_uniform_scale(bool)));
rect_gizmo = add_gizmo(GIZMO_TYPE_POLY);
rect_gizmo->x_field1 = position_x;
rect_gizmo->y_field1 = position_y;
// set defaults
uniform_scale_field->set_bool_value(true);
blend_mode_box->set_combo_index(0);
set = false;
refresh();
connect(uniform_scale_field, SIGNAL(toggled(bool)), this, SLOT(toggle_uniform_scale(bool)));
// set defaults
uniform_scale_field->set_bool_value(true);
blend_mode_box->set_combo_index(0);
set = false;
refresh();
}
void adjust_field(EffectField* field, double old_offset, double new_offset) {
if (field->keyframes.size() > 0) {
for (int i=0;i<field->keyframes.size();i++) {
field->keyframes[i].data = field->keyframes.at(i).data.toDouble() - old_offset + new_offset;
}
} else {
field->set_current_data(field->get_current_data().toDouble() - old_offset + new_offset);
}
if (field->keyframes.size() > 0) {
for (int i=0;i<field->keyframes.size();i++) {
field->keyframes[i].data = field->keyframes.at(i).data.toDouble() - old_offset + new_offset;
}
} else {
field->set_current_data(field->get_current_data().toDouble() - old_offset + new_offset);
}
}
void TransformEffect::refresh() {
if (parent_clip != nullptr && parent_clip->sequence != nullptr) {
double new_default_pos_x = parent_clip->sequence->width/2;
double new_default_pos_y = parent_clip->sequence->height/2;
if (parent_clip != nullptr && parent_clip->sequence != nullptr) {
double new_default_pos_x = parent_clip->sequence->width/2;
double new_default_pos_y = parent_clip->sequence->height/2;
/*if (set) {
adjust_field(position_x, default_pos_x, new_default_pos_x);
adjust_field(position_y, default_pos_y, new_default_pos_y);
}*/
/*if (set) {
adjust_field(position_x, default_pos_x, new_default_pos_x);
adjust_field(position_y, default_pos_y, new_default_pos_y);
}*/
double default_pos_x = new_default_pos_x;
double default_pos_y = new_default_pos_y;
double default_pos_x = new_default_pos_x;
double default_pos_y = new_default_pos_y;
position_x->set_double_default_value(default_pos_x);
position_y->set_double_default_value(default_pos_y);
scale_x->set_double_default_value(100);
scale_y->set_double_default_value(100);
position_x->set_double_default_value(default_pos_x);
position_y->set_double_default_value(default_pos_y);
scale_x->set_double_default_value(100);
scale_y->set_double_default_value(100);
anchor_x_box->set_double_default_value(0);
anchor_y_box->set_double_default_value(0);
opacity->set_double_default_value(100);
anchor_x_box->set_double_default_value(0);
anchor_y_box->set_double_default_value(0);
opacity->set_double_default_value(100);
double x_percent_multipler = 200.0 / parent_clip->sequence->width;
double y_percent_multipler = 200.0 / parent_clip->sequence->height;
top_left_gizmo->x_field_multi1 = -x_percent_multipler;
top_left_gizmo->y_field_multi1 = -y_percent_multipler;
top_center_gizmo->y_field_multi1 = -y_percent_multipler;
top_right_gizmo->x_field_multi1 = x_percent_multipler;
top_right_gizmo->y_field_multi1 = -y_percent_multipler;
bottom_left_gizmo->x_field_multi1 = -x_percent_multipler;
bottom_left_gizmo->y_field_multi1 = y_percent_multipler;
bottom_center_gizmo->y_field_multi1 = y_percent_multipler;
bottom_right_gizmo->x_field_multi1 = x_percent_multipler;
bottom_right_gizmo->y_field_multi1 = y_percent_multipler;
left_center_gizmo->x_field_multi1 = -x_percent_multipler;
right_center_gizmo->x_field_multi1 = x_percent_multipler;
rotate_gizmo->x_field_multi1 = x_percent_multipler;
double x_percent_multipler = 200.0 / parent_clip->sequence->width;
double y_percent_multipler = 200.0 / parent_clip->sequence->height;
top_left_gizmo->x_field_multi1 = -x_percent_multipler;
top_left_gizmo->y_field_multi1 = -y_percent_multipler;
top_center_gizmo->y_field_multi1 = -y_percent_multipler;
top_right_gizmo->x_field_multi1 = x_percent_multipler;
top_right_gizmo->y_field_multi1 = -y_percent_multipler;
bottom_left_gizmo->x_field_multi1 = -x_percent_multipler;
bottom_left_gizmo->y_field_multi1 = y_percent_multipler;
bottom_center_gizmo->y_field_multi1 = y_percent_multipler;
bottom_right_gizmo->x_field_multi1 = x_percent_multipler;
bottom_right_gizmo->y_field_multi1 = y_percent_multipler;
left_center_gizmo->x_field_multi1 = -x_percent_multipler;
right_center_gizmo->x_field_multi1 = x_percent_multipler;
rotate_gizmo->x_field_multi1 = x_percent_multipler;
set = true;
}
set = true;
}
}
void TransformEffect::toggle_uniform_scale(bool enabled) {
scale_y->set_enabled(!enabled);
scale_y->set_enabled(!enabled);
top_center_gizmo->y_field1 = enabled ? scale_x : scale_y;
bottom_center_gizmo->y_field1 = enabled ? scale_x : scale_y;
top_left_gizmo->y_field1 = enabled ? nullptr : scale_y;
top_right_gizmo->y_field1 = enabled ? nullptr : scale_y;
bottom_left_gizmo->y_field1 = enabled ? nullptr : scale_y;
bottom_right_gizmo->y_field1 = enabled ? nullptr : scale_y;
top_center_gizmo->y_field1 = enabled ? scale_x : scale_y;
bottom_center_gizmo->y_field1 = enabled ? scale_x : scale_y;
top_left_gizmo->y_field1 = enabled ? nullptr : scale_y;
top_right_gizmo->y_field1 = enabled ? nullptr : scale_y;
bottom_left_gizmo->y_field1 = enabled ? nullptr : scale_y;
bottom_right_gizmo->y_field1 = enabled ? nullptr : scale_y;
}
void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, int) {
// position
glTranslated(position_x->get_double_value(timecode)-(parent_clip->sequence->width/2), position_y->get_double_value(timecode)-(parent_clip->sequence->height/2), 0);
// position
glTranslated(position_x->get_double_value(timecode)-(parent_clip->sequence->width/2), position_y->get_double_value(timecode)-(parent_clip->sequence->height/2), 0);
// anchor point
int anchor_x_offset = qRound(anchor_x_box->get_double_value(timecode));
int anchor_y_offset = qRound(anchor_y_box->get_double_value(timecode));
coords.vertexTopLeftX -= anchor_x_offset;
coords.vertexTopRightX -= anchor_x_offset;
coords.vertexBottomLeftX -= anchor_x_offset;
coords.vertexBottomRightX -= anchor_x_offset;
coords.vertexTopLeftY -= anchor_y_offset;
coords.vertexTopRightY -= anchor_y_offset;
coords.vertexBottomLeftY -= anchor_y_offset;
coords.vertexBottomRightY -= anchor_y_offset;
// anchor point
int anchor_x_offset = qRound(anchor_x_box->get_double_value(timecode));
int anchor_y_offset = qRound(anchor_y_box->get_double_value(timecode));
coords.vertexTopLeftX -= anchor_x_offset;
coords.vertexTopRightX -= anchor_x_offset;
coords.vertexBottomLeftX -= anchor_x_offset;
coords.vertexBottomRightX -= anchor_x_offset;
coords.vertexTopLeftY -= anchor_y_offset;
coords.vertexTopRightY -= anchor_y_offset;
coords.vertexBottomLeftY -= anchor_y_offset;
coords.vertexBottomRightY -= anchor_y_offset;
// rotation
glRotated(rotation->get_double_value(timecode), 0, 0, 1);
// rotation
glRotated(rotation->get_double_value(timecode), 0, 0, 1);
// scale
double sx = scale_x->get_double_value(timecode)*0.01;
double sy = (uniform_scale_field->get_bool_value(timecode)) ? sx : scale_y->get_double_value(timecode)*0.01;
glScaled(sx, sy, 1);
// scale
double sx = scale_x->get_double_value(timecode)*0.01;
double sy = (uniform_scale_field->get_bool_value(timecode)) ? sx : scale_y->get_double_value(timecode)*0.01;
glScaled(sx, sy, 1);
// blend mode
coords.blendmode = blend_mode_box->get_combo_data(timecode).toInt();
// blend mode
coords.blendmode = blend_mode_box->get_combo_data(timecode).toInt();
// opacity
coords.opacity *= float(opacity->get_double_value(timecode)*0.01);
// opacity
coords.opacity *= float(opacity->get_double_value(timecode)*0.01);
}
void TransformEffect::gizmo_draw(double, GLTextureCoords& coords) {
top_left_gizmo->world_pos[0] = QPoint(coords.vertexTopLeftX, coords.vertexTopLeftY);
top_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexTopLeftX, coords.vertexTopRightX, 0.5), lerp(coords.vertexTopLeftY, coords.vertexTopRightY, 0.5));
top_right_gizmo->world_pos[0] = QPoint(coords.vertexTopRightX, coords.vertexTopRightY);
right_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexTopRightX, coords.vertexBottomRightX, 0.5), lerp(coords.vertexTopRightY, coords.vertexBottomRightY, 0.5));
bottom_right_gizmo->world_pos[0] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY);
bottom_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexBottomRightX, coords.vertexBottomLeftX, 0.5), lerp(coords.vertexBottomRightY, coords.vertexBottomLeftY, 0.5));
bottom_left_gizmo->world_pos[0] = QPoint(coords.vertexBottomLeftX, coords.vertexBottomLeftY);
left_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexBottomLeftX, coords.vertexTopLeftX, 0.5), lerp(coords.vertexBottomLeftY, coords.vertexTopLeftY, 0.5));
top_left_gizmo->world_pos[0] = QPoint(coords.vertexTopLeftX, coords.vertexTopLeftY);
top_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexTopLeftX, coords.vertexTopRightX, 0.5), lerp(coords.vertexTopLeftY, coords.vertexTopRightY, 0.5));
top_right_gizmo->world_pos[0] = QPoint(coords.vertexTopRightX, coords.vertexTopRightY);
right_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexTopRightX, coords.vertexBottomRightX, 0.5), lerp(coords.vertexTopRightY, coords.vertexBottomRightY, 0.5));
bottom_right_gizmo->world_pos[0] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY);
bottom_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexBottomRightX, coords.vertexBottomLeftX, 0.5), lerp(coords.vertexBottomRightY, coords.vertexBottomLeftY, 0.5));
bottom_left_gizmo->world_pos[0] = QPoint(coords.vertexBottomLeftX, coords.vertexBottomLeftY);
left_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexBottomLeftX, coords.vertexTopLeftX, 0.5), lerp(coords.vertexBottomLeftY, coords.vertexTopLeftY, 0.5));
rotate_gizmo->world_pos[0] = QPoint(lerp(top_center_gizmo->world_pos[0].x(), bottom_center_gizmo->world_pos[0].x(), -0.1), lerp(top_center_gizmo->world_pos[0].y(), bottom_center_gizmo->world_pos[0].y(), -0.1));
rotate_gizmo->world_pos[0] = QPoint(lerp(top_center_gizmo->world_pos[0].x(), bottom_center_gizmo->world_pos[0].x(), -0.1), lerp(top_center_gizmo->world_pos[0].y(), bottom_center_gizmo->world_pos[0].y(), -0.1));
rect_gizmo->world_pos[0] = QPoint(coords.vertexTopLeftX, coords.vertexTopLeftY);
rect_gizmo->world_pos[1] = QPoint(coords.vertexTopRightX, coords.vertexTopRightY);
rect_gizmo->world_pos[2] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY);
rect_gizmo->world_pos[3] = QPoint(coords.vertexBottomLeftX, coords.vertexBottomLeftY);
rect_gizmo->world_pos[0] = QPoint(coords.vertexTopLeftX, coords.vertexTopLeftY);
rect_gizmo->world_pos[1] = QPoint(coords.vertexTopRightX, coords.vertexTopRightY);
rect_gizmo->world_pos[2] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY);
rect_gizmo->world_pos[3] = QPoint(coords.vertexBottomLeftX, coords.vertexBottomLeftY);
}
+9
View File
@@ -0,0 +1,9 @@
vec3 blendMultiply(vec3 base, vec3 blend) {
return base*blend;
}
vec3 blendMultiply(vec3 base, vec3 blend, float opacity) {
return (blendMultiply(base, blend) * opacity + base * (1.0 - opacity));
}
#pragma glslify: export(blendMultiply)
+1 -2
View File
@@ -285,6 +285,5 @@ void Config::save(QString path) {
}
RuntimeConfig::RuntimeConfig() :
shaders_are_enabled(true),
disable_blending(false)
shaders_are_enabled(true)
{}
-8
View File
@@ -561,14 +561,6 @@ struct RuntimeConfig {
*/
bool shaders_are_enabled;
/**
* @brief Disable blending modes
*
* Some users had difficulty utilizing blending modes (provided by shaders). Set this to **TRUE** to bypass
* shader-based blending modes and utilize standard (less versatile) OpenGL blending instead.
*/
bool disable_blending;
/**
* @brief Load an external translation file
*
+1 -4
View File
@@ -34,7 +34,7 @@ extern "C" {
#include <libavfilter/avfilter.h>
}
int main(int argc, char *argv[]) {
int main(int argc, char *argv[]) {
olive::Global = std::unique_ptr<OliveGlobal>(new OliveGlobal);
bool launch_fullscreen = false;
@@ -60,7 +60,6 @@ int main(int argc, char *argv[]) {
"\t-f, --fullscreen\tStart in full screen mode\n"
"\t--disable-shaders\tDisable OpenGL shaders (for debugging)\n"
"\t--no-debug\t\tDisable internal debug log and output directly to console\n"
"\t--disable-blend-modes\tDisable shader-based blending for older GPUs\n"
"\t--translation <file>\tSet an external language file to use\n"
"\n"
"Environment Variables:\n"
@@ -75,8 +74,6 @@ int main(int argc, char *argv[]) {
olive::CurrentRuntimeConfig.shaders_are_enabled = false;
} else if (!strcmp(argv[i], "--no-debug")) {
use_internal_logger = false;
} else if (!strcmp(argv[i], "--disable-blend-modes")) {
olive::CurrentRuntimeConfig.disable_blending = true;
} else if (!strcmp(argv[i], "--translation")) {
if (i + 1 < argc && argv[i + 1][0] != '-') {
// load translation file
+2 -2
View File
@@ -199,8 +199,8 @@ void EffectControls::show_effect_menu(int type, int subtype) {
QMenu effects_menu(this);
effects_menu.setToolTipsVisible(true);
for (int i=0;i<effects.size();i++) {
const EffectMeta& em = effects.at(i);
for (int i=0;i<olive::effects.size();i++) {
const EffectMeta& em = olive::effects.at(i);
if (em.type == type && em.subtype == subtype) {
QAction* action = new QAction(&effects_menu);
+4 -4
View File
@@ -1792,8 +1792,8 @@ void Timeline::transition_tool_click() {
QMenu transition_menu(this);
for (int i=0;i<effects.size();i++) {
const EffectMeta& em = effects.at(i);
for (int i=0;i<olive::effects.size();i++) {
const EffectMeta& em = olive::effects.at(i);
if (em.type == EFFECT_TYPE_TRANSITION && em.subtype == EFFECT_TYPE_VIDEO) {
QAction* a = transition_menu.addAction(em.name);
a->setObjectName("v");
@@ -1803,8 +1803,8 @@ void Timeline::transition_tool_click() {
transition_menu.addSeparator();
for (int i=0;i<effects.size();i++) {
const EffectMeta& em = effects.at(i);
for (int i=0;i<olive::effects.size();i++) {
const EffectMeta& em = olive::effects.at(i);
if (em.type == EFFECT_TYPE_TRANSITION && em.subtype == EFFECT_TYPE_AUDIO) {
QAction* a = transition_menu.addAction(em.name);
a->setObjectName("a");
+768 -767
View File
File diff suppressed because it is too large Load Diff
+10 -31
View File
@@ -58,7 +58,16 @@ struct EffectMeta {
int type;
int subtype;
};
extern QVector<EffectMeta> effects;
struct BlendMode {
QString name;
QString url;
};
namespace olive {
extern QVector<EffectMeta> effects;
extern QVector<BlendMode> blend_modes;
}
double log_volume(double linear);
@@ -94,36 +103,6 @@ enum EffectInternal {
EFFECT_INTERNAL_COUNT
};
enum EffectBlendMode {
BLEND_MODE_ADD,
BLEND_MODE_AVERAGE,
BLEND_MODE_COLORBURN,
BLEND_MODE_COLORDODGE,
BLEND_MODE_DARKEN,
BLEND_MODE_DIFFERENCE,
BLEND_MODE_EXCLUSION,
BLEND_MODE_GLOW,
BLEND_MODE_HARDLIGHT,
BLEND_MODE_HARDMIX,
BLEND_MODE_LIGHTEN,
BLEND_MODE_LINEARBURN,
BLEND_MODE_LINEARDODGE,
BLEND_MODE_LINEARLIGHT,
BLEND_MODE_MULTIPLY,
BLEND_MODE_NEGATION,
BLEND_MODE_NORMAL,
BLEND_MODE_OVERLAY,
BLEND_MODE_PHOENIX,
BLEND_MODE_PINLIGHT,
BLEND_MODE_REFLECT,
BLEND_MODE_SCREEN,
BLEND_MODE_SOFTLIGHT,
BLEND_MODE_SUBSTRACT,
BLEND_MODE_SUBTRACT,
BLEND_MODE_VIVIDLIGHT,
BLEND_MODE_COUNT
};
struct GLTextureCoords {
int grid_size;
+167 -167
View File
@@ -39,233 +39,233 @@ typedef void (*f0rGetPluginInfo)(f0r_plugin_info_t* info);
#endif
void load_internal_effects() {
if (!olive::CurrentRuntimeConfig.shaders_are_enabled) qWarning() << "Shaders are disabled, some effects may be nonfunctional";
if (!olive::CurrentRuntimeConfig.shaders_are_enabled) qWarning() << "Shaders are disabled, some effects may be nonfunctional";
EffectMeta em;
EffectMeta em;
// load internal effects
em.path = ":/internalshaders";
// load internal effects
em.path = ":/internalshaders";
em.type = EFFECT_TYPE_EFFECT;
em.subtype = EFFECT_TYPE_AUDIO;
em.type = EFFECT_TYPE_EFFECT;
em.subtype = EFFECT_TYPE_AUDIO;
em.name = "Volume";
em.internal = EFFECT_INTERNAL_VOLUME;
effects.append(em);
em.name = "Volume";
em.internal = EFFECT_INTERNAL_VOLUME;
olive::effects.append(em);
em.name = "Pan";
em.internal = EFFECT_INTERNAL_PAN;
effects.append(em);
em.name = "Pan";
em.internal = EFFECT_INTERNAL_PAN;
olive::effects.append(em);
#ifndef NOVST
em.name = "VST Plugin 2.x";
em.internal = EFFECT_INTERNAL_VST;
effects.append(em);
em.name = "VST Plugin 2.x";
em.internal = EFFECT_INTERNAL_VST;
olive::effects.append(em);
#endif
em.name = "Tone";
em.internal = EFFECT_INTERNAL_TONE;
effects.append(em);
em.name = "Tone";
em.internal = EFFECT_INTERNAL_TONE;
olive::effects.append(em);
em.name = "Noise";
em.internal = EFFECT_INTERNAL_NOISE;
effects.append(em);
em.name = "Noise";
em.internal = EFFECT_INTERNAL_NOISE;
olive::effects.append(em);
em.name = "Fill Left/Right";
em.internal = EFFECT_INTERNAL_FILLLEFTRIGHT;
effects.append(em);
em.name = "Fill Left/Right";
em.internal = EFFECT_INTERNAL_FILLLEFTRIGHT;
olive::effects.append(em);
em.subtype = EFFECT_TYPE_VIDEO;
em.subtype = EFFECT_TYPE_VIDEO;
em.name = "Transform";
em.category = "Distort";
em.internal = EFFECT_INTERNAL_TRANSFORM;
effects.append(em);
em.name = "Transform";
em.category = "Distort";
em.internal = EFFECT_INTERNAL_TRANSFORM;
olive::effects.append(em);
em.name = "Corner Pin";
em.internal = EFFECT_INTERNAL_CORNERPIN;
effects.append(em);
em.name = "Corner Pin";
em.internal = EFFECT_INTERNAL_CORNERPIN;
olive::effects.append(em);
/*em.name = "Mask";
em.internal = EFFECT_INTERNAL_MASK;
effects.append(em);*/
/*em.name = "Mask";
em.internal = EFFECT_INTERNAL_MASK;
olive::effects.append(em);*/
em.name = "Shake";
em.internal = EFFECT_INTERNAL_SHAKE;
effects.append(em);
em.name = "Shake";
em.internal = EFFECT_INTERNAL_SHAKE;
olive::effects.append(em);
em.name = "Text";
em.category = "Render";
em.internal = EFFECT_INTERNAL_TEXT;
effects.append(em);
em.name = "Text";
em.category = "Render";
em.internal = EFFECT_INTERNAL_TEXT;
olive::effects.append(em);
em.name = "Timecode";
em.internal = EFFECT_INTERNAL_TIMECODE;
effects.append(em);
em.name = "Timecode";
em.internal = EFFECT_INTERNAL_TIMECODE;
olive::effects.append(em);
em.name = "Solid";
em.internal = EFFECT_INTERNAL_SOLID;
effects.append(em);
em.name = "Solid";
em.internal = EFFECT_INTERNAL_SOLID;
olive::effects.append(em);
// internal transitions
em.type = EFFECT_TYPE_TRANSITION;
em.category = "";
// internal transitions
em.type = EFFECT_TYPE_TRANSITION;
em.category = "";
em.name = "Cross Dissolve";
em.internal = TRANSITION_INTERNAL_CROSSDISSOLVE;
effects.append(em);
em.name = "Cross Dissolve";
em.internal = TRANSITION_INTERNAL_CROSSDISSOLVE;
olive::effects.append(em);
em.subtype = EFFECT_TYPE_AUDIO;
em.subtype = EFFECT_TYPE_AUDIO;
em.name = "Linear Fade";
em.internal = TRANSITION_INTERNAL_LINEARFADE;
effects.append(em);
em.name = "Linear Fade";
em.internal = TRANSITION_INTERNAL_LINEARFADE;
olive::effects.append(em);
em.name = "Exponential Fade";
em.internal = TRANSITION_INTERNAL_EXPONENTIALFADE;
effects.append(em);
em.name = "Exponential Fade";
em.internal = TRANSITION_INTERNAL_EXPONENTIALFADE;
olive::effects.append(em);
em.name = "Logarithmic Fade";
em.internal = TRANSITION_INTERNAL_LOGARITHMICFADE;
effects.append(em);
em.name = "Logarithmic Fade";
em.internal = TRANSITION_INTERNAL_LOGARITHMICFADE;
olive::effects.append(em);
}
void load_shader_effects() {
QList<QString> effects_paths = get_effects_paths();
QList<QString> effects_paths = get_effects_paths();
for (int h=0;h<effects_paths.size();h++) {
const QString& effects_path = effects_paths.at(h);
QDir effects_dir(effects_path);
if (effects_dir.exists()) {
QList<QString> entries = effects_dir.entryList(QStringList("*.xml"), QDir::Files);
for (int i=0;i<entries.size();i++) {
QFile file(effects_path + "/" + entries.at(i));
if (!file.open(QIODevice::ReadOnly)) {
qCritical() << "Could not open" << entries.at(i);
return;
}
for (int h=0;h<effects_paths.size();h++) {
const QString& effects_path = effects_paths.at(h);
QDir effects_dir(effects_path);
if (effects_dir.exists()) {
QList<QString> entries = effects_dir.entryList(QStringList("*.xml"), QDir::Files);
for (int i=0;i<entries.size();i++) {
QFile file(effects_path + "/" + entries.at(i));
if (!file.open(QIODevice::ReadOnly)) {
qCritical() << "Could not open" << entries.at(i);
return;
}
QXmlStreamReader reader(&file);
while (!reader.atEnd()) {
if (reader.name() == "effect") {
QString effect_name = "";
QString effect_cat = "";
const QXmlStreamAttributes attr = reader.attributes();
for (int j=0;j<attr.size();j++) {
if (attr.at(j).name() == "name") {
effect_name = attr.at(j).value().toString();
} else if (attr.at(j).name() == "category") {
effect_cat = attr.at(j).value().toString();
}
}
if (!effect_name.isEmpty()) {
EffectMeta em;
em.type = EFFECT_TYPE_EFFECT;
em.subtype = EFFECT_TYPE_VIDEO;
em.name = effect_name;
em.category = effect_cat;
em.filename = file.fileName();
em.path = effects_path;
em.internal = -1;
effects.append(em);
} else {
qCritical() << "Invalid effect found in" << entries.at(i);
}
break;
}
reader.readNext();
}
QXmlStreamReader reader(&file);
while (!reader.atEnd()) {
if (reader.name() == "effect") {
QString effect_name = "";
QString effect_cat = "";
const QXmlStreamAttributes attr = reader.attributes();
for (int j=0;j<attr.size();j++) {
if (attr.at(j).name() == "name") {
effect_name = attr.at(j).value().toString();
} else if (attr.at(j).name() == "category") {
effect_cat = attr.at(j).value().toString();
}
}
if (!effect_name.isEmpty()) {
EffectMeta em;
em.type = EFFECT_TYPE_EFFECT;
em.subtype = EFFECT_TYPE_VIDEO;
em.name = effect_name;
em.category = effect_cat;
em.filename = file.fileName();
em.path = effects_path;
em.internal = -1;
olive::effects.append(em);
} else {
qCritical() << "Invalid effect found in" << entries.at(i);
}
break;
}
reader.readNext();
}
file.close();
}
}
}
file.close();
}
}
}
}
void init_effects() {
EffectInit* init_thread = new EffectInit();
QObject::connect(init_thread, SIGNAL(finished()), init_thread, SLOT(deleteLater()));
init_thread->start();
EffectInit* init_thread = new EffectInit();
QObject::connect(init_thread, SIGNAL(finished()), init_thread, SLOT(deleteLater()));
init_thread->start();
}
#ifndef NOFREI0R
void load_frei0r_effects_worker(const QString& dir, EffectMeta& em, QVector<QString>& loaded_names) {
QDir search_dir(dir);
if (search_dir.exists()) {
QList<QString> entry_list = search_dir.entryList(LibFilter(), QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
for (int j=0;j<entry_list.size();j++) {
QString entry_path = search_dir.filePath(entry_list.at(j));
if (QFileInfo(entry_path).isDir()) {
load_frei0r_effects_worker(entry_path, em, loaded_names);
} else {
ModulePtr effect = LibLoad(entry_path);
if (effect != nullptr) {
f0rGetPluginInfo get_info_func = reinterpret_cast<f0rGetPluginInfo>(LibAddress(effect, "f0r_get_plugin_info"));
if (get_info_func != nullptr) {
f0r_plugin_info_t info;
get_info_func(&info);
QDir search_dir(dir);
if (search_dir.exists()) {
QList<QString> entry_list = search_dir.entryList(LibFilter(), QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
for (int j=0;j<entry_list.size();j++) {
QString entry_path = search_dir.filePath(entry_list.at(j));
if (QFileInfo(entry_path).isDir()) {
load_frei0r_effects_worker(entry_path, em, loaded_names);
} else {
ModulePtr effect = LibLoad(entry_path);
if (effect != nullptr) {
f0rGetPluginInfo get_info_func = reinterpret_cast<f0rGetPluginInfo>(LibAddress(effect, "f0r_get_plugin_info"));
if (get_info_func != nullptr) {
f0r_plugin_info_t info;
get_info_func(&info);
if (!loaded_names.contains(info.name)
&& info.plugin_type == F0R_PLUGIN_TYPE_FILTER
&& info.color_model == F0R_COLOR_MODEL_RGBA8888) {
em.name = info.name;
em.path = dir;
em.filename = entry_list.at(j);
em.tooltip = QString("%1\n%2\n%3\n%4").arg(em.name, info.author, info.explanation, em.filename);
if (!loaded_names.contains(info.name)
&& info.plugin_type == F0R_PLUGIN_TYPE_FILTER
&& info.color_model == F0R_COLOR_MODEL_RGBA8888) {
em.name = info.name;
em.path = dir;
em.filename = entry_list.at(j);
em.tooltip = QString("%1\n%2\n%3\n%4").arg(em.name, info.author, info.explanation, em.filename);
loaded_names.append(em.name);
loaded_names.append(em.name);
effects.append(em);
}
olive::effects.append(em);
}
// qDebug() << "Found:" << info.name << "by" << info.author;
}
LibClose(effect);
}
}
LibClose(effect);
}
// qDebug() << search_dir.filePath(entry_list.at(j));
}
}
}
}
}
}
}
void load_frei0r_effects() {
QList<QString> effect_dirs = get_effects_paths();
QList<QString> effect_dirs = get_effects_paths();
// add defined paths for frei0r plugins on unix
// add defined paths for frei0r plugins on unix
#if defined(__APPLE__) || defined(__linux__) || defined(__HAIKU__)
effect_dirs.prepend("/usr/lib/frei0r-1");
effect_dirs.prepend("/usr/local/lib/frei0r-1");
effect_dirs.prepend(QDir::homePath() + "/.frei0r-1/lib");
effect_dirs.prepend("/usr/lib/frei0r-1");
effect_dirs.prepend("/usr/local/lib/frei0r-1");
effect_dirs.prepend(QDir::homePath() + "/.frei0r-1/lib");
#endif
QString env_path(qgetenv("FREI0R_PATH"));
if (!env_path.isEmpty()) effect_dirs.append(env_path);
QString env_path(qgetenv("FREI0R_PATH"));
if (!env_path.isEmpty()) effect_dirs.append(env_path);
QVector<QString> loaded_names;
QVector<QString> loaded_names;
// search for paths
EffectMeta em;
em.category = "Frei0r";
em.type = EFFECT_TYPE_EFFECT;
em.subtype = EFFECT_TYPE_VIDEO;
em.internal = EFFECT_INTERNAL_FREI0R;
// search for paths
EffectMeta em;
em.category = "Frei0r";
em.type = EFFECT_TYPE_EFFECT;
em.subtype = EFFECT_TYPE_VIDEO;
em.internal = EFFECT_INTERNAL_FREI0R;
for (int i=0;i<effect_dirs.size();i++) {
load_frei0r_effects_worker(effect_dirs.at(i), em, loaded_names);
}
for (int i=0;i<effect_dirs.size();i++) {
load_frei0r_effects_worker(effect_dirs.at(i), em, loaded_names);
}
}
#endif
EffectInit::EffectInit() {
panel_effect_controls->effects_loaded.lock();
panel_effect_controls->effects_loaded.lock();
}
void EffectInit::run() {
qInfo() << "Initializing effects...";
load_internal_effects();
load_shader_effects();
qInfo() << "Initializing effects...";
load_internal_effects();
load_shader_effects();
#ifndef NOFREI0R
load_frei0r_effects();
load_frei0r_effects();
#endif
panel_effect_controls->effects_loaded.unlock();
qInfo() << "Finished initializing effects";
panel_effect_controls->effects_loaded.unlock();
qInfo() << "Finished initializing effects";
}
+8 -5
View File
@@ -399,7 +399,7 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
coords.textureTopLeftY = coords.textureTopRightY = coords.textureTopLeftX = coords.textureBottomLeftX = 0.0;
coords.textureBottomLeftY = coords.textureBottomRightY = coords.textureTopRightX = coords.textureBottomRightX = 1.0;
coords.textureTopLeftQ = coords.textureTopRightQ = coords.textureTopLeftQ = coords.textureBottomLeftQ = 1;
coords.blendmode = BLEND_MODE_NORMAL;
coords.blendmode = -1;
coords.opacity = 1.0;
// if auto-scale is enabled, auto-scale the clip
@@ -514,8 +514,8 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
// copy front buffer to back buffer (only if we're using blending modes - which we usually will be)
if (!olive::CurrentRuntimeConfig.disable_blending) {
// copy front buffer to back buffer (only if we're using a blending mode)
if (coords.blendmode >= 0) {
if (params.nests.size() > 0) {
draw_clip(params.ctx, params.nests.last()->fbo[2]->handle(), params.nests.last()->fbo[0]->texture(), true);
} else {
@@ -533,8 +533,8 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
// bind front buffer as draw buffer
params.ctx->functions()->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, final_fbo);
if (olive::CurrentRuntimeConfig.disable_blending) {
// some GPUs don't like the blending shader, so we provide a pure GL fallback here
// Check if we're using a blend mode (< 0 means no blend mode)
if (coords.blendmode < 0) {
params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, backend_tex_1);
@@ -543,7 +543,9 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
full_blit();
params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, 0);
} else {
// load background texture into texture unit 0
params.ctx->functions()->glActiveTexture(GL_TEXTURE0 + 0); // Texture unit 0
params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, backend_tex_2);
@@ -572,6 +574,7 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
// unbind texture from texture unit 0
params.ctx->functions()->glActiveTexture(GL_TEXTURE0 + 0); // Texture unit 0
params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, 0);
}
// unbind framebuffer