entriesToInts static method

List<int> entriesToInts(
  1. List<Float32x4> list
)

Implementation

static List<int> entriesToInts(List<Float32x4> list) {
  final lastEntryIndex = list.length - 1;
  var entryIndex = 0;
  var entry = list.first;
  var entryCursor = -1;
  var valueCursor = -1;

  var fs = List.generate(list.length * 4, (i) {
    assert(++valueCursor == i);

    switch (++entryCursor) {
      case 0:
        {
          return entry.x.toInt();
        }
      case 1:
        {
          return entry.y.toInt();
        }
      case 2:
        {
          return entry.z.toInt();
        }
      case 3:
        {
          var w = entry.w;
          if (entryIndex < lastEntryIndex) {
            entry = list[++entryIndex];
            entryCursor = -1;
          }
          return w.toInt();
        }
      default:
        throw StateError('Invalid entryCursor: $entryCursor');
    }
  });

  return fs;
}