Move serial management to TextureStorage.

TRAC #18730 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@854 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 5e4dbb30
......@@ -27,7 +27,7 @@
namespace gl
{
unsigned int Texture::mCurrentSerial = 1;
unsigned int TextureStorage::mCurrentSerial = 1;
Image::Image()
: mWidth(0), mHeight(0), mDirty(false), mSurface(NULL), mFormat(GL_NONE), mType(GL_UNSIGNED_BYTE)
......@@ -1199,7 +1199,7 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width,
mDirty = true;
}
TextureStorage::TextureStorage(bool renderable) : mIsRenderable(renderable)
TextureStorage::TextureStorage(bool renderable) : mIsRenderable(renderable), mSerial(issueSerial())
{
}
......@@ -1207,15 +1207,23 @@ TextureStorage::~TextureStorage()
{
}
bool TextureStorage::isRenderable()
bool TextureStorage::isRenderable() const
{
return mIsRenderable;
}
Texture::Texture(GLuint id) : RefCountObject(id)
unsigned int TextureStorage::getSerial() const
{
return mSerial;
}
unsigned int TextureStorage::issueSerial()
{
mSerial = 0;
return mCurrentSerial++;
}
Texture::Texture(GLuint id) : RefCountObject(id)
{
mMinFilter = GL_NEAREST_MIPMAP_LINEAR;
mMagFilter = GL_LINEAR;
mWrapS = GL_REPEAT;
......@@ -1488,7 +1496,8 @@ void Texture::resetDirty()
unsigned int Texture::getSerial() const
{
return mSerial;
TextureStorage *texture = getStorage();
return texture ? texture->getSerial() : 0;
}
GLint Texture::creationLevels(GLsizei width, GLsizei height) const
......@@ -1514,11 +1523,6 @@ int Texture::levelCount() const
return getBaseTexture() ? getBaseTexture()->GetLevelCount() : 0;
}
unsigned int Texture::issueSerial()
{
return mCurrentSerial++;
}
TextureStorage2D::TextureStorage2D(IDirect3DTexture9 *surfaceTexture) : TextureStorage(true)
{
mTexture = surfaceTexture;
......@@ -1626,7 +1630,6 @@ void Texture2D::redefineImage(GLint level, GLenum format, GLsizei width, GLsizei
delete mTexture;
mTexture = NULL;
mSerial = 0;
mDirtyImages = true;
mColorbufferProxy.set(NULL);
}
......@@ -1662,7 +1665,6 @@ void Texture2D::bindTexImage(egl::Surface *surface)
delete mTexture;
mTexture = new TextureStorage2D(surface->getOffscreenTexture());
mSerial = issueSerial();
mColorbufferProxy.set(NULL);
mDirtyImages = true;
mSurface = surface;
......@@ -1680,7 +1682,6 @@ void Texture2D::releaseTexImage()
{
delete mTexture;
mTexture = NULL;
mSerial = 0;
mColorbufferProxy.set(NULL);
}
......@@ -1948,7 +1949,6 @@ void Texture2D::createTexture()
delete mTexture;
mTexture = new TextureStorage2D(levels, format, width, height, false);
mSerial = issueSerial();
mColorbufferProxy.set(NULL);
mDirtyImages = true;
}
......@@ -2017,7 +2017,6 @@ void Texture2D::convertToRenderTarget()
delete mTexture;
mTexture = newTexture;
mSerial = issueSerial();
mColorbufferProxy.set(NULL);
mDirtyImages = true;
}
......@@ -2113,6 +2112,11 @@ IDirect3DSurface9 *Texture2D::getRenderTarget(GLenum target)
return mTexture->getSurfaceLevel(0);
}
TextureStorage *Texture2D::getStorage() const
{
return mTexture;
}
TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, int size, bool renderable) : TextureStorage(renderable)
{
IDirect3DDevice9 *device = getDevice();
......@@ -2387,7 +2391,6 @@ void TextureCubeMap::createTexture()
delete mTexture;
mTexture = new TextureStorageCubeMap(levels, format, size, false);
mSerial = issueSerial();
for(int face = 0; face < 6; face++) mFaceProxies[face].set(NULL);
mDirtyImages = true;
}
......@@ -2460,7 +2463,7 @@ void TextureCubeMap::convertToRenderTarget()
delete mTexture;
mTexture = newTexture;
mSerial = issueSerial();
for(int face = 0; face < 6; face++) mFaceProxies[face].set(NULL);
mDirtyImages = true;
}
......@@ -2499,7 +2502,7 @@ void TextureCubeMap::redefineImage(int face, GLint level, GLenum format, GLsizei
delete mTexture;
mTexture = NULL;
mSerial = 0;
for(int face = 0; face < 6; face++) mFaceProxies[face].set(NULL);
mDirtyImages = true;
}
......@@ -2739,4 +2742,9 @@ IDirect3DSurface9 *TextureCubeMap::getRenderTarget(GLenum target)
return mTexture->getCubeMapSurface(target, 0);
}
TextureStorage *TextureCubeMap::getStorage() const
{
return mTexture;
}
}
\ No newline at end of file
......@@ -142,12 +142,18 @@ class TextureStorage
virtual ~TextureStorage();
bool isRenderable();
bool isRenderable() const;
unsigned int getSerial() const;
private:
DISALLOW_COPY_AND_ASSIGN(TextureStorage);
bool mIsRenderable;
const bool mIsRenderable;
const unsigned int mSerial;
static unsigned int issueSerial();
static unsigned int mCurrentSerial;
};
class Texture : public RefCountObject
......@@ -220,13 +226,10 @@ class Texture : public RefCountObject
bool mDirtyImages;
unsigned int mSerial;
static unsigned int issueSerial();
private:
DISALLOW_COPY_AND_ASSIGN(Texture);
static unsigned int mCurrentSerial;
virtual TextureStorage *getStorage() const = 0;
};
class TextureStorage2D : public TextureStorage
......@@ -285,6 +288,7 @@ class Texture2D : public Texture
virtual void updateTexture();
virtual void convertToRenderTarget();
virtual IDirect3DSurface9 *getRenderTarget(GLenum target);
virtual TextureStorage *getStorage() const;
void redefineImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLenum type);
void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
......@@ -357,6 +361,7 @@ class TextureCubeMap : public Texture
virtual void updateTexture();
virtual void convertToRenderTarget();
virtual IDirect3DSurface9 *getRenderTarget(GLenum target);
virtual TextureStorage *getStorage() const;
static unsigned int faceIndex(GLenum face);
......
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