@@ -167,7 +167,9 @@ WebView::WebView(flutter::PluginRegistrar* registrar, int viewId,
167
167
is_mouse_lbutton_down_(false ),
168
168
has_navigation_delegate_(false ),
169
169
has_progress_tracking_(false ),
170
- context_(nullptr ) {
170
+ context_(nullptr ),
171
+ texture_variant_(nullptr ),
172
+ gpu_buffer_(nullptr ) {
171
173
texture_variant_ = new flutter::TextureVariant (flutter::GpuBufferTexture (
172
174
[this ](size_t width, size_t height) -> const FlutterDesktopGpuBuffer* {
173
175
return this ->CopyGpuBuffer (width, height);
@@ -393,6 +395,11 @@ void WebView::Dispose() {
393
395
delete texture_variant_;
394
396
texture_variant_ = nullptr ;
395
397
}
398
+
399
+ if (gpu_buffer_) {
400
+ delete gpu_buffer_;
401
+ gpu_buffer_ = nullptr ;
402
+ }
396
403
}
397
404
398
405
void WebView::Resize (double width, double height) {
@@ -759,6 +766,10 @@ void WebView::InitWebView() {
759
766
webview_instance_->Destroy ();
760
767
webview_instance_ = nullptr ;
761
768
}
769
+ if (!gpu_buffer_) {
770
+ gpu_buffer_ = new FlutterDesktopGpuBuffer ();
771
+ }
772
+
762
773
float scale_factor = 1 ;
763
774
764
775
webview_instance_ = (LWE::WebContainer*)createWebViewInstance (
@@ -925,11 +936,12 @@ FlutterDesktopGpuBuffer* WebView::CopyGpuBuffer(size_t width, size_t height) {
925
936
rendered_surface_ = candidate_surface_;
926
937
candidate_surface_ = nullptr ;
927
938
928
- FlutterDesktopGpuBuffer* gpu_buffer = new FlutterDesktopGpuBuffer ();
929
- gpu_buffer->buffer = rendered_surface_;
930
- gpu_buffer->width = width;
931
- gpu_buffer->height = height;
932
- return gpu_buffer;
939
+ if (gpu_buffer_) {
940
+ gpu_buffer_->buffer = rendered_surface_;
941
+ gpu_buffer_->width = width;
942
+ gpu_buffer_->height = height;
943
+ }
944
+ return gpu_buffer_;
933
945
}
934
946
935
947
void WebView::DestructBuffer (void * buffer) {
0 commit comments