From fa51d82639a500939907fdc9d18497914c60fe2c Mon Sep 17 00:00:00 2001 From: dhewg Date: Sun, 13 Mar 2011 16:37:56 +0100 Subject: ANDROID: Prevent unnecessary reallocs --- backends/platform/android/texture.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'backends/platform') diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp index a20222ec64..c309bd51b4 100644 --- a/backends/platform/android/texture.cpp +++ b/backends/platform/android/texture.cpp @@ -218,8 +218,14 @@ GLESTexture::~GLESTexture() { } void GLESTexture::allocBuffer(GLuint w, GLuint h) { + GLuint oldw = _surface.w; + GLuint oldh = _surface.h; + GLESBaseTexture::allocBuffer(w, h); + if (_surface.w == oldw && _surface.h == oldh) + return; + delete[] _buf; delete[] _pixels; @@ -341,9 +347,13 @@ GLESPaletteTexture::~GLESPaletteTexture() { } void GLESPaletteTexture::allocBuffer(GLuint w, GLuint h) { + GLuint oldw = _surface.w; + GLuint oldh = _surface.h; + GLESBaseTexture::allocBuffer(w, h); - // Texture gets uploaded later (from drawTexture()) + if (_surface.w == oldw && _surface.h == oldh) + return; byte *new_buffer = new byte[_paletteSize + _texture_width * _texture_height]; @@ -457,8 +467,14 @@ GLESFakePaletteTexture::~GLESFakePaletteTexture() { } void GLESFakePaletteTexture::allocBuffer(GLuint w, GLuint h) { + GLuint oldw = _surface.w; + GLuint oldh = _surface.h; + GLESBaseTexture::allocBuffer(w, h); + if (_surface.w == oldw && _surface.h == oldh) + return; + delete[] _buf; delete[] _pixels; -- cgit v1.2.3