1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

CoreGraphicsContext: Fix issue where clipping a gradient on a layer-backed view could cause rendering glitches

This commit is contained in:
reuk 2023-05-03 18:29:28 +01:00
parent b56f386b6b
commit 8ed3618e12
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
2 changed files with 6 additions and 37 deletions

View file

@ -143,7 +143,6 @@ private:
void setContextClipToPath (const Path&, const AffineTransform&);
void drawGradient();
void createPath (const Path&) const;
void createPath (const Path&, const AffineTransform&) const;
void flip() const;
void applyTransform (const AffineTransform&) const;

View file

@ -497,26 +497,14 @@ void CoreGraphicsContext::fillPath (const Path& path, const AffineTransform& tra
{
ScopedCGContextState scopedState (context.get());
setContextClipToPath (path, transform);
if (state->fillType.isColour())
{
flip();
applyTransform (transform);
createPath (path);
if (path.isUsingNonZeroWinding())
CGContextFillPath (context.get());
else
CGContextEOFillPath (context.get());
}
CGContextFillRect (context.get(), CGContextGetClipBoundingBox (context.get()));
else if (state->fillType.isGradient())
drawGradient();
else
{
setContextClipToPath (path, transform);
if (state->fillType.isGradient())
drawGradient();
else
drawImage (state->fillType.image, state->fillType.transform, true);
}
drawImage (state->fillType.image, state->fillType.transform, true);
}
void CoreGraphicsContext::drawImage (const Image& sourceImage, const AffineTransform& transform)
@ -770,24 +758,6 @@ void CoreGraphicsContext::drawGradient()
kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
}
void CoreGraphicsContext::createPath (const Path& path) const
{
CGContextBeginPath (context.get());
for (Path::Iterator i (path); i.next();)
{
switch (i.elementType)
{
case Path::Iterator::startNewSubPath: CGContextMoveToPoint (context.get(), i.x1, i.y1); break;
case Path::Iterator::lineTo: CGContextAddLineToPoint (context.get(), i.x1, i.y1); break;
case Path::Iterator::quadraticTo: CGContextAddQuadCurveToPoint (context.get(), i.x1, i.y1, i.x2, i.y2); break;
case Path::Iterator::cubicTo: CGContextAddCurveToPoint (context.get(), i.x1, i.y1, i.x2, i.y2, i.x3, i.y3); break;
case Path::Iterator::closePath: CGContextClosePath (context.get()); break;
default: jassertfalse; break;
}
}
}
void CoreGraphicsContext::createPath (const Path& path, const AffineTransform& transform) const
{
CGContextBeginPath (context.get());