resize method

Future<void> resize(
  1. FlutterAngleTexture texture,
  2. AngleOptions options
)

Implementation

Future<void> resize(FlutterAngleTexture texture, AngleOptions options) async{
  if(_disposed || Platform.isAndroid) return;

  final height = (options.height * options.dpr).toInt();
  final width = (options.width * options.dpr).toInt();
  await deleteTexture(texture,false);

  final result = await _channel.invokeMethod('resizeTexture', {
    "width": width,
    "height": height,
    "textureId": texture.textureId,
  });

  if(_useSurface){
    final surfacePointer = result['surfacePointer'] as int;
    final surfacePtr = Pointer<Void>.fromAddress(surfacePointer);
    texture.surfaceId = Platform.isWindows?_createEGLSurfaceFromD3DSurface(surfacePtr, width, height) :_createEGLSurfaceFromIOSurface(surfacePtr, width, height);
    _libEGL!.eglMakeCurrent(_display, texture.surfaceId!, texture.surfaceId!, _baseAppContext);
  }
  else if(result != null){
    final int rbo = (result['openglTexture'] as int?) ?? (result['rbo'] as int?) ?? 0;
    _initRenderbuffer(rbo);
    _resizeDepthRenderbuffer(texture.depth, width, height);
    texture.rboId = rbo;

    if(Platform.isLinux){
      _libEGL!.makeCurrent(_baseAppContext);
    }
    else{
      _libEGL!.eglMakeCurrent(_display, _dummySurface, _dummySurface, _baseAppContext);
    }
    _rawOpenGl.glViewport(0, 0, width, height);
  }

  texture.options = options;
}