From d06de26a4fd828b6a0a9da8718e3b0c829a4d162 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 20 Mar 2017 17:11:56 +0100 Subject: [PATCH] Towards a consistent render() API. This fixes an -Woverloaded-virtual ambiguity introduced in b5e613d45 void render (cairo_t*, cairo_rectagle*) void render (Cairo::RefPtr const&, cairo_rectangle_t*) ArdourCanvas prefers cairomm and CairoWidget itself uses Cairo::Context, this improves overall API consistency. --- gtk2_ardour/ardour_button.cc | 5 +++-- gtk2_ardour/ardour_button.h | 2 +- gtk2_ardour/ardour_knob.cc | 4 ++-- gtk2_ardour/ardour_knob.h | 2 +- gtk2_ardour/ardour_spacer.h | 8 ++++---- gtk2_ardour/audio_clock.cc | 3 ++- gtk2_ardour/audio_clock.h | 2 +- gtk2_ardour/button_joiner.cc | 3 ++- gtk2_ardour/button_joiner.h | 2 +- gtk2_ardour/editor_summary.cc | 3 ++- gtk2_ardour/editor_summary.h | 2 +- gtk2_ardour/export_report.h | 10 +++++----- gtk2_ardour/group_tabs.cc | 3 ++- gtk2_ardour/group_tabs.h | 2 +- gtk2_ardour/led.cc | 3 ++- gtk2_ardour/led.h | 2 +- gtk2_ardour/mini_timeline.cc | 3 ++- gtk2_ardour/mini_timeline.h | 2 +- gtk2_ardour/shuttle_control.cc | 3 ++- gtk2_ardour/shuttle_control.h | 2 +- libs/canvas/widget.cc | 2 +- libs/gtkmm2ext/cairo_widget.cc | 4 ++-- libs/gtkmm2ext/fader.cc | 3 ++- libs/gtkmm2ext/fastmeter.cc | 6 +++--- libs/gtkmm2ext/gtkmm2ext/cairo_widget.h | 7 +------ libs/gtkmm2ext/gtkmm2ext/fader.h | 2 +- libs/gtkmm2ext/gtkmm2ext/fastmeter.h | 2 +- libs/gtkmm2ext/gtkmm2ext/pixfader.h | 2 +- libs/gtkmm2ext/pixfader.cc | 4 +++- libs/gtkmm2ext/waves_fastmeter.cc | 6 +++--- 30 files changed, 55 insertions(+), 49 deletions(-) diff --git a/gtk2_ardour/ardour_button.cc b/gtk2_ardour/ardour_button.cc index 21330014a5..98c54e409f 100644 --- a/gtk2_ardour/ardour_button.cc +++ b/gtk2_ardour/ardour_button.cc @@ -44,7 +44,6 @@ #define BASELINESTRETCH (1.25) #define TRACKHEADERBTNW (3.10) -using namespace Gdk; using namespace Gtk; using namespace Glib; using namespace PBD; @@ -256,8 +255,10 @@ ArdourButton::set_alignment (const float xa, const float ya) * ARDOUR_UI_UTILS::render_vector_icon() */ void -ArdourButton::render (cairo_t* cr, cairo_rectangle_t *) +ArdourButton::render (Cairo::RefPtr const& ctx, cairo_rectangle_t*) { + cairo_t* cr = ctx->cobj(); + uint32_t text_color; uint32_t led_color; diff --git a/gtk2_ardour/ardour_button.h b/gtk2_ardour/ardour_button.h index ddee6ce8d4..edccfd209f 100644 --- a/gtk2_ardour/ardour_button.h +++ b/gtk2_ardour/ardour_button.h @@ -127,7 +127,7 @@ class ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable float char_avg_pixel_width() { if (_char_pixel_width < 1) recalc_char_pixel_geometry() ; return _char_avg_pixel_width; } protected: - void render (cairo_t *, cairo_rectangle_t *); + void render (Cairo::RefPtr const&, cairo_rectangle_t*); void on_size_request (Gtk::Requisition* req); void on_size_allocate (Gtk::Allocation&); void on_style_changed (const Glib::RefPtr&); diff --git a/gtk2_ardour/ardour_knob.cc b/gtk2_ardour/ardour_knob.cc index cf9eaced57..dbea277a1b 100644 --- a/gtk2_ardour/ardour_knob.cc +++ b/gtk2_ardour/ardour_knob.cc @@ -46,7 +46,6 @@ #include "pbd/i18n.h" using namespace Gtkmm2ext; -using namespace Gdk; using namespace Gtk; using namespace Glib; using namespace PBD; @@ -79,8 +78,9 @@ ArdourKnob::~ArdourKnob() } void -ArdourKnob::render (cairo_t* cr, cairo_rectangle_t *) +ArdourKnob::render (Cairo::RefPtr const& ctx, cairo_rectangle_t*) { + cairo_t* cr = ctx->cobj(); cairo_pattern_t* shade_pattern; float width = get_width(); diff --git a/gtk2_ardour/ardour_knob.h b/gtk2_ardour/ardour_knob.h index ede200f4b1..689c5fb67b 100644 --- a/gtk2_ardour/ardour_knob.h +++ b/gtk2_ardour/ardour_knob.h @@ -91,7 +91,7 @@ public: void color_handler (); protected: - void render (cairo_t *, cairo_rectangle_t *); + void render (Cairo::RefPtr const&, cairo_rectangle_t*); void on_size_request (Gtk::Requisition* req); void on_size_allocate (Gtk::Allocation&); void on_style_changed (const Glib::RefPtr&); diff --git a/gtk2_ardour/ardour_spacer.h b/gtk2_ardour/ardour_spacer.h index b2fdd56a34..28d2f1c378 100644 --- a/gtk2_ardour/ardour_spacer.h +++ b/gtk2_ardour/ardour_spacer.h @@ -27,12 +27,12 @@ public: ArdourVSpacer (float r = 0.75f) : CairoWidget (), ratio (r) {} protected: - void render (cairo_t* cr, cairo_rectangle_t* r) { + void render (Cairo::RefPtr const& ctx, cairo_rectangle_t* r) { float h = r->height * ratio; float t = .5f * (r->height - h); - cairo_rectangle (cr, 0, t, 1, h); - cairo_set_source_rgb (cr, 0, 0, 0); - cairo_fill (cr); + ctx->rectangle (0, t, 1, h); + ctx->set_source_rgb (0, 0, 0); + ctx->fill (); } void on_size_request (Gtk::Requisition* req) { diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index b21d327201..70d5b3a713 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -275,8 +275,9 @@ AudioClock::set_scale (double x, double y) } void -AudioClock::render (cairo_t* cr, cairo_rectangle_t*) +AudioClock::render (Cairo::RefPtr const& ctx, cairo_rectangle_t*) { + cairo_t* cr = ctx->cobj(); /* main layout: rounded rect, plus the text */ if (_need_bg) { diff --git a/gtk2_ardour/audio_clock.h b/gtk2_ardour/audio_clock.h index 6b8c31d5ad..3336f9e2bd 100644 --- a/gtk2_ardour/audio_clock.h +++ b/gtk2_ardour/audio_clock.h @@ -102,7 +102,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr static std::vector clocks; protected: - void render (cairo_t*, cairo_rectangle_t*); + void render (Cairo::RefPtr const&, cairo_rectangle_t*); bool get_is_duration () const { return is_duration; } ; virtual void build_ops_menu (); diff --git a/gtk2_ardour/button_joiner.cc b/gtk2_ardour/button_joiner.cc index a3ef36ac80..eaa22363aa 100644 --- a/gtk2_ardour/button_joiner.cc +++ b/gtk2_ardour/button_joiner.cc @@ -101,8 +101,9 @@ ButtonJoiner::~ButtonJoiner () } void -ButtonJoiner::render (cairo_t* cr, cairo_rectangle_t*) +ButtonJoiner::render (Cairo::RefPtr const& ctx, cairo_rectangle_t*) { + cairo_t* cr = ctx->cobj(); double h = get_height(); if (!get_active()) { diff --git a/gtk2_ardour/button_joiner.h b/gtk2_ardour/button_joiner.h index 41e5f745c0..1010ea1c46 100644 --- a/gtk2_ardour/button_joiner.h +++ b/gtk2_ardour/button_joiner.h @@ -36,7 +36,7 @@ class ButtonJoiner : public CairoWidget, public Gtkmm2ext::Activatable { void set_active_state (Gtkmm2ext::ActiveState); protected: - void render (cairo_t*, cairo_rectangle_t*); + void render (Cairo::RefPtr const&, cairo_rectangle_t*); bool on_button_release_event (GdkEventButton*); void on_size_request (Gtk::Requisition*); void on_size_allocate (Gtk::Allocation&); diff --git a/gtk2_ardour/editor_summary.cc b/gtk2_ardour/editor_summary.cc index 66e387299b..4a238259ef 100644 --- a/gtk2_ardour/editor_summary.cc +++ b/gtk2_ardour/editor_summary.cc @@ -211,8 +211,9 @@ EditorSummary::render_background_image () * @param cr Context. */ void -EditorSummary::render (cairo_t* cr, cairo_rectangle_t*) +EditorSummary::render (Cairo::RefPtr const& ctx, cairo_rectangle_t*) { + cairo_t* cr = ctx->cobj(); if (_session == 0) { return; diff --git a/gtk2_ardour/editor_summary.h b/gtk2_ardour/editor_summary.h index 4fb406a9ab..48b1ab9378 100644 --- a/gtk2_ardour/editor_summary.h +++ b/gtk2_ardour/editor_summary.h @@ -73,7 +73,7 @@ private: bool on_leave_notify_event (GdkEventCrossing*); void centre_on_click (GdkEventButton *); - void render (cairo_t *, cairo_rectangle_t*); + void render (Cairo::RefPtr const&, cairo_rectangle_t*); void render_region (RegionView*, cairo_t*, double) const; void get_editor (std::pair *, std::pair *) const; void set_editor (double, double); diff --git a/gtk2_ardour/export_report.h b/gtk2_ardour/export_report.h index 65339be701..4639cafc44 100644 --- a/gtk2_ardour/export_report.h +++ b/gtk2_ardour/export_report.h @@ -46,12 +46,12 @@ protected: virtual void overlay (cairo_t* cr, cairo_rectangle_t* r) {} - virtual void render (cairo_t* cr, cairo_rectangle_t* r) + virtual void render (Cairo::RefPtr const& ctx, cairo_rectangle_t* r) { - cairo_rectangle (cr, r->x, r->y, r->width, r->height); - cairo_clip (cr); - background (cr, r); - overlay (cr, r); + ctx->rectangle (r->x, r->y, r->width, r->height); + ctx->clip (); + background (ctx->cobj(), r); + overlay (ctx->cobj(), r); } Cairo::RefPtr _surface; diff --git a/gtk2_ardour/group_tabs.cc b/gtk2_ardour/group_tabs.cc index 85a4dc8d20..ef01293575 100644 --- a/gtk2_ardour/group_tabs.cc +++ b/gtk2_ardour/group_tabs.cc @@ -241,8 +241,9 @@ GroupTabs::on_button_release_event (GdkEventButton*) } void -GroupTabs::render (cairo_t* cr, cairo_rectangle_t*) +GroupTabs::render (Cairo::RefPtr const& ctx, cairo_rectangle_t*) { + cairo_t* cr = ctx->cobj(); if (_dragging == 0) { _tabs = compute_tabs (); } diff --git a/gtk2_ardour/group_tabs.h b/gtk2_ardour/group_tabs.h index eadc19cc6c..c635cff825 100644 --- a/gtk2_ardour/group_tabs.h +++ b/gtk2_ardour/group_tabs.h @@ -115,7 +115,7 @@ private: void disable_all (); void remove_group (ARDOUR::RouteGroup *); - void render (cairo_t *, cairo_rectangle_t*); + void render (Cairo::RefPtr const&, cairo_rectangle_t*); void on_size_request (Gtk::Requisition *); bool on_button_press_event (GdkEventButton *); bool on_motion_notify_event (GdkEventMotion *); diff --git a/gtk2_ardour/led.cc b/gtk2_ardour/led.cc index dca5caefc1..6112f9c429 100644 --- a/gtk2_ardour/led.cc +++ b/gtk2_ardour/led.cc @@ -42,8 +42,9 @@ LED::~LED() } void -LED::render (cairo_t* cr, cairo_rectangle_t*) +LED::render (Cairo::RefPtr const& ctx, cairo_rectangle_t*) { + cairo_t* cr = ctx->cobj(); if (!_fixed_diameter) { _diameter = std::min (get_width(), get_height()); } diff --git a/gtk2_ardour/led.h b/gtk2_ardour/led.h index ef5ae7b68d..67f4a9bb3c 100644 --- a/gtk2_ardour/led.h +++ b/gtk2_ardour/led.h @@ -33,7 +33,7 @@ class LED : public CairoWidget void set_diameter (float); protected: - void render (cairo_t *, cairo_rectangle_t*); + void render (Cairo::RefPtr const&, cairo_rectangle_t*); void on_size_request (Gtk::Requisition* req); void on_realize (); diff --git a/gtk2_ardour/mini_timeline.cc b/gtk2_ardour/mini_timeline.cc index 09506066f8..28fbe0f4a5 100644 --- a/gtk2_ardour/mini_timeline.cc +++ b/gtk2_ardour/mini_timeline.cc @@ -405,8 +405,9 @@ struct LocationMarkerSort { }; void -MiniTimeline::render (cairo_t* cr, cairo_rectangle_t*) +MiniTimeline::render (Cairo::RefPtr const& ctx, cairo_rectangle_t*) { + cairo_t* cr = ctx->cobj(); // TODO cache, set_colors() ArdourCanvas::Color base = UIConfiguration::instance().color ("ruler base"); ArdourCanvas::Color text = UIConfiguration::instance().color ("ruler text"); diff --git a/gtk2_ardour/mini_timeline.h b/gtk2_ardour/mini_timeline.h index c6dea5326b..42d41ddd81 100644 --- a/gtk2_ardour/mini_timeline.h +++ b/gtk2_ardour/mini_timeline.h @@ -67,7 +67,7 @@ private: void draw_dots (cairo_t*, int left, int right, int y, ArdourCanvas::Color); int draw_mark (cairo_t*, int x0, int x1, const std::string&, bool& prelight); - void render (cairo_t*, cairo_rectangle_t*); + void render (Cairo::RefPtr const&, cairo_rectangle_t*); void format_time (framepos_t when); bool on_button_press_event (GdkEventButton*); diff --git a/gtk2_ardour/shuttle_control.cc b/gtk2_ardour/shuttle_control.cc index 010ac2d119..d4936098d0 100644 --- a/gtk2_ardour/shuttle_control.cc +++ b/gtk2_ardour/shuttle_control.cc @@ -570,8 +570,9 @@ ShuttleControl::set_colors () } void -ShuttleControl::render (cairo_t* cr, cairo_rectangle_t*) +ShuttleControl::render (Cairo::RefPtr const& ctx, cairo_rectangle_t*) { + cairo_t* cr = ctx->cobj(); // center slider line float yc = get_height() / 2; float lw = 3; diff --git a/gtk2_ardour/shuttle_control.h b/gtk2_ardour/shuttle_control.h index 62a55ab846..f7d3bd3601 100644 --- a/gtk2_ardour/shuttle_control.h +++ b/gtk2_ardour/shuttle_control.h @@ -93,7 +93,7 @@ protected: bool on_scroll_event (GdkEventScroll*); bool on_motion_notify_event(GdkEventMotion*); - void render (cairo_t *, cairo_rectangle_t*); + void render (Cairo::RefPtr const&, cairo_rectangle_t*); void on_size_allocate (Gtk::Allocation&); bool on_query_tooltip (int, int, bool, const Glib::RefPtr&); diff --git a/libs/canvas/widget.cc b/libs/canvas/widget.cc index 4c98d6651d..5968de5fbb 100644 --- a/libs/canvas/widget.cc +++ b/libs/canvas/widget.cc @@ -104,7 +104,7 @@ Widget::render (Rect const & area, Cairo::RefPtr context) const //context->rectangle (draw.x0, draw.y0, draw.width(), draw.height()); //context->clip (); - _widget.render (context->cobj(), &crect); + _widget.render (context, &crect); context->restore (); } diff --git a/libs/gtkmm2ext/cairo_widget.cc b/libs/gtkmm2ext/cairo_widget.cc index 088e21b6a8..d06f07ced2 100644 --- a/libs/gtkmm2ext/cairo_widget.cc +++ b/libs/gtkmm2ext/cairo_widget.cc @@ -195,7 +195,7 @@ CairoWidget::on_expose_event (GdkEventExpose *ev) cr->fill (); } - render (cr->cobj(), &expose_area); + render (cr, &expose_area); #ifdef USE_CAIRO_IMAGE_SURFACE_FOR_CAIRO_WIDGET if(get_visible_window ()) { @@ -283,7 +283,7 @@ CairoWidget::on_expose_event (GdkEventExpose *ev) expose_area.width = ev->area.width; expose_area.height = ev->area.height; - render (cr->cobj(), &expose_area); + render (cr, &expose_area); #ifdef OPTIONAL_CAIRO_IMAGE_SURFACE if (getenv("ARDOUR_IMAGE_SURFACE")) { diff --git a/libs/gtkmm2ext/fader.cc b/libs/gtkmm2ext/fader.cc index f6fe487ed1..899e0a886f 100644 --- a/libs/gtkmm2ext/fader.cc +++ b/libs/gtkmm2ext/fader.cc @@ -184,8 +184,9 @@ Fader::set_touch_cursor (const Glib::RefPtr& touch_cursor) } void -Fader::render (cairo_t* cr, cairo_rectangle_t*) +Fader::render (Cairo::RefPtr const& ctx, cairo_rectangle_t*) { + cairo_t* cr = ctx->cobj(); double xscale = 1.0; double yscale = 1.0; diff --git a/libs/gtkmm2ext/fastmeter.cc b/libs/gtkmm2ext/fastmeter.cc index f3928910bc..c2275eab9f 100644 --- a/libs/gtkmm2ext/fastmeter.cc +++ b/libs/gtkmm2ext/fastmeter.cc @@ -544,12 +544,12 @@ FastMeter::horizontal_size_allocate (Gtk::Allocation &alloc) } void -FastMeter::render (cairo_t* cr, cairo_rectangle_t* area) +FastMeter::render (Cairo::RefPtr const& ctx, cairo_rectangle_t* area) { if (orientation == Vertical) { - return vertical_expose (cr, area); + return vertical_expose (ctx->cobj(), area); } else { - return horizontal_expose (cr, area); + return horizontal_expose (ctx->cobj(), area); } } diff --git a/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h b/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h index 3b8fc545a9..6d8c1f5d55 100644 --- a/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h +++ b/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h @@ -20,6 +20,7 @@ #ifndef __gtk2_ardour_cairo_widget_h__ #define __gtk2_ardour_cairo_widget_h__ +#include #include #include @@ -81,12 +82,6 @@ public: static void provide_background_for_cairo_widget (Gtk::Widget& w, const Gdk::Color& bg); - virtual void render (cairo_t *, cairo_rectangle_t*) = 0; - - virtual void render (Cairo::RefPtr const & ctx, cairo_rectangle_t* r) { - render (ctx->cobj(), r); - } - uint32_t background_color (); static void set_flat_buttons (bool yn); diff --git a/libs/gtkmm2ext/gtkmm2ext/fader.h b/libs/gtkmm2ext/gtkmm2ext/fader.h index e82771901c..ec6df5384b 100644 --- a/libs/gtkmm2ext/gtkmm2ext/fader.h +++ b/libs/gtkmm2ext/gtkmm2ext/fader.h @@ -62,7 +62,7 @@ class LIBGTKMM2EXT_API Fader : public CairoWidget void on_size_request (GtkRequisition*); void on_size_allocate (Gtk::Allocation& alloc); - void render (cairo_t* cr, cairo_rectangle_t*); + void render (Cairo::RefPtr const&, cairo_rectangle_t*); bool on_button_press_event (GdkEventButton*); bool on_button_release_event (GdkEventButton*); bool on_motion_notify_event (GdkEventMotion*); diff --git a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h index dbb3296c46..7b71289d3e 100644 --- a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h +++ b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h @@ -65,9 +65,9 @@ class LIBGTKMM2EXT_API FastMeter : public CairoWidget { void set_hold_count (long); void set_highlight (bool); bool get_highlight () { return highlight; } + void render (Cairo::RefPtr const&, cairo_rectangle_t*); protected: - void render (cairo_t *, cairo_rectangle_t*); void on_size_request (GtkRequisition*); void on_size_allocate (Gtk::Allocation&); private: diff --git a/libs/gtkmm2ext/gtkmm2ext/pixfader.h b/libs/gtkmm2ext/gtkmm2ext/pixfader.h index c5ed9c585c..5454ac53be 100644 --- a/libs/gtkmm2ext/gtkmm2ext/pixfader.h +++ b/libs/gtkmm2ext/gtkmm2ext/pixfader.h @@ -58,7 +58,7 @@ class LIBGTKMM2EXT_API PixFader : public CairoWidget void on_size_request (GtkRequisition*); void on_size_allocate (Gtk::Allocation& alloc); - void render (cairo_t *, cairo_rectangle_t*); + void render (Cairo::RefPtr const&, cairo_rectangle_t*); bool on_grab_broken_event (GdkEventGrabBroken*); bool on_button_press_event (GdkEventButton*); bool on_button_release_event (GdkEventButton*); diff --git a/libs/gtkmm2ext/pixfader.cc b/libs/gtkmm2ext/pixfader.cc index 64ee449646..23510e824e 100644 --- a/libs/gtkmm2ext/pixfader.cc +++ b/libs/gtkmm2ext/pixfader.cc @@ -205,8 +205,10 @@ PixFader::create_patterns () } void -PixFader::render (cairo_t *cr, cairo_rectangle_t* area) +PixFader::render (Cairo::RefPtr const& ctx, cairo_rectangle_t* area) { + cairo_t* cr = ctx->cobj(); + if (!_pattern) { create_patterns(); } diff --git a/libs/gtkmm2ext/waves_fastmeter.cc b/libs/gtkmm2ext/waves_fastmeter.cc index e6b973b130..f290e6ce64 100644 --- a/libs/gtkmm2ext/waves_fastmeter.cc +++ b/libs/gtkmm2ext/waves_fastmeter.cc @@ -542,12 +542,12 @@ FastMeter::horizontal_size_allocate (Gtk::Allocation &alloc) } void -FastMeter::render (cairo_t* cr, cairo_rectangle_t* area) +FastMeter::render (Cairo::RefPtr const& ctx, cairo_rectangle_t* area) { if (orientation == Vertical) { - return vertical_expose (cr, area); + return vertical_expose (cr->cobj(), area); } else { - return horizontal_expose (cr, area); + return horizontal_expose (cr->cobj(), area); } }