mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-04 08:17:40 +00:00
TINYGL: Fix memory leak
This commit is contained in:
parent
4b2e3e6726
commit
ad6dab7bfd
@ -33,7 +33,6 @@ TinyGLTexture::TinyGLTexture(const Graphics::Surface *surface) {
|
||||
_width = surface->w;
|
||||
_height = surface->h;
|
||||
_format = surface->format;
|
||||
_id = 0;
|
||||
_internalFormat = 0;
|
||||
_sourceFormat = 0;
|
||||
|
||||
@ -43,7 +42,6 @@ TinyGLTexture::TinyGLTexture(const Graphics::Surface *surface) {
|
||||
}
|
||||
|
||||
TinyGLTexture::~TinyGLTexture() {
|
||||
tglDeleteTextures(1, &_id);
|
||||
tglDeleteBlitImage(_blitImage);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,6 @@ public:
|
||||
void update(const Graphics::Surface *surface) override;
|
||||
void updatePartial(const Graphics::Surface *surface, const Common::Rect &rect) override;
|
||||
|
||||
TGLuint _id;
|
||||
TGLuint _internalFormat;
|
||||
TGLuint _sourceFormat;
|
||||
|
||||
|
@ -37,15 +37,11 @@ void GLContext::initSharedState() {
|
||||
GLSharedState *s = &shared_state;
|
||||
s->lists = (GLList **)gl_zalloc(sizeof(GLList *) * MAX_DISPLAY_LISTS);
|
||||
s->texture_hash_table = (GLTexture **)gl_zalloc(sizeof(GLTexture *) * TEXTURE_HASH_TABLE_SIZE);
|
||||
|
||||
alloc_texture(0);
|
||||
}
|
||||
|
||||
void GLContext::endSharedState() {
|
||||
GLSharedState *s = &shared_state;
|
||||
|
||||
uint h = 0;
|
||||
free_texture(h);
|
||||
for (int i = 0; i < MAX_DISPLAY_LISTS; i++) {
|
||||
// TODO
|
||||
}
|
||||
@ -146,7 +142,7 @@ void GLContext::init(int screenW, int screenH, Graphics::PixelFormat pixelFormat
|
||||
|
||||
// textures
|
||||
texture_2d_enabled = false;
|
||||
current_texture = alloc_texture(0);
|
||||
current_texture = default_texture = alloc_texture(0);
|
||||
maxTextureName = 0;
|
||||
texture_mag_filter = TGL_LINEAR;
|
||||
texture_min_filter = TGL_NEAREST_MIPMAP_LINEAR;
|
||||
@ -291,6 +287,7 @@ void GLContext::deinit() {
|
||||
specbuf_cleanup();
|
||||
for (int i = 0; i < 3; i++)
|
||||
gl_free(matrix_stack[i]);
|
||||
free_texture(default_texture);
|
||||
endSharedState();
|
||||
gl_free(vertex);
|
||||
delete fb;
|
||||
|
@ -45,10 +45,6 @@ GLTexture *GLContext::find_texture(uint h) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GLContext::free_texture(uint h) {
|
||||
free_texture(find_texture(h));
|
||||
}
|
||||
|
||||
void GLContext::free_texture(GLTexture *t) {
|
||||
GLTexture **ht;
|
||||
GLImage *im;
|
||||
@ -269,7 +265,7 @@ void GLContext::gl_DeleteTextures(TGLsizei n, const TGLuint *textures) {
|
||||
TinyGL::GLTexture *t = find_texture(textures[i]);
|
||||
if (t) {
|
||||
if (t == current_texture) {
|
||||
current_texture = find_texture(0);
|
||||
current_texture = default_texture;
|
||||
}
|
||||
t->disposed = true;
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ struct GLContext {
|
||||
int current_color_material_type;
|
||||
|
||||
// textures
|
||||
GLTexture *current_texture;
|
||||
GLTexture *current_texture, *default_texture;
|
||||
uint maxTextureName;
|
||||
bool texture_2d_enabled;
|
||||
int texture_mag_filter;
|
||||
@ -477,7 +477,6 @@ public:
|
||||
|
||||
GLTexture *alloc_texture(uint h);
|
||||
GLTexture *find_texture(uint h);
|
||||
void free_texture(uint h);
|
||||
void free_texture(GLTexture *t);
|
||||
void gl_GenTextures(TGLsizei n, TGLuint *textures);
|
||||
void gl_DeleteTextures(TGLsizei n, const TGLuint *textures);
|
||||
|
Loading…
Reference in New Issue
Block a user