diff --git a/effects/effect.cpp b/effects/effect.cpp index 0f8a6da14..b72c17351 100644 --- a/effects/effect.cpp +++ b/effects/effect.cpp @@ -20,6 +20,7 @@ #include "debug.h" #include "io/path.h" #include "mainwindow.h" +#include "io/math.h" #include "effects/internal/transformeffect.h" #include "effects/internal/texteffect.h" @@ -228,10 +229,6 @@ void EffectInit::run() { dout << "[INFO] Finished initializing effects"; } -double double_lerp(double a, double b, double t) { - return ((1.0 - t) * a) + (t * b); -} - Effect::Effect(Clip* c, const EffectMeta *em) : parent_clip(c), meta(em), diff --git a/effects/effect.h b/effects/effect.h index 0ff464bd6..5ac86f3fc 100644 --- a/effects/effect.h +++ b/effects/effect.h @@ -84,6 +84,8 @@ extern QMutex effects_loaded; #define TRAN_TYPE_CLOSEWLINK 4 struct GLTextureCoords { + int grid_size; + int vertexTopLeftX; int vertexTopLeftY; int vertexTopRightX; diff --git a/effects/internal/cornerpineffect.cpp b/effects/internal/cornerpineffect.cpp index c3c57c35e..36c282902 100644 --- a/effects/internal/cornerpineffect.cpp +++ b/effects/internal/cornerpineffect.cpp @@ -5,19 +5,27 @@ CornerPinEffect::CornerPinEffect(Clip *c, const EffectMeta *em) : Effect(c, em) EffectRow* top_left = add_row("Top Left:"); top_left_x = top_left->add_field(EFFECT_FIELD_DOUBLE); + top_left_x->id = "topleftx"; top_left_y = top_left->add_field(EFFECT_FIELD_DOUBLE); + top_left_y->id = "toplefty"; EffectRow* top_right = add_row("Top Right:"); top_right_x = top_right->add_field(EFFECT_FIELD_DOUBLE); + top_right_x->id = "toprightx"; top_right_y = top_right->add_field(EFFECT_FIELD_DOUBLE); + top_right_y->id = "toprighty"; EffectRow* bottom_left = add_row("Bottom Left:"); bottom_left_x = bottom_left->add_field(EFFECT_FIELD_DOUBLE); + bottom_left_x->id = "bottomleftx"; bottom_left_y = bottom_left->add_field(EFFECT_FIELD_DOUBLE); + bottom_left_y->id = "bottomlefty"; EffectRow* bottom_right = add_row("Bottom Right:"); bottom_right_x = bottom_right->add_field(EFFECT_FIELD_DOUBLE); + bottom_right_x->id = "bottomrightx"; bottom_right_y = bottom_right->add_field(EFFECT_FIELD_DOUBLE); + bottom_right_y->id = "bottomrighty"; connect(top_left_x, SIGNAL(changed()), this, SLOT(field_changed())); connect(top_left_y, SIGNAL(changed()), this, SLOT(field_changed())); @@ -30,6 +38,8 @@ CornerPinEffect::CornerPinEffect(Clip *c, const EffectMeta *em) : Effect(c, em) } void CornerPinEffect::process_coords(double timecode, GLTextureCoords &coords) { + coords.grid_size += 4; + coords.vertexTopLeftX += top_left_x->get_double_value(timecode); coords.vertexTopLeftY += top_left_y->get_double_value(timecode); diff --git a/io/math.cpp b/io/math.cpp new file mode 100644 index 000000000..714f6ad90 --- /dev/null +++ b/io/math.cpp @@ -0,0 +1,9 @@ +#include "math.h" + +int lerp(int a, int b, double t) { + return ((1.0 - t) * a) + (t * b); +} + +double double_lerp(double a, double b, double t) { + return ((1.0 - t) * a) + (t * b); +} diff --git a/io/math.h b/io/math.h new file mode 100644 index 000000000..68264cff7 --- /dev/null +++ b/io/math.h @@ -0,0 +1,7 @@ +#ifndef MATH_H +#define MATH_H + +int lerp(int a, int b, double t); +double double_lerp(double a, double b, double t); + +#endif // MATH_H diff --git a/olive.pro b/olive.pro index c548f9532..aa8deb58f 100644 --- a/olive.pro +++ b/olive.pro @@ -83,7 +83,8 @@ SOURCES += \ effects/internal/shakeeffect.cpp \ effects/internal/exponentialfadetransition.cpp \ effects/internal/logarithmicfadetransition.cpp \ - effects/internal/cornerpineffect.cpp + effects/internal/cornerpineffect.cpp \ + io/math.cpp HEADERS += \ mainwindow.h \ @@ -147,7 +148,8 @@ HEADERS += \ effects/internal/crossdissolvetransition.h \ effects/internal/exponentialfadetransition.h \ effects/internal/logarithmicfadetransition.h \ - effects/internal/cornerpineffect.h + effects/internal/cornerpineffect.h \ + io/math.h FORMS += \ mainwindow.ui \ diff --git a/panels/timeline.cpp b/panels/timeline.cpp index a4471f064..f19414912 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -352,10 +352,6 @@ void Timeline::delete_selection(QVector& selections, bool ripple_dele } } -int lerp(int a, int b, double t) { - return ((1.0 - t) * a) + (t * b); -} - void Timeline::set_zoom_value(double v) { zoom = v; ui->headers->update_zoom(zoom); diff --git a/panels/timeline.h b/panels/timeline.h index 3528c3e0e..8af2cab63 100644 --- a/panels/timeline.h +++ b/panels/timeline.h @@ -28,7 +28,6 @@ struct Clip; struct Media; struct MediaStream; -int lerp(int a, int b, double t); long refactor_frame_number(long framenumber, double source_frame_rate, double target_frame_rate); int getScreenPointFromFrame(double zoom, long frame); long getFrameFromScreenPoint(double zoom, int x); diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index 08c8e3c89..cb5a79f55 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -13,6 +13,7 @@ #include "playback/cacher.h" #include "io/config.h" #include "debug.h" +#include "io/math.h" #include #include @@ -376,6 +377,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) fbo_switcher = !fbo_switcher; GLTextureCoords coords; + coords.grid_size = 1; coords.vertexTopLeftX = coords.vertexBottomLeftX = -video_width/2; coords.vertexTopLeftY = coords.vertexTopRightY = -video_height/2; coords.vertexTopRightX = coords.vertexBottomRightX = video_width/2; @@ -434,14 +436,49 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glBegin(GL_QUADS); - glTexCoord2f(coords.textureTopLeftX, coords.textureTopLeftY); // top left - glVertex2f(coords.vertexTopLeftX, coords.vertexTopLeftY); // top left - glTexCoord2f(coords.textureTopRightX, coords.textureTopRightY); // top right - glVertex2f(coords.vertexTopRightX, coords.vertexTopRightY); // top right - glTexCoord2f(coords.textureBottomRightX, coords.textureBottomRightY); // bottom right - glVertex2f(coords.vertexBottomRightX, coords.vertexBottomRightY); // bottom right - glTexCoord2f(coords.textureBottomLeftX, coords.textureBottomLeftY); // bottom left - glVertex2f(coords.vertexBottomLeftX, coords.vertexBottomLeftY); // bottom left + + if (coords.grid_size <= 1) { + glTexCoord2f(coords.textureTopLeftX, coords.textureTopLeftY); // top left + glVertex2f(coords.vertexTopLeftX, coords.vertexTopLeftY); // top left + glTexCoord2f(coords.textureTopRightX, coords.textureTopRightY); // top right + glVertex2f(coords.vertexTopRightX, coords.vertexTopRightY); // top right + glTexCoord2f(coords.textureBottomRightX, coords.textureBottomRightY); // bottom right + glVertex2f(coords.vertexBottomRightX, coords.vertexBottomRightY); // bottom right + glTexCoord2f(coords.textureBottomLeftX, coords.textureBottomLeftY); // bottom left + glVertex2f(coords.vertexBottomLeftX, coords.vertexBottomLeftY); // bottom left + } else { + double rows = coords.grid_size; + double cols = coords.grid_size; + + for (double i=0;i