Lines Matching defs:atlas
1506 // Build atlas on demand
1697 IM_ASSERT(TexWidth > 0 && TexHeight > 0); // Font atlas needs to be built before we can calculate UV coordinates
1757 int DstIndex; // Index into atlas->Fonts[] and dst_tmp_array[]
1785 bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
1787 IM_ASSERT(atlas->ConfigData.Size > 0);
1789 ImFontAtlasBuildRegisterDefaultCustomRects(atlas);
1791 // Clear atlas
1792 atlas->TexID = (ImTextureID)NULL;
1793 atlas->TexWidth = atlas->TexHeight = 0;
1794 atlas->TexUvScale = ImVec2(0.0f, 0.0f);
1795 atlas->TexUvWhitePixel = ImVec2(0.0f, 0.0f);
1796 atlas->ClearTexData();
1801 src_tmp_array.resize(atlas->ConfigData.Size);
1802 dst_tmp_array.resize(atlas->Fonts.Size);
1807 for (int src_i = 0; src_i < atlas->ConfigData.Size; src_i++)
1810 ImFontConfig& cfg = atlas->ConfigData[src_i];
1811 IM_ASSERT(cfg.DstFont && (!cfg.DstFont->IsLoaded() || cfg.DstFont->ContainerAtlas == atlas));
1815 for (int output_i = 0; output_i < atlas->Fonts.Size && src_tmp.DstIndex == -1; output_i++)
1816 if (cfg.DstFont == atlas->Fonts[output_i])
1818 IM_ASSERT(src_tmp.DstIndex != -1); // cfg.DstFont not pointing within atlas->Fonts[] array?
1830 src_tmp.SrcRanges = cfg.GlyphRanges ? cfg.GlyphRanges : atlas->GetGlyphRangesDefault();
1843 ImFontConfig& cfg = atlas->ConfigData[src_i];
1904 ImFontConfig& cfg = atlas->ConfigData[src_i];
1915 const int padding = atlas->TexGlyphPadding;
1932 atlas->TexHeight = 0;
1933 if (atlas->TexDesiredWidth > 0)
1934 atlas->TexWidth = atlas->TexDesiredWidth;
1936 atlas->TexWidth = (surface_sqrt >= 4096*0.7f) ? 4096 : (surface_sqrt >= 2048*0.7f) ? 2048 : (surface_sqrt >= 1024*0.7f) ? 1024 : 512;
1942 stbtt_PackBegin(&spc, NULL, atlas->TexWidth, TEX_HEIGHT_MAX, 0, atlas->TexGlyphPadding, NULL);
1943 ImFontAtlasBuildPackCustomRects(atlas, spc.pack_info);
1958 atlas->TexHeight = ImMax(atlas->TexHeight, src_tmp.Rects[glyph_i].y + src_tmp.Rects[glyph_i].h);
1962 atlas->TexHeight = (atlas->Flags & ImFontAtlasFlags_NoPowerOfTwoHeight) ? (atlas->TexHeight + 1) : ImUpperPowerOfTwo(atlas->TexHeight);
1963 atlas->TexUvScale = ImVec2(1.0f / atlas->TexWidth, 1.0f / atlas->TexHeight);
1964 atlas->TexPixelsAlpha8 = (unsigned char*)ImGui::MemAlloc(atlas->TexWidth * atlas->TexHeight);
1965 memset(atlas->TexPixelsAlpha8, 0, atlas->TexWidth * atlas->TexHeight);
1966 spc.pixels = atlas->TexPixelsAlpha8;
1967 spc.height = atlas->TexHeight;
1972 ImFontConfig& cfg = atlas->ConfigData[src_i];
1987 ImFontAtlasBuildMultiplyRectAlpha8(multiply_table, atlas->TexPixelsAlpha8, r->x, r->y, r->w, r->h, atlas->TexWidth * 1);
2003 ImFontConfig& cfg = atlas->ConfigData[src_i];
2012 ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent);
2030 stbtt_GetPackedQuad(src_tmp.PackedChars, atlas->TexWidth, atlas->TexHeight, glyph_i, &dummy_x, &dummy_y, &q, 0);
2039 ImFontAtlasBuildFinish(atlas);
2043 void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas)
2045 if (atlas->CustomRectIds[0] >= 0)
2047 if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
2048 atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF*2+1, FONT_ATLAS_DEFAULT_TEX_DATA_H);
2050 atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, 2, 2);
2053 void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent)
2060 font->ContainerAtlas = atlas;
2067 void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque)
2072 ImVector<ImFontAtlas::CustomRect>& user_rects = atlas->CustomRects;
2090 atlas->TexHeight = ImMax(atlas->TexHeight, pack_rects[i].y + pack_rects[i].h);
2094 static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas)
2096 IM_ASSERT(atlas->CustomRectIds[0] >= 0);
2097 IM_ASSERT(atlas->TexPixelsAlpha8 != NULL);
2098 ImFontAtlas::CustomRect& r = atlas->CustomRects[atlas->CustomRectIds[0]];
2102 const int w = atlas->TexWidth;
2103 if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
2112 atlas->TexPixelsAlpha8[offset0] = FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[n] == '.' ? 0xFF : 0x00;
2113 atlas->TexPixelsAlpha8[offset1] = FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[n] == 'X' ? 0xFF : 0x00;
2120 atlas->TexPixelsAlpha8[offset] = atlas->TexPixelsAlpha8[offset + 1] = atlas->TexPixelsAlpha8[offset + w] = atlas->TexPixelsAlpha8[offset + w + 1] = 0xFF;
2122 atlas->TexUvWhitePixel = ImVec2((r.X + 0.5f) * atlas->TexUvScale.x, (r.Y + 0.5f) * atlas->TexUvScale.y);
2125 void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
2128 ImFontAtlasBuildRenderDefaultTexData(atlas);
2131 for (int i = 0; i < atlas->CustomRects.Size; i++)
2133 const ImFontAtlas::CustomRect& r = atlas->CustomRects[i];
2137 IM_ASSERT(r.Font->ContainerAtlas == atlas);
2139 atlas->CalcCustomRectUV(&r, &uv0, &uv1);
2144 for (int i = 0; i < atlas->Fonts.Size; i++)
2145 if (atlas->Fonts[i]->DirtyLookupTables)
2146 atlas->Fonts[i]->BuildLookupTable();