Allow Ui::GL::Renderer::deinit on lost context.
This commit is contained in:
parent
a8ce22fd75
commit
29f339e26e
4 changed files with 21 additions and 15 deletions
|
|
@ -29,10 +29,12 @@ void GenerateTextures(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyTextures(QOpenGLFunctions &f, gsl::span<GLuint> values) {
|
void DestroyTextures(QOpenGLFunctions *f, gsl::span<GLuint> values) {
|
||||||
Expects(!values.empty());
|
Expects(!values.empty());
|
||||||
|
|
||||||
f.glDeleteTextures(values.size(), values.data());
|
if (f) {
|
||||||
|
f->glDeleteTextures(values.size(), values.data());
|
||||||
|
}
|
||||||
ranges::fill(values, 0);
|
ranges::fill(values, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,10 +44,12 @@ void GenerateFramebuffers(QOpenGLFunctions &f, gsl::span<GLuint> values) {
|
||||||
f.glGenFramebuffers(values.size(), values.data());
|
f.glGenFramebuffers(values.size(), values.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyFramebuffers(QOpenGLFunctions &f, gsl::span<GLuint> values) {
|
void DestroyFramebuffers(QOpenGLFunctions *f, gsl::span<GLuint> values) {
|
||||||
Expects(!values.empty());
|
Expects(!values.empty());
|
||||||
|
|
||||||
f.glDeleteTextures(values.size(), values.data());
|
if (f) {
|
||||||
|
f->glDeleteTextures(values.size(), values.data());
|
||||||
|
}
|
||||||
ranges::fill(values, 0);
|
ranges::fill(values, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,7 +118,7 @@ void Image::bind(QOpenGLFunctions &f) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::destroy(QOpenGLFunctions &f) {
|
void Image::destroy(QOpenGLFunctions *f) {
|
||||||
_textures.destroy(f);
|
_textures.destroy(f);
|
||||||
_cacheKey = 0;
|
_cacheKey = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@ void GenerateTextures(
|
||||||
gsl::span<GLuint> values,
|
gsl::span<GLuint> values,
|
||||||
GLint filter,
|
GLint filter,
|
||||||
GLint clamp);
|
GLint clamp);
|
||||||
void DestroyTextures(QOpenGLFunctions &f, gsl::span<GLuint> values);
|
void DestroyTextures(QOpenGLFunctions *f, gsl::span<GLuint> values);
|
||||||
|
|
||||||
void GenerateFramebuffers(QOpenGLFunctions &f, gsl::span<GLuint> values);
|
void GenerateFramebuffers(QOpenGLFunctions &f, gsl::span<GLuint> values);
|
||||||
void DestroyFramebuffers(QOpenGLFunctions &f, gsl::span<GLuint> values);
|
void DestroyFramebuffers(QOpenGLFunctions *f, gsl::span<GLuint> values);
|
||||||
|
|
||||||
} // namespace details
|
} // namespace details
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ public:
|
||||||
clamp);
|
clamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void destroy(QOpenGLFunctions &f) {
|
void destroy(QOpenGLFunctions *f) {
|
||||||
if (created()) {
|
if (created()) {
|
||||||
details::DestroyTextures(f, gsl::make_span(_values));
|
details::DestroyTextures(f, gsl::make_span(_values));
|
||||||
}
|
}
|
||||||
|
|
@ -79,7 +79,7 @@ public:
|
||||||
details::GenerateFramebuffers(f, gsl::make_span(_values));
|
details::GenerateFramebuffers(f, gsl::make_span(_values));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void destroy(QOpenGLFunctions &f) {
|
void destroy(QOpenGLFunctions *f) {
|
||||||
if (created()) {
|
if (created()) {
|
||||||
details::DestroyFramebuffers(f, gsl::make_span(_values));
|
details::DestroyFramebuffers(f, gsl::make_span(_values));
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +113,7 @@ public:
|
||||||
void invalidate();
|
void invalidate();
|
||||||
|
|
||||||
void bind(QOpenGLFunctions &f);
|
void bind(QOpenGLFunctions &f);
|
||||||
void destroy(QOpenGLFunctions &f);
|
void destroy(QOpenGLFunctions *f);
|
||||||
|
|
||||||
[[nodiscard]] TexturedRect texturedRect(
|
[[nodiscard]] TexturedRect texturedRect(
|
||||||
const QRect &geometry,
|
const QRect &geometry,
|
||||||
|
|
|
||||||
|
|
@ -107,11 +107,13 @@ void SurfaceOpenGL::callDeInit() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QObject::disconnect(base::take(_connection));
|
QObject::disconnect(base::take(_connection));
|
||||||
const auto surface = window()->windowHandle();
|
makeCurrent();
|
||||||
Assert(surface != nullptr);
|
|
||||||
const auto context = this->context();
|
const auto context = this->context();
|
||||||
context->makeCurrent(surface);
|
_renderer->deinit(
|
||||||
_renderer->deinit(this, *context->functions());
|
this,
|
||||||
|
((isValid() && context && QOpenGLContext::currentContext() == context)
|
||||||
|
? context->functions()
|
||||||
|
: nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
SurfaceRaster::SurfaceRaster(
|
SurfaceRaster::SurfaceRaster(
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public:
|
||||||
|
|
||||||
virtual void deinit(
|
virtual void deinit(
|
||||||
not_null<QOpenGLWidget*> widget,
|
not_null<QOpenGLWidget*> widget,
|
||||||
QOpenGLFunctions &f) {
|
QOpenGLFunctions *f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void resize(
|
virtual void resize(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue