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

Split drawing code into separate files #934

Merged
merged 88 commits into from
Jan 10, 2022

Conversation

wieslawsoltes
Copy link
Contributor

@wieslawsoltes wieslawsoltes commented Jan 6, 2022

Reference Issue

Part of #590
Continuation of #931

What does this implement/fix? Explain your changes.

Splits of all drawing code inside NO_SDC if/def into separate files. This should be easier to read and maintain also make next step closer for #590

Any other comments?

Notable changes from master:

  1. SvgGaussianBlur
  • Moved PreCalculate to NO_SDC if/def
  • Moved all fields related to PreCalculate/Apply to NO_SDC if/def
  1. SvgDocument
  • Moved SkipGdiPlusCapabilityCheck to NO_SDC if/def
  • Moved SystemIsGdiPlusCapable to NO_SDC if/def
  • Moved EnsureSystemIsGdiPlusCapable to NO_SDC if/def
  • Moved ExceptionCaughtIsGdiPlusRelated to NO_SDC if/def
  • Moved Win32 related api in SvgDocument to a separate file
  1. SvgLinearGradientServer
  • Moved NormalizeUnit to NO_SDC if/def
  • Moved CandidateIntersections to NO_SDC if/def
  • Moved CalculateClosestIntersectionPoint to NO_SDC if/def
  • Moved MovePointAlongVector to NO_SDC if/def
  • Moved LineF to NO_SDC if/def
  • Moved LinePoints to NO_SDC if/def
  • Moved GradientPoints to NO_SDC if/def
  1. SvgMarker
  • Moved AdjustForViewBoxWidth to NO_SDC if/def
  • Moved AdjustForViewBoxHeight to NO_SDC if/def
  1. SvgRadialGradientServer
  • Moved NormalizeUnit to NO_SDC if/def
  • Remove unused _lockObj field
  1. SvgArcSegment
  • Moved CalculateVectorAngle to NO_SDC if/def
  • Made class partial
  1. SvgClosePathSegment
  • Made class partial
  1. SvgCubicCurveSegment
  • Made class partial
  1. SvgLineSegment
  • Made class partial
  1. SvgMoveToSegment
  • Made class partial
  • Made class sealed as the other path segments classes are too
  1. SvgPathSegment
  • Made class partial
  1. SvgQuadraticCurveSegment
  • Made class partial
  • Moved CalculateFirstControlPoint to NO_SDC if/def
  • Moved CalculateSecondControlPoint to NO_SDC if/def
  1. IGraphicsProvider
  • Moved entire interface into NO_SDC if/def as it's only used there
  1. ISvgRenderer
  • Moved entire interface into NO_SDC if/def as it's only used there
  1. ISvgClipable
  • Moved entire interface into NO_SDC if/def as it's only used there
  1. SvgUnit
  • Made struct partial
  • Moved ToDeviceValue into NO_SDC if/def as it's only used there
  • Moved implicit operator float to NO_SDC if/def
  • Moved GetDevicePoint to NO_SDC if/def
  • Moved GetDevicePointOffset to NO_SDC if/def
  • Moved GetDeviceSize to NO_SDC if/def
  1. GdiFontDefn
  • Moved entire class into NO_SDC if/def as it's only used there
  1. SvgFontDefn
  • Moved entire class into NO_SDC if/def as it's only used there
  1. IFontDefn
  • Moved entire interface into NO_SDC if/def as it's only used there
  1. SvgMatrix
  • Made class partial
  1. SvgTransform
  • Made class partial
  1. SvgRotate
  • Made class partial
  1. SvgScale
  • Made class partial
  1. SvgShear
  • Made class partial
  1. SvgSkew
  • Made class partial
  1. SvgTransformCollection
  • Made class partial
  1. SvgTranslate
  • Made class partial
  1. SvgPoint
  • Made struct partial
  1. SvgExtentions
  • Added GetRectangle method into NO_SDC if/def as SvgUnit float implicit operator is not available

Interface specific to System.Drawing renderer:

  • ISvgClipable
  • ISvgBoundable
  • ISvgStylable - only Path method, the rest is not related
  • IGraphicsProvider
  • ISvgRenderer
  • ISvgElement - only Render method, the rest is not related
  • IFontDefn
  • ISvgTransformable - PushTransforms/PopTransforms methods
  • ISvgElement - only Render method, the rest is not related

Classes specific to System.Drawing renderer:

  • ImageBuffer
  • RawBitmap
  • SvgRenderer
  • SvgFontManager
  • GdiFontDefn
  • PathStatistics
  • SvgFontDefn

@mrbean-bremen mrbean-bremen changed the title Slit drawing code into separate files Split drawing code into separate files Jan 6, 2022
@mrbean-bremen
Copy link
Member

Yes, I think this is a good idea. As far as I can see, you didn't change any code so far, just moved out the drawing code into partial classes. As this is a bit difficult to review, you may want to add a note if you do change anything else.

@wieslawsoltes
Copy link
Contributor Author

Yes, I think this is a good idea. As far as I can see, you didn't change any code so far, just moved out the drawing code into partial classes. As this is a bit difficult to review, you may want to add a note if you do change anything else.

Ok will add PR comments if something is changed.

@wieslawsoltes wieslawsoltes marked this pull request as ready for review January 6, 2022 22:22
@wieslawsoltes
Copy link
Contributor Author

Yes, I think this is a good idea. As far as I can see, you didn't change any code so far, just moved out the drawing code into partial classes. As this is a bit difficult to review, you may want to add a note if you do change anything else.

@mrbean-bremen @H1Gdev Added notes to PR description.

@H1Gdev
Copy link
Contributor

H1Gdev commented Jan 7, 2022

@wieslawsoltes
@mrbean-bremen

I think it's not readable in IDE...
How about using File nesting ?

I think the following will be helpful.
https://stackoverflow.com/questions/59406201/filenesting-not-working-for-class-or-shared-library-projects

@wieslawsoltes
Copy link
Contributor Author

@wieslawsoltes @mrbean-bremen

I think it's not readable in IDE... How about using File nesting ?

I think the following will be helpful. https://stackoverflow.com/questions/59406201/filenesting-not-working-for-class-or-shared-library-projects

I think next step would be moving all drawing code into separate project.

@mrbean-bremen
Copy link
Member

I think next step would be moving all drawing code into separate project.

Yes, exactly.

@H1Gdev
Copy link
Contributor

H1Gdev commented Jan 7, 2022

@mrbean-bremen

It seems that the PR related to this will make a big change toward .Net 6.
So I think it's better to release to Nuget once based on 7c643dd.

@mrbean-bremen
Copy link
Member

So I think it's better to release to Nuget once based on 7c643dd.

Yes, I also thought that we should make a release before these changes, good point.

@wieslawsoltes
Copy link
Contributor Author

This PR is ready for final review. Moving to separate project is more complex task and requires some interfaces and code refactoring with breaking changes so I would do that work is separate PR.

@mrbean-bremen
Copy link
Member

I'll see if I can review this tomorrow, and also make a release of the current version (bit knocked out today after the Booster).

@mrbean-bremen
Copy link
Member

mrbean-bremen commented Jan 9, 2022

I made a release based on the current version (really have to understand how this works with Nerdbank.GitVersioning, I couldn't get it to work correctly and worked around it), but didn't get the time for a review (again). Though from a cursory glance it looks as if nothing is really changed apart from the restructuring (which is what I would expect). Maybe @H1Gdev can have a look, and I will see if I can merge this finally later tomorrow.

Copy link
Member

@mrbean-bremen mrbean-bremen left a comment

Choose a reason for hiding this comment

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

As far as I can see, this all looks good. Anyway, the compiler is your friend in this case - thanks for this time-consuming piece of work.

Comment on lines +24 to +29
#if !NO_SDC
public static RectangleF GetRectangle(this SvgRectangle r)
{
return new RectangleF(r.X, r.Y, r.Width, r.Height);
}

#endif
Copy link
Member

Choose a reason for hiding this comment

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

This should not be factored out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would leave that when we split into separate project, there are more such issues to solve

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I think we can merge this, thanks!

@mrbean-bremen mrbean-bremen merged commit a7e1e12 into svg-net:master Jan 10, 2022
github-actions bot pushed a commit that referenced this pull request Jan 10, 2022
…ONTRIBUTING.md Generators Nuget README.md Samples Source Tests doc docfx.json index.md license.txt Split all classes classes with drawing code BuildProcessTemplates CONTRIBUTING.md Generators Nuget README.md Samples Source Tests doc docfx.json index.md license.txt Put NO_SDC if/def around drawing interfaces (ISvgClipable, IGraphicsProvider, ISvgRenderer, IFontDefn) BuildProcessTemplates CONTRIBUTING.md Generators Nuget README.md Samples Source Tests doc docfx.json index.md license.txt Put NO_SDC if/def around drawing only classes (GdiFontDefn, SvgFontDefn) BuildProcessTemplates CONTRIBUTING.md Generators Nuget README.md Samples Source Tests doc docfx.json index.md license.txt Move implicit operator float to NO_SDC if/def BuildProcessTemplates CONTRIBUTING.md Generators Nuget README.md Samples Source Tests doc docfx.json index.md license.txt Move GetRectangle method into NO_SDC if/def
@wieslawsoltes wieslawsoltes deleted the SplitDrawingCode branch January 10, 2022 19:35
Copy link
Contributor

@H1Gdev H1Gdev left a comment

Choose a reason for hiding this comment

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

I was out on the weekends and couldn't review.

Unnecessary code remains due to the separation. I think these removals are necessary to clarify the dependencies.
Please consider in next PR.


namespace Svg
{
public partial class SvgDocument : SvgFragment, ITypeDescriptorContext
Copy link
Contributor

@H1Gdev H1Gdev Jan 10, 2022

Choose a reason for hiding this comment

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

I think not need ITypeDescriptorContext.

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.

3 participants