Add BlendWithCoverage overloads. Optimize Rgba32 compatible shuffling.

Merged
JI
3mo ago
+52697-3473

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules :cop:.
  • I have provided test coverage for my change (where applicable)

Description

This pull request introduces new blending functionality to support raster coverage in Porter-Duff composition operations and thoroughly tests these new methods. The main focus is on adding the BlendWithCoverage methods for different vector types and ensuring their correctness through comprehensive unit tests.

New blending functionality:

  • Added BlendWithCoverage methods to PorterDuffFunctions for Vector4, Vector256<float>, and Vector512<float>, which apply raster coverage to Porter-Duff composition results. These methods handle premultiplied alpha blending and un-premultiplication for accurate compositing.

These methods are used by ImageSharp Drawing for proper composition in the canvas.

Testing and validation:

  • Added a comprehensive suite of unit tests in PixelBlenderTests.cs to verify the correctness of the new BlendWithCoverage methods. These tests cover various scenarios, including constant and span sources, varying coverage and amount arrays, and usage of working buffers.
  • Updated the ExerciseBlender helper method to include calls to the new BlendWithCoverage overloads, ensuring all blending paths are tested for expected output. [1] [2]