overwrite method

bool overwrite(
  1. ByteData sourceBytes
)

Overwrite the entire base mipmap level of this Texture.

This method can only be used if the Texture was created with StorageMode.hostVisible. An exception will be thrown otherwise.

The length of sourceBytes must be exactly the size of the base mip level, otherwise an exception will be thrown. The size of the base mip level is always width * height * bytesPerPixel.

Returns true if the write was successful, or false if the write failed due to an internal error.

Implementation

bool overwrite(ByteData sourceBytes) {
  if (storageMode != StorageMode.hostVisible) {
    throw Exception(
        'Texture.overwrite can only be used with Textures that are host visible');
  }
  int baseMipSize = GetBaseMipLevelSizeInBytes();
  if (sourceBytes.lengthInBytes != baseMipSize) {
    throw Exception(
        'The length of sourceBytes (bytes: ${sourceBytes.lengthInBytes}) must exactly match the size of the base mip level (bytes: ${baseMipSize})');
  }
  return _overwrite(sourceBytes);
}