Release the D3D texture on any actual redefine.

TRAC #18714 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@841 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent d14558a2
...@@ -42,24 +42,28 @@ Image::~Image() ...@@ -42,24 +42,28 @@ Image::~Image()
} }
} }
void Image::redefine(GLenum format, GLsizei width, GLsizei height, GLenum type) bool Image::redefine(GLenum format, GLsizei width, GLsizei height, GLenum type)
{ {
if (mWidth != width || if (mWidth != width ||
mHeight != height || mHeight != height ||
mFormat != format || mFormat != format ||
mType != type) mType != type)
{ {
mWidth = width;
mHeight = height;
mFormat = format;
mType = type;
if (mSurface) if (mSurface)
{ {
mSurface->Release(); mSurface->Release();
mSurface = NULL; mSurface = NULL;
} }
return true;
} }
mWidth = width; return false;
mHeight = height;
mFormat = format;
mType = type;
} }
void Image::createSurface() void Image::createSurface()
...@@ -1559,25 +1563,11 @@ D3DFORMAT Texture2D::getD3DFormat() const ...@@ -1559,25 +1563,11 @@ D3DFORMAT Texture2D::getD3DFormat() const
void Texture2D::redefineImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type) void Texture2D::redefineImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type)
{ {
GLsizei textureWidth = mImageArray[0].getWidth();
GLsizei textureHeight = mImageArray[0].getHeight();
GLenum textureFormat = mImageArray[0].getFormat();
GLenum textureType = mImageArray[0].getType();
releaseTexImage(); releaseTexImage();
mImageArray[level].redefine(format, width, height, type); bool redefined = mImageArray[level].redefine(format, width, height, type);
if (!mTexture)
{
return;
}
bool widthOkay = (textureWidth >> level == width) || (textureWidth >> level == 0 && width == 1);
bool heightOkay = (textureHeight >> level == height) || (textureHeight >> level == 0 && height == 1);
bool textureOkay = (widthOkay && heightOkay && textureFormat == format && textureType == type);
if (!textureOkay) if (mTexture && redefined)
{ {
for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++) for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
{ {
...@@ -2493,22 +2483,9 @@ unsigned int TextureCubeMap::faceIndex(GLenum face) ...@@ -2493,22 +2483,9 @@ unsigned int TextureCubeMap::faceIndex(GLenum face)
void TextureCubeMap::redefineImage(int face, GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type) void TextureCubeMap::redefineImage(int face, GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type)
{ {
GLsizei textureWidth = mImageArray[0][0].getWidth(); bool redefined = mImageArray[face][level].redefine(format, width, height, type);
GLsizei textureHeight = mImageArray[0][0].getHeight();
GLenum textureFormat = mImageArray[0][0].getFormat();
GLenum textureType = mImageArray[0][0].getType();
mImageArray[face][level].redefine(format, width, height, type);
if (!mTexture)
{
return;
}
bool sizeOkay = (textureWidth >> level == width);
bool textureOkay = (sizeOkay && textureFormat == format && textureType == type);
if (!textureOkay) if (mTexture && redefined)
{ {
for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++) for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
{ {
......
...@@ -49,7 +49,7 @@ class Image ...@@ -49,7 +49,7 @@ class Image
Image(); Image();
~Image(); ~Image();
void redefine(GLenum format, GLsizei width, GLsizei height, GLenum type); bool redefine(GLenum format, GLsizei width, GLsizei height, GLenum type);
void markDirty() {mDirty = true;} void markDirty() {mDirty = true;}
void markClean() {mDirty = false;} void markClean() {mDirty = false;}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment