diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-06-21 18:38:33 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-06-21 18:38:33 -0400 |
| commit | 9f61d85fd0fe91f9a17a9f304d67e55f8ae38b2e (patch) | |
| tree | 296126042d3f90e96cc3b7ed809ec534d63fc359 | |
| parent | 13f499f076c67675e6e3022973729b5d906a84e9 (diff) | |
perf ui: Move objdump_line specific stuff out of ui_browser
By adding a ui_browser->refresh_entries() pure virtual member.
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
| -rw-r--r-- | tools/perf/util/newt.c | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c index 9fa5b20d4090..7bdbfd3e24d2 100644 --- a/tools/perf/util/newt.c +++ b/tools/perf/util/newt.c | |||
| @@ -267,6 +267,7 @@ struct ui_browser { | |||
| 267 | void *first_visible_entry, *entries; | 267 | void *first_visible_entry, *entries; |
| 268 | u16 top, left, width, height; | 268 | u16 top, left, width, height; |
| 269 | void *priv; | 269 | void *priv; |
| 270 | unsigned int (*refresh_entries)(struct ui_browser *self); | ||
| 270 | void (*seek)(struct ui_browser *self, | 271 | void (*seek)(struct ui_browser *self, |
| 271 | off_t offset, int whence); | 272 | off_t offset, int whence); |
| 272 | u32 nr_entries; | 273 | u32 nr_entries; |
| @@ -405,26 +406,10 @@ static int objdump_line__show(struct objdump_line *self, struct list_head *head, | |||
| 405 | 406 | ||
| 406 | static int ui_browser__refresh_entries(struct ui_browser *self) | 407 | static int ui_browser__refresh_entries(struct ui_browser *self) |
| 407 | { | 408 | { |
| 408 | struct objdump_line *pos; | 409 | int row; |
| 409 | struct list_head *head = self->entries; | ||
| 410 | struct hist_entry *he = self->priv; | ||
| 411 | int row = 0; | ||
| 412 | int len = he->ms.sym->end - he->ms.sym->start; | ||
| 413 | |||
| 414 | if (self->first_visible_entry == NULL || self->first_visible_entry == self->entries) | ||
| 415 | self->first_visible_entry = head->next; | ||
| 416 | |||
| 417 | pos = list_entry(self->first_visible_entry, struct objdump_line, node); | ||
| 418 | |||
| 419 | list_for_each_entry_from(pos, head, node) { | ||
| 420 | bool current_entry = ui_browser__is_current_entry(self, row); | ||
| 421 | SLsmg_gotorc(self->top + row, self->left); | ||
| 422 | objdump_line__show(pos, head, self->width, | ||
| 423 | he, len, current_entry); | ||
| 424 | if (++row == self->height) | ||
| 425 | break; | ||
| 426 | } | ||
| 427 | 410 | ||
| 411 | newtScrollbarSet(self->sb, self->index, self->nr_entries - 1); | ||
| 412 | row = self->refresh_entries(self); | ||
| 428 | SLsmg_set_color(HE_COLORSET_NORMAL); | 413 | SLsmg_set_color(HE_COLORSET_NORMAL); |
| 429 | SLsmg_fill_region(self->top + row, self->left, | 414 | SLsmg_fill_region(self->top + row, self->left, |
| 430 | self->height - row, self->width, ' '); | 415 | self->height - row, self->width, ' '); |
| @@ -557,6 +542,31 @@ static char *callchain_list__sym_name(struct callchain_list *self, | |||
| 557 | return bf; | 542 | return bf; |
| 558 | } | 543 | } |
| 559 | 544 | ||
| 545 | static unsigned int hist_entry__annotate_browser_refresh(struct ui_browser *self) | ||
| 546 | { | ||
| 547 | struct objdump_line *pos; | ||
| 548 | struct list_head *head = self->entries; | ||
| 549 | struct hist_entry *he = self->priv; | ||
| 550 | int row = 0; | ||
| 551 | int len = he->ms.sym->end - he->ms.sym->start; | ||
| 552 | |||
| 553 | if (self->first_visible_entry == NULL || self->first_visible_entry == self->entries) | ||
| 554 | self->first_visible_entry = head->next; | ||
| 555 | |||
| 556 | pos = list_entry(self->first_visible_entry, struct objdump_line, node); | ||
| 557 | |||
| 558 | list_for_each_entry_from(pos, head, node) { | ||
| 559 | bool current_entry = ui_browser__is_current_entry(self, row); | ||
| 560 | SLsmg_gotorc(self->top + row, self->left); | ||
| 561 | objdump_line__show(pos, head, self->width, | ||
| 562 | he, len, current_entry); | ||
| 563 | if (++row == self->height) | ||
| 564 | break; | ||
| 565 | } | ||
| 566 | |||
| 567 | return row; | ||
| 568 | } | ||
| 569 | |||
| 560 | static void __callchain__append_graph_browser(struct callchain_node *self, | 570 | static void __callchain__append_graph_browser(struct callchain_node *self, |
| 561 | newtComponent tree, u64 total, | 571 | newtComponent tree, u64 total, |
| 562 | int *indexes, int depth) | 572 | int *indexes, int depth) |
| @@ -720,6 +730,7 @@ int hist_entry__tui_annotate(struct hist_entry *self) | |||
| 720 | 730 | ||
| 721 | memset(&browser, 0, sizeof(browser)); | 731 | memset(&browser, 0, sizeof(browser)); |
| 722 | browser.entries = &head; | 732 | browser.entries = &head; |
| 733 | browser.refresh_entries = hist_entry__annotate_browser_refresh; | ||
| 723 | browser.seek = ui_browser__list_head_seek; | 734 | browser.seek = ui_browser__list_head_seek; |
| 724 | browser.priv = self; | 735 | browser.priv = self; |
| 725 | list_for_each_entry(pos, &head, node) { | 736 | list_for_each_entry(pos, &head, node) { |
