Skip to content

Direct2D: Fix partial Image::clear while Graphics is active - #1773

Open
asxxb wants to merge 1 commit into
juce-framework:developfrom
asxxb:fix/direct2d-image-clear
Open

asxxb wants to merge 1 commit into
juce-framework:developfrom
asxxb:fix/direct2d-image-clear

Conversation

@asxxb

@asxxb asxxb commented Oct 17, 2026

Copy link
Copy Markdown

Description

Fixes an issue where juce::Image::clear() is silently ignored on Direct2D-backed images when a juce::Graphics context is already active.

The existing implementation attempted to create another graphics context while the image was already being drawn to. Direct2D rejects the second context, leaving the active render target unchanged.

This change:

  • Dispatches Image::clear() through ImagePixelData.
  • Reuses the already-active Direct2D graphics context when available.
  • Performs the clear using JUCE's existing rectangle-fill path with replacement/source semantics.
  • Preserves the requested clear rectangle instead of clearing the entire render target.
  • Adds a Direct2D regression test covering partial clears and pixels outside the cleared region.

Testing

  • git diff --check — passed
  • macOS CMake DemoRunner build — passed
  • Direct2D/Windows runtime testing — not available in the current macOS environment; should be validated by Windows CI.

@asxxb
asxxb changed the base branch from master to develop October 17, 2026 14:48
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@asxxb
asxxb force-pushed the fix/direct2d-image-clear branch from df4c9f8 to bb8154a Compare October 17, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant