Bug 1622520 - only run Renderbuffer cleanup code when erased. r=jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D66868

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Lee Salzman 2020-03-14 14:41:15 +00:00
Родитель 4aa4a8f29b
Коммит 358ec1ba7f
1 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -151,7 +151,7 @@ struct Framebuffer {
struct Renderbuffer {
GLuint texture = 0;
~Renderbuffer();
void on_erase();
};
TextureFilter gl_filter_to_texture_filter(int type) {
@ -376,8 +376,14 @@ struct ObjectStore {
O* find(size_t i) const { return i < size ? objects[i] : nullptr; }
template <typename T> void on_erase(T* o, ...) {}
template <typename T> void on_erase(T* o, decltype(&T::on_erase)) {
o->on_erase();
}
bool erase(size_t i) {
if (i < size && objects[i]) {
on_erase(objects[i], nullptr);
delete objects[i];
objects[i] = nullptr;
if (i < first_free) first_free = i;
@ -1398,7 +1404,7 @@ void GenRenderbuffers(int n, GLuint* result) {
}
}
Renderbuffer::~Renderbuffer() {
void Renderbuffer::on_erase() {
for (auto* fb : ctx->framebuffers) {
if (fb) {
if (unlink(fb->color_attachment, texture)) {