Skip to content
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

Refactor & simplify conversion API's #744

Merged
merged 21 commits into from
Oct 23, 2018
Merged

Conversation

antonfirsov
Copy link
Member

@antonfirsov antonfirsov commented Oct 23, 2018

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 matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

API cleanup

1. IPixel

  • Better terminology/naming: PackFrom*** ==> From***
  • Rgba32 ToRgba32() ==> void ToRgba32(ref dest) for perf
  • ToVector4 and ToScaledVector4 were not touched: after introducing scaling to my benchmarks it turned out that the current retval form is OK

2. PixelOperations<T>

  • PackFrom*** -> From***
  • The last count parameter has been removed, we now follow Span.CopyTo(...) semantics, copying source.Length elements

3. Bulk conversion methods on ColorSpaceConverter

  • For consistency with PixelOperations<T>: The last count parameter has been removed, we now follow Span.CopyTo(...) semantics, copying source.Length elements

Internal refactor

  • All IPixel structs and specific PixelOperations<T> implementations were moved to a (non-namespace-provider) subfolder PixelImplementations
  • DRY out all pixel specific generator templates (***.PixelOperations.Generated.tt) by using shared code in _Common.ttinclude
  • New methods and MethodImpl tricks in Guard

@codecov
Copy link

codecov bot commented Oct 23, 2018

Codecov Report

Merging #744 into master will decrease coverage by 0.11%.
The diff coverage is 65.79%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #744      +/-   ##
==========================================
- Coverage   88.44%   88.32%   -0.12%     
==========================================
  Files         982      983       +1     
  Lines       41592    41846     +254     
  Branches     3126     3127       +1     
==========================================
+ Hits        36784    36961     +177     
- Misses       4124     4203      +79     
+ Partials      684      682       -2
Impacted Files Coverage Δ
src/ImageSharp/Common/Helpers/ImageMaths.cs 87.17% <ø> (ø) ⬆️
tests/ImageSharp.Tests/Issues/Issue594.cs 0% <0%> (ø) ⬆️
...elFormats/PixelImplementations/NormalizedShort2.cs 51.11% <0%> (ø)
...rocessors/Quantization/WuFrameQuantizer{TPixel}.cs 96.03% <100%> (ø) ⬆️
...orspaces/Conversion/CieLchAndRgbConversionTests.cs 100% <100%> (ø) ⬆️
...sors/Binarization/BinaryErrorDiffusionProcessor.cs 94.87% <100%> (+0.13%) ⬆️
...spaces/Conversion/CieXyzAndCieLabConversionTest.cs 100% <100%> (ø) ⬆️
...geSharp.Drawing/Processing/RecolorBrush{TPixel}.cs 100% <100%> (ø) ⬆️
...ssors/Binarization/BinaryOrderedDitherProcessor.cs 100% <100%> (ø) ⬆️
...ests/Processing/Transforms/AffineTransformTests.cs 98.49% <100%> (+0.01%) ⬆️
... and 197 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d65cf67...15415ef. Read the comment docs.

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Didn't know you could import templates like that and the bulk changes dropping the count param are welcome.

Maybe update the doc on IPixel but I'll leave that up to your discretion.

@@ -32,7 +32,7 @@ public interface IPixel
/// Sets the packed representation from a scaled <see cref="Vector4"/>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should update the docs to remove "packed"

@@ -24,93 +24,93 @@ public interface IPixel<TSelf> : IPixel, IEquatable<TSelf>
}

/// <summary>
/// An interface that represents a pixel type.
/// A base interface for all pixels, defining the mandatory operations to be implemented by a pixel type.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

@antonfirsov antonfirsov merged commit 62396c0 into master Oct 23, 2018
SimantoR added a commit to SimantoR/ImageSharp that referenced this pull request Oct 24, 2018
@antonfirsov antonfirsov deleted the af/refactor-pixel-api branch October 30, 2018 21:08
antonfirsov added a commit to antonfirsov/ImageSharp that referenced this pull request Nov 11, 2019
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.

2 participants