Commit Graph

64 Commits

Author SHA1 Message Date
Martin Fouilleul f6a992e5f4 [mtl canvas] very first draft of new canvas backend based on edge-counting instead of triangle overlap 2023-03-28 13:09:48 +02:00
Martin Fouilleul b0be21795e [mtl canvas] prevent tiles entirely covered by textured shapes to be treated as solid (as the texture could be non-uniformly transparent) 2023-03-22 12:02:13 +01:00
Martin Fouilleul 0d8bc824a2 [mtl canvas] bucket triangles into per-shape tile queues, then gather into tile arrays. This somewhat improves perf for perf_text test and avoids an awful degradation due to sorting in tiger test (tiger now runs at ~20fps, which is still much slower than it could be, but the triangle coverage method we're using just incurs too much cross product computations...) 2023-03-21 10:22:37 +01:00
Martin Fouilleul a4ef58f2d8 [mtl canvas] Tiling per rectangles into per-shape tile queues (linked lists of triangle indices) to avoid sorting 2023-03-20 16:46:12 +01:00
Martin Fouilleul 92f4909d63 [mtl canvas] testing the metal canvas rendering the ghostscript tiger, and acknowledging it's painfully slow 2023-03-18 14:35:51 +01:00
Martin Fouilleul 5ce53001e2 [canvas, mtl] clear resets command count and stores clear color. Ccanvas' backend begin proc now takes a clearColor parameter and clears final surface to that color before drawing any batch 2023-03-15 11:09:42 +01:00
Martin Fouilleul b907578eb4 Fix clipping one pixel short 2023-03-11 16:55:30 +01:00
Martin Fouilleul 873d4ab6db [ui, canvas]
- Allow querying the size of the canvas's underlying surface
- Set size of ui root to canvas' size
2023-03-08 15:03:35 +01:00
Martin Fouilleul 1212d714d5 [platform/canvas]
- Changed canvas coordinate system to match UI coord system (origin at top left, y axis down)
- Changed mouse coordinate system to match UI and canvas
- No need to pass width/height to ui_begin_frame() anymore
2023-03-08 13:19:18 +01:00
Martin Fouilleul 3682605f97 [util, formatting] changed list api to snakecase for consistency with the rest of the codebase 2023-03-08 12:00:10 +01:00
Martin Fouilleul 592f4cdecd end of line renormalization 2023-03-05 16:05:43 +01:00
martinfouilleul 653ddec978 [win32 surface sharing] win32 surface sharing using window reparenting 2023-03-03 12:41:09 +01:00
Martin Fouilleul 731e5b1ae8 [surface] pull mp_layer into the generic mg_surface_data struct, out of each backend-specific implementation 2023-03-03 11:50:12 +01:00
martinfouilleul ac00cc9def [wip, win32 surface sharing] simplifyin the surface sharing API 2023-03-02 19:21:39 +01:00
martinfouilleul ee87976429 [win32 surface sharing] hacky proof of concept 2023-03-02 18:24:15 +01:00
Martin Fouilleul 43d413dbbc [surface] graphics surface sharing API + osx implementation 2023-03-01 16:15:36 +01:00
Martin Fouilleul 28f5af32fa [graphics] Allocate canvases and fonts from graphics subsystem's arena 2023-03-01 11:37:33 +01:00
Martin Fouilleul 6bf989564d [graphics] use a single handle arena for all graphics subsystem handles 2023-02-28 20:33:55 +01:00
Martin Fouilleul 5a19c03ad6 [canvas] removing unused old atlasing api 2023-02-28 18:47:45 +01:00
Martin Fouilleul 3615775168 [canvas] decompose image atlas API into simple rect atlas API + image atlas helpers. This avoids creating a bunch of new types/handles, and exposes the underlying image/sourceRegion so that user code can freely use these for more complex scenarios (eg drawing only a sub-region of an atlased image, or using an atlas image for arbitrary path filling) 2023-02-28 16:54:39 +01:00
Martin Fouilleul d4bceba7e9 [canvas] basic image atlas API 2023-02-28 13:16:36 +01:00
martinfouilleul 8f834fa1a5 [wip, canvas, gl] implementing basic image API 2023-02-27 19:25:41 +01:00
Martin Fouilleul 30aa6a4a48 [canvas] Put primitive's transform in the attributes struct. When rendering, set current transform at the beginning of mg_next_shape(). (This avoid using an additional prevTransform matrix to correctly setup uvTransform when mg_finalize_shape() at the beginning of mg_next_shape()) 2023-02-27 15:01:44 +01:00
Martin Fouilleul 9ed630fc55 [canvas]
- Clear final surface to clear color, and enable blending layers onto it
- Fixed Batching bug where we were writing to vertex/shape buffers while the previous batch is using them
- Fixed bug where uvTransform uses transform of next shape instead of that of shape being finalized
2023-02-27 11:56:04 +01:00
Martin Fouilleul e66932e624 [canvas] Set command attributes to canvas->attributes by default in mg_push_command() 2023-02-25 15:35:24 +01:00
Martin Fouilleul 193afb61fd [canvas] move canvas structs decl from graphics_internal.h to graphics.c, keep only surface/canvas backend interface stuff in graphics_internal.h 2023-02-25 15:23:15 +01:00
Martin Fouilleul 074b17b743 [canvas] Set transform matrix as part of primitive and don't replay push/pop during render 2023-02-25 14:20:07 +01:00
Martin Fouilleul b24de5d969 [canvas] Allow setting image source region 2023-02-25 12:59:49 +01:00
Martin Fouilleul 50569a1427 Allow setting texture on arbitrary path fills 2023-02-24 23:06:39 +01:00
Martin Fouilleul 4333ed02b0 [canvas] remove image draw commands, replace with rect/rounded rects + image source 2023-02-24 22:59:33 +01:00
Martin Fouilleul 1b62ec568c [canvas, mtl backend] Handle image rotation 2023-02-24 20:40:16 +01:00
Martin Fouilleul bb106b717f Build user-space bounding box of shape in mg_push_vertex() _before_ transforming vertices 2023-02-24 19:20:05 +01:00
Martin Fouilleul 11c25bf001 Make transform implicit in mg_push_vertex() 2023-02-24 19:11:03 +01:00
Martin Fouilleul 5be019d166 [canvas, metal] compute uv coords in shader using uvTransformed computed in canvas backend, using shape bounding box, image dimension, source and dest regions 2023-02-24 18:50:46 +01:00
Martin Fouilleul fd4c4e7be3 [canvas] simple image API 2023-02-24 12:01:00 +01:00
Martin Fouilleul d1b71110bb - Fixed metal canvas backend's drawBatch argument order
- Removed texturing in metal shader while we work on image API
- Started working on simple image API
2023-02-23 18:30:47 +01:00
Martin Fouilleul 2b60db292a [wip] image api 2023-02-23 17:07:41 +01:00
Martin Fouilleul 2232b647ed reintroduced GLES backend to osx 2023-02-20 11:05:01 +01:00
martinfouilleul 333d3e9f9c [gles, wip] reintroducing egl surface (for win32 at first) 2023-02-17 18:56:16 +01:00
martinfouilleul 80ea8db687 [surface/canvas cleanup]
- Make build-time and runtime backend selection a bit easier
- Reorganized backend-specific files with slightly more coherent naming scheme
2023-02-10 16:56:10 +01:00
martinfouilleul f54f639db5 properly destroying windows and fonts 2023-02-10 12:05:52 +01:00
martinfouilleul 35e396e4c4 [canvas cleanup]
- Remove attributes/color arguments in functions where we don't need them anymore (since they're defined when calling mg_next_shape())
- Renamed "_with_zindex" functions with "_path" -> these function only fill a path (eg rect), but don't increment the current shape
2023-02-09 17:02:58 +01:00
martinfouilleul 09a18419e4 [canvas] make shapeIndex implicit in calls to mg_push_vertex 2023-02-09 16:42:02 +01:00
martinfouilleul 4e816a838b [Clean canvas/shaders]
- Simplified shader names, prefix embedded strings by "glsl_"
- Extracted shader compilation in common function
- Add shader version string and common structs in canvas code rather than in every shader file
- Renamed zIndex with shapeIndex everywhere
2023-02-09 16:14:15 +01:00
martinfouilleul 7cf4c3d925 opengl surface/renderer: set surface scaling according to dpi of first monitor. Use that dpi to scale backing texture of canvas renderer. Note: changing monitor isn't handled yet! 2023-02-08 18:22:54 +01:00
martinfouilleul 7fbc4ba270 canvas renderer: Use clip rects to cull tiles/pixels in tiling and drawing passes 2023-02-08 12:59:31 +01:00
martinfouilleul e6e674ee04 Allow setting surface swap interval in opengl surface 2023-02-08 11:49:00 +01:00
martinfouilleul c982b524c0 Merge branch 'gl_canvas' of ssh://git.forkingpaths.dev/martinfouilleul/milepost into gl_canvas 2023-02-08 10:47:20 +01:00
martinfouilleul 38c27f21d6 canvas: allow flushing externally built commands with mg_flush_commands() 2023-02-08 10:46:12 +01:00
Martin Fouilleul afaa95fe07 applied canvas changes to metal backend 2023-02-08 10:42:21 +01:00