MCPcopy Create free account
hub / github.com/RenderKit/embree / ImFontAtlasBuildPackCustomRects

Function ImFontAtlasBuildPackCustomRects

tutorials/common/imgui/imgui_draw.cpp:2612–2637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2610}
2611
2612void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque)
2613{
2614 stbrp_context* pack_context = (stbrp_context*)stbrp_context_opaque;
2615 IM_ASSERT(pack_context != NULL);
2616
2617 ImVector<ImFontAtlasCustomRect>& user_rects = atlas->CustomRects;
2618 IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong.
2619
2620 ImVector<stbrp_rect> pack_rects;
2621 pack_rects.resize(user_rects.Size);
2622 memset(pack_rects.Data, 0, (size_t)pack_rects.size_in_bytes());
2623 for (int i = 0; i < user_rects.Size; i++)
2624 {
2625 pack_rects[i].w = user_rects[i].Width;
2626 pack_rects[i].h = user_rects[i].Height;
2627 }
2628 stbrp_pack_rects(pack_context, &pack_rects[0], pack_rects.Size);
2629 for (int i = 0; i < pack_rects.Size; i++)
2630 if (pack_rects[i].was_packed)
2631 {
2632 user_rects[i].X = (unsigned short)pack_rects[i].x;
2633 user_rects[i].Y = (unsigned short)pack_rects[i].y;
2634 IM_ASSERT(pack_rects[i].w == user_rects[i].Width && pack_rects[i].h == user_rects[i].Height);
2635 atlas->TexHeight = ImMax(atlas->TexHeight, pack_rects[i].y + pack_rects[i].h);
2636 }
2637}
2638
2639void ImFontAtlasBuildRender8bppRectFromString(ImFontAtlas* atlas, int x, int y, int w, int h, const char* in_str, char in_marker_char, unsigned char in_marker_pixel_value)
2640{

Callers 1

Calls 4

ImMaxFunction · 0.85
size_in_bytesMethod · 0.80
stbrp_pack_rectsFunction · 0.70
resizeMethod · 0.45

Tested by

no test coverage detected