Example #1
0
static void
prepare_text(struct lstopo_output *loutput, hwloc_obj_t obj)
{
  struct lstopo_obj_userdata *lud = obj->userdata;
  unsigned fontsize = loutput->fontsize;
  int n;

  /* sane defaults */
  lud->ntext = 0;
  lud->textwidth = 0;
  lud->textxoffset = 0;

  if (!fontsize)
    return;

  /* main object identifier line */
  if (obj->type == HWLOC_OBJ_PCI_DEVICE && loutput->show_attrs[HWLOC_OBJ_PCI_DEVICE]) {
    /* PCI text collapsing */
    char busid[32];
    char _text[64];
    lstopo_obj_snprintf(loutput, _text, sizeof(_text), obj);
    lstopo_busid_snprintf(busid, sizeof(busid), obj, lud->pci_collapsed, loutput->need_pci_domain);
    if (lud->pci_collapsed > 1) {
      n = snprintf(lud->text[0], sizeof(lud->text[0]), "%d x { %s %s }", lud->pci_collapsed, _text, busid);
    } else {
      n = snprintf(lud->text[0], sizeof(lud->text[0]), "%s %s", _text, busid);
    }
  } else {
    /* normal object text */
    n = lstopo_obj_snprintf(loutput, lud->text[0], sizeof(lud->text[0]), obj);
  }
  lud->textwidth = get_textwidth(loutput, lud->text[0], n, fontsize);
  lud->ntext = 1;

  if (obj->type == HWLOC_OBJ_PU) {
    /* if smaller than other PU, artificially extend/shift it
     * to make PU boxes nicer when vertically stacked.
     */
    if (lud->textwidth < loutput->min_pu_textwidth) {
      lud->textxoffset = (loutput->min_pu_textwidth - lud->textwidth) / 2;
      lud->textwidth = loutput->min_pu_textwidth;
    }
  }

  /* additional text */
  prepare_more_text(loutput, obj);
}
Example #2
0
static void
pci_device_draw(struct lstopo_output *loutput, struct draw_methods *methods, hwloc_obj_t level, unsigned depth, unsigned x, unsigned *retwidth, unsigned y, unsigned *retheight)
{
  hwloc_topology_t topology = loutput->topology;
  int logical = loutput->logical;
  unsigned gridsize = loutput->gridsize;
  unsigned fontsize = loutput->fontsize;
  unsigned textwidth = gridsize;
  unsigned textheight = (fontsize ? fontsize + gridsize : 0);
  unsigned myheight = textheight;
  unsigned mywidth = 0;
  unsigned totwidth, totheight;
  unsigned overlaidoffset = 0;
  struct style style;
  char text[64], _text[64];
  const char *collapsestr = hwloc_obj_get_info_by_name(level, "lstopoCollapse");
  unsigned collapse = collapsestr ? atoi(collapsestr) : 1;
  int n;

  DYNA_CHECK();

  if (fontsize) {
    char busid[32];
    lstopo_obj_snprintf(_text, sizeof(_text), level, logical);
    lstopo_busid_snprintf(busid, sizeof(busid), level, collapse, topology->pci_nonzero_domains);
    if (collapse > 1) {
      n = snprintf(text, sizeof(text), "%u x { %s %s }", collapse, _text, busid);
    } else {
      n = snprintf(text, sizeof(text), "%s %s", _text, busid);
    }
    textwidth = get_textwidth(loutput, methods, text, n, fontsize, gridsize);
  }

  if (collapse > 1) {
    /* additional depths and height for overlaid boxes */
    depth -= 2;
    if (collapse > 2) {
      overlaidoffset = gridsize;
    } else {
      overlaidoffset = gridsize/2;
    }
    textwidth += overlaidoffset;
    textheight += overlaidoffset;
    myheight = textheight;
  }

  RECURSE_RECT(level, &null_draw_methods, gridsize, gridsize);

  lstopo_set_object_color(methods, topology, level, 0, &style);

  if (collapse > 1) {
    methods->box(loutput, style.bg.r, style.bg.g, style.bg.b, depth+2, x + overlaidoffset, *retwidth - overlaidoffset, y + overlaidoffset, *retheight - overlaidoffset);
    if (collapse > 2)
      methods->box(loutput, style.bg.r, style.bg.g, style.bg.b, depth+1, x + overlaidoffset/2, *retwidth - overlaidoffset, y + overlaidoffset/2, *retheight - overlaidoffset);
    methods->box(loutput, style.bg.r, style.bg.g, style.bg.b, depth, x, *retwidth - overlaidoffset, y, *retheight - overlaidoffset);
  } else {
    methods->box(loutput, style.bg.r, style.bg.g, style.bg.b, depth, x, *retwidth, y, *retheight);
  }

  if (fontsize)
    methods->text(loutput, style.t.r, style.t.g, style.t.b, fontsize, depth-1, x + gridsize, y + gridsize, text);

  RECURSE_RECT(level, methods, gridsize, gridsize);

  DYNA_SAVE();
}