Skip to content

Externalize ImageSharp.Drawing #1002

Closed

Description

@antonfirsov

Prerequisite: #967


UPDATE

Final repository & package structure

image

Refactor steps

I think the best would be to follow the order I suggest. Please let me know if something is missing!

  • Copy all contents of SixLabors.Core into the SixLabors.ImageSharp repository (test and product code)
  • Create a new, 100% self-contained repository for ImageSharp.Drawing, copy the following content into the repository:
    • Current Drawing code:
      • Product code
      • Test code
      • Benchmark code (!!!)
    • Test images used by Drawing tests
    • Reference images used by Drawing tests
    • Product and test code of SixLabors.Shapes
  • Configure CI for the ImageSharp.Drawing repository
  • Update ImageSharp.Web (dogfeeding)

The steps above will also touch #868. If we want to completely resolve that issue, we shall also:

  • Clean-up history of binary artifacts in SixLabors.ImageSharp master
  • Copy all reference images to SixLabors.ImageSharp

We shall consider introducing GitHub workflows while implementing these steps, but I need more help if we want to do so.

Activity

  1. added this to the 1.0.0-rc1 milestone on Sep 7, 2019
  2. antonfirsov commented on Oct 24, 2019

    @antonfirsov
    MemberAuthor

    I have two competing proposals for reorganizing our GitHub repositories. (Ignoring ImageSharp.Web, since it will be kept as-is.)

    A, 2 Repositories 2 NuGet packages

    • SixLabors.ImageSharp

      • Fully internalizing SixLabors.Core
      • Excluding Drawing
    • New repository SixLabors.ImageSharp.Drawing

      • Including SixLabors.Fonts, SixLabors.Shapes and Drawing
      • Continue current line of NuGet packages (Next version: beta0008)

    B, 2 Repositories 5 NuGet packages

    • Repo: SixLabors.ImageSharp

      • Including SixLabors.Core
        • But define a separate package for it
        • Versions are bound together (Next version: RC1)
      • Excluding Drawing
    • Repo: SixLabors.ImageSharp.Drawing

      • Including SixLabors.Fonts, SixLabors.Shapes and Drawing
      • But keep separate NuGet packages
      • Versions are bound together. (Next version: beta0010, also for Drawing)

    /cc @tocsoft @dlemstra @JimBobSquarePants

  3. JimBobSquarePants commented on Oct 24, 2019

    @JimBobSquarePants
    Member

    I vote for A to keep maintenance costs down.

  4. tocsoft commented on Oct 24, 2019

    @tocsoft
    Member

    I feel SixLabors.Fonts should still be kept a separate repo there is definitely scope there to be a much more useful project standalone from the rest of the projects.

    However I feel shapes and drawing should be merged into a single project/repo and just label it SixLabors.ImageSharp.Drawing.

    We should inline core into imagesharp and just expose them so that drawing and shapes can depend on them directly.

    So in conclusion we would end up with 4 packages & repositories.

    1. SixLabors.ImageSharp - includes base IS code & codecs + everything applicable from Core.
    2. SixLabors.ImageSharp.Drawing - includes all current drawing & shapes code.
    3. SixLabors.ImageSharp.Web - includes all current web stuff (unchanged)
    4. SixLabors.Fonts - current Fonts library (unchanged).

    Each will version independently an inline with changes to dependent projects. i.e. if either fonts of imagesharp is updated we would try to release an updated drawing package using the latest bits.

  5. antonfirsov commented on Oct 24, 2019

    @antonfirsov
    MemberAuthor

    @tocsoft your point is probably valid, since SixLabors.Fonts has more downloads than SixLabors.Shapes.Text or SixLabors.ImageSharp.Drawing. However, a "standalone" font library depending on the whole heavyweight ImageSharp package seems rather unfortunate to me. If we really want to keep it separate, we should probably avoid that.

    How about having SixLabors.Core as a separate NuGet package versioned together with ImageSharp? I don't think it's that much extra maintenance. (Having 2 packages in a single repo is infinitely less painful than keeping them entirely separate IMO.)

  6. tocsoft commented on Oct 24, 2019

    @tocsoft
    Member

    Fonts doesn't have any dependencies on ImageSharp... there might possibly be currently a couple of dependencies on some of the point primitives but we can just switch them out to different classes or just Vector2 directly.

  7. tocsoft commented on Oct 24, 2019

    @tocsoft
    Member

    The internals of Fonts definitely have no dependencies on core anyway. Like i said we can just switch the public API to return Vector2.

    However I am not opposed to retaining SixLabors.Core as a package inside the ImageSharp repo and versioned inline with the main ImageSharp package if it makes the public apis & interop between fonts and drawing/core cleaner.

  8. antonfirsov commented on Oct 24, 2019

    @antonfirsov
    MemberAuthor

    It also uses RectangleF, but I can't see anything more. So we can remove the dependency by defining a (not so nice) FontRectangle struct or similar.

    Are font internals memory intensive, or not at all? (=> Is custom memory management a possible optimization enabler?)

  9. tocsoft commented on Oct 24, 2019

    @tocsoft
    Member

    Its been a while since I've been diving deeply into fonts internals but I doubt the memory manager would give us much benefit and in fact would probably end up complicating stuff making maintenance more difficult so I think memory management should probably just be left in ImageSharp and left out of core.

  10. antonfirsov commented on Oct 24, 2019

    @antonfirsov
    MemberAuthor

    Okkay, how about this (let's call it option Z):

    • Keep Core as a separate repository, but move Memory Management back to ImageSharp
    • Keep Fonts as is
    • Merge Shapes into the new Drawing repository
      • Note: Shapes already depends on Memory Management, since shapes could be heavy (eg. a tessellated Glyph)
        image

    Benefits:

    • Less effort spent on restructuring
    • No multi-package repositories
    • Still maintainable
      • Memory Management could be changed in sync with Imaging
      • Shapes could be changed in sync with Drawing
    • Enables keeping Core and Fonts under Apache license, if we want
  11. JimBobSquarePants commented on Oct 24, 2019

    @JimBobSquarePants
    Member

    Ok, I've had a dig around in the repositories and that plan makes sense. Fonts is not memory intensive and does not require memory management.

  12. dlemstra commented on Oct 25, 2019

    @dlemstra
    Member

    Do we really need the Core package in option Z? And I do understand that it would make sense to have a separate Font package but I wonder if people would use it without the Drawing library. Having two libraries would simplify things.

  13. JimBobSquarePants commented on Oct 25, 2019

    @JimBobSquarePants
    Member

    It's there so Fonts can reuse the primitives.

  14. dlemstra commented on Oct 25, 2019

    @dlemstra
    Member

    Will need to take a good look at the code but a tiny bit of duplication might not be bad here.

  15. tocsoft commented on Oct 25, 2019

    @tocsoft
    Member

    I think I agree with Dirk lets just drop the Core package and duplicate the 1/2 small structs what we need for Fonts it will simplify the dependency tree.

  16. JimBobSquarePants commented on Oct 25, 2019

    @JimBobSquarePants
    Member

    Are there any public API crossover points? I’m thinking handling conversion between structs.

  17. tocsoft commented on Oct 25, 2019

    @tocsoft
    Member

    don't think so, not that can't be replaced by switching usages of PointF to Vector2 which already has implicit conversion to PointF

  18. antonfirsov commented on Oct 25, 2019

    @antonfirsov
    MemberAuthor

    @dlemstra I'm also very curious about those independent use cases of SixLabors.Fonts. But based on NuGet stats, it's clear that we have such users.

  19. dlemstra commented on Oct 25, 2019

    @dlemstra
    Member

    @antonfirsov When you go to https://www.nuget.org/packages/SixLabors.Fonts/1.0.0-beta0009 there is a GitHub Usage block and that shows only 2 repos.

  20. antonfirsov commented on Oct 25, 2019

    @antonfirsov
    MemberAuthor

    @dlemstra those are only OSS consumers, and only top repositories are listed.

    What I mean is that SixLabors.Fonts has more downloads than SixLabors.Shapes.Text or SixLabors.ImageSharp.Drawing. I see no other explanation for this, than the existence of independent (closed source) consumers.

  21. antonfirsov commented on Nov 10, 2019

    @antonfirsov
    MemberAuthor

    Posted an update in the issue description summarizing the final plans and the steps to achieve them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions