diff --git a/ui/gl/gl_image.cpp b/ui/gl/gl_image.cpp index fc0e348..cb04fdd 100644 --- a/ui/gl/gl_image.cpp +++ b/ui/gl/gl_image.cpp @@ -73,6 +73,7 @@ QImage Image::takeImage() { void Image::invalidate() { _storage = base::take(_image); + _subimage = QSize(); } void Image::bind(QOpenGLFunctions &f) { @@ -119,8 +120,10 @@ void Image::bind(QOpenGLFunctions &f) { } void Image::destroy(QOpenGLFunctions *f) { + invalidate(); _textures.destroy(f); _cacheKey = 0; + _textureSize = QSize(); } TexturedRect Image::texturedRect( diff --git a/ui/gl/gl_surface.cpp b/ui/gl/gl_surface.cpp index cd57156..c9ac213 100644 --- a/ui/gl/gl_surface.cpp +++ b/ui/gl/gl_surface.cpp @@ -30,11 +30,14 @@ public: private: void initializeGL() override; void resizeGL(int w, int h) override; + void paintEvent(QPaintEvent *e) override; void paintGL() override; void callDeInit(); const std::unique_ptr _renderer; QMetaObject::Connection _connection; + QSize _deviceSize; + bool _inPaintEvent = false; }; @@ -76,9 +79,23 @@ void SurfaceOpenGL::initializeGL() { } void SurfaceOpenGL::resizeGL(int w, int h) { + _deviceSize = QSize(w, h) * devicePixelRatio(); _renderer->resize(this, *context()->functions(), w, h); } +void SurfaceOpenGL::paintEvent(QPaintEvent *e) { + if (_inPaintEvent) { + return; + } + _inPaintEvent = true; + if (_deviceSize != size() * devicePixelRatio()) { + QResizeEvent event = { size(), size() }; + resizeEvent(&event); + } + QOpenGLWidget::paintEvent(e); + _inPaintEvent = false; +} + void SurfaceOpenGL::paintGL() { if (!updatesEnabled() || size().isEmpty() || !isValid()) { return;