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