Fixes erroneous copy in subImage calls after failure is already detected.

TRAC #13074 Also adds initializations for missed Texture members. Signed-off-by: Daniel Koch Author: Shannon Woods git-svn-id: https://angleproject.googlecode.com/svn/trunk@368 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 257e8d0f
...@@ -39,6 +39,9 @@ Texture::Texture(GLuint id) : RefCountObject(id) ...@@ -39,6 +39,9 @@ Texture::Texture(GLuint id) : RefCountObject(id)
mWrapS = GL_REPEAT; mWrapS = GL_REPEAT;
mWrapT = GL_REPEAT; mWrapT = GL_REPEAT;
mWidth = 0;
mHeight = 0;
mDirtyMetaData = true; mDirtyMetaData = true;
mDirty = true; mDirty = true;
mIsRenderable = false; mIsRenderable = false;
...@@ -337,9 +340,13 @@ void Texture::setImage(GLsizei width, GLsizei height, GLenum format, GLenum type ...@@ -337,9 +340,13 @@ void Texture::setImage(GLsizei width, GLsizei height, GLenum format, GLenum type
mDirtyMetaData = true; mDirtyMetaData = true;
} }
void Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *img) bool Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *img)
{ {
if (width + xoffset > img->width || height + yoffset > img->height) return error(GL_INVALID_VALUE); if (width + xoffset > img->width || height + yoffset > img->height)
{
error(GL_INVALID_VALUE);
return false;
}
D3DLOCKED_RECT locked; D3DLOCKED_RECT locked;
HRESULT result = img->surface->LockRect(&locked, NULL, 0); HRESULT result = img->surface->LockRect(&locked, NULL, 0);
...@@ -353,6 +360,7 @@ void Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig ...@@ -353,6 +360,7 @@ void Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig
} }
img->dirty = true; img->dirty = true;
return true;
} }
IDirect3DBaseTexture9 *Texture::getTexture() IDirect3DBaseTexture9 *Texture::getTexture()
...@@ -560,8 +568,10 @@ void Texture2D::commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei wi ...@@ -560,8 +568,10 @@ void Texture2D::commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei wi
void Texture2D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels) void Texture2D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{ {
Texture::subImage(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels, &mImageArray[level]); if (Texture::subImage(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels, &mImageArray[level]))
commitRect(level, xoffset, yoffset, width, height); {
commitRect(level, xoffset, yoffset, width, height);
}
} }
void Texture2D::copyImage(GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source) void Texture2D::copyImage(GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, RenderbufferStorage *source)
...@@ -996,8 +1006,10 @@ void TextureCubeMap::commitRect(GLenum faceTarget, GLint level, GLint xoffset, G ...@@ -996,8 +1006,10 @@ void TextureCubeMap::commitRect(GLenum faceTarget, GLint level, GLint xoffset, G
void TextureCubeMap::subImage(GLenum face, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels) void TextureCubeMap::subImage(GLenum face, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{ {
Texture::subImage(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels, &mImageArray[faceIndex(face)][level]); if (Texture::subImage(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels, &mImageArray[faceIndex(face)][level]))
commitRect(face, level, xoffset, yoffset, width, height); {
commitRect(face, level, xoffset, yoffset, width, height);
}
} }
// Tests for GL texture object completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81. // Tests for GL texture object completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
......
...@@ -106,13 +106,8 @@ class Texture : public RefCountObject ...@@ -106,13 +106,8 @@ class Texture : public RefCountObject
static D3DFORMAT selectFormat(GLenum format); static D3DFORMAT selectFormat(GLenum format);
int imagePitch(const Image& img) const; int imagePitch(const Image& img) const;
GLenum mMinFilter;
GLenum mMagFilter;
GLenum mWrapS;
GLenum mWrapT;
void setImage(GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *img); void setImage(GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *img);
void subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *img); bool subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, Image *img);
void needRenderTarget(); void needRenderTarget();
...@@ -132,22 +127,26 @@ class Texture : public RefCountObject ...@@ -132,22 +127,26 @@ class Texture : public RefCountObject
Blit *getBlitter(); Blit *getBlitter();
int levelCount() const;
unsigned int mWidth; unsigned int mWidth;
unsigned int mHeight; unsigned int mHeight;
GLenum mMinFilter;
int levelCount() const; GLenum mMagFilter;
GLenum mWrapS;
GLenum mWrapT;
private: private:
DISALLOW_COPY_AND_ASSIGN(Texture); DISALLOW_COPY_AND_ASSIGN(Texture);
void loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type,
GLint unpackAlignment, const void *input, std::size_t outputPitch, void *output) const;
IDirect3DBaseTexture9 *mBaseTexture; // This is a weak pointer. The derived class is assumed to own a strong pointer. IDirect3DBaseTexture9 *mBaseTexture; // This is a weak pointer. The derived class is assumed to own a strong pointer.
bool mDirtyMetaData;
bool mIsRenderable;
bool mDirty; bool mDirty;
bool mDirtyMetaData;
void loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, bool mIsRenderable;
GLint unpackAlignment, const void *input, std::size_t outputPitch, void *output) const;
}; };
class Texture2D : public Texture class Texture2D : public Texture
...@@ -176,9 +175,11 @@ class Texture2D : public Texture ...@@ -176,9 +175,11 @@ class Texture2D : public Texture
virtual IDirect3DBaseTexture9 *createTexture(); virtual IDirect3DBaseTexture9 *createTexture();
virtual void updateTexture(); virtual void updateTexture();
virtual IDirect3DBaseTexture9 *convertToRenderTarget(); virtual IDirect3DBaseTexture9 *convertToRenderTarget();
virtual IDirect3DSurface9 *getRenderTarget(GLenum target);
virtual bool dirtyImageData() const; virtual bool dirtyImageData() const;
bool redefineTexture(GLint level, GLenum internalFormat, GLsizei width, GLsizei height);
void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
Image mImageArray[MAX_TEXTURE_LEVELS]; Image mImageArray[MAX_TEXTURE_LEVELS];
...@@ -186,10 +187,6 @@ class Texture2D : public Texture ...@@ -186,10 +187,6 @@ class Texture2D : public Texture
IDirect3DTexture9 *mTexture; IDirect3DTexture9 *mTexture;
Renderbuffer *mColorbufferProxy; Renderbuffer *mColorbufferProxy;
bool redefineTexture(GLint level, GLenum internalFormat, GLsizei width, GLsizei height);
virtual IDirect3DSurface9 *getRenderTarget(GLenum target);
}; };
class TextureCubeMap : public Texture class TextureCubeMap : public Texture
...@@ -224,6 +221,7 @@ class TextureCubeMap : public Texture ...@@ -224,6 +221,7 @@ class TextureCubeMap : public Texture
virtual IDirect3DBaseTexture9 *createTexture(); virtual IDirect3DBaseTexture9 *createTexture();
virtual void updateTexture(); virtual void updateTexture();
virtual IDirect3DBaseTexture9 *convertToRenderTarget(); virtual IDirect3DBaseTexture9 *convertToRenderTarget();
virtual IDirect3DSurface9 *getRenderTarget(GLenum target);
virtual bool dirtyImageData() const; virtual bool dirtyImageData() const;
...@@ -244,8 +242,6 @@ class TextureCubeMap : public Texture ...@@ -244,8 +242,6 @@ class TextureCubeMap : public Texture
IDirect3DCubeTexture9 *mTexture; IDirect3DCubeTexture9 *mTexture;
Renderbuffer *mFaceProxies[6]; Renderbuffer *mFaceProxies[6];
virtual IDirect3DSurface9 *getRenderTarget(GLenum target);
}; };
} }
......
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