diff --git a/modules/juce_graphics/native/juce_Direct2DGraphicsContextImpl_windows.h b/modules/juce_graphics/native/juce_Direct2DGraphicsContextImpl_windows.h index 4f30f9d5a3..a6f89a22bf 100644 --- a/modules/juce_graphics/native/juce_Direct2DGraphicsContextImpl_windows.h +++ b/modules/juce_graphics/native/juce_Direct2DGraphicsContextImpl_windows.h @@ -763,12 +763,11 @@ public: return transform.translated (r); }; - rectangleListSpriteBatch->fillRectangles (deviceContext, - list, - owner.currentState->fillType.colour, - translateRectangle, - owner.metrics.get()); - return true; + return rectangleListSpriteBatch->fillRectangles (deviceContext, + list, + owner.currentState->fillType.colour, + translateRectangle, + owner.metrics.get()); } if (owner.currentState->isCurrentTransformAxisAligned()) @@ -778,12 +777,11 @@ public: return transform.boundsAfterTransform (r); }; - rectangleListSpriteBatch->fillRectangles (deviceContext, - list, - owner.currentState->fillType.colour, - transformRectangle, - owner.metrics.get()); - return true; + return rectangleListSpriteBatch->fillRectangles (deviceContext, + list, + owner.currentState->fillType.colour, + transformRectangle, + owner.metrics.get()); } auto checkRectangleWithoutTransforming = [&] (const Rectangle& r) -> Rectangle @@ -792,13 +790,11 @@ public: }; ScopedTransform scopedTransform { *this, owner.currentState }; - rectangleListSpriteBatch->fillRectangles (deviceContext, - list, - owner.currentState->fillType.colour, - checkRectangleWithoutTransforming, - owner.metrics.get()); - - return true; + return rectangleListSpriteBatch->fillRectangles (deviceContext, + list, + owner.currentState->fillType.colour, + checkRectangleWithoutTransforming, + owner.metrics.get()); } static Line offsetShape (Line a, Point b) diff --git a/modules/juce_graphics/native/juce_DirectX_windows.h b/modules/juce_graphics/native/juce_DirectX_windows.h index 76e6dddff4..67aca6a6f8 100644 --- a/modules/juce_graphics/native/juce_DirectX_windows.h +++ b/modules/juce_graphics/native/juce_DirectX_windows.h @@ -963,14 +963,14 @@ public: } template - void fillRectangles (ComSmartPtr deviceContext, + bool fillRectangles (ComSmartPtr deviceContext, const RectangleList& rectangles, const Colour colour, TransformRectangle&& transformRectangle, [[maybe_unused]] Direct2DMetrics* metrics) { if (rectangles.isEmpty()) - return; + return true; JUCE_D2DMETRICS_SCOPED_ELAPSED_TIME (metrics, spriteBatchTime) @@ -995,6 +995,10 @@ public: { auto r = rectangles.getRectangle (i); r = transformRectangle (r); + + if (r.getWidth() < 1.0f || r.getHeight() < 1.0f) + return false; + *destination = D2DUtilities::toRECT_F (r); ++destination; } @@ -1009,7 +1013,7 @@ public: D2D1_PIXEL_FORMAT { DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED }, whiteRectangle.resetAndGetPointerAddress()); if (FAILED (hr)) - return; + return false; whiteRectangle->BeginDraw(); whiteRectangle->Clear (D2D1_COLOR_F { 1.0f, 1.0f, 1.0f, 1.0f }); @@ -1017,16 +1021,18 @@ public: } ComSmartPtr bitmap; + if (auto hr = whiteRectangle->GetBitmap (bitmap.resetAndGetPointerAddress()); SUCCEEDED (hr)) { ComSmartPtr deviceContext3; + if (hr = deviceContext->QueryInterface (deviceContext3.resetAndGetPointerAddress()); SUCCEEDED (hr)) { auto d2dColour = D2DUtilities::toCOLOR_F (colour); auto spriteBatch = getSpriteBatch (*deviceContext3, (uint32) spriteBatchSize); if (spriteBatch == nullptr) - return; + return false; auto setCount = jmin ((uint32) spriteBatchSize, spriteBatch->GetSpriteCount()); auto addCount = (uint32) spriteBatchSize > setCount ? (uint32) spriteBatchSize - setCount : 0; @@ -1055,6 +1061,8 @@ public: numRectanglesPainted += spriteBatchSize; } + + return true; } private: