CapturedResource.fromJson constructor

CapturedResource.fromJson(
  1. Map<String, Object?> json
)

Rebuilds a resource from toJson output. Textures are not restored; a serialized thumbnail comes back as thumbnailPng.

Implementation

factory CapturedResource.fromJson(Map<String, Object?> json) {
  final png = json['thumbnailPng'];
  return CapturedResource(
    key: json['key'] as String,
    passIndex: json['pass'] as int,
    debugName: json['debugName'] as String?,
    width: json['width'] as int? ?? 0,
    height: json['height'] as int? ?? 0,
    format: _enumByName(gpu.PixelFormat.values, json['format']),
    sampleCount: json['sampleCount'] as int? ?? 1,
    storageMode: _enumByName(gpu.StorageMode.values, json['storageMode']),
    isTexture: json['isTexture'] as bool? ?? true,
    byteLength: json['byteLength'] as int?,
    snapshotFailed: json['snapshotFailed'] as bool? ?? false,
    thumbnailPng: png is String ? base64Decode(png) : null,
  );
}