From 064d1f229ee2384554a19f14bef4f8de75cb5567 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 2 Feb 2019 12:31:42 +1100 Subject: [PATCH] reimplemented opacity without blending modes --- io/config.cpp | 6 +++++ io/config.h | 10 ++++++++ main.cpp | 48 +++++++++++++++++++-------------------- mainwindow.cpp | 7 ++---- mainwindow.h | 11 ++++----- project/effect.cpp | 6 ++--- project/effect.h | 2 -- project/effectloaders.cpp | 3 ++- ui/renderfunctions.cpp | 12 ++++++---- ui/renderfunctions.h | 2 -- ui/viewercontainer.cpp | 3 +++ 11 files changed, 60 insertions(+), 50 deletions(-) diff --git a/io/config.cpp b/io/config.cpp index a3f356794..b12e8d010 100644 --- a/io/config.cpp +++ b/io/config.cpp @@ -10,6 +10,7 @@ #include "debug.h" Config config; +RuntimeConfig runtime_config; Config::Config() : saved_layout(false), @@ -262,3 +263,8 @@ void Config::save(QString path) { stream.writeEndDocument(); // doc f.close(); } + +RuntimeConfig::RuntimeConfig() : + shaders_are_enabled(true), + disable_blending(false) +{} diff --git a/io/config.h b/io/config.h index ec6d2af89..9c9bf9b7b 100644 --- a/io/config.h +++ b/io/config.h @@ -26,6 +26,7 @@ struct Config { Config(); + bool saved_layout; bool show_track_lines; bool scroll_zooms; @@ -74,6 +75,15 @@ struct Config { void save(QString path); }; +struct RuntimeConfig { + RuntimeConfig(); + + bool shaders_are_enabled; + bool disable_blending; + QString external_translation_file; +}; + extern Config config; +extern RuntimeConfig runtime_config; #endif // CONFIG_H diff --git a/main.cpp b/main.cpp index 48188e2a6..434a62113 100644 --- a/main.cpp +++ b/main.cpp @@ -3,9 +3,7 @@ #include "debug.h" -// importing classes for certain command line args -#include "project/effect.h" -#include "ui/renderfunctions.h" +#include "io/config.h" extern "C" { #include @@ -35,36 +33,36 @@ int main(int argc, char *argv[]) { printf("%s\n", appName.toUtf8().constData()); return 0; } else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) { - printf("Usage: %s [options] [filename]\n\n" - "[filename] is the file to open on startup.\n\n" - "Options:\n" - "\t-v, --version\t\tShow version information\n" - "\t-h, --help\t\tShow this help\n" - "\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 \tSet an external language file to use\n" - "\n", argv[0]); + printf("Usage: %s [options] [filename]\n\n" + "[filename] is the file to open on startup.\n\n" + "Options:\n" + "\t-v, --version\t\tShow version information\n" + "\t-h, --help\t\tShow this help\n" + "\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 \tSet an external language file to use\n" + "\n", argv[0]); return 0; } else if (!strcmp(argv[i], "--fullscreen") || !strcmp(argv[i], "-f")) { launch_fullscreen = true; } else if (!strcmp(argv[i], "--disable-shaders")) { - shaders_are_enabled = false; + runtime_config.shaders_are_enabled = false; } else if (!strcmp(argv[i], "--no-debug")) { use_internal_logger = false; } else if (!strcmp(argv[i], "--disable-blend-modes")) { - disable_blending = true; - } else if (!strcmp(argv[i], "--translation")) { - if (i + 1 < argc && argv[i + 1][0] != '-') { - // load translation file - external_translation_file = argv[i + 1]; + runtime_config.disable_blending = true; + } else if (!strcmp(argv[i], "--translation")) { + if (i + 1 < argc && argv[i + 1][0] != '-') { + // load translation file + runtime_config.external_translation_file = argv[i + 1]; - i++; - } else { - printf("[ERROR] No translation file specified\n"); - return 1; - } + i++; + } else { + printf("[ERROR] No translation file specified\n"); + return 1; + } } else { printf("[ERROR] Unknown argument '%s'\n", argv[1]); return 1; diff --git a/mainwindow.cpp b/mainwindow.cpp index 060447494..5f756fd4c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -57,9 +57,6 @@ MainWindow* mainWindow; #define DEFAULT_CSS "QPushButton::checked { background: rgb(25, 25, 25); }" #define OLIVE_FILE_FILTER "Olive Project (*.ove)" -// load external translation file -QString external_translation_file; - QTimer autorecovery_timer; QString config_fn; bool demoNoticeShown = false; @@ -205,9 +202,9 @@ MainWindow::MainWindow(QWidget *parent, const QString &an) : } // load preferred language from file - QString language_file = external_translation_file.isEmpty() ? + QString language_file = runtime_config.external_translation_file.isEmpty() ? config.language_file : - external_translation_file; + runtime_config.external_translation_file; if (!language_file.isEmpty() && QFileInfo::exists(language_file)) { diff --git a/mainwindow.h b/mainwindow.h index 4ef98ebae..f74655704 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -78,7 +78,7 @@ private slots: void prev_cut(); void next_cut(); - void maximize_panel(); + void maximize_panel(); void reset_layout(); void preferences(); @@ -86,7 +86,7 @@ private slots: void zoom_in_tracks(); void zoom_out_tracks(); - void full_screen_viewer(); + void full_screen_viewer(); void fileMenu_About_To_Be_Shown(); void fileMenu_About_To_Hide(); @@ -207,13 +207,10 @@ private: QString appName; - // used to store the panel state when one panel is maximized - QByteArray temp_panel_state; + // used to store the panel state when one panel is maximized + QByteArray temp_panel_state; }; extern MainWindow* mainWindow; -// load external translation file -extern QString external_translation_file; - #endif // MAINWINDOW_H diff --git a/project/effect.cpp b/project/effect.cpp index 81d686053..59d8b2206 100644 --- a/project/effect.cpp +++ b/project/effect.cpp @@ -17,6 +17,7 @@ #include "mainwindow.h" #include "io/math.h" #include "io/clipboard.h" +#include "io/config.h" #include "transition.h" #include "effects/internal/transformeffect.h" @@ -45,7 +46,6 @@ #include #include -bool shaders_are_enabled = true; QVector effects; Effect* create_effect(Clip* c, const EffectMeta* em) { @@ -627,7 +627,7 @@ void Effect::open() { qWarning() << "Tried to open an effect that was already open"; close(); } - if (shaders_are_enabled && enable_shader) { + if (runtime_config.shaders_are_enabled && enable_shader) { if (QOpenGLContext::currentContext() == nullptr) { qWarning() << "No current context to create a shader program for - will retry next repaint"; } else { @@ -685,7 +685,7 @@ void Effect::startEffect() { open(); qWarning() << "Tried to start a closed effect - opening"; } - if (shaders_are_enabled + if (runtime_config.shaders_are_enabled && enable_shader && glslProgram->isLinked()) { bound = glslProgram->bind(); diff --git a/project/effect.h b/project/effect.h index 22a8213bd..fc045bda9 100644 --- a/project/effect.h +++ b/project/effect.h @@ -34,8 +34,6 @@ struct EffectMeta { int type; int subtype; }; - -extern bool shaders_are_enabled; extern QVector effects; double log_volume(double linear); diff --git a/project/effectloaders.cpp b/project/effectloaders.cpp index e9cee3c69..f5822a0f9 100644 --- a/project/effectloaders.cpp +++ b/project/effectloaders.cpp @@ -6,6 +6,7 @@ #include "panels/panels.h" #include "panels/effectcontrols.h" #include "io/crossplatformlib.h" +#include "io/config.h" #include #include @@ -18,7 +19,7 @@ typedef void (*f0rGetPluginInfo)(f0r_plugin_info_t* info); #endif void load_internal_effects() { - if (!shaders_are_enabled) qWarning() << "Shaders are disabled, some effects may be nonfunctional"; + if (!runtime_config.shaders_are_enabled) qWarning() << "Shaders are disabled, some effects may be nonfunctional"; EffectMeta em; diff --git a/ui/renderfunctions.cpp b/ui/renderfunctions.cpp index 0e0dfa8d4..aad5d9bbd 100644 --- a/ui/renderfunctions.cpp +++ b/ui/renderfunctions.cpp @@ -24,8 +24,6 @@ #include "panels/timeline.h" #include "panels/viewer.h" -bool disable_blending = false; - extern "C" { #include } @@ -95,7 +93,7 @@ void process_effect(Clip* c, if (e->enable_coords) { e->process_coords(timecode, coords, data); } - bool can_process_shaders = (e->enable_shader && shaders_are_enabled); + bool can_process_shaders = (e->enable_shader && runtime_config.shaders_are_enabled); if (can_process_shaders || e->enable_superimpose) { e->startEffect(); if (can_process_shaders && e->is_glsl_linked()) { @@ -489,7 +487,7 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) { // copy front buffer to back buffer (only if we're using blending modes - which we usually will be) - if (!disable_blending) { + if (!runtime_config.disable_blending) { if (params.nests.size() > 0) { draw_clip(params.ctx, params.nests.last()->fbo[2]->handle(), params.nests.last()->fbo[0]->texture(), true); } else { @@ -506,13 +504,17 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) { // bind front buffer as draw buffer params.ctx->functions()->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, final_fbo); - if (disable_blending) { + if (runtime_config.disable_blending) { // some GPUs don't like the blending shader, so we provide a pure GL fallback here params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, backend_tex_1); + glColor4f(coords.opacity, coords.opacity, coords.opacity, coords.opacity); + full_blit(); +// glColor4f(1.0, 1.0, 1.0, 1.0); + params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, 0); } else { // load background texture into texture unit 0 diff --git a/ui/renderfunctions.h b/ui/renderfunctions.h index 1fe238db8..0830d6cb4 100644 --- a/ui/renderfunctions.h +++ b/ui/renderfunctions.h @@ -10,8 +10,6 @@ class QOpenGLShaderProgram; struct Sequence; struct Clip; -extern bool disable_blending; - struct ComposeSequenceParams { Viewer* viewer; QOpenGLContext* ctx; diff --git a/ui/viewercontainer.cpp b/ui/viewercontainer.cpp index 2a30dafbc..5ae31db03 100644 --- a/ui/viewercontainer.cpp +++ b/ui/viewercontainer.cpp @@ -20,6 +20,9 @@ ViewerContainer::ViewerContainer(QWidget *parent) : horizontal_scrollbar = new QScrollBar(Qt::Horizontal, this); vertical_scrollbar = new QScrollBar(Qt::Vertical, this); + horizontal_scrollbar->setVisible(false); + vertical_scrollbar->setVisible(false); + horizontal_scrollbar->setSingleStep(20); vertical_scrollbar->setSingleStep(20);