Skip to content

Commit

Permalink
fix #308
Browse files Browse the repository at this point in the history
Change the clip to be always axis aligned as the layer approach doesn't work any more.
  • Loading branch information
scheffle committed Oct 15, 2023
1 parent 65c353f commit d6b2085
Showing 1 changed file with 8 additions and 38 deletions.
46 changes: 8 additions & 38 deletions vstgui/lib/platform/win32/direct2d/d2dgraphicscontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,49 +166,19 @@ struct D2DGraphicsDeviceContext::Impl
auto transform = convert (tmGuard.matrix) * globalTM * state.tm;
transform.scale (scaleFactor, scaleFactor);
transform.translate (transformOffset);
bool useLayer = transform.m12 != 0. || transform.m21 != 0.;
if (useLayer)
{ // we have a rotated matrix, we need to use a layer
COM::Ptr<ID2D1Factory> factory {};
deviceContext->GetFactory (factory.adoptPtr ());
COM::Ptr<ID2D1RectangleGeometry> geometry;
if (SUCCEEDED (
factory->CreateRectangleGeometry (convert (state.clip), geometry.adoptPtr ())))
{
if (applyClip.isEmpty () == false)
deviceContext->PopAxisAlignedClip ();
deviceContext->PushLayer (D2D1::LayerParameters (D2D1::InfiniteRect (),
geometry.get (),
D2D1_ANTIALIAS_MODE_ALIASED),
nullptr);
geometry->Release ();
applyClip = state.clip;
}
else
{
useLayer = false;
}
}
if (!useLayer)
auto newClip = state.clip;
globalTM.transform (newClip);
if (applyClip != newClip)
{
auto newClip = state.clip;
globalTM.transform (newClip);
if (applyClip != newClip)
{
if (applyClip.isEmpty () == false)
deviceContext->PopAxisAlignedClip ();
if (newClip.isEmpty () == false)
deviceContext->PushAxisAlignedClip (convert (newClip),
D2D1_ANTIALIAS_MODE_ALIASED);
applyClip = newClip;
}
if (applyClip.isEmpty () == false)
deviceContext->PopAxisAlignedClip ();
if (newClip.isEmpty () == false)
deviceContext->PushAxisAlignedClip (convert (newClip), D2D1_ANTIALIAS_MODE_ALIASED);
applyClip = newClip;
}
deviceContext->SetTransform (convert (transform));

p (deviceContext.get ());

if (useLayer)
deviceContext->PopLayer ();
}

//-----------------------------------------------------------------------------
Expand Down

0 comments on commit d6b2085

Please sign in to comment.