Canvas: temporary easy way to get debug output from Canvas::render() in a test program

This commit is contained in:
Paul Davis 2020-06-24 18:11:37 -06:00
parent 427998e2d2
commit f5d67e6520
2 changed files with 18 additions and 10 deletions

View file

@ -108,6 +108,9 @@ Canvas::zoomed ()
pick_current_item (0); // no current mouse position pick_current_item (0); // no current mouse position
} }
static bool debug_render = true;
#define CANVAS_DEBUG
/** Render an area of the canvas. /** Render an area of the canvas.
* @param area Area in window coordinates. * @param area Area in window coordinates.
* @param context Cairo context to render to. * @param context Cairo context to render to.
@ -120,7 +123,7 @@ Canvas::render (Rect const & area, Cairo::RefPtr<Cairo::Context> const & context
_last_render_start_timestamp = g_get_monotonic_time(); _last_render_start_timestamp = g_get_monotonic_time();
#ifdef CANVAS_DEBUG #ifdef CANVAS_DEBUG
if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { if (debug_render || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
cerr << this << " RENDER: " << area << endl; cerr << this << " RENDER: " << area << endl;
//cerr << "CANVAS @ " << this << endl; //cerr << "CANVAS @ " << this << endl;
//dump (cerr); //dump (cerr);
@ -133,6 +136,7 @@ Canvas::render (Rect const & area, Cairo::RefPtr<Cairo::Context> const & context
Rect root_bbox = _root.bounding_box(); Rect root_bbox = _root.bounding_box();
if (!root_bbox) { if (!root_bbox) {
/* the root has no bounding box, so there's nothing to render */ /* the root has no bounding box, so there's nothing to render */
cerr << "no bbox\n";
return; return;
} }
@ -143,6 +147,7 @@ Canvas::render (Rect const & area, Cairo::RefPtr<Cairo::Context> const & context
area, so render it. area, so render it.
*/ */
cerr << "root draw\n";
_root.render (draw, context); _root.render (draw, context);
#if defined CANVAS_DEBUG && !PLATFORM_WINDOWS #if defined CANVAS_DEBUG && !PLATFORM_WINDOWS

View file

@ -747,9 +747,14 @@ Item::covers (Duple const & point) const
/* nesting/grouping API */ /* nesting/grouping API */
static bool debug_render = true;
#define CANVAS_DEBUG 1
void void
Item::render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const Item::render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{ {
cerr << "I::rc\n";
if (_items.empty()) { if (_items.empty()) {
return; return;
} }
@ -758,7 +763,7 @@ Item::render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context)
std::vector<Item*> items = _lut->get (area); std::vector<Item*> items = _lut->get (area);
#ifdef CANVAS_DEBUG #ifdef CANVAS_DEBUG
if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { if (debug_render || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
cerr << string_compose ("%1%8 %2 @ %7 render %5 @ %6 %3 items out of %4\n", 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 */, _canvas->render_indent(), (name.empty() ? string ("[unnamed]") : name), items.size(), _items.size(), area, _position, 0 /* this */,
whatami()); whatami());
@ -771,7 +776,7 @@ Item::render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context)
if (!(*i)->visible ()) { if (!(*i)->visible ()) {
#ifdef CANVAS_DEBUG #ifdef CANVAS_DEBUG
if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { if (debug_render || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
cerr << _canvas->render_indent() << "Item " << (*i)->whatami() << " [" << (*i)->name << "] invisible - skipped\n"; cerr << _canvas->render_indent() << "Item " << (*i)->whatami() << " [" << (*i)->name << "] invisible - skipped\n";
} }
#endif #endif
@ -782,7 +787,7 @@ Item::render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context)
if (!item_bbox) { if (!item_bbox) {
#ifdef CANVAS_DEBUG #ifdef CANVAS_DEBUG
if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { if (debug_render || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
cerr << _canvas->render_indent() << "Item " << (*i)->whatami() << " [" << (*i)->name << "] empty - skipped\n"; cerr << _canvas->render_indent() << "Item " << (*i)->whatami() << " [" << (*i)->name << "] empty - skipped\n";
} }
#endif #endif
@ -796,16 +801,13 @@ Item::render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context)
Rect draw = d; Rect draw = d;
if (draw.width() && draw.height()) { if (draw.width() && draw.height()) {
#ifdef CANVAS_DEBUG #ifdef CANVAS_DEBUG
if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { if (debug_render || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
if (dynamic_cast<Container*>(*i) == 0) { if (dynamic_cast<Container*>(*i) == 0) {
cerr << _canvas->render_indent() << "render " cerr << _canvas->render_indent() << "render "
<< ' ' << ' '
<< (*i) << (*i)
<< ' ' << ' '
<< (*i)->whatami() << (*i)->whoami()
<< ' '
<< (*i)->name
<< " item " << " item "
<< item_bbox << item_bbox
<< " window = " << " window = "
@ -826,7 +828,7 @@ Item::render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context)
} else { } else {
#ifdef CANVAS_DEBUG #ifdef CANVAS_DEBUG
if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) { if (debug_render || DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
cerr << string_compose ("%1skip render of %2 %3, no intersection between %4 and %5\n", _canvas->render_indent(), (*i)->whatami(), cerr << string_compose ("%1skip render of %2 %3, no intersection between %4 and %5\n", _canvas->render_indent(), (*i)->whatami(),
(*i)->name, item, area); (*i)->name, item, area);
} }
@ -837,6 +839,7 @@ Item::render_children (Rect const & area, Cairo::RefPtr<Cairo::Context> context)
--render_depth; --render_depth;
} }
#undef CANVAS_DEBUG
void void
Item::prepare_for_render_children (Rect const & area) const Item::prepare_for_render_children (Rect const & area) const