GlassQualityAdapter constructor

GlassQualityAdapter({
  1. required GlassQuality minQuality,
  2. required GlassQuality maxQuality,
  3. required int targetFrameMs,
  4. required bool allowStepUp,
  5. required void onQualityChanged(
    1. GlassQuality from,
    2. GlassQuality to
    ),
  6. GlassQuality? initialQuality,
  7. double warmupPremiumThresholdMs = 20.0,
  8. double warmupStandardThresholdMs = 28.0,
  9. void onWarmupComplete(
    1. GlassQuality settled,
    2. double p75Ms,
    3. int frames
    )?,
})

Creates a GlassQualityAdapter.

onQualityChanged is called on the Dart main thread whenever the effective quality changes. The callback receives (from, to).

initialQuality overrides both the session cache and Phase 2 — the adapter skips the warm-up benchmark and jumps directly to Phase 3 using the provided quality as its starting point. Use this to restore a quality level previously persisted to storage (e.g. SharedPreferences) so repeat launches skip the warm-up jank window entirely.

Implementation

GlassQualityAdapter({
  required this.minQuality,
  required this.maxQuality,
  required this.targetFrameMs,
  required this.allowStepUp,
  required void Function(GlassQuality from, GlassQuality to) onQualityChanged,
  this.initialQuality,
  this.warmupPremiumThresholdMs = 20.0,
  this.warmupStandardThresholdMs = 28.0,
  void Function(GlassQuality settled, double p75Ms, int frames)?
      onWarmupComplete,
})  : _onQualityChanged = onQualityChanged,
      _onWarmupComplete = onWarmupComplete,
      _currentQuality = maxQuality;