Skip to content

Commit 111af75

Browse files
committed
contrib/android: disambiguate multiple box IDs to fix the text in collapsed PCI devices
Each box is now obj->gp_index*100+box_id Signed-off-by: Brice Goglin <[email protected]>
1 parent fc01868 commit 111af75

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

utils/lstopo/lstopo-android.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ extern void JNIprepare(int width, int height, int fontsize);
2121
#define ANDROID_TEXT_WIDTH(length, fontsize) (((length) * (fontsize))/2)
2222
#define ANDROID_FONTSIZE_SCALE(size) (((size) * 11) / 9)
2323

24-
static void native_android_box(struct lstopo_output *loutput, const struct lstopo_color *lcolor, unsigned depth __hwloc_attribute_unused, unsigned x, unsigned width, unsigned y, unsigned height, hwloc_obj_t obj, unsigned box_id __hwloc_attribute_unused)
24+
#define GP_INDEX_MULTIPLIER 100 /* there can be multiple boxes per object, so multiple gp_index by 100 and add the box_id to get a unique box ID */
25+
26+
static void native_android_box(struct lstopo_output *loutput, const struct lstopo_color *lcolor, unsigned depth __hwloc_attribute_unused, unsigned x, unsigned width, unsigned y, unsigned height, hwloc_obj_t obj, unsigned box_id)
2527
{
2628
unsigned cpukind_style = lstopo_obj_cpukind_style(loutput, obj);
27-
int gp_index = -1;
29+
int viewid = -1;
2830
int r = lcolor->r, g = lcolor->g, b = lcolor->b;
2931
char * info = malloc(1096);
3032
const char * sep = " ";
@@ -34,14 +36,14 @@ static void native_android_box(struct lstopo_output *loutput, const struct lstop
3436
/* we could remove this info for factorized objects and bridges,
3537
* but it pretty much doesn't appear at all anyway because it's in the very small bow.
3638
*/
37-
gp_index = obj->gp_index;
39+
viewid = obj->gp_index * GP_INDEX_MULTIPLIER + box_id;
3840
hwloc_obj_attr_snprintf(info, 1096, obj, sep, HWLOC_OBJ_SNPRINTF_FLAG_LONG_NAMES|HWLOC_OBJ_SNPRINTF_FLAG_MORE_ATTRS);
3941
}
4042

4143
if (cpukind_style)
4244
style = cpukind_style;
4345

44-
JNIbox(r, g, b, x, y, width, height, style, gp_index, info);
46+
JNIbox(r, g, b, x, y, width, height, style, viewid, info);
4547
//Creating a usable java string from char * may trigger an UTF-8 error
4648
//This code creates a byte array from the char * variable before creating the java string
4749
}
@@ -65,13 +67,13 @@ static void
6567
native_android_text(struct lstopo_output *loutput, const struct lstopo_color *lcolor __hwloc_attribute_unused, int size __hwloc_attribute_unused, unsigned depth __hwloc_attribute_unused, unsigned x, unsigned y, const char *text, hwloc_obj_t obj, unsigned text_id __hwloc_attribute_unused)
6668
{
6769
unsigned cpukind_style = lstopo_obj_cpukind_style(loutput, obj);
68-
int gp_index = -1;
70+
int viewid = -1;
6971
int bold = 0;
7072
int outside = 0;
7173

7274
if(obj) {
7375
struct lstopo_obj_userdata *lud = obj->userdata;
74-
gp_index = obj->gp_index;
76+
viewid = obj->gp_index * GP_INDEX_MULTIPLIER;
7577
/* no info box in small boxes */
7678
if (loutput->factorize_enabled
7779
&& lud->factorized == 1
@@ -84,7 +86,7 @@ native_android_text(struct lstopo_output *loutput, const struct lstopo_color *lc
8486
if (cpukind_style % 2)
8587
bold = 1;
8688

87-
JNItext((char *)text, gp_index, x, y, loutput->fontsize, bold, outside);
89+
JNItext((char *)text, viewid, x, y, loutput->fontsize, bold, outside);
8890
}
8991

9092
static struct draw_methods native_android_draw_methods = {

0 commit comments

Comments
 (0)