mirror of
https://github.com/ocornut/imgui.git
synced 2025-09-08 04:18:23 +00:00
DrawList, Fonts: fixed ImFontAtlasTextureRepack() overwriting draw list shared data UV's etc. even when not bound. (#8694, #8465)
ImFontAtlasUpdateDrawListsSharedData() call from ImFontAtlasTextureRepack() would trigger this. For simplicity we also track current atlas in ImDrawListSharedData, but we could probably use Font->ContainerAtlas.
This commit is contained in:
10
imgui.cpp
10
imgui.cpp
@@ -3932,7 +3932,7 @@ void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCurso
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (mouse_cursor <= ImGuiMouseCursor_None || mouse_cursor >= ImGuiMouseCursor_COUNT) // We intentionally accept out of bound values.
|
if (mouse_cursor <= ImGuiMouseCursor_None || mouse_cursor >= ImGuiMouseCursor_COUNT) // We intentionally accept out of bound values.
|
||||||
mouse_cursor = ImGuiMouseCursor_Arrow;
|
mouse_cursor = ImGuiMouseCursor_Arrow;
|
||||||
ImFontAtlas* font_atlas = g.DrawListSharedData.Font->ContainerAtlas;
|
ImFontAtlas* font_atlas = g.DrawListSharedData.FontAtlas;
|
||||||
for (ImGuiViewportP* viewport : g.Viewports)
|
for (ImGuiViewportP* viewport : g.Viewports)
|
||||||
{
|
{
|
||||||
// We scale cursor with current viewport/monitor, however Windows 10 for its own hardware cursor seems to be using a different scale factor.
|
// We scale cursor with current viewport/monitor, however Windows 10 for its own hardware cursor seems to be using a different scale factor.
|
||||||
@@ -8813,10 +8813,12 @@ void ImGui::SetCurrentFont(ImFont* font, float font_size_before_scaling, float f
|
|||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
IM_ASSERT(font->Scale > 0.0f);
|
IM_ASSERT(font->Scale > 0.0f);
|
||||||
#endif
|
#endif
|
||||||
g.DrawListSharedData.Font = g.Font;
|
ImFontAtlas* atlas = font->ContainerAtlas;
|
||||||
ImFontAtlasUpdateDrawListsSharedData(g.Font->ContainerAtlas);
|
g.DrawListSharedData.FontAtlas = atlas;
|
||||||
|
g.DrawListSharedData.Font = font;
|
||||||
|
ImFontAtlasUpdateDrawListsSharedData(atlas);
|
||||||
if (g.CurrentWindow != NULL)
|
if (g.CurrentWindow != NULL)
|
||||||
g.CurrentWindow->DrawList->_SetTexture(font->ContainerAtlas->TexRef);
|
g.CurrentWindow->DrawList->_SetTexture(atlas->TexRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2694,6 +2694,7 @@ void ImFontAtlas::ClearFonts()
|
|||||||
Fonts.clear_delete();
|
Fonts.clear_delete();
|
||||||
TexIsBuilt = false;
|
TexIsBuilt = false;
|
||||||
for (ImDrawListSharedData* shared_data : DrawListSharedDatas)
|
for (ImDrawListSharedData* shared_data : DrawListSharedDatas)
|
||||||
|
if (shared_data->FontAtlas == this)
|
||||||
{
|
{
|
||||||
shared_data->Font = NULL;
|
shared_data->Font = NULL;
|
||||||
shared_data->FontScale = shared_data->FontSize = 0.0f;
|
shared_data->FontScale = shared_data->FontSize = 0.0f;
|
||||||
@@ -3914,6 +3915,7 @@ void ImFontAtlasUpdateDrawListsTextures(ImFontAtlas* atlas, ImTextureRef old_tex
|
|||||||
void ImFontAtlasUpdateDrawListsSharedData(ImFontAtlas* atlas)
|
void ImFontAtlasUpdateDrawListsSharedData(ImFontAtlas* atlas)
|
||||||
{
|
{
|
||||||
for (ImDrawListSharedData* shared_data : atlas->DrawListSharedDatas)
|
for (ImDrawListSharedData* shared_data : atlas->DrawListSharedDatas)
|
||||||
|
if (shared_data->FontAtlas == atlas)
|
||||||
{
|
{
|
||||||
shared_data->TexUvWhitePixel = atlas->TexUvWhitePixel;
|
shared_data->TexUvWhitePixel = atlas->TexUvWhitePixel;
|
||||||
shared_data->TexUvLines = atlas->TexUvLines;
|
shared_data->TexUvLines = atlas->TexUvLines;
|
||||||
|
@@ -838,9 +838,10 @@ struct IMGUI_API ImDrawListSharedData
|
|||||||
{
|
{
|
||||||
ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas (== FontAtlas->TexUvWhitePixel)
|
ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas (== FontAtlas->TexUvWhitePixel)
|
||||||
const ImVec4* TexUvLines; // UV of anti-aliased lines in the atlas (== FontAtlas->TexUvLines)
|
const ImVec4* TexUvLines; // UV of anti-aliased lines in the atlas (== FontAtlas->TexUvLines)
|
||||||
ImFont* Font; // Current/default font (optional, for simplified AddText overload)
|
ImFontAtlas* FontAtlas; // Current font atlas
|
||||||
float FontSize; // Current/default font size (optional, for simplified AddText overload)
|
ImFont* Font; // Current font (used for simplified AddText overload)
|
||||||
float FontScale; // Current/default font scale (== FontSize / Font->FontSize)
|
float FontSize; // Current font size (used for for simplified AddText overload)
|
||||||
|
float FontScale; // Current font scale (== FontSize / Font->FontSize)
|
||||||
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo()
|
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo()
|
||||||
float CircleSegmentMaxError; // Number of circle segments to use per pixel of radius for AddCircle() etc
|
float CircleSegmentMaxError; // Number of circle segments to use per pixel of radius for AddCircle() etc
|
||||||
float InitialFringeScale; // Initial scale to apply to AA fringe
|
float InitialFringeScale; // Initial scale to apply to AA fringe
|
||||||
|
Reference in New Issue
Block a user