writePath method
void
writePath({})
Write raw path commands and points to the buffer.
This is the low-level API. For convenience, use GlassEffectService.
commands - List of path commands (moveTo, lineTo, etc.)
points - Flat list of coordinates x0, y0, x1, y1, ...
windowHeight - Height for Y-flip (Flutter Y=0 top, macOS Y=0 bottom)
Implementation
void writePath({
required String windowId,
required List<GlassPathCommand> commands,
required List<double> points,
required double windowHeight,
int layerId = 0,
}) {
final buffer = _buffers[windowId]?[layerId];
if (buffer == null) return;
final layerFrames = _frameIds.putIfAbsent(windowId, () => {});
final frameId = (layerFrames[layerId] ?? 0) + 1;
layerFrames[layerId] = frameId;
// Signal write in progress
buffer.ref.frameIdPost = frameId;
buffer.ref.windowHeight = windowHeight;
// Write commands (max 1024)
final cmdCount = commands.length < 1024 ? commands.length : 1024;
buffer.ref.commandCount = cmdCount;
for (int i = 0; i < cmdCount; i++) {
buffer.ref.commands[i] = commands[i].index;
}
// Write points (max 2048 floats = 1024 points)
final ptCount = points.length < 2048 ? points.length : 2048;
buffer.ref.pointCount = ptCount ~/ 2;
for (int i = 0; i < ptCount; i++) {
buffer.ref.points[i] = points[i];
}
// Signal write complete
buffer.ref.frameId = frameId;
}