GlassLedger class Cost and policy

The register of glass surfaces on one screen.

A Listenable rather than an inherited value, because geometry moves every frame and a surface changing position must not rebuild anybody's subtree. GlassScope carries one of these down the tree; its identity never changes, so the inherited widget never notifies.

Entries are keyed by the render object that owns them, so a surface which stops repainting keeps its last known place instead of vanishing from the tally on a frame where nothing moved. It leaves the register when its render object detaches, which is what a disposed list cell does.

GlassHost owns one and provides it through GlassScope; reading it is the way to put a number on how much glass a screen carries:

final GlassLoad? load = GlassScope.maybeOf(context)?.read(
  viewSize: MediaQuery.sizeOf(context),
  model: GlassHardware.detect().surfaceCostModel,
);
if (load != null && load.verdict != GlassLoadVerdict.withinMeasured) {
  debugPrint('$load'); // e.g. past the 0.30 screens Adreno was measured to
}

See also:

Inheritance

Constructors

GlassLedger()

Properties

bounds → Rect?
What one capture covering every surface would have to span.
no setter
clusters → Iterable<GlassSurfaceCluster>
The blend groups on this screen, in registration order.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
registered → Iterable<GlassSurfaceGeometry>
The surfaces themselves, in registration order.
no setter
registeredCount → int
How many surfaces are registered — including any that cannot currently say where they are, which is why this is not surfaces.length.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
surfaces → Iterable<GlassSurfaceRecord>
Every surface that can say where it is, read now.
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
dispose() → void
Discards any resources used by the object.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
read({required Size viewSize, required GlassSurfaceCostModel model}) → GlassLoad
Reads the register against the measured limits of one platform.
register(GlassSurfaceGeometry surface) → void
Adds a surface. Notifies, because the set changed: geometry does not notify at all, since it is read rather than stored.
registerCluster(GlassSurfaceCluster cluster) → void
Adds a blend group. Notifies for the same reason register does: the atlas's slots are a function of this, so the grouping changing is the set changing.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
toString() → String
A string representation of this object.
inherited
unregister(GlassSurfaceGeometry surface) → void
Removes a surface, notifying if it was registered. Called when its render object detaches.
unregisterCluster(GlassSurfaceCluster cluster) → void
Removes a blend group, notifying if it was registered.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

shapeAreaOf(RSuperellipse shape) → double
Area of the engine's round superellipse, in logical px².

Constants

cornerCutCoefficient → const double
What one corner of a round superellipse cuts away, as a fraction of rx·ry — measured against the engine's own RSuperellipse.contains, not derived.