From: Robin Gareus Date: Sat, 6 Apr 2013 02:09:58 +0000 (+0200) Subject: vtl: make videotimeline work with new cairo canvas X-Git-Tag: 1.0.0~1478^2 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=6830d83236ae047eb077802cdb54eff5492928d3;p=ardour.git vtl: make videotimeline work with new cairo canvas timeline thumbnail display, moving (drag/drop) and zoom works. There still some crashes e.g. resizing the height of the timeline and with off-screen image buffering when zooming in. Likely due to concurrency issues: VideoImageFrame::exposeimg() and direct access of the pixbuf: "Assertion `!_bounding_box_dirty' failed." in canvas/item.cc:191 more work is needed.. --- diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index 4b9b21dc5c..48aeb1aeb3 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -151,20 +151,13 @@ Editor::initialize_canvas () marker_group = new ArdourCanvas::Group (_time_markers_group, ArdourCanvas::Duple (0.0, timebar_height)); cd_marker_group = new ArdourCanvas::Group (_time_markers_group, ArdourCanvas::Duple (0.0, 0.0)); #ifdef WITH_VIDEOTIMELINE - videotl_group = new ArdourCanvas::Group (_time_markers_group, 0.0, 0.0); + videotl_group = new ArdourCanvas::Group (_time_markers_group, ArdourCanvas::Duple(0.0, 0.0)); #endif #ifdef WITH_VIDEOTIMELINE - videotl_bar_group = new ArdourCanvas::Group (track_canvas->root ()); - if (Profile->get_sae()) { - videotl_bar = new ArdourCanvas::Rectangle (videotl_bar_group, 0.0, 0.0, phys_width, (timebar_height * videotl_bar_height - 1)); - videotl_bar->property_outline_pixels() = 1; - } else { - videotl_bar = new ArdourCanvas::Rectangle (videotl_bar_group, 0.0, 0.0, phys_width, (timebar_height * videotl_bar_height)); - videotl_bar->property_outline_pixels() = 0; - } - videotl_bar->property_outline_what() = (0x1 | 0x8); + videotl_bar_group = new ArdourCanvas::Group (_time_bars_canvas->root ()); + videotl_bar = new ArdourCanvas::Rectangle (videotl_bar_group, ArdourCanvas::Rect (0.0, 0.0, 100,(timebar_height * videotl_bar_height))); ARDOUR_UI::instance()->video_timeline = new VideoTimeLine(this, videotl_bar_group, (timebar_height * videotl_bar_height)); #endif diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc index 5047feb1cb..dd13e153b5 100644 --- a/gtk2_ardour/editor_rulers.cc +++ b/gtk2_ardour/editor_rulers.cc @@ -791,13 +791,13 @@ Editor::update_ruler_visibility () #ifdef WITH_VIDEOTIMELINE if (ruler_video_action->get_active()) { - old_unit_pos = videotl_group->property_y(); + old_unit_pos = videotl_group->position().y; if (tbpos != old_unit_pos) { - videotl_group->move ( 0.0, tbpos - old_unit_pos); + videotl_group->move (ArdourCanvas::Duple (0.0, tbpos - old_unit_pos)); } - old_unit_pos = videotl_bar_group->property_y(); + old_unit_pos = videotl_bar_group->position().y; if (tbgpos != old_unit_pos) { - videotl_bar_group->move ( 0.0, tbgpos - old_unit_pos); + videotl_bar_group->move (ArdourCanvas::Duple (0.0, tbgpos - old_unit_pos)); } videotl_bar_group->show(); videotl_group->show(); diff --git a/gtk2_ardour/editor_videotimeline.cc b/gtk2_ardour/editor_videotimeline.cc index 564e3016e7..a4a0b1b210 100644 --- a/gtk2_ardour/editor_videotimeline.cc +++ b/gtk2_ardour/editor_videotimeline.cc @@ -28,8 +28,7 @@ #include "ardour_ui.h" #include "editor.h" -#include "simplerect.h" -#include "canvas_impl.h" +#include "canvas/rectangle.h" #include "editing.h" #include "audio_time_axis.h" #include "video_image_frame.h" @@ -49,7 +48,7 @@ Editor::set_video_timeline_height (const int h) videotl_bar_height = h; const double nh = (videotl_bar_height * timebar_height - ((ARDOUR::Profile->get_sae())?1.0:0.0)); videotl_label.set_size_request (-1, (int)timebar_height * videotl_bar_height); - videotl_bar->property_y2().set_value(nh); + videotl_bar->set_y1(nh); ARDOUR_UI::instance()->video_timeline->set_height(videotl_bar_height * timebar_height); update_ruler_visibility(); } diff --git a/gtk2_ardour/video_image_frame.cc b/gtk2_ardour/video_image_frame.cc index cc964c7e43..f04a23bf04 100644 --- a/gtk2_ardour/video_image_frame.cc +++ b/gtk2_ardour/video_image_frame.cc @@ -26,8 +26,7 @@ #include "video_image_frame.h" #include "public_editor.h" #include "utils.h" -#include "canvas_impl.h" -#include "simpleline.h" +#include "canvas/group.h" #include "rgb_macros.h" #include "utils_videotl.h" @@ -60,20 +59,20 @@ VideoImageFrame::VideoImageFrame (PublicEditor& ed, ArdourCanvas::Group& parent, #endif unit_position = editor.frame_to_unit (frame_position); - group = new Group (parent, unit_position, 1.0); - img_pixbuf = new ArdourCanvas::Pixbuf(*group); + group = new ArdourCanvas::Group (_parent, ArdourCanvas::Duple(unit_position, 1.0)); + img_pixbuf = new ArdourCanvas::Pixbuf(group); Glib::RefPtr img; img = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, clip_width, clip_height); img->fill(RGBA_TO_UINT(0,0,0,255)); - img_pixbuf->property_pixbuf() = img; + img_pixbuf->set(img); draw_line(); - video_draw_cross(img_pixbuf->property_pixbuf()); + video_draw_cross(img_pixbuf->pixbuf()); + img_pixbuf->set(img_pixbuf->pixbuf()); - group->signal_event().connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_videotl_bar_event), _parent)); - //img_pixbuf->signal_event().connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_videotl_bar_event), _parent)); + group->Event.connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_videotl_bar_event), _parent)); } VideoImageFrame::~VideoImageFrame () @@ -89,7 +88,7 @@ void VideoImageFrame::set_position (framepos_t frame) { double new_unit_position = editor.frame_to_unit (frame); - group->move (new_unit_position - unit_position, 0.0); + group->move (ArdourCanvas::Duple (new_unit_position - unit_position, 0.0)); frame_position = frame; unit_position = new_unit_position; } @@ -119,16 +118,17 @@ VideoImageFrame::set_videoframe (framepos_t videoframenumber, int re) #if 0 /* dummy mode: print framenumber */ gchar buf[16]; snprintf (buf, sizeof(buf), "%li", (long int) videoframenumber); - img_pixbuf->property_pixbuf() = pixbuf_from_ustring(g_strdup (buf), get_font_for_style (N_("MarkerText")), 80, 60, Gdk::Color ("#C0C0C0")); + img_pixbuf->pixbuf() = pixbuf_from_ustring(g_strdup (buf), get_font_for_style (N_("MarkerText")), 80, 60, Gdk::Color ("#C0C0C0")); return; #endif #if 1 /* draw "empty frame" while we request the data */ Glib::RefPtr img; - img = img_pixbuf->property_pixbuf(); + img = img_pixbuf->pixbuf(); img->fill(RGBA_TO_UINT(0,0,0,255)); - video_draw_cross(img_pixbuf->property_pixbuf()); + video_draw_cross(img_pixbuf->pixbuf()); draw_line(); cut_rightend(); + img_pixbuf->set(img); exposeimg(); #endif /* request video-frame from decoder in background thread */ @@ -139,7 +139,7 @@ void VideoImageFrame::draw_line () { Glib::RefPtr img; - img = img_pixbuf->property_pixbuf(); + img = img_pixbuf->pixbuf(); int rowstride = img->get_rowstride(); int clip_height = img->get_height(); @@ -160,7 +160,7 @@ VideoImageFrame::cut_rightend () { if (rightend < 0 ) { return; } Glib::RefPtr img; - img = img_pixbuf->property_pixbuf(); + img = img_pixbuf->pixbuf(); int rowstride = img->get_rowstride(); int clip_height = img->get_height(); @@ -222,12 +222,13 @@ VideoImageFrame::http_download_done (char *data){ if (!data) { /* Image request failed (HTTP error or timeout) */ Glib::RefPtr img; - img = img_pixbuf->property_pixbuf(); + img = img_pixbuf->pixbuf(); img->fill(RGBA_TO_UINT(128,0,0,255)); - video_draw_cross(img_pixbuf->property_pixbuf()); + video_draw_cross(img_pixbuf->pixbuf()); cut_rightend(); draw_line(); cut_rightend(); + img_pixbuf->set(img); /* TODO: mark as invalid: * video_frame_number = -1; * TODO: but prevent live-loops when calling update again @@ -239,11 +240,12 @@ VideoImageFrame::http_download_done (char *data){ #else // RGB tmp = Gdk::Pixbuf::create_from_data ((guint8*) data, Gdk::COLORSPACE_RGB, false, 8, clip_width, clip_height, clip_width*3); #endif - img = img_pixbuf->property_pixbuf(); + img = img_pixbuf->pixbuf(); tmp->copy_area (0, 0, clip_width, clip_height, img, 0, 0); free(data); draw_line(); cut_rightend(); + img_pixbuf->set(img); } exposeimg(); diff --git a/gtk2_ardour/video_image_frame.h b/gtk2_ardour/video_image_frame.h index 6988274d7e..403eff9cf9 100644 --- a/gtk2_ardour/video_image_frame.h +++ b/gtk2_ardour/video_image_frame.h @@ -34,7 +34,8 @@ #include "ardour/ardour.h" #include "pbd/signals.h" -#include "canvas.h" +#include "canvas/group.h" +#include "canvas/pixbuf.h" namespace ARDOUR { class TempoSection; diff --git a/gtk2_ardour/video_timeline.cc b/gtk2_ardour/video_timeline.cc index 9cd9d35315..8360ef75d4 100644 --- a/gtk2_ardour/video_timeline.cc +++ b/gtk2_ardour/video_timeline.cc @@ -30,8 +30,6 @@ #include "public_editor.h" #include "gui_thread.h" #include "utils.h" -#include "canvas_impl.h" -#include "simpleline.h" #include "utils_videotl.h" #include "rgb_macros.h" #include "video_timeline.h" diff --git a/gtk2_ardour/video_timeline.h b/gtk2_ardour/video_timeline.h index ab1a9a92d8..8775a64265 100644 --- a/gtk2_ardour/video_timeline.h +++ b/gtk2_ardour/video_timeline.h @@ -31,7 +31,7 @@ #include "video_image_frame.h" #include "video_monitor.h" #include "pbd/signals.h" -#include "canvas.h" +#include "canvas/group.h" namespace ARDOUR { class Session;