copyTextureToTexture method

void copyTextureToTexture(
  1. TextureRegion source,
  2. TextureDestinationRegion destination
)

Copies pixels from source into destination.

This is a raw copy. Source and destination textures must have matching formats and sample counts.

Implementation

void copyTextureToTexture(
  TextureRegion source,
  TextureDestinationRegion destination,
) {
  source._validate(allowMipAndSlice: false);
  destination._validate(source);
  if (source.texture.format != destination.texture.format) {
    throw Exception(
      'Source and destination textures must have matching formats',
    );
  }
  if (source.texture.sampleCount != destination.texture.sampleCount) {
    throw Exception(
      'Source and destination textures must have matching sample counts',
    );
  }
  final String? error = _copyTextureToTexture(
    source.texture,
    destination.texture,
    source.x,
    source.y,
    source._resolvedWidth(),
    source._resolvedHeight(),
    destination.x,
    destination.y,
  );
  if (error != null) {
    throw Exception(error);
  }
}