luv

Workshop wiki

mcclim.lisp

lobby/mcclim.lisp

system luv/lobby/mcclim · 21 definitions · on GitHub

A shared retained-GPU lobby instrument.

handle-repaint reads only the frame's immutable semantic snapshot. The application refresh seam copies lobby state before paint, then the direct compositor evaluates analytic media and Slug text in the destination's native pixels with ordinary premultiplied-alpha composition.

in-package#:luv.lobby.mcclim
defconstant+lobby-hud-width+320
defconstant+lobby-hud-height+140
defconstant+lobby-hud-margin+16
defunlobby-hud-alpha-ink
redgreenbluealpha
compose-in
make-rgb-colorredgreenblue
make-opacityalpha
defparameter*lobby-hud-edge-ink*
lobby-hud-alpha-ink0.440.490.460.48
defparameter*lobby-hud-panel-ink*
lobby-hud-alpha-ink0.0250.0300.0340.84
defparameter*lobby-hud-text-ink*
make-rgb-color0.820.850.83
defparameter*lobby-hud-muted-ink*
make-rgb-color0.490.530.51
define-application-framelobby-hud
client:initarg:client:readerlobby-hud-client
visible-snapshot:initarg:visible-snapshot:accessorlobby-hud-visible-snapshot
painted-revision:initform-1:accessorlobby-hud-painted-revision
compositor:initformnil:accessorlobby-hud-compositor
:menu-barnil

The pane background is part of McCLIM's retained stream. Leaving it at the implementation default paints an opaque white rectangle behind the rounded translucent card even though the card itself is analytic.

:panes
sheet
make-pane'lobby-hud-pane:background+transparent-ink+:width+lobby-hud-width+:height+lobby-hud-height+:min-width+lobby-hud-width+:min-height+lobby-hud-height+:max-width+lobby-hud-width+:max-height+lobby-hud-height+

This single authored surface is its own layout. An intermediate rack pane would contribute the implementation's opaque background.

:layouts
defaultsheet
defunlobby-status-ink
status
ecasestatus
:online
make-rgb-color0.340.860.43
:starting:connecting
make-rgb-color0.880.700.28
:offline
make-rgb-color0.720.380.32
:stopping:stopped
make-rgb-color0.380.420.41
defunlobby-short-error
error
whenerror
if
>
lengtherror
42
concatenate'string
subseqerror039
"..."
error
defmethodhandle-repaint
region
declare
ignoreregion

This is deliberately the only state read by paint. CLIENT's lock and worker are outside the McCLIM repaint transaction.

let*
snapshot
lobby-hud-visible-snapshot
pane-framepane
status
luv.lobby:lobby-snapshot-statussnapshot
peers
luv.lobby:lobby-snapshot-peerssnapshot
error
luv.lobby:lobby-snapshot-last-errorsnapshot
with-sheet-medium
mediumpane
draw-circle*pane20225:ink
draw-text*pane"lobby"3422:align-y:center:text-size14:text-face:bold:ink*lobby-hud-text-ink*
draw-text*pane
string-downcase
symbol-namestatus
22:align-x:right:align-y:center:text-size11:ink*lobby-hud-muted-ink*
cond
peers
loopforpeerinpeersforyfrom51by21repeat4do
draw-circle*pane21y4:ink
make-rgb-color0.340.860.43
draw-text*pane
luv.lobby:lobby-peer-namepeer
35y:align-y:center:text-size13:ink*lobby-hud-text-ink*
anderror
eqstatus:offline
draw-text*pane1752:align-y:center:text-size11:ink*lobby-hud-muted-ink*
t
draw-text*pane"quiet"1752:align-y:center:text-size11:ink*lobby-hud-muted-ink*
defunlobby-hud-mirror
frame&key
errorpt
let*
sheet
frame-top-level-sheetframe
mirror
andsheet
mcluv::sheet-direct-mirrorsheet
cond
mirror
errorp
error"Lobby HUD requires an embedded direct-GPU mirror, got ~S."mirror
tnil
defunvalidate-lobby-hud-direct-presentation
let*
sheet
mcluv:mirror-sheetmirror
when
mcluv:mirror-texturemirror
error"Lobby HUD unexpectedly acquired a raster backing texture."
dolist
let
when
error"Lobby HUD used decomposed primitive fallbacks: ~S"
when
error"Lobby HUD prepared an image/raster command."
frame
defunrepaint-lobby-hud
let
unless
mcluv:mirror-embedded-pmirror
error"Lobby HUD mirror is not embedded in its application canvas."
setf
lobby-hud-painted-revisionframe
luv.lobby:lobby-snapshot-revision
lobby-hud-visible-snapshotframe
frame
defunrefresh-lobby-hud

Copy the current semantic snapshot and repaint only when its revision moved.

let
snapshot
if
/=
luv.lobby:lobby-snapshot-revisionsnapshot
lobby-hud-painted-revisionframe
progn

Publish the complete value before McCLIM begins its repaint.

setf
lobby-hud-visible-snapshotframe
snapshot
frame
defunlobby-hud-screen-state
frameviewport-logical-extent&key

Place frame in the lower-left using destination logical coordinates.

The affine state is expressed against the logical viewport. A high-density drawable therefore supplies its native samples directly to analytic edges and Slug glyphs; no panel-sized texture is enlarged.

declare
ignoreframe
destructuring-bind
viewport-widthviewport-height
viewport-logical-extent
let*
scale
min1.0
/
max1.0
-viewport-width
*2margin
+lobby-hud-width+
/
max1.0
-viewport-height
*2margin
+lobby-hud-height+
half-width
half-height
center-x
+-1.0
/
*2.0margin
viewport-width
half-width
center-y
+-1.0
/
*2.0margin
viewport-height
half-height
make-array12:element-type'single-float:initial-contents
mapcar
lambda
value
coercevalue'single-float
listcenter-xcenter-y0.01.0half-width0.00.00.00.0half-height0.00.0
defunmake-embedded-lobby-hud
clientcanvascontextdevice&key
title"lobby"
install-compositor-pt

Create client's textureless retained HUD on an application's GPU owner.

let*
port
find-port:server-path'
:luv-gpu
manager
or
first
clim-internals::frame-managersport
make-instance'mcluv:luv-frame-manager:portport
frame
let
make-application-frame'lobby-hud:frame-managermanager:enablet:clientclient:visible-snapshotsnapshot
setf
frame-pretty-nameframe
title
handler-case
let*
compositor
andinstall-compositor-p
make-instance'mcluv:direct-gpu-mirror-compositor:mirrormirror
unless
and
mcluv:mirror-embedded-pmirror
null
mcluv:mirror-texturemirror
error"Lobby HUD did not receive a textureless embedded mirror."
whencompositor
setf
mcluv:mirror-compositormirror
compositor
lobby-hud-compositorframe
compositor
frame
error
condition
unless
eq:disowned
frame-stateframe
destroy-frameframe
errorcondition
defundestroy-lobby-hud
when
andframe
not
eq:disowned
frame-stateframe
destroy-frameframe
nil