feat: (flutter) (windows) add DestroyRenderingSurface method

This commit is contained in:
Nick Fisher
2024-10-23 02:24:34 +11:00
parent b6fe78b82c
commit 2536f7fc6f
2 changed files with 34 additions and 3 deletions

View File

@@ -13,8 +13,8 @@ WGLContext::WGLContext(flutter::PluginRegistrarWindows *pluginRegistrar,
: FlutterRenderContext(pluginRegistrar, textureRegistrar) {
#if WGL_USE_BACKING_WINDOW
return;
#endif
#else
auto hwnd = pluginRegistrar->GetView()->GetNativeWindow();
@@ -98,6 +98,7 @@ WGLContext::WGLContext(flutter::PluginRegistrarWindows *pluginRegistrar,
std::cout << "Failed to create OpenGL context." << std::endl;
return;
}
#endif
}
void WGLContext::ResizeRenderingSurface(uint32_t width, uint32_t height, uint32_t left, uint32_t top) {
@@ -106,6 +107,33 @@ void WGLContext::ResizeRenderingSurface(uint32_t width, uint32_t height, uint32_
#endif
}
void WGLContext::DestroyRenderingSurface(std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
#if WGL_USE_BACKING_WINDOW
_backingWindow->Destroy();
_backingWindow = nullptr;
#else
// if (!_active) {
// result->Success("Texture has already been detroyed, ignoring");
// return;
// }
// auto sh = std::make_shared<
// std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>>>(
// std::move(result));
// _textureRegistrar->UnregisterTexture(
// _active->flutterTextureId, [=, sharedResult = std::move(sh)]() {
// this->_inactive = std::move(this->_active);
// auto unique = std::move(*(sharedResult.get()));
// unique->Success(flutter::EncodableValue(true));
// std::cout << "Unregistered/destroyed texture." << std::endl;
// });
// }
#endif
}
void WGLContext::CreateRenderingSurface(
uint32_t width, uint32_t height,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result, uint32_t left, uint32_t top) {

View File

@@ -16,6 +16,9 @@ namespace thermion_flutter {
void CreateRenderingSurface(
uint32_t width, uint32_t height,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result, uint32_t left, uint32_t top);
void DestroyRenderingSurface(std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
void ResizeRenderingSurface(
uint32_t width, uint32_t height, uint32_t left, uint32_t top
);