This document outlines the incremental implementation plan for building GPUI on top of WGPU and winit. We're starting from a basic WGPU + winit foundation and gradually adding GPUI concepts.
- Basic WGPU Context - Instance, adapter, device, queue setup
- Basic winit Window - Event loop, window creation, basic event handling
- Surface Management - Create and configure WGPU surface for rendering
- Basic Render Loop - Clear screen, present frames
- Coordinate Systems - Define pixel types (logical vs device pixels)
- Clear Color - Render solid color background
- Basic Shapes - Rectangles, circles using simple shaders
- Color Management - RGB/RGBA color types and conversion
- Viewport Management - Handle window resizing
- Point - 2D points with generic units
- Size - Width/height with generic units
- Bounds - Rectangle defined by origin + size
- Margins/Padding - Layout spacing types
- Transform2D - 2D transformations (translate, scale, rotate)
- Unit Types - Pixels, DevicePixels, ScaledPixels, etc.
- Vector Math - Basic 2D vector operations
- Rectangle Operations - Intersection, union, contains, etc.
- Coordinate Conversions - Between different pixel types
- Element Trait - Core rendering interface
- IntoElement Trait - Conversion to elements
- LayoutId - Unique identifiers for layout nodes
- ElementId - Unique identifiers for elements
- Hitbox - Click/interaction target areas
- Div - Basic rectangular container (
div.rs) - Text - Basic text rendering (
text.rs) - Image - Basic image display (
img.rs) - Canvas - Custom drawing surface (
canvas.rs)
- Layout Engine - Integrate Taffy flexbox/grid layout
- Layout Tree - Build and maintain layout hierarchy
- Layout Constraints - Min/max sizes, aspect ratios
- Layout Caching - Avoid unnecessary recalculations
- Style Types - Width, height, margins, padding, etc.
- Flexbox Properties - Direction, justify, align, wrap, etc.
- Position Types - Relative, absolute positioning
- Style Resolution - Apply styles to layout engine
- Font Loading - Load system fonts and custom fonts
- Font Fallbacks - Handle missing glyphs (
font_fallbacks.rs) - Text Shaping - Layout text with proper spacing
- Line Layout - Multi-line text layout (
line_layout.rs) - Line Wrapping - Break text across lines (
line_wrapper.rs) - Text Rendering - Raster glyphs to texture atlas
- Font Features - Ligatures, kerning, etc. (
font_features.rs) - Text Selection - Highlight ranges of text
- Text Editing - Cursor, insertion, deletion
- Rich Text - Multiple fonts/styles in one block
- Mouse Events - Click, move, enter/exit, wheel
- Keyboard Events - Key press/release, text input
- Touch Events - For touch-capable devices
- Focus Management - Tab order, focus states
- Hit Testing - Determine which element receives events
- Event Routing - Send events to appropriate handlers
- Event Bubbling - Propagate events up the tree
- Event Prevention - Stop propagation when handled
- Keyboard Shortcuts - Global and context-sensitive
- Window State - Size, position, focus, etc.
- Window Events - Resize, close, minimize, etc.
- Window Options - Title, decorations, transparency
- Multi-Window - Support multiple windows
- Native Window - Bridge to OS window system
- Window Controls - Min/max/close buttons
- Window Menu - Native menu integration (if needed)
- Clipboard - Copy/paste support
- Scene Graph - Hierarchical rendering structure
- Render Batching - Group similar draw calls
- Clipping - Scissor rectangles for overflow
- Layering - Z-order and transparency
- Gradients - Linear and radial gradients
- Shadows - Drop shadows and box shadows
- Borders - Border styles, rounded corners
- Animations - Interpolated property changes
- GPU Shaders - Custom fragment/vertex shaders
- Asset Loading - Images, fonts, other resources
- Asset Caching - Avoid redundant loading
- Asset Watching - Reload changed assets in dev
- Asset Bundling - Package assets for distribution
- Image Formats - PNG, JPEG, SVG support
- Image Caching - GPU texture management
- Image Scaling - High-DPI support
- Image Effects - Filters, color adjustments
- List - Scrollable lists (
list.rs) - UniformList - Virtualized lists (
uniform_list.rs) - Anchored - Positioned overlays (
anchored.rs) - Deferred - Lazy-rendered content (
deferred.rs)
- SVG - Scalable vector graphics (
svg.rs) - Animation - Animated transitions (
animation.rs) - Surface - 3D-like surfaces (
surface.rs)
- Application - Main app lifecycle management
- App Context - Global application state
- Entity System - Component-entity management
- View System - MVC-like view management
- Global State - Application-wide state (
global.rs) - Actions - Command pattern for user actions (
action.rs) - Subscriptions - Reactive data updates (
subscription.rs) - Context Propagation - Pass data down the tree
- Inspector - Runtime UI debugging (
inspector.rs) - Test Framework - Automated UI testing (
test.rs) - Performance Profiling - Frame time, memory usage
- Hot Reload - Live code updates during development
- Error Handling - Clear error messages
- Documentation - Examples and API docs
- Type Safety - Leverage Rust's type system
- IDE Integration - Good tooling support
- Begin with the basic WGPU hello triangle/rectangle
- Add one concept at a time
- Test thoroughly at each step
- Keep examples working as we go
- Each phase builds on the previous
- Maintain backward compatibility within phases
- Create examples for each major milestone
- Document decisions and trade-offs
- Design for eventual integration with full GPUI
- Keep APIs similar to original GPUI where possible
- Plan for features like hot-reload and debugging
- Consider WASM compatibility from the start
- Project setup in fts-extensions
- Phase 1: Foundation
- All other phases pending
- This is a substantial project that will take considerable time
- Focus on getting a minimal viable implementation first
- Consider which GPUI features are truly essential vs nice-to-have
- The goal is to prove WGPU viability, not feature parity