mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Direct2D: Use axis-aligned clip layer when possible in clipToImageAlpha
This commit is contained in:
parent
6ca54e8c97
commit
dfb21da572
1 changed files with 14 additions and 5 deletions
|
|
@ -1078,12 +1078,21 @@ void Direct2DGraphicsContext::clipToImageAlpha (const Image& sourceImage, const
|
|||
// to the sourceImage bounds
|
||||
auto brushTransform = currentState->currentTransform.getTransformWith (transform);
|
||||
{
|
||||
D2D1_RECT_F sourceImageRectF = D2DUtilities::toRECT_F (sourceImage.getBounds());
|
||||
ComSmartPtr<ID2D1RectangleGeometry> geometry;
|
||||
getPimpl()->getDirect2DFactory()->CreateRectangleGeometry (sourceImageRectF, geometry.resetAndGetPointerAddress());
|
||||
if (D2DHelpers::isTransformAxisAligned (brushTransform))
|
||||
{
|
||||
currentState->pushAliasedAxisAlignedClipLayer (sourceImage.getBounds().toFloat().transformedBy (brushTransform));
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto sourceImageRectF = D2DUtilities::toRECT_F (sourceImage.getBounds());
|
||||
ComSmartPtr<ID2D1RectangleGeometry> geometry;
|
||||
|
||||
if (geometry)
|
||||
currentState->pushTransformedRectangleGeometryClipLayer (geometry, brushTransform);
|
||||
if (const auto hr = getPimpl()->getDirect2DFactory()->CreateRectangleGeometry (sourceImageRectF, geometry.resetAndGetPointerAddress());
|
||||
SUCCEEDED (hr) && geometry != nullptr)
|
||||
{
|
||||
currentState->pushTransformedRectangleGeometryClipLayer (geometry, brushTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the clip list to the full size of the frame to match
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue