From 8642cfe6b37f1c38acd5d4b685bce7b2dfd1f46a Mon Sep 17 00:00:00 2001 From: reuk Date: Tue, 9 Jul 2024 12:09:44 +0100 Subject: [PATCH] Direct2D: Remove rectangular clip assertion This assertion was intended to emulate a performance warning that could be emitted by the D2D debug layer, but it often gets in the way during development. To check for this performance issue, users can change D2D1_DEBUG_LEVEL_NONE to D2D1_DEBUG_LEVEL_INFORMATION in juce_DirectX_windows.h --- .../juce_Direct2DGraphicsContext_windows.cpp | 64 ------------------- 1 file changed, 64 deletions(-) diff --git a/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp b/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp index c2ead0ec73..600dcc1427 100644 --- a/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp +++ b/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp @@ -71,70 +71,6 @@ public: void push (ComSmartPtr context, const D2D1_LAYER_PARAMETERS1& layerParameters) { - // Clipping and transparency are all handled by pushing Direct2D - // layers. The SavedState creates an internal stack of Layer objects to - // keep track of how many layers need to be popped. Pass nullptr for - // the PushLayer layer parameter to allow Direct2D to manage the layers - // (Windows 8 or later) - - #if JUCE_DEBUG - - // Check if this should be an axis-aligned clip layer (per the D2D - // debug layer) - const auto isGeometryAxisAlignedRectangle = [&] - { - auto* geometry = layerParameters.geometricMask; - - if (geometry == nullptr) - return false; - - struct Sink : public ComBaseClassHelper - { - D2D1_POINT_2F lastPoint{}; - bool axisAlignedLines = true; - UINT32 lineCount = 0; - - STDMETHOD (Close)() override { return S_OK; } - STDMETHOD_ (void, SetFillMode) (D2D1_FILL_MODE) override {} - STDMETHOD_ (void, SetSegmentFlags) (D2D1_PATH_SEGMENT) override {} - STDMETHOD_ (void, EndFigure) (D2D1_FIGURE_END) override {} - - STDMETHOD_ (void, BeginFigure) (D2D1_POINT_2F p, D2D1_FIGURE_BEGIN) override { lastPoint = p; } - - STDMETHOD_ (void, AddLines) (const D2D1_POINT_2F* points, UINT32 count) override - { - for (UINT32 i = 0; i < count; ++i) - { - auto p = points[i]; - - axisAlignedLines &= (approximatelyEqual (p.x, lastPoint.x) || approximatelyEqual (p.y, lastPoint.y)); - lastPoint = p; - } - - lineCount += count; - } - - STDMETHOD_ (void, AddBeziers) (const D2D1_BEZIER_SEGMENT*, UINT32) override - { - axisAlignedLines = false; - } - }; - - Sink sink; - geometry->Simplify (D2D1_GEOMETRY_SIMPLIFICATION_OPTION_CUBICS_AND_LINES, - layerParameters.maskTransform, - 1.0f, - &sink); - - // Check for 3 lines; the BeginFigure counts as 1 line - return sink.axisAlignedLines && sink.lineCount == 3; - }(); - - jassert (layerParameters.opacity != 1.0f - || layerParameters.opacityBrush - || ! isGeometryAxisAlignedRectangle); - #endif - pushedLayers.emplace_back (OwningLayer { layerParameters }); pushedLayers.back().push (context); }