add layout_scale preference, scaling cleanup, rework init bc_resources, init tip_info...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / overlay / overlay.C
index 8f8cdea5693999439027ac3badb3036f059d7ad2..ae9087815b7a664b7b592602f7e14bc95dcac9da 100644 (file)
@@ -22,6 +22,7 @@
 #include "bcdisplayinfo.h"
 #include "clip.h"
 #include "bchash.h"
+#include "edl.h"
 #include "edlsession.h"
 #include "filexml.h"
 #include "guicast.h"
@@ -182,12 +183,7 @@ const char* OverlayConfig::output_to_text(int output_layer)
 
 
 OverlayWindow::OverlayWindow(Overlay *plugin)
- : PluginClientWindow(plugin,
-       300,
-       160,
-       300,
-       160,
-       0)
+ : PluginClientWindow(plugin, xS(300), yS(100), xS(300), yS(100), 0)
 {
        this->plugin = plugin;
 }
@@ -198,26 +194,28 @@ OverlayWindow::~OverlayWindow()
 
 void OverlayWindow::create_objects()
 {
-       int x = 10, y = 10;
+       int xs5 = xS(5), xs10 = xS(10);
+       int ys10 = yS(10), ys30 = yS(30);
+       int x = xs10, y = ys10;
 
        BC_Title *title;
        add_subwindow(title = new BC_Title(x, y, _("Mode:")));
        add_subwindow(mode = new OverlayMode(plugin,
-               x + title->get_w() + 5,
+               x + title->get_w() + xs5,
                y));
        mode->create_objects();
 
-       y += 30;
+       y += ys30;
        add_subwindow(title = new BC_Title(x, y, _("Layer order:")));
        add_subwindow(direction = new OverlayDirection(plugin,
-               x + title->get_w() + 5,
+               x + title->get_w() + xs5,
                y));
        direction->create_objects();
 
-       y += 30;
+       y += ys30;
        add_subwindow(title = new BC_Title(x, y, _("Output layer:")));
        add_subwindow(output = new OverlayOutput(plugin,
-               x + title->get_w() + 5,
+               x + title->get_w() + xs5,
                y));
        output->create_objects();
 
@@ -232,7 +230,7 @@ void OverlayWindow::create_objects()
 
 
 OverlayMode::OverlayMode(Overlay *plugin, int x, int y)
- : BC_PopupMenu(x, y, 150,
+ : BC_PopupMenu(x, y, xS(150),
        OverlayConfig::mode_to_text(plugin->config.mode), 1)
 {
        this->plugin = plugin;
@@ -265,9 +263,7 @@ int OverlayMode::handle_event()
 OverlayDirection::OverlayDirection(Overlay *plugin,
        int x,
        int y)
- : BC_PopupMenu(x,
-       y,
-       150,
+ : BC_PopupMenu(x, y, xS(150),
        OverlayConfig::direction_to_text(plugin->config.direction),
        1)
 {
@@ -306,9 +302,7 @@ int OverlayDirection::handle_event()
 OverlayOutput::OverlayOutput(Overlay *plugin,
        int x,
        int y)
- : BC_PopupMenu(x,
-       y,
-       100,
+ : BC_PopupMenu(x, y, xS(100),
        OverlayConfig::output_to_text(plugin->config.output_layer),
        1)
 {
@@ -393,7 +387,7 @@ int Overlay::process_buffer(VFrame **frame,
 {
        load_configuration();
 
-       EDLSession* session = get_edlsession();
+       EDLSession* session = get_edl()->session;
        int interpolation_type = session ? session->interpolation_type : NEAREST_NEIGHBOR;
 
        int step = config.direction == OverlayConfig::BOTTOM_FIRST ?  -1 : 1;
@@ -484,20 +478,12 @@ int Overlay::handle_opengl()
 #undef TWO
 #define TWO 2.0
 
-static const char *blend_NORMAL_frag =
-       "       vec4 result = mix(src_color, src_color, src_color.a);\n";
-
-static const char *blend_ADDITION_frag =
-       "       vec4 result = dst_color + src_color;\n"
-       "       result = clamp(result, 0.0, 1.0);\n";
-
-static const char *blend_SUBTRACT_frag =
-       "       vec4 result = dst_color - src_color;\n"
-       "       result = clamp(result, 0.0, 1.0);\n";
-
 static const char *blend_REPLACE_frag =
        "       vec4 result = src_color;\n";
 
+GL_VEC_FRAG(NORMAL);
+GL_VEC_FRAG(ADDITION);
+GL_VEC_FRAG(SUBTRACT);
 GL_STD_FRAG(MULTIPLY);
 GL_VEC_FRAG(DIVIDE);
 GL_VEC_FRAG(MAX);
@@ -571,21 +557,6 @@ static const char * const overlay_shaders[TRANSFER_TYPES] = {
                dst->init_screen();
                src->draw_texture();
                break;
-       case TRANSFER_NORMAL:
-// Move destination to screen
-               if( dst->get_opengl_state() != VFrame::SCREEN ) {
-                       dst->to_texture();
-                       dst->enable_opengl();
-                       dst->init_screen();
-                       dst->draw_texture();
-               }
-               src->to_texture();
-               dst->enable_opengl();
-               dst->init_screen();
-               glEnable(GL_BLEND);
-               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-               src->draw_texture();
-               break;
        default:
                src->to_texture();
                dst->to_texture();