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:
parent
7981957f50
commit
81e4d59da2
1 changed files with 16 additions and 4 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue