From 384530984a59f0703bf75b495de1c1a8c5949965 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 3 Sep 2022 16:18:02 -0600 Subject: [PATCH] canvas: make "debug_render" into a per-canvas member variable This allows us to debug rendering in specific canvases, rather than all of them. --- libs/canvas/canvas.cc | 5 ++--- libs/canvas/canvas/canvas.h | 3 +++ libs/canvas/item.cc | 13 ++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libs/canvas/canvas.cc b/libs/canvas/canvas.cc index 188f81b2cf..821a94972e 100644 --- a/libs/canvas/canvas.cc +++ b/libs/canvas/canvas.cc @@ -57,6 +57,7 @@ Canvas::Canvas () : _root (this) , _queue_draw_frozen (0) , _bg_color (Gtkmm2ext::rgba_to_color (0, 1.0, 0.0, 1.0)) + , _debug_render (false) , _last_render_start_timestamp(0) , _use_intermediate_surface (false) { @@ -109,8 +110,6 @@ Canvas::zoomed () pick_current_item (0); // no current mouse position } -static bool debug_render = false; - #ifndef NDEBUG #ifdef CANVAS_DEBUG #undef CANVAS_DEBUG @@ -130,7 +129,7 @@ Canvas::render (Rect const & area, Cairo::RefPtr const & context _last_render_start_timestamp = g_get_monotonic_time(); #ifdef CANVAS_DEBUG - if (debug_render || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { + if (_debug_render || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { cerr << this << " RENDER: " << area << endl; cerr << "CANVAS @ " << this << endl; dump (cerr); diff --git a/libs/canvas/canvas/canvas.h b/libs/canvas/canvas/canvas.h index 32d12c3eb2..fa927794a1 100644 --- a/libs/canvas/canvas/canvas.h +++ b/libs/canvas/canvas/canvas.h @@ -186,11 +186,14 @@ public: */ void use_intermediate_surface (bool yn = true); + void set_debug_render (bool yn) { _debug_render = yn; } + bool debug_render() const { return _debug_render; } protected: Root _root; uint32_t _queue_draw_frozen; Rect frozen_area; Gtkmm2ext::Color _bg_color; + bool _debug_render; mutable gint64 _last_render_start_timestamp; diff --git a/libs/canvas/item.cc b/libs/canvas/item.cc index 3800fdc847..8728d83b04 100644 --- a/libs/canvas/item.cc +++ b/libs/canvas/item.cc @@ -866,7 +866,6 @@ Item::covers (Duple const & point) const /* nesting/grouping API */ -static bool debug_render = false; #define CANVAS_DEBUG 1 void @@ -880,8 +879,8 @@ Item::render_children (Rect const & area, Cairo::RefPtr context) std::vector items = _lut->get (area); #ifdef CANVAS_DEBUG - if (debug_render || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { - cerr << string_compose ("%1%8 %2 @ %7 render %5 @ %6 %3 items out of %4\n", + if (_canvas->debug_render() || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { + cerr << string_compose (">>>> %1%8 %2 @ %7 render %5 @ %6 %3 items out of %4\n", _canvas->render_indent(), (name.empty() ? string ("[unnamed]") : name), items.size(), _items.size(), area, _position, 0 /* this */, whatami()); } @@ -893,7 +892,7 @@ Item::render_children (Rect const & area, Cairo::RefPtr context) if (!(*i)->visible ()) { #ifdef CANVAS_DEBUG - if (debug_render || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { + if (_canvas->debug_render() || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { cerr << _canvas->render_indent() << "Item " << (*i)->whoami() << " invisible - skipped\n"; } #endif @@ -904,7 +903,7 @@ Item::render_children (Rect const & area, Cairo::RefPtr context) if (!item_bbox) { #ifdef CANVAS_DEBUG - if (debug_render || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { + if (_canvas->debug_render() || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { cerr << _canvas->render_indent() << "Item " << (*i)->whoami() << " empty - skipped\n"; } #endif @@ -918,7 +917,7 @@ Item::render_children (Rect const & area, Cairo::RefPtr context) Rect draw = d; if (draw.width() && draw.height()) { #ifdef CANVAS_DEBUG - if (debug_render || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { + if (_canvas->debug_render() || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { if (dynamic_cast(*i) == 0) { cerr << _canvas->render_indent() << "render " << ' ' @@ -945,7 +944,7 @@ Item::render_children (Rect const & area, Cairo::RefPtr context) } else { #ifdef CANVAS_DEBUG - if (debug_render || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { + if (_canvas->debug_render() || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { cerr << string_compose ("%1skip render of %2, no intersection between %3 and %4\n", _canvas->render_indent(), (*i)->whoami(), item, area); } #endif