1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

Direct2D: Avoid unnecessarily transforming solid colour brush

The changes were not cleared between frames, so they could end up
accumulating and causing floating-point exceptions.
This commit is contained in:
reuk 2025-09-10 16:47:26 +01:00
parent 7981957f50
commit 81e4d59da2
No known key found for this signature in database

View file

@ -1130,6 +1130,13 @@ void Direct2DGraphicsContext::drawGlyphs (Span<const uint16_t> glyphNumbers,
if (brush == nullptr)
return;
const auto getBrushTransform = [] (auto brushIn) -> AffineTransform
{
D2D1::Matrix3x2F matrix{};
brushIn->GetTransform (&matrix);
return D2DUtilities::matrixToTransform (matrix);
};
applyPendingClipList();
D2D1_POINT_2F baselineOrigin { 0.0f, 0.0f };
@ -1140,13 +1147,18 @@ void Direct2DGraphicsContext::drawGlyphs (Span<const uint16_t> glyphNumbers,
}
else
{
D2D1::Matrix3x2F matrix{};
brush->GetTransform (&matrix);
const auto brushTransform = D2DUtilities::matrixToTransform (matrix);
brush->SetTransform (D2DUtilities::transformToMatrix (brushTransform.followedBy (textTransform.inverted())));
if (brush != currentState->colourBrush)
{
const auto brushTransform = getBrushTransform (brush);
brush->SetTransform (D2DUtilities::transformToMatrix (brushTransform.followedBy (textTransform.inverted())));
}
getPimpl()->setDeviceContextTransform (textAndWorldTransform);
}
// There's no need to transform a plain colour brush
jassert (brush != currentState->colourBrush || getBrushTransform (brush).isIdentity());
auto& run = getPimpl()->glyphRun;
run.replace (positions, fontScale);