vicon jittering, opengl no draw_refresh if no ovly for last frame
authorGood Guy <[email protected]>
Thu, 23 Aug 2018 23:56:24 +0000 (17:56 -0600)
committerGood Guy <[email protected]>
Thu, 23 Aug 2018 23:56:24 +0000 (17:56 -0600)
cinelerra-5.1/cinelerra/awindowgui.C
cinelerra-5.1/cinelerra/awindowgui.h
cinelerra-5.1/cinelerra/canvas.h
cinelerra-5.1/cinelerra/cwindowgui.C
cinelerra-5.1/cinelerra/cwindowgui.h
cinelerra-5.1/cinelerra/vdevicex11.C
cinelerra-5.1/guicast/bclistbox.C
cinelerra-5.1/guicast/bclistbox.h
cinelerra-5.1/guicast/bclistboxitem.h
cinelerra-5.1/guicast/vicon.C
cinelerra-5.1/guicast/vicon.h

index 9f966f75f6a8116087033dd530b7abd62979aa85..d7f6268b3cbc4a49ba7968c70fc33675dc65d60b 100644 (file)
@@ -173,12 +173,12 @@ int64_t AssetVIcon::set_seq_no(int64_t no)
 int AssetVIcon::get_vx()
 {
        BC_ListBox *lbox = picon->gui->asset_list;
-       return lbox->get_item_x(picon) + ICON_MARGIN;
+       return lbox->get_icon_x(picon);
 }
 int AssetVIcon::get_vy()
 {
        BC_ListBox *lbox = picon->gui->asset_list;
-       return lbox->get_item_y(picon) + ICON_MARGIN;
+       return lbox->get_icon_y(picon);
 }
 
 void AssetVIcon::load_audio()
@@ -371,6 +371,7 @@ AssetPicon::~AssetPicon()
 {
        if( vicon )
                gui->vicon_thread->del_vicon(vicon);
+       delete vicon_frame;
        if( indexable ) indexable->remove_user();
        if( edl ) edl->remove_user();
        if( icon && !gui->protected_pixmap(icon) ) {
@@ -436,6 +437,7 @@ void AssetPicon::reset()
        icon = 0;
        icon_vframe = 0;
        vicon = 0;
+       vicon_frame = 0;
        in_use = 1;
        comments_time = 0;
        id = 0;
@@ -1049,8 +1051,7 @@ void AWindowGUI::create_objects()
        add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
 
        vicon_thread = new VIconThread(asset_list);
-       int x0 = 0, y0 = asset_list->get_title_h();
-       vicon_thread->set_drawing_area(x0,y0, get_w(),get_h());
+       asset_list->update_vicon_area();
        vicon_thread->start();
        vicon_audio = new AssetVIconAudio(this);
 
@@ -1136,10 +1137,7 @@ int AWindowGUI::resize_event(int w, int h)
 //     view->reposition_window(x, y);
 
        BC_WindowBase::resize_event(w, h);
-       int x0 = 0, x1 = asset_list->get_w();
-       int y0 = asset_list->get_title_h();
-       int y1 = asset_list->get_h();
-       vicon_thread->set_drawing_area(x0,y0, x1,y1);
+       asset_list->update_vicon_area();
        return 1;
 }
 
@@ -1201,13 +1199,14 @@ int AWindowGUI::close_event()
 
 void AWindowGUI::start_vicon_drawing()
 {
-       if( !vicon_drawing ) return;
+       if( !vicon_drawing || !vicon_thread->interrupted ) return;
        if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
            mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
                switch( mwindow->edl->session->assetlist_format ) {
                case ASSETS_ICONS:
                case ASSETS_ICONS_PACKED:
                case ASSETS_ICON_LIST:
+                       asset_list->update_vicon_area();
                        vicon_thread->start_drawing();
                        break;
                default:
@@ -1218,9 +1217,22 @@ void AWindowGUI::start_vicon_drawing()
 
 void AWindowGUI::stop_vicon_drawing()
 {
+       if( vicon_thread->interrupted ) return;
        vicon_thread->stop_drawing();
 }
 
+VFrame *AssetPicon::get_vicon_frame()
+{
+       if( !vicon ) return 0;
+       if( gui->vicon_thread->interrupted ) return 0;
+       VFrame *frame = vicon->frame();
+       if( !frame ) return 0;
+       if( !vicon_frame )
+               vicon_frame = new VFrame(vicon->vw, vicon->vh, frame->get_color_model());
+       vicon_frame->transfer_from(frame);
+       return vicon_frame;
+}
+
 int AWindowGUI::cycle_assetlist_format()
 {
        EDLSession *session = mwindow->edl->session;
@@ -1244,11 +1256,6 @@ int AWindowGUI::cycle_assetlist_format()
        stop_vicon_drawing();
        session->assetlist_format = format;
        asset_list->update_format(session->assetlist_format, 0);
-       int x0 = 0;
-       int x1 = asset_list->get_w();
-       int y0 = asset_list->get_title_h();
-       int y1 = asset_list->get_h();
-       vicon_thread->set_drawing_area(x0,y0, x1,y1);
        async_update_assets();
        start_vicon_drawing();
        return 1;
@@ -1882,11 +1889,6 @@ void AWindowGUI::update_assets()
 
        if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
                asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
-               int x0 = 0;
-               int x1 = asset_list->get_w();
-               int y0 = asset_list->get_title_h();
-               int y1 = asset_list->get_h();
-               vicon_thread->set_drawing_area(x0,y0, x1,y1);
        }
        int asset_xposition = asset_list->get_xposition();
        int asset_yposition = asset_list->get_yposition();
@@ -2225,7 +2227,6 @@ int AWindowAssets::selection_changed()
                }
 
                BC_ListBox::deactivate_selection();
-               return 1;
        }
        else if( gui->vicon_drawing &&
                 get_button_down() && get_buttonpress() == 1 &&
@@ -2237,7 +2238,7 @@ int AWindowAssets::selection_changed()
                gui->vicon_thread->set_view_popup(vicon);
 
        }
-       return 0;
+       return 1;
 }
 
 void AWindowAssets::draw_background()
@@ -2412,6 +2413,18 @@ int AWindowAssets::focus_out_event()
        return BC_ListBox::focus_out_event();
 }
 
+void AWindowAssets::update_vicon_area()
+{
+       int x0 = 0, x1 = get_w();
+       int y0 = get_title_h();
+       int y1 = get_h();
+       if( is_highlighted() ) {
+               x0 += LISTBOX_BORDER;  x1 -= LISTBOX_BORDER;
+               y0 += LISTBOX_BORDER;  y1 -= LISTBOX_BORDER;
+       }
+       gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
+}
+
 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
  : BC_TextBox(x, y, w, 1, "")
 {
index b96a5602850ecf94327c22029efe0e351717782b..6aade3ca6925d03a09e8b199ae0dfe165decb221 100644 (file)
@@ -68,11 +68,13 @@ public:
        void close_render_engine();
        void render_video(int64_t pos, VFrame *vfrm);
        void render_audio(int64_t pos, Samples **samples, int len);
+       VFrame *get_vicon_frame();
 
        MWindow *mwindow;
        AWindowGUI *gui;
        BC_Pixmap *icon;
        VFrame *icon_vframe;
+       VFrame *vicon_frame;
        int foldernum;
 // ID of thing pointed to
        int id;
@@ -319,6 +321,7 @@ public:
        int column_resize_event();
        int focus_in_event();
        int focus_out_event();
+       void update_vicon_area();
 
        MWindow *mwindow;
        AWindowGUI *gui;
index 89a7eb8268e375b6686df39e319ef5e79f3c9cb7..aa4879a125e28e34d763e1ab419061f6ebdaa08f 100644 (file)
@@ -97,6 +97,7 @@ public:
        virtual int button_release_event() { return 0; };
        virtual int button_press_event();
        virtual int cursor_motion_event() { return 0; };
+       virtual int need_overlays() { return 1; }
        virtual void draw_overlays() { };
        virtual void toggle_controls() { } ;
        virtual int get_cwindow_controls() { return 0; };
index c51eb0c3d155fc8bcef72a316efbc8521689849d..ea957147637ff434eb2234f4ef164302391aaadd 100644 (file)
@@ -2312,6 +2312,24 @@ int CWindowCanvas::do_eyedrop(int &rerender, int button_press, int draw)
        return result;
 }
 
+int CWindowCanvas::need_overlays()
+{
+       if( mwindow->edl->session->safe_regions ) return 1;
+       if( mwindow->edl->session->cwindow_scrollbars ) return 1;
+       if( gui->highlighted ) return 1;
+       switch( mwindow->edl->session->cwindow_operation ) {
+               case CWINDOW_EYEDROP:
+                       if( ! gui->eyedrop_visible ) break;
+               case CWINDOW_CAMERA:
+               case CWINDOW_PROJECTOR:
+               case CWINDOW_CROP:
+               case CWINDOW_MASK:
+               case CWINDOW_RULER:
+                       return 1;
+       }
+       return 0;
+}
+
 void CWindowCanvas::draw_overlays()
 {
        if(mwindow->edl->session->safe_regions)
index 8753fa43b1a4a5ee30cb9f10a58dc1e3fbf3760a..45734e4259603e74d5ed66b57761125ba12d02f5 100644 (file)
@@ -272,6 +272,7 @@ public:
                int cursor_motion,
                int draw);
        void draw_refresh(int flash = 1);
+       int need_overlays();
        void draw_overlays();
        void draw_safe_regions();
 // Cursor may have to be drawn
index 1407d2e97ea91f263e8858bae72f9a7ec1756a46..fc9e84097a0bc2c44f9e99c3510fb755746a1dbc 100644 (file)
@@ -172,7 +172,9 @@ int VDeviceX11::close_all()
 
        if( output && output_frame ) {
                output->update_refresh(device, output_frame);
-               output->draw_refresh(1);
+// if the last frame is good, don't draw over it
+               if( output->need_overlays() )
+                       output->draw_refresh(1);
        }
 
        delete bitmap;          bitmap = 0;
index 16a477bbe309d0de365f9029675516f61a3f2487..e52d42fa49a1dd4a43f9174d043457a0eefa71cb 100644 (file)
@@ -918,14 +918,24 @@ int BC_ListBox::get_item_h(BC_ListBoxItem *item)
 }
 
 
+int BC_ListBox::get_icon_x(BC_ListBoxItem *item)
+{
+       return get_item_x(item) + ICON_MARGIN;
+}
+
+int BC_ListBox::get_icon_y(BC_ListBoxItem *item)
+{
+       return get_item_y(item) + ICON_MARGIN;
+}
+
 int BC_ListBox::get_icon_w(BC_ListBoxItem *item)
 {
-       return item->get_icon_w();
+       return item->get_icon_w() + 2*ICON_MARGIN;
 }
 
 int BC_ListBox::get_icon_h(BC_ListBoxItem *item)
 {
-       return item->get_icon_h();
+       return item->get_icon_h() + 2*ICON_MARGIN;
 }
 
 int BC_ListBox::get_text_w(BC_ListBoxItem *item)
@@ -1041,6 +1051,11 @@ int BC_ListBox::set_xposition(int position)
        return 0;
 }
 
+int BC_ListBox::is_highlighted()
+{
+       return list_highlighted;
+}
+
 void BC_ListBox::expand_item(BC_ListBoxItem *item, int expand)
 {
        if( item ) {
@@ -1173,10 +1188,10 @@ int BC_ListBox::get_icon_mask(BC_ListBoxItem *item,
        case LISTBOX_ICONS:
        case LISTBOX_ICONS_PACKED:
        case LISTBOX_ICON_LIST: {
-               x = get_item_x(item) + ICON_MARGIN;
-               y = get_item_y(item) + ICON_MARGIN;
-               w = get_icon_w(item) + ICON_MARGIN;
-               h = get_icon_h(item) + ICON_MARGIN;
+               x = get_icon_x(item);
+               y = get_icon_y(item);
+               w = get_icon_w(item);
+               h = get_icon_h(item);
                break; }
        case LISTBOX_TEXT:
        default: {
@@ -1200,15 +1215,15 @@ int BC_ListBox::get_text_mask(BC_ListBoxItem *item,
        case LISTBOX_ICONS:
        case LISTBOX_ICONS_PACKED: {
                if( icon_position == ICON_LEFT ) {
-                       x += get_icon_w(item) + ICON_MARGIN * 2;
+                       x += get_icon_w(item);
                        y += get_icon_h(item) - get_text_h(item);
                }
                else {
-                       y += get_icon_h(item) + ICON_MARGIN;
+                       y += get_icon_h(item);
                }
 
                w = packed_icons ?
-                       get_icon_w(item) + ICON_MARGIN * 4 :
+                       get_icon_w(item) + ICON_MARGIN * 2 :
                        get_text_w(item) + ICON_MARGIN * 2 ;
                h = get_text_h(item) + ICON_MARGIN * 2;
                break; }
@@ -3694,16 +3709,17 @@ int BC_ListBox::draw_items(int flush, int draw_bg)
                                        }
 // Draw icons
                                        gui->set_color(get_item_color(data, 0, i));
-                                       if( item->icon )
-                                               gui->pixmap->draw_pixmap(item->icon,
-                                                       icon_x + ICON_MARGIN, icon_y + ICON_MARGIN);
+                                       VFrame *vicon = item->get_vicon_frame();
+                                       if( vicon )
+                                               gui->pixmap->draw_vframe(vicon, icon_x, icon_y);
+                                       else if( item->icon )
+                                               gui->pixmap->draw_pixmap(item->icon, icon_x, icon_y);
                                        char item_text[BCTEXTLEN];
                                        if( display_format == LISTBOX_ICONS_PACKED )
                                                gui->truncate_text(item_text, item->text, text_w);
                                        else
                                                strcpy(item_text, item->text);
-                                       gui->draw_text(text_x + ICON_MARGIN,
-                                               text_y + ICON_MARGIN + get_baseline(item), item_text);
+                                       gui->draw_text(text_x, text_y + get_baseline(item), item_text);
                                }
                                else
                                        item->set_in_view(0);
@@ -3821,8 +3837,14 @@ void BC_ListBox::draw_text_recursive(ArrayList<BC_ListBoxItem*> *data,
 
 
                        if( column == 0 && display_format == LISTBOX_ICON_LIST ) {
-                               if( item->icon ) {
-                                       gui->pixmap->draw_pixmap(item->icon, x, y);
+                               int ix = get_icon_x(item), iy = get_icon_y(item);
+                               VFrame *vicon = item->get_vicon_frame();
+                               if( vicon ) {
+                                       gui->pixmap->draw_vframe(vicon, ix, iy);
+                                       x += vicon->get_w() + ICON_MARGIN;
+                               }
+                               else if( item->icon ) {
+                                       gui->pixmap->draw_pixmap(item->icon, ix, iy);
                                        x += item->icon->get_w() + ICON_MARGIN;
                                }
                        }
index 78c4315b79137e3d8da4e6fc2b8c579e6514834a..a10446d9a52f1ce572fdf36011adc3033cf8274a 100644 (file)
@@ -316,6 +316,12 @@ public:
                int indent /* = 0 */,
                int master_column);
 
+       int get_icon_x(BC_ListBoxItem *item);
+       int get_icon_y(BC_ListBoxItem *item);
+       int get_icon_w(BC_ListBoxItem *item);
+       int get_icon_h(BC_ListBoxItem *item);
+       int get_text_w(BC_ListBoxItem *item);
+       int get_text_h(BC_ListBoxItem *item);
        int get_item_x(BC_ListBoxItem *item);
        int get_item_y(BC_ListBoxItem *item);
        int get_item_w(BC_ListBoxItem *item);
@@ -323,7 +329,7 @@ public:
 
 // Draw the list items
        int draw_items(int flash, int bg_draw=0);
-
+       int is_highlighted();
        int get_cursor_item();
 
 private:
@@ -405,10 +411,6 @@ private:
        int get_items_height(ArrayList<BC_ListBoxItem*> *data,
                int columns,
                int *result = 0);
-       int get_icon_w(BC_ListBoxItem *item);
-       int get_icon_h(BC_ListBoxItem *item);
-       int get_text_w(BC_ListBoxItem *item);
-       int get_text_h(BC_ListBoxItem *item);
        int get_baseline(BC_ListBoxItem *item);
        int get_item_highlight(ArrayList<BC_ListBoxItem*> *data, int column, int item);
        int get_item_color(ArrayList<BC_ListBoxItem*> *data, int column, int item);
index a77519a95f09bfaca1553e249820a5d28b98aef5..78db9d663e68f8b4f9afe838baf4c24eef54f90c 100644 (file)
@@ -81,6 +81,7 @@ public:
        void set_icon_vframe(VFrame *p) { icon_vframe = p; }
        void set_color(int v) { color = v; }
        int get_color() { return color; }
+       virtual VFrame *get_vicon_frame() { return 0; }
 
        void copy_from(BC_ListBoxItem *item);
        BC_ListBoxItem& operator=(BC_ListBoxItem& item) {
index 9c41ccf1ea915d20548a0f755f6676ea92249abe..8ae7a7c0ba667a10ad2978113b1b6fc52bde14db 100644 (file)
@@ -105,6 +105,7 @@ VIconThread(BC_WindowBase *wdw, int vw, int vh)
        this->refresh_rate = VICON_RATE;
        done = 0;
        interrupted = -1;
+       stop_age = 0;
 }
 
 VIconThread::
@@ -130,6 +131,8 @@ start_drawing()
                wdw->set_active_subwindow(view_win);
         if( interrupted < 0 )
                draw_lock->unlock();
+       timer->update();
+       timer->subtract(-stop_age);
        interrupted = 0;
        wdw->unlock_window();
 }
@@ -141,6 +144,7 @@ stop_drawing()
        set_view_popup(0);
        if( !interrupted )
                interrupted = 1;
+       stop_age = timer->get_difference();
        wdw->unlock_window();
 }
 
index 22cfd6f9a0af07349bad6b434748b31a233f9f06..e1dd04c5629a41577fe8783c416e7aa83ab47dd4 100644 (file)
@@ -80,6 +80,7 @@ public:
        int draw_x1, draw_y1;
        int img_dirty, win_dirty;
        double refresh_rate;
+       int64_t stop_age;
 
        ArrayList<VIcon *>t_heap;
        VIcon *low_vicon();