Skip to content

Commit

Permalink
Avoid statically allocated shared mutable state
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbrooks committed Sep 16, 2024
1 parent 46937c9 commit 9aec11c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 48 deletions.
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(),
),
)

0 comments on commit 9aec11c

Please sign in to comment.