1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00
Commit graph

59 commits

Author SHA1 Message Date
Anthony Nicholls
fc29df83b5 Direct2D: Fix an issue with excludeClipRectangle
Without this fix many of the component tests that appear in the
following commit will fail for the Direct2D renderer only.
2025-11-20 17:47:47 +00:00
reuk
81e4d59da2
Direct2D: Avoid unnecessarily transforming solid colour brush
The changes were not cleared between frames, so they could end up
accumulating and causing floating-point exceptions.
2025-09-11 14:28:23 +01:00
reuk
641497918c
Direct2D: Always call SetTransform for gradient/image brushes
This partly reverts commit ad28684b10.
Prior to that change, getBrush() would always end up calling
SetTransform on gradient/image brushes. This is important because, when
drawing text, we combine the current brush transform with the text
transform. If we don't reset the brush transform each time, these
transforms end up accumulating across frames.
2025-09-09 11:32:00 +01:00
attila
35fe3ac714 Direct2D: Fix gradient fill when the brush is transformed with not just translation
The code contains a performance optimisation for cases where the world
transform is translation only. In this case instead of applying the
brush transformation first and then the world translation, the order is
reversed. The translation is applied first and then the brush
transformation.

Flipping the transformations however is only correct in the special case
when both transformations are translation only.
2025-08-19 16:51:15 +01:00
attila
f97355b9f6 Direct2D: Fix seams between tiles for large bitmaps 2025-07-25 20:45:17 +02:00
attila
19906c9d2f Direct2DGraphicsContextTests: Ignore the image edges to allow for differences in anti-aliasing 2025-07-25 20:45:17 +02:00
attila
3f898f6fee Direct2D: Fix jitter when drawing bitmaps with non-unity scaling
Reverts ca3abbb96d.

Prior to this fix gradually changing the Component scale would lead to
the jittery movement of drawn bitmaps, as their position would be
snapped to an arbitrary integral representation.
2025-07-25 20:45:17 +02:00
attila
5bc44c301f Make Direct2DGraphicsContextTests acceptance criteria stricter 2025-07-25 20:45:17 +02:00
reuk
137d9820b1 Direct2D: Move D2DHelpers to Direct2DGraphicsContext.cpp 2025-04-24 13:58:24 +01:00
reuk
2aed72d0d7 Direct2D: Move paintPrimitive implementation into Direct2DGraphicsContext 2025-04-24 13:58:24 +01:00
Oli
ca3abbb96d Direct2D: Round virtual texture tile position
This fixes the issue reported here: https://forum.juce.com/t/regression-in-drawimage/65084/5
2025-04-24 13:58:24 +01:00
Oli
1dce4ae0fe Direct2DGraphicsContext: Use path bounds to check for emptiness
Co-authored-by: Matt Gonzalez <matt@echoaudio.com>
2025-04-24 13:58:24 +01:00
Oli
5e5258591f Direct2D: Move Direct2DGraphicsContext::Impl into separate header 2025-04-24 13:58:23 +01:00
attila
c786e6160c Direct2D: Fix fillAlphaChannelWithCurrentBrush when the source position is non-zero 2025-04-17 10:27:24 +02:00
reuk
eca83213eb
Direct2D: Fix issue where vertical/horizontal lines were ignored by strokePath 2025-04-02 10:57:09 +01:00
attila
5aab60f4e5 Direct2D: Fix text drawing using gradients 2025-03-28 12:19:11 +01:00
attila
273c7936d3 Direct2D: Fix text drawing using gradients when the screen scaling is 1 2025-03-17 15:32:59 +01:00
reuk
92c7d73d2d
Direct2D: Fix image artefacts at the edge of alpha-clipped regions
This addresses the same issue that
95d416ab77 was intended to fix:

Drawing a drop shadow on a high-res display on Windows could sometimes
produce thin lines around the edge of the shadow. Using the 'clamp'
rather than the 'wrap' clipping mode seems to help.
2025-02-11 18:11:12 +00:00
reuk
f12d29899c
Direct2D: Remove SetDpi call in startFrame
Previously, plugins and standalone apps could produce slightly different
visual results, particularly anti-aliasing, when displaying on a display
with native scaling applied. The discrepancy was caused by SetDpi being
called with a larger-than-default value (e.g. 192 DPI on a 200% scaled
display) in a standalone app, whereas SetDpi would always be called with
the default value of 96 in a plugin.

Keeping the default value seems to produce better results, so standalone
apps will now retain the default DPI.
2025-01-29 11:00:44 +00:00
reuk
d3ca5961e7
Direct2D: Use Image NativeExtensions to avoid dynamic casts in graphics context 2025-01-23 12:21:33 +00:00
reuk
f887979ec0 Direct2D: Fix performance issue when drawing transformed unclipped regions
This issue could be observed in the GraphicsDemo's SVG pane, when the
"rotation" option was enabled.

Drawables internally enable the unclipped painting flag, which normally
prevents slow clipping when drawing subcomponents of the drawable.

The Direct2D graphics context was using the frame area as the default
area, used to signal that no clipping should be applied. However, when
non-axis-aligned transform was active, this area was incorrectly applied
as a geometric clipping region. D2D geometric clips are relatively slow,
so this caused large slowdowns.

This solution adds a flag that is set whenever a clip is explicitly
requested. If no clip is explicitly requested, then clipping will be
entirely bypassed. This can make rendering of Drawables significantly
faster.
2024-12-13 14:49:46 +00:00
reuk
336dcfc08c Direct2DImage: Update interface to accept a Device instead of a DeviceContext 2024-12-13 14:43:06 +00:00
reuk
dcca72484f Image: Update return type of getPixelData to avoid dangling pointers 2024-12-13 14:42:26 +00:00
reuk
80ac9a78a0
Singleton: Add new macros to simplify singleton creation
The INLINE macros allow singletons to be declared and defined in one
line, without requiring a separate JUCE_IMPLEMENT_SINGLETON statement.
2024-10-16 10:36:52 +01:00
reuk
c57041e5bc
Direct2D: Simplify threading of swapchain presentation
Previously, IDXGISwapChain::Present was called on a background thread,
which made it difficult to avoid race conditions. e.g. during a
live-resize of a window, we would occasionally draw old incomplete
frames instead of new frames at the correct size.

The new approach moves the Present call to the main thread via
AsyncUpdater. We attempt to present whenever the swap event wakes, and
whenever a frame is drawn. Only a single Present call may be made after
the swap event wakes. Subsequent Present calls will be ignored until the
next time the swap event wakes.
2024-10-08 16:10:07 +01:00
reuk
6374540f19
Direct2D: Fix bug where Image::clear did not respect the requested area 2024-09-18 15:44:04 +01:00
reuk
589d9940ed
Direct2D: Add support for bitmaps spanning multiple texture pages 2024-09-18 15:44:04 +01:00
reuk
25e2fa44ff
Direct2D: Correctly recreate ID2D1DeviceContext when moving transparent windows between devices 2024-09-05 12:16:02 +01:00
reuk
348d638581
Direct2D: Temporarily disable window transparency for D2D windows 2024-08-22 18:18:17 +01:00
reuk
c94b8e1712
Direct2D: Refactor paintAreas handling in graphics contexts 2024-08-22 18:18:15 +01:00
reuk
e2b9dd9a05
Direct2D: Remove redundant adapter member from Direct2DGraphicsContext 2024-08-22 18:18:15 +01:00
reuk
45305dbfa7
Direct2D: Remove redundant adapter member from SavedState 2024-08-22 18:18:15 +01:00
reuk
68441e0726
Direct2D: Refactor DeviceResources helper 2024-08-22 18:18:15 +01:00
reuk
8bbcfe4d6b
Direct2D: Move DeviceContext helpers to shared DirectX header 2024-08-22 18:18:14 +01:00
reuk
f3a74896fc
Direct2D: Move bitmap helpers to shared DirectX header 2024-08-22 18:18:14 +01:00
reuk
8642cfe6b3
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
2024-07-09 12:47:30 +01:00
reuk
a4022df686
Direct2D: Fix issue where contexts would not clear properly after pushing multiple clip layers
This issue could be seen when calling setBufferedToImage on a component
with a transparent background with a size different to the component's
size.

The details are unclear to me, but it seems like both calling Clear on
the device context, and using the COPY blend mode, ignore alpha values
and instead use a constant alpha of 1.0 when there is a geometric
clipping layer active.

As a workaround for this issue, when clearing a rectangle we now pop all
active layers, fill their intersection using the COPY blend mode while
there are no layers active, and then reinstate the layers.

The new implementation is likely to be very slow, however I think this
code path is unlikely to be used frequently in practice. The main
use-case for rendering clear transparent areas is the rendering of
buffered component images, but such cases normally use axis-aligned
clipping regions, which should be able to use the faster path.
2024-07-04 13:03:56 +01:00
reuk
f3dfd0d9be
Direct2D: Update formatting in clipToImageAlpha 2024-07-04 13:03:35 +01:00
reuk
6402641d49
Direct2D: Avoid applying pending clip list in excludeClipRectangle unless the transform is non-trivial
Frequently, excludeClipRectangle will be called several times in a row,
in order to trim away borders on each side of a rectangle. When this
happens, we want to avoid creating geometric clip layers which exclude
only two or three of the borders, and instead wait until all borders
have been excluded before applying the clip list. This way, it may be
possible to simplify the clip list to a single rectangle, which can be
implemented using the faster axis-aligned clipping layer.
2024-07-04 13:03:35 +01:00
reuk
b0bd58c5e6
Direct2D: Refactor layer storage to keep strong references to geometries and opacity brushes
Also switches to the slightly newer layer parameters type.
2024-07-04 13:03:35 +01:00
Matt Gonzalez
0789048777 Direct2D: Set transform for tiled image brush 2024-06-26 14:33:25 +01:00
reuk
8acd81e587
Direct2D: Allow drawing rects with very small widths/heights 2024-06-11 11:34:05 +01:00
reuk
2a264390e8
Direct2D: Update assertion to check for alignment against screen rather than current transform
This assertion is intended to mirror the behaviour of an
informational/performance diagnostic message raised by the D2D debugging
layer.

It seems the D2D diagnostic is raised when the proposed clip region is
aligned to the screen, not to the current transform.

Before this change, the assertion could incorrectly fire when clipping
to transformed rectangles. This could be seen when clicking the
star-shaped buttons in the ComponentTransformsDemo.

With this change in place, the assertion will still fire when e.g.
calling Graphics::reduceClipRegion on a screen-aligned rectangular path,
but will not fire when this path is skewed/rotated etc.
2024-06-11 11:34:04 +01:00
Matt Gonzalez
77f6eb00ff
Direct2D: Reset pending clip list after setting device space origin
https://forum.juce.com/t/the-juce-8-preview-branch-is-available-now/60950/144?u=matt
2024-05-28 16:08:55 +01:00
Matt Gonzalez
dfb21da572
Direct2D: Use axis-aligned clip layer when possible in clipToImageAlpha 2024-05-28 16:08:55 +01:00
Matt Gonzalez
6ca54e8c97
Direct2D: Add debug check for axis-aligned clip layers
This is similar to the check performed by the D2D debug layer that will still work with the debug layer disabled.
2024-05-28 16:08:55 +01:00
reuk
5b2f9d4019
GraphicsContext: Avoid attempting to paint empty rectangles in all renderers 2024-05-20 12:49:56 +01:00
reuk
06137fb7f5
Direct2D: Slightly shrink excluded clip regions in order to draw transformed opaque components without border artefacts 2024-05-20 12:49:55 +01:00
reuk
7991c91fb2
D2D: Move null checks 2024-04-29 16:08:24 +01:00
reuk
248a400b88
D2D: Use currently-selected colour when replace-clearing NativeImage 2024-04-29 16:08:23 +01:00