Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- **Collapsible animation glitch on Wayland** ([#152](https://github.com/gogpu/ui/issues/152)) — force final redraw after animation completes + full-window `wl_surface.damage_buffer` on root repaint. Confirmed by @porjo.

### Removed

- **`internal/layout/Engine`** (ADR-032 CACHE-030) — centralized layout engine with 0 production usage. Per-widget layout caching is now fully handled by `widget.LayoutChild` on `WidgetBase`. -769 lines of dead code.

### Changed

- **deps:** gg v0.50.1 → v0.50.2, gogpu v0.43.1 → v0.43.4, wgpu v0.30.8 → v0.30.9, goffi v0.5.5 → v0.5.6
Expand Down
49 changes: 0 additions & 49 deletions internal/layout/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ func (b *benchLayoutable) Layout(_ geometry.Constraints) geometry.Size {
func (b *benchLayoutable) Children() []Layoutable { return nil }
func (b *benchLayoutable) ID() uint64 { return 0 }

// cachableLayoutable is a Layoutable with a non-zero ID for cache benchmarks.
type cachableLayoutable struct {
benchLayoutable
id uint64
}

func (c *cachableLayoutable) ID() uint64 { return c.id }

// --- Flex layout benchmarks ---

func newFlexWithChildren(n int) *FlexContainer {
Expand Down Expand Up @@ -158,44 +150,3 @@ func BenchmarkGridLayout10x10(b *testing.B) {
grid.Layout(constraints)
}
}

// --- Layout engine cache benchmarks ---

func BenchmarkLayoutCacheHit(b *testing.B) {
engine := NewEngine()
engine.EnableCache(true)

child := &cachableLayoutable{
benchLayoutable: benchLayoutable{preferredSize: geometry.Sz(100, 50)},
id: 42,
}
constraints := geometry.BoxConstraints(0, 800, 0, 600)

// Warm up cache with one layout call.
engine.Layout(child, constraints)

b.ReportAllocs()
b.ResetTimer()
for b.Loop() {
engine.Layout(child, constraints)
}
}

func BenchmarkLayoutCacheMiss(b *testing.B) {
engine := NewEngine()
engine.EnableCache(true)

child := &cachableLayoutable{
benchLayoutable: benchLayoutable{preferredSize: geometry.Sz(100, 50)},
id: 42,
}
constraints := geometry.BoxConstraints(0, 800, 0, 600)

b.ReportAllocs()
b.ResetTimer()
for b.Loop() {
// Mark dirty before each layout to force recomputation.
engine.MarkDirty(child.ID())
engine.Layout(child, constraints)
}
}
23 changes: 5 additions & 18 deletions internal/layout/doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package layout provides the internal layout engine implementation for gogpu/ui.
// Package layout provides internal layout algorithm implementations for gogpu/ui.
//
// This package is INTERNAL and not intended for public use. It implements
// constraint-based layout algorithms used by the widget system.
Expand All @@ -7,11 +7,14 @@
//
// The layout package provides several layout algorithms:
//
// - [Engine]: Manages layout passes with caching and dirty tracking
// - [FlexContainer]: CSS Flexbox-style layout (row, column, wrap)
// - [VStack], [HStack], [ZStack]: Simplified stack layouts
// - [GridContainer]: Basic grid layout with rows and columns
//
// Per-widget layout caching is handled by [widget.LayoutChild] (ADR-032),
// not by this package. Container widgets call LayoutChild instead of
// child.Layout directly, which checks the per-widget cache on WidgetBase.
//
// # Constraint-Based Layout
//
// Layout follows a constraint-passing model similar to Flutter:
Expand All @@ -25,15 +28,6 @@
// forces a specific size (min == max), while a "loose" constraint allows
// flexibility (min = 0).
//
// # Layout Engine
//
// The Engine manages layout passes efficiently:
//
// - Single-pass layout for simple hierarchies
// - Multi-pass layout for intrinsic sizing
// - Caching of layout results to avoid redundant calculations
// - Dirty tracking for incremental layout updates
//
// # Flexbox Layout
//
// FlexContainer implements a simplified CSS Flexbox model:
Expand Down Expand Up @@ -70,11 +64,4 @@
//
// This package is used internally by the UI framework. Application code should
// use the public layout widgets instead of directly using this package.
//
// // Internal framework usage
// engine := layout.NewEngine()
// flex := layout.NewFlexContainer(layout.Row, layout.JustifyStart, layout.AlignStretch)
// flex.AddChild(child1, layout.FlexItem{Grow: 1})
// flex.AddChild(child2, layout.FlexItem{Grow: 2})
// size := engine.Layout(flex, constraints)
package layout
Loading
Loading