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

Fix parallel execution of shrinkVectorArtwork #80

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed

- A bug that would sometimes introduce a grouping comma into a large number, breaking path data. This most often occurred in the convert curves to arcs optimization when an arc with a large radius was more compact than the corresponding Bézier curve.
- Thread safety issues that prevented the `shrinkVectorArtwork` task from being executed in parallel in a highly-modularized parallel Gradle build.

## 2.2.2 - 2024-08-30

Expand Down
45 changes: 21 additions & 24 deletions vgo/src/main/kotlin/com/jzbrooks/vgo/svg/SvgOptimizationRegistry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,24 @@ import com.jzbrooks.vgo.core.optimization.RemoveTransparentPaths
import com.jzbrooks.vgo.core.optimization.SimplifyBezierCurveCommands
import com.jzbrooks.vgo.core.optimization.SimplifyLineCommands

class SvgOptimizationRegistry : OptimizationRegistry(BOTTOM_UP, TOP_DOWN) {
companion object {
private val BOTTOM_UP =
listOf(
BakeTransformations(),
CollapseGroups(),
RemoveEmptyGroups(),
MergePaths(),
)

private val TOP_DOWN =
listOf(
RemoveTransparentPaths(),
BreakoutImplicitCommands(),
CommandVariant(CommandVariant.Mode.Relative),
SimplifyLineCommands(1e-3f),
ConvertCurvesToArcs(ScalableVectorGraphicCommandPrinter(3)),
SimplifyBezierCurveCommands(1e-3f),
RemoveRedundantCommands(),
CommandVariant(CommandVariant.Mode.Compact(ScalableVectorGraphicCommandPrinter(3))),
Polycommands(),
)
}
}
class SvgOptimizationRegistry : OptimizationRegistry(
bottomUpOptimizations =
listOf(
BakeTransformations(),
CollapseGroups(),
RemoveEmptyGroups(),
MergePaths(),
),
topDownOptimizations =
listOf(
RemoveTransparentPaths(),
BreakoutImplicitCommands(),
CommandVariant(CommandVariant.Mode.Relative),
SimplifyLineCommands(1e-3f),
ConvertCurvesToArcs(ScalableVectorGraphicCommandPrinter(3)),
SimplifyBezierCurveCommands(1e-3f),
RemoveRedundantCommands(),
CommandVariant(CommandVariant.Mode.Compact(ScalableVectorGraphicCommandPrinter(3))),
Polycommands(),
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,24 @@ import com.jzbrooks.vgo.core.optimization.RemoveTransparentPaths
import com.jzbrooks.vgo.core.optimization.SimplifyBezierCurveCommands
import com.jzbrooks.vgo.core.optimization.SimplifyLineCommands

class VectorDrawableOptimizationRegistry : OptimizationRegistry(BOTTOM_UP, TOP_DOWN) {
companion object {
private val BOTTOM_UP =
listOf(
BakeTransformations(),
CollapseGroups(),
RemoveEmptyGroups(),
MergePaths(),
)

private val TOP_DOWN =
listOf(
RemoveTransparentPaths(),
BreakoutImplicitCommands(),
CommandVariant(CommandVariant.Mode.Relative),
SimplifyLineCommands(1e-3f),
ConvertCurvesToArcs(VectorDrawableCommandPrinter(3)),
SimplifyBezierCurveCommands(1e-3f),
RemoveRedundantCommands(),
CommandVariant(CommandVariant.Mode.Compact(VectorDrawableCommandPrinter(3))),
Polycommands(),
)
}
}
class VectorDrawableOptimizationRegistry : OptimizationRegistry(
bottomUpOptimizations =
listOf(
BakeTransformations(),
CollapseGroups(),
RemoveEmptyGroups(),
MergePaths(),
),
topDownOptimizations =
listOf(
RemoveTransparentPaths(),
BreakoutImplicitCommands(),
CommandVariant(CommandVariant.Mode.Relative),
SimplifyLineCommands(1e-3f),
ConvertCurvesToArcs(VectorDrawableCommandPrinter(3)),
SimplifyBezierCurveCommands(1e-3f),
RemoveRedundantCommands(),
CommandVariant(CommandVariant.Mode.Compact(VectorDrawableCommandPrinter(3))),
Polycommands(),
),
)