-
-
Notifications
You must be signed in to change notification settings - Fork 889
PixelOperations<TPixel>.From<RgbaVector> speedup #1435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
JimBobSquarePants
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely stuff! Will merge once tests are finished. 👍
Codecov Report
@@ Coverage Diff @@
## master #1435 +/- ##
==========================================
- Coverage 83.63% 83.63% -0.01%
==========================================
Files 733 733
Lines 31919 31922 +3
Branches 3590 3590
==========================================
Hits 26697 26697
- Misses 4508 4511 +3
Partials 714 714
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
PixelOperations<TPixel>.From<RgbaVector> speedup
Prerequisites
Description
When using any of the generic
Image.CloneAs<TPixel>APIs, if the target format wasRgbaVector, the selected code paths was not optimized to take advantage of the fact thatRgbaVectoris blittable toVector4. In particular, thisPixelOperations<TPixel>.Tomethod was called:ImageSharp/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
Lines 103 to 134 in 521fae3
You can see the method is virtual but was not overridden by
RgbaVector, so this slower implementation was used, which required both chunking of the target span as well as doing an extra copy to a temporary buffer. This PR adds a new override for this method toPixelOperations<RgbaVector>that simply does a directToVector4copy on the reinterpreted target span.