Textures: extract ImTextureDataUpdateNewFrame() out of ImFontAtlasUpdateNewFrame(). (#8465)
This commit is contained in:
+19
-12
@@ -2817,7 +2817,25 @@ void ImFontAtlasUpdateNewFrame(ImFontAtlas* atlas, int frame_count, bool rendere
|
|||||||
// Update texture status
|
// Update texture status
|
||||||
for (int tex_n = 0; tex_n < atlas->TexList.Size; tex_n++)
|
for (int tex_n = 0; tex_n < atlas->TexList.Size; tex_n++)
|
||||||
{
|
{
|
||||||
|
// Update and remove if requested
|
||||||
ImTextureData* tex = atlas->TexList[tex_n];
|
ImTextureData* tex = atlas->TexList[tex_n];
|
||||||
|
if (tex->Status == ImTextureStatus_WantCreate && atlas->RendererHasTextures)
|
||||||
|
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == NULL && "Backend set texture's TexID/BackendUserData but did not update Status to OK.");
|
||||||
|
|
||||||
|
bool remove_from_list = ImTextureDataUpdateNewFrame(tex);
|
||||||
|
if (remove_from_list)
|
||||||
|
{
|
||||||
|
IM_ASSERT(atlas->TexData != tex);
|
||||||
|
tex->DestroyPixels();
|
||||||
|
IM_DELETE(tex);
|
||||||
|
atlas->TexList.erase(atlas->TexList.begin() + tex_n);
|
||||||
|
tex_n--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ImTextureDataUpdateNewFrame(ImTextureData* tex)
|
||||||
|
{
|
||||||
bool remove_from_list = false;
|
bool remove_from_list = false;
|
||||||
if (tex->Status == ImTextureStatus_OK)
|
if (tex->Status == ImTextureStatus_OK)
|
||||||
{
|
{
|
||||||
@@ -2825,8 +2843,6 @@ void ImFontAtlasUpdateNewFrame(ImFontAtlas* atlas, int frame_count, bool rendere
|
|||||||
tex->UpdateRect.x = tex->UpdateRect.y = (unsigned short)~0;
|
tex->UpdateRect.x = tex->UpdateRect.y = (unsigned short)~0;
|
||||||
tex->UpdateRect.w = tex->UpdateRect.h = 0;
|
tex->UpdateRect.w = tex->UpdateRect.h = 0;
|
||||||
}
|
}
|
||||||
if (tex->Status == ImTextureStatus_WantCreate && atlas->RendererHasTextures)
|
|
||||||
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == NULL && "Backend set texture's TexID/BackendUserData but did not update Status to OK.");
|
|
||||||
|
|
||||||
// Request destroy
|
// Request destroy
|
||||||
// - Keep bool to true in order to differentiate a planned destroy vs a destroy decided by the backend.
|
// - Keep bool to true in order to differentiate a planned destroy vs a destroy decided by the backend.
|
||||||
@@ -2858,16 +2874,7 @@ void ImFontAtlasUpdateNewFrame(ImFontAtlas* atlas, int frame_count, bool rendere
|
|||||||
if (tex->Status == ImTextureStatus_WantDestroy)
|
if (tex->Status == ImTextureStatus_WantDestroy)
|
||||||
tex->UnusedFrames++;
|
tex->UnusedFrames++;
|
||||||
|
|
||||||
// Destroy and remove
|
return remove_from_list;
|
||||||
if (remove_from_list)
|
|
||||||
{
|
|
||||||
IM_ASSERT(atlas->TexData != tex);
|
|
||||||
tex->DestroyPixels();
|
|
||||||
IM_DELETE(tex);
|
|
||||||
atlas->TexList.erase(atlas->TexList.begin() + tex_n);
|
|
||||||
tex_n--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFontAtlasTextureBlockConvert(const unsigned char* src_pixels, ImTextureFormat src_fmt, int src_pitch, unsigned char* dst_pixels, ImTextureFormat dst_fmt, int dst_pitch, int w, int h)
|
void ImFontAtlasTextureBlockConvert(const unsigned char* src_pixels, ImTextureFormat src_fmt, int src_pitch, unsigned char* dst_pixels, ImTextureFormat dst_fmt, int dst_pitch, int w, int h)
|
||||||
|
|||||||
@@ -1702,6 +1702,7 @@ enum ImGuiActivateFlags_
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Early work-in-progress API for ScrollToItem()
|
// Early work-in-progress API for ScrollToItem()
|
||||||
|
// FIXME: Missing flags to request making both edges visible when possible.
|
||||||
enum ImGuiScrollFlags_
|
enum ImGuiScrollFlags_
|
||||||
{
|
{
|
||||||
ImGuiScrollFlags_None = 0,
|
ImGuiScrollFlags_None = 0,
|
||||||
@@ -3979,6 +3980,7 @@ IMGUI_API void ImFontAtlasTextureBlockFill(ImTextureData* dst_tex,
|
|||||||
IMGUI_API void ImFontAtlasTextureBlockCopy(ImTextureData* src_tex, int src_x, int src_y, ImTextureData* dst_tex, int dst_x, int dst_y, int w, int h);
|
IMGUI_API void ImFontAtlasTextureBlockCopy(ImTextureData* src_tex, int src_x, int src_y, ImTextureData* dst_tex, int dst_x, int dst_y, int w, int h);
|
||||||
IMGUI_API void ImFontAtlasTextureBlockQueueUpload(ImFontAtlas* atlas, ImTextureData* tex, int x, int y, int w, int h);
|
IMGUI_API void ImFontAtlasTextureBlockQueueUpload(ImFontAtlas* atlas, ImTextureData* tex, int x, int y, int w, int h);
|
||||||
|
|
||||||
|
IMGUI_API bool ImTextureDataUpdateNewFrame(ImTextureData* tex);
|
||||||
IMGUI_API void ImTextureDataQueueUpload(ImTextureData* tex, int x, int y, int w, int h);
|
IMGUI_API void ImTextureDataQueueUpload(ImTextureData* tex, int x, int y, int w, int h);
|
||||||
IMGUI_API int ImTextureDataGetFormatBytesPerPixel(ImTextureFormat format);
|
IMGUI_API int ImTextureDataGetFormatBytesPerPixel(ImTextureFormat format);
|
||||||
IMGUI_API const char* ImTextureDataGetStatusName(ImTextureStatus status);
|
IMGUI_API const char* ImTextureDataGetStatusName(ImTextureStatus status);
|
||||||
|
|||||||
Reference in New Issue
Block a user