Commit eeb7b0e9 by Jamie Madill

Squash the Texture attachment classes into one.

BUG=angle:732 Change-Id: Ib6b26fe1351bc09e729178f6ec8b8d2ec1f7ff58 Reviewed-on: https://chromium-review.googlesource.com/213970Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent cc00239d
...@@ -69,8 +69,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum binding, GLenum type ...@@ -69,8 +69,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum binding, GLenum type
Texture *texture = context->getTexture(handle); Texture *texture = context->getTexture(handle);
if (texture && texture->getTarget() == GL_TEXTURE_2D) if (texture && texture->getTarget() == GL_TEXTURE_2D)
{ {
Texture2D *tex2D = static_cast<Texture2D*>(texture); return new TextureAttachment(binding, texture, ImageIndex::Make2D(level));
return new Texture2DAttachment(binding, tex2D, level);
} }
else else
{ {
...@@ -88,8 +87,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum binding, GLenum type ...@@ -88,8 +87,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum binding, GLenum type
Texture *texture = context->getTexture(handle); Texture *texture = context->getTexture(handle);
if (texture && texture->getTarget() == GL_TEXTURE_CUBE_MAP) if (texture && texture->getTarget() == GL_TEXTURE_CUBE_MAP)
{ {
TextureCubeMap *texCube = static_cast<TextureCubeMap*>(texture); return new TextureAttachment(binding, texture, ImageIndex::MakeCube(type, level));
return new TextureCubeMapAttachment(binding, texCube, type, level);
} }
else else
{ {
...@@ -102,8 +100,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum binding, GLenum type ...@@ -102,8 +100,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum binding, GLenum type
Texture *texture = context->getTexture(handle); Texture *texture = context->getTexture(handle);
if (texture && texture->getTarget() == GL_TEXTURE_3D) if (texture && texture->getTarget() == GL_TEXTURE_3D)
{ {
Texture3D *tex3D = static_cast<Texture3D*>(texture); return new TextureAttachment(binding, texture, ImageIndex::Make3D(level, layer));
return new Texture3DAttachment(binding, tex3D, level, layer);
} }
else else
{ {
...@@ -116,8 +113,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum binding, GLenum type ...@@ -116,8 +113,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum binding, GLenum type
Texture *texture = context->getTexture(handle); Texture *texture = context->getTexture(handle);
if (texture && texture->getTarget() == GL_TEXTURE_2D_ARRAY) if (texture && texture->getTarget() == GL_TEXTURE_2D_ARRAY)
{ {
Texture2DArray *tex2DArray = static_cast<Texture2DArray*>(texture); return new TextureAttachment(binding, texture, ImageIndex::Make2DArray(level, layer));
return new Texture2DArrayAttachment(binding, tex2DArray, level, layer);
} }
else else
{ {
......
...@@ -78,14 +78,21 @@ bool FramebufferAttachment::isTexture() const ...@@ -78,14 +78,21 @@ bool FramebufferAttachment::isTexture() const
///// TextureAttachment Implementation //////// ///// TextureAttachment Implementation ////////
TextureAttachment::TextureAttachment(GLenum binding, const ImageIndex &index) TextureAttachment::TextureAttachment(GLenum binding, Texture *texture, const ImageIndex &index)
: FramebufferAttachment(binding), : FramebufferAttachment(binding),
mIndex(index) mIndex(index)
{} {
mTexture.set(texture);
}
TextureAttachment::~TextureAttachment()
{
mTexture.set(NULL);
}
rx::TextureStorage *TextureAttachment::getTextureStorage() rx::TextureStorage *TextureAttachment::getTextureStorage()
{ {
return getTexture()->getNativeTexture()->getStorageInstance(); return mTexture->getNativeTexture()->getStorageInstance();
} }
GLsizei TextureAttachment::getSamples() const GLsizei TextureAttachment::getSamples() const
...@@ -95,32 +102,32 @@ GLsizei TextureAttachment::getSamples() const ...@@ -95,32 +102,32 @@ GLsizei TextureAttachment::getSamples() const
GLuint TextureAttachment::id() const GLuint TextureAttachment::id() const
{ {
return getTexture()->id(); return mTexture->id();
} }
unsigned int TextureAttachment::getTextureSerial() const unsigned int TextureAttachment::getTextureSerial() const
{ {
return getTexture()->getTextureSerial(); return mTexture->getTextureSerial();
} }
GLsizei TextureAttachment::getWidth() const GLsizei TextureAttachment::getWidth() const
{ {
return getTexture()->getWidth(mIndex); return mTexture->getWidth(mIndex);
} }
GLsizei TextureAttachment::getHeight() const GLsizei TextureAttachment::getHeight() const
{ {
return getTexture()->getHeight(mIndex); return mTexture->getHeight(mIndex);
} }
GLenum TextureAttachment::getInternalFormat() const GLenum TextureAttachment::getInternalFormat() const
{ {
return getTexture()->getInternalFormat(mIndex); return mTexture->getInternalFormat(mIndex);
} }
GLenum TextureAttachment::getActualFormat() const GLenum TextureAttachment::getActualFormat() const
{ {
return getTexture()->getActualFormat(mIndex); return mTexture->getActualFormat(mIndex);
} }
GLenum TextureAttachment::type() const GLenum TextureAttachment::type() const
...@@ -140,91 +147,12 @@ GLint TextureAttachment::layer() const ...@@ -140,91 +147,12 @@ GLint TextureAttachment::layer() const
rx::RenderTarget *TextureAttachment::getRenderTarget() rx::RenderTarget *TextureAttachment::getRenderTarget()
{ {
return getTexture()->getRenderTarget(mIndex); return mTexture->getRenderTarget(mIndex);
} }
unsigned int TextureAttachment::getSerial() const unsigned int TextureAttachment::getSerial() const
{ {
return getTexture()->getRenderTargetSerial(mIndex); return mTexture->getRenderTargetSerial(mIndex);
}
///// Texture2DAttachment Implementation ////////
Texture2DAttachment::Texture2DAttachment(GLenum binding, Texture2D *texture, GLint level)
: TextureAttachment(binding, ImageIndex::Make2D(level)),
mLevel(level)
{
mTexture2D.set(texture);
}
Texture2DAttachment::~Texture2DAttachment()
{
mTexture2D.set(NULL);
}
Texture *Texture2DAttachment::getTexture() const
{
return mTexture2D.get();
}
///// TextureCubeMapAttachment Implementation ////////
TextureCubeMapAttachment::TextureCubeMapAttachment(GLenum binding, TextureCubeMap *texture, GLenum faceTarget, GLint level)
: TextureAttachment(binding, ImageIndex::MakeCube(faceTarget, level)),
mFaceTarget(faceTarget),
mLevel(level)
{
mTextureCubeMap.set(texture);
}
TextureCubeMapAttachment::~TextureCubeMapAttachment()
{
mTextureCubeMap.set(NULL);
}
Texture *TextureCubeMapAttachment::getTexture() const
{
return mTextureCubeMap.get();
}
///// Texture3DAttachment Implementation ////////
Texture3DAttachment::Texture3DAttachment(GLenum binding, Texture3D *texture, GLint level, GLint layer)
: TextureAttachment(binding, ImageIndex::Make3D(level, layer)),
mLevel(level),
mLayer(layer)
{
mTexture3D.set(texture);
}
Texture3DAttachment::~Texture3DAttachment()
{
mTexture3D.set(NULL);
}
Texture *Texture3DAttachment::getTexture() const
{
return mTexture3D.get();
}
////// Texture2DArrayAttachment Implementation //////
Texture2DArrayAttachment::Texture2DArrayAttachment(GLenum binding, Texture2DArray *texture, GLint level, GLint layer)
: TextureAttachment(binding, ImageIndex::Make2DArray(level, layer)),
mLevel(level),
mLayer(layer)
{
mTexture2DArray.set(texture);
}
Texture2DArrayAttachment::~Texture2DArrayAttachment()
{
mTexture2DArray.set(NULL);
}
Texture *Texture2DArrayAttachment::getTexture() const
{
return mTexture2DArray.get();
} }
////// RenderbufferAttachment Implementation ////// ////// RenderbufferAttachment Implementation //////
......
...@@ -82,7 +82,8 @@ class FramebufferAttachment ...@@ -82,7 +82,8 @@ class FramebufferAttachment
class TextureAttachment : public FramebufferAttachment class TextureAttachment : public FramebufferAttachment
{ {
public: public:
TextureAttachment(GLenum binding, const ImageIndex &index); TextureAttachment(GLenum binding, Texture *texture, const ImageIndex &index);
virtual ~TextureAttachment();
rx::TextureStorage *getTextureStorage(); rx::TextureStorage *getTextureStorage();
virtual GLsizei getSamples() const; virtual GLsizei getSamples() const;
...@@ -101,75 +102,11 @@ class TextureAttachment : public FramebufferAttachment ...@@ -101,75 +102,11 @@ class TextureAttachment : public FramebufferAttachment
virtual rx::RenderTarget *getRenderTarget(); virtual rx::RenderTarget *getRenderTarget();
virtual unsigned int getSerial() const; virtual unsigned int getSerial() const;
protected:
virtual Texture *getTexture() const = 0;
ImageIndex mIndex;
private: private:
DISALLOW_COPY_AND_ASSIGN(TextureAttachment); DISALLOW_COPY_AND_ASSIGN(TextureAttachment);
};
class Texture2DAttachment : public TextureAttachment
{
public:
Texture2DAttachment(GLenum binding, Texture2D *texture, GLint level);
virtual ~Texture2DAttachment();
virtual Texture *getTexture() const;
private:
DISALLOW_COPY_AND_ASSIGN(Texture2DAttachment);
BindingPointer<Texture2D> mTexture2D;
const GLint mLevel;
};
class TextureCubeMapAttachment : public TextureAttachment
{
public:
TextureCubeMapAttachment(GLenum binding, TextureCubeMap *texture, GLenum faceTarget, GLint level);
virtual ~TextureCubeMapAttachment();
virtual Texture *getTexture() const;
private:
DISALLOW_COPY_AND_ASSIGN(TextureCubeMapAttachment);
BindingPointer<TextureCubeMap> mTextureCubeMap; BindingPointer<Texture> mTexture;
const GLint mLevel; ImageIndex mIndex;
const GLenum mFaceTarget;
};
class Texture3DAttachment : public TextureAttachment
{
public:
Texture3DAttachment(GLenum binding, Texture3D *texture, GLint level, GLint layer);
virtual ~Texture3DAttachment();
virtual Texture *getTexture() const;
private:
DISALLOW_COPY_AND_ASSIGN(Texture3DAttachment);
BindingPointer<Texture3D> mTexture3D;
const GLint mLevel;
const GLint mLayer;
};
class Texture2DArrayAttachment : public TextureAttachment
{
public:
Texture2DArrayAttachment(GLenum binding, Texture2DArray *texture, GLint level, GLint layer);
virtual ~Texture2DArrayAttachment();
virtual Texture *getTexture() const;
private:
DISALLOW_COPY_AND_ASSIGN(Texture2DArrayAttachment);
BindingPointer<Texture2DArray> mTexture2DArray;
const GLint mLevel;
const GLint mLayer;
}; };
class RenderbufferAttachment : public FramebufferAttachment class RenderbufferAttachment : public FramebufferAttachment
......
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