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

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
This commit is contained in:
reuk 2024-07-09 12:09:44 +01:00
parent 4c1a93e8d8
commit 8642cfe6b3
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -71,70 +71,6 @@ public:
void push (ComSmartPtr<ID2D1DeviceContext1> 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<ID2D1SimplifiedGeometrySink>
{
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);
}