From d6b208505e9f592cfcf2490a5b1eda86010c4d8f Mon Sep 17 00:00:00 2001 From: scheffle Date: Sun, 15 Oct 2023 10:37:08 +0200 Subject: [PATCH] fix #308 Change the clip to be always axis aligned as the layer approach doesn't work any more. --- .../win32/direct2d/d2dgraphicscontext.cpp | 46 ++++--------------- 1 file changed, 8 insertions(+), 38 deletions(-) diff --git a/vstgui/lib/platform/win32/direct2d/d2dgraphicscontext.cpp b/vstgui/lib/platform/win32/direct2d/d2dgraphicscontext.cpp index d16758672..9a9e77426 100644 --- a/vstgui/lib/platform/win32/direct2d/d2dgraphicscontext.cpp +++ b/vstgui/lib/platform/win32/direct2d/d2dgraphicscontext.cpp @@ -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 factory {}; - deviceContext->GetFactory (factory.adoptPtr ()); - COM::Ptr 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 (); } //-----------------------------------------------------------------------------