-
-
Notifications
You must be signed in to change notification settings - Fork 888
Make processors public, refactor cloning. #1011
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
Codecov Report
@@ Coverage Diff @@
## master #1011 +/- ##
==========================================
+ Coverage 89.86% 89.86% +<.01%
==========================================
Files 1098 1099 +1
Lines 48832 48836 +4
Branches 3435 3439 +4
==========================================
+ Hits 43881 43888 +7
+ Misses 4249 4246 -3
Partials 702 702
Continue to review full report at Codecov.
|
|
I had an idea a few weeks ago for the same point. Actually, I had two options in my mind, and wanted to ask for input to decide which one is better, but I haven't got the the chance to present them so far. This solution is a third option actually 😄 I will have a deeper look at it now, but I can't promise I can summarize my thoughts properly tonight. |
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.
Pointing out a few not-so-nice points. I remember I had ideas to solve them, when I was thinking about the problem (and faced other non-trivial questions afterwards), I'm just dead tired to recall those ideas now 😄
We'll be back tomorrow!
src/ImageSharp/Processing/DefaultImageProcessorContext{TPixel}.cs
Outdated
Show resolved
Hide resolved
src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs
Outdated
Show resolved
Hide resolved
src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs
Outdated
Show resolved
Hide resolved
Excellent. Looking forward to seeing what you come up with. I'm going to replace the Mocks with dummy pass-through instances so I can demonstrate my intent in the interim and continue to provide coverage. |
| { | ||
| var test = new OctreeFrameQuantizer<TPixel>(new OctreeQuantizer(false)); | ||
| test.AotGetPalette(); | ||
| using (var test = new OctreeFrameQuantizer<TPixel>(new OctreeQuantizer(false))) |
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.
Spotted these when removing the AOT CreateDestination method. No longer required as not virtual.
|
|
||
| /// <inheritdoc/> | ||
| public Image<TPixel> CloneAndApply() | ||
| Image<TPixel> ICloningImageProcessor<TPixel>.CloneAndExecute() |
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.
Hidden so not to clutter child classes.
| { | ||
| } | ||
|
|
||
| private Image<TPixel> CreateTarget() |
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.
This method was identical in every implementation. The only different was where the target size came from.
| ParallelHelper.IterateRows( | ||
| targetBounds, | ||
| this.Configuration, | ||
| configuration, |
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.
Spotted we were capturing the whole class in the lambda
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.
I don't get the difference. this.Configuration also returns a Configuration instance.
Also: capturing the whole class is not necessarily evil. Or is it? Am I missing something?
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.
Bad practice as I understand that can lead to negative performance and issues since capturing variables affects the lifetime of those captures.
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.
@JimBobSquarePants the current state might be good enough actually, but if you don't mind, let's keep it open for another few days.
Hope I get the chance to check it once again with a fresh mind. (Sunday probably.)
Maybe we can clean up / simplify even more.
| throw new ImageProcessingException($"An error occurred when processing the image using {this.GetType().Name}. The processor changed the number of frames."); | ||
| } | ||
| Image<TPixel> clone = this.CreateTarget(); | ||
| this.CheckFrameCount(this.Source, clone); |
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.
Not sure if the checks are necessary. The centralized cloning logic should guarantee that the frame counts are matching.
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.
I actually thought that but was too lazy to check and just merged the code into a single method
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.
It's an iterative way to delete bloated code 😉
|
Setting a countdown on this one. I want to keep progressing. |
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.
Agree, it's more important now to progress, than to polish everything. I'm struggling to find time this week, improvements could be added later in a separate PR.
Make processors public, refactor cloning.
Prerequisites
Description
Touches. #967
I've marked this as draft as I want to do something more extreme and removeICloningImageProcessor<TPixel>moving the interface method into the base class. This makes additional methods impossible to test against though via mocking.Changed my mind and figured out a better way to create contracts for cloned/regular processors.
Thoughts please!