|
|
|
@ -12,6 +12,7 @@
|
|
|
|
|
|
|
|
|
|
// CHANGELOG
|
|
|
|
|
// (minor and older changes stripped away, please see git history for details)
|
|
|
|
|
// 2021-08-24: Metal: Fixed a crash when clipping rect larger than framebuffer is submitted. (#4464)
|
|
|
|
|
// 2021-05-19: Metal: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
|
|
|
|
// 2021-02-18: Metal: Change blending equation to preserve alpha in output buffer.
|
|
|
|
|
// 2021-01-25: Metal: Fixed texture storage mode when building on Mac Catalyst.
|
|
|
|
@ -504,25 +505,27 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Project scissor/clipping rectangles into framebuffer space
|
|
|
|
|
ImVec4 clip_rect;
|
|
|
|
|
clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
|
|
|
|
|
clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
|
|
|
|
|
clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
|
|
|
|
|
clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
|
|
|
|
|
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y);
|
|
|
|
|
ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y);
|
|
|
|
|
|
|
|
|
|
// Clamp to viewport as setScissorRect() won't accept values that are off bounds
|
|
|
|
|
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; }
|
|
|
|
|
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; }
|
|
|
|
|
if (clip_max.x > fb_width) { clip_max.x = (float)fb_width; }
|
|
|
|
|
if (clip_max.y > fb_height) { clip_max.y = (float)fb_height; }
|
|
|
|
|
if (clip_max.x < clip_min.x || clip_max.y < clip_min.y)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
|
|
|
|
{
|
|
|
|
|
// Apply scissor/clipping rectangle
|
|
|
|
|
MTLScissorRect scissorRect =
|
|
|
|
|
{
|
|
|
|
|
.x = NSUInteger(clip_rect.x),
|
|
|
|
|
.y = NSUInteger(clip_rect.y),
|
|
|
|
|
.width = NSUInteger(clip_rect.z - clip_rect.x),
|
|
|
|
|
.height = NSUInteger(clip_rect.w - clip_rect.y)
|
|
|
|
|
.x = NSUInteger(clip_min.x),
|
|
|
|
|
.y = NSUInteger(clip_min.y),
|
|
|
|
|
.width = NSUInteger(clip_max.x - clip_min.x),
|
|
|
|
|
.height = NSUInteger(clip_max.y - clip_min.y)
|
|
|
|
|
};
|
|
|
|
|
[commandEncoder setScissorRect:scissorRect];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Bind texture, Draw
|
|
|
|
|
if (ImTextureID tex_id = pcmd->GetTexID())
|
|
|
|
|
[commandEncoder setFragmentTexture:(__bridge id<MTLTexture>)(tex_id) atIndex:0];
|
|
|
|
@ -535,7 +538,6 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|
|
|
|
indexBufferOffset:indexBufferOffset + pcmd->IdxOffset * sizeof(ImDrawIdx)];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vertexBufferOffset += (size_t)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
|
|
|
|
|
indexBufferOffset += (size_t)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx);
|
|
|
|
|