blob: 42bf2248b72bc0ec6303717dd5d899de8db5b674 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:fidl_fuchsia_cobalt/fidl_async.dart';
import '../utils/frame_rate_tracer.dart';
import '../widgets/rk4_spring_simulation.dart';
import 'spring_model.dart';
export 'spring_model.dart' show ScopedModel, Model, ScopedModelDescendant;
const RK4SpringDescription _kSimulationDesc =
RK4SpringDescription(tension: 450.0, friction: 50.0);
/// Models the progress of a spring simulation.
class TracingSpringModel extends SpringModel {
final FrameRateTracer _frameRateTracer;
final Map<double, int> _targetToCobaltMetricIdMap;
/// Constructor.
RK4SpringDescription springDescription = _kSimulationDesc,
String traceName = 'TracingSpringModel',
Logger cobaltLogger,
Map<double, int> targetToCobaltMetricIdMap = const <double, int>{},
}) : _frameRateTracer = FrameRateTracer(
name: traceName,
cobaltLogger: cobaltLogger,
_targetToCobaltMetricIdMap = targetToCobaltMetricIdMap,
super(springDescription: springDescription);
set target(double target) {
targetName: '$target',
cobaltMetricId: _targetToCobaltMetricIdMap[target],
); = target;
bool handleTick(double elapsedSeconds) {
bool result = super.handleTick(elapsedSeconds);
if (isDone) {
return result;