Commit 3592a338 by Jamie Madill

Add a new TextureAttachment class to simplify FBO attachments.

This single class will eventually replace the four child classes. BUG=angle:732 Change-Id: Ie2862b4458c8b1302ff4fc5fbe0e4ded3b81894d Reviewed-on: https://chromium-review.googlesource.com/213857Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 945f7329
...@@ -75,6 +75,28 @@ bool FramebufferAttachment::isTexture() const ...@@ -75,6 +75,28 @@ bool FramebufferAttachment::isTexture() const
return (type() != GL_RENDERBUFFER); return (type() != GL_RENDERBUFFER);
} }
///// TextureAttachment Implementation ////////
rx::TextureStorage *TextureAttachment::getTextureStorage()
{
return getTexture()->getNativeTexture()->getStorageInstance();
}
GLsizei TextureAttachment::getSamples() const
{
return 0;
}
GLuint TextureAttachment::id() const
{
return getTexture()->id();
}
unsigned int TextureAttachment::getTextureSerial() const
{
return getTexture()->getTextureSerial();
}
///// Texture2DAttachment Implementation //////// ///// Texture2DAttachment Implementation ////////
Texture2DAttachment::Texture2DAttachment(Texture2D *texture, GLint level) : mLevel(level) Texture2DAttachment::Texture2DAttachment(Texture2D *texture, GLint level) : mLevel(level)
...@@ -92,11 +114,6 @@ rx::RenderTarget *Texture2DAttachment::getRenderTarget() ...@@ -92,11 +114,6 @@ rx::RenderTarget *Texture2DAttachment::getRenderTarget()
return mTexture2D->getRenderTarget(mLevel); return mTexture2D->getRenderTarget(mLevel);
} }
rx::TextureStorage *Texture2DAttachment::getTextureStorage()
{
return mTexture2D->getNativeTexture()->getStorageInstance();
}
GLsizei Texture2DAttachment::getWidth() const GLsizei Texture2DAttachment::getWidth() const
{ {
return mTexture2D->getWidth(mLevel); return mTexture2D->getWidth(mLevel);
...@@ -117,21 +134,11 @@ GLenum Texture2DAttachment::getActualFormat() const ...@@ -117,21 +134,11 @@ GLenum Texture2DAttachment::getActualFormat() const
return mTexture2D->getActualFormat(mLevel); return mTexture2D->getActualFormat(mLevel);
} }
GLsizei Texture2DAttachment::getSamples() const
{
return 0;
}
unsigned int Texture2DAttachment::getSerial() const unsigned int Texture2DAttachment::getSerial() const
{ {
return mTexture2D->getRenderTargetSerial(mLevel); return mTexture2D->getRenderTargetSerial(mLevel);
} }
GLuint Texture2DAttachment::id() const
{
return mTexture2D->id();
}
GLenum Texture2DAttachment::type() const GLenum Texture2DAttachment::type() const
{ {
return GL_TEXTURE_2D; return GL_TEXTURE_2D;
...@@ -147,9 +154,9 @@ GLint Texture2DAttachment::layer() const ...@@ -147,9 +154,9 @@ GLint Texture2DAttachment::layer() const
return 0; return 0;
} }
unsigned int Texture2DAttachment::getTextureSerial() const Texture *Texture2DAttachment::getTexture() const
{ {
return mTexture2D->getTextureSerial(); return mTexture2D.get();
} }
///// TextureCubeMapAttachment Implementation //////// ///// TextureCubeMapAttachment Implementation ////////
...@@ -170,11 +177,6 @@ rx::RenderTarget *TextureCubeMapAttachment::getRenderTarget() ...@@ -170,11 +177,6 @@ rx::RenderTarget *TextureCubeMapAttachment::getRenderTarget()
return mTextureCubeMap->getRenderTarget(mFaceTarget, mLevel); return mTextureCubeMap->getRenderTarget(mFaceTarget, mLevel);
} }
rx::TextureStorage *TextureCubeMapAttachment::getTextureStorage()
{
return mTextureCubeMap->getNativeTexture()->getStorageInstance();
}
GLsizei TextureCubeMapAttachment::getWidth() const GLsizei TextureCubeMapAttachment::getWidth() const
{ {
return mTextureCubeMap->getWidth(mFaceTarget, mLevel); return mTextureCubeMap->getWidth(mFaceTarget, mLevel);
...@@ -195,21 +197,11 @@ GLenum TextureCubeMapAttachment::getActualFormat() const ...@@ -195,21 +197,11 @@ GLenum TextureCubeMapAttachment::getActualFormat() const
return mTextureCubeMap->getActualFormat(mFaceTarget, mLevel); return mTextureCubeMap->getActualFormat(mFaceTarget, mLevel);
} }
GLsizei TextureCubeMapAttachment::getSamples() const
{
return 0;
}
unsigned int TextureCubeMapAttachment::getSerial() const unsigned int TextureCubeMapAttachment::getSerial() const
{ {
return mTextureCubeMap->getRenderTargetSerial(mFaceTarget, mLevel); return mTextureCubeMap->getRenderTargetSerial(mFaceTarget, mLevel);
} }
GLuint TextureCubeMapAttachment::id() const
{
return mTextureCubeMap->id();
}
GLenum TextureCubeMapAttachment::type() const GLenum TextureCubeMapAttachment::type() const
{ {
return mFaceTarget; return mFaceTarget;
...@@ -225,9 +217,9 @@ GLint TextureCubeMapAttachment::layer() const ...@@ -225,9 +217,9 @@ GLint TextureCubeMapAttachment::layer() const
return 0; return 0;
} }
unsigned int TextureCubeMapAttachment::getTextureSerial() const Texture *TextureCubeMapAttachment::getTexture() const
{ {
return mTextureCubeMap->getTextureSerial(); return mTextureCubeMap.get();
} }
///// Texture3DAttachment Implementation //////// ///// Texture3DAttachment Implementation ////////
...@@ -248,11 +240,6 @@ rx::RenderTarget *Texture3DAttachment::getRenderTarget() ...@@ -248,11 +240,6 @@ rx::RenderTarget *Texture3DAttachment::getRenderTarget()
return mTexture3D->getRenderTarget(mLevel, mLayer); return mTexture3D->getRenderTarget(mLevel, mLayer);
} }
rx::TextureStorage *Texture3DAttachment::getTextureStorage()
{
return mTexture3D->getNativeTexture()->getStorageInstance();
}
GLsizei Texture3DAttachment::getWidth() const GLsizei Texture3DAttachment::getWidth() const
{ {
return mTexture3D->getWidth(mLevel); return mTexture3D->getWidth(mLevel);
...@@ -273,21 +260,11 @@ GLenum Texture3DAttachment::getActualFormat() const ...@@ -273,21 +260,11 @@ GLenum Texture3DAttachment::getActualFormat() const
return mTexture3D->getActualFormat(mLevel); return mTexture3D->getActualFormat(mLevel);
} }
GLsizei Texture3DAttachment::getSamples() const
{
return 0;
}
unsigned int Texture3DAttachment::getSerial() const unsigned int Texture3DAttachment::getSerial() const
{ {
return mTexture3D->getRenderTargetSerial(mLevel, mLayer); return mTexture3D->getRenderTargetSerial(mLevel, mLayer);
} }
GLuint Texture3DAttachment::id() const
{
return mTexture3D->id();
}
GLenum Texture3DAttachment::type() const GLenum Texture3DAttachment::type() const
{ {
return GL_TEXTURE_3D; return GL_TEXTURE_3D;
...@@ -303,9 +280,9 @@ GLint Texture3DAttachment::layer() const ...@@ -303,9 +280,9 @@ GLint Texture3DAttachment::layer() const
return mLayer; return mLayer;
} }
unsigned int Texture3DAttachment::getTextureSerial() const Texture *Texture3DAttachment::getTexture() const
{ {
return mTexture3D->getTextureSerial(); return mTexture3D.get();
} }
////// Texture2DArrayAttachment Implementation ////// ////// Texture2DArrayAttachment Implementation //////
...@@ -326,11 +303,6 @@ rx::RenderTarget *Texture2DArrayAttachment::getRenderTarget() ...@@ -326,11 +303,6 @@ rx::RenderTarget *Texture2DArrayAttachment::getRenderTarget()
return mTexture2DArray->getRenderTarget(mLevel, mLayer); return mTexture2DArray->getRenderTarget(mLevel, mLayer);
} }
rx::TextureStorage *Texture2DArrayAttachment::getTextureStorage()
{
return mTexture2DArray->getNativeTexture()->getStorageInstance();
}
GLsizei Texture2DArrayAttachment::getWidth() const GLsizei Texture2DArrayAttachment::getWidth() const
{ {
return mTexture2DArray->getWidth(mLevel); return mTexture2DArray->getWidth(mLevel);
...@@ -351,21 +323,11 @@ GLenum Texture2DArrayAttachment::getActualFormat() const ...@@ -351,21 +323,11 @@ GLenum Texture2DArrayAttachment::getActualFormat() const
return mTexture2DArray->getActualFormat(mLevel); return mTexture2DArray->getActualFormat(mLevel);
} }
GLsizei Texture2DArrayAttachment::getSamples() const
{
return 0;
}
unsigned int Texture2DArrayAttachment::getSerial() const unsigned int Texture2DArrayAttachment::getSerial() const
{ {
return mTexture2DArray->getRenderTargetSerial(mLevel, mLayer); return mTexture2DArray->getRenderTargetSerial(mLevel, mLayer);
} }
GLuint Texture2DArrayAttachment::id() const
{
return mTexture2DArray->id();
}
GLenum Texture2DArrayAttachment::type() const GLenum Texture2DArrayAttachment::type() const
{ {
return GL_TEXTURE_2D_ARRAY; return GL_TEXTURE_2D_ARRAY;
...@@ -381,9 +343,9 @@ GLint Texture2DArrayAttachment::layer() const ...@@ -381,9 +343,9 @@ GLint Texture2DArrayAttachment::layer() const
return mLayer; return mLayer;
} }
unsigned int Texture2DArrayAttachment::getTextureSerial() const Texture *Texture2DArrayAttachment::getTexture() const
{ {
return mTexture2DArray->getTextureSerial(); return mTexture2DArray.get();
} }
////// RenderbufferAttachment Implementation ////// ////// RenderbufferAttachment Implementation //////
......
...@@ -24,6 +24,7 @@ class TextureStorage; ...@@ -24,6 +24,7 @@ class TextureStorage;
namespace gl namespace gl
{ {
class Texture;
class Texture2D; class Texture2D;
class TextureCubeMap; class TextureCubeMap;
class Texture3D; class Texture3D;
...@@ -78,7 +79,24 @@ class FramebufferAttachment ...@@ -78,7 +79,24 @@ class FramebufferAttachment
DISALLOW_COPY_AND_ASSIGN(FramebufferAttachment); DISALLOW_COPY_AND_ASSIGN(FramebufferAttachment);
}; };
class Texture2DAttachment : public FramebufferAttachment class TextureAttachment : public FramebufferAttachment
{
public:
TextureAttachment() {}
rx::TextureStorage *getTextureStorage();
virtual GLsizei getSamples() const;
virtual GLuint id() const;
virtual unsigned int getTextureSerial() const;
protected:
virtual Texture *getTexture() const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(TextureAttachment);
};
class Texture2DAttachment : public TextureAttachment
{ {
public: public:
Texture2DAttachment(Texture2D *texture, GLint level); Texture2DAttachment(Texture2D *texture, GLint level);
...@@ -86,21 +104,18 @@ class Texture2DAttachment : public FramebufferAttachment ...@@ -86,21 +104,18 @@ class Texture2DAttachment : public FramebufferAttachment
virtual ~Texture2DAttachment(); virtual ~Texture2DAttachment();
rx::RenderTarget *getRenderTarget(); rx::RenderTarget *getRenderTarget();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const; virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const; virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const; virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const; virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const; virtual unsigned int getSerial() const;
virtual GLuint id() const;
virtual GLenum type() const; virtual GLenum type() const;
virtual GLint mipLevel() const; virtual GLint mipLevel() const;
virtual GLint layer() const; virtual GLint layer() const;
virtual unsigned int getTextureSerial() const; virtual Texture *getTexture() const;
private: private:
DISALLOW_COPY_AND_ASSIGN(Texture2DAttachment); DISALLOW_COPY_AND_ASSIGN(Texture2DAttachment);
...@@ -109,7 +124,7 @@ class Texture2DAttachment : public FramebufferAttachment ...@@ -109,7 +124,7 @@ class Texture2DAttachment : public FramebufferAttachment
const GLint mLevel; const GLint mLevel;
}; };
class TextureCubeMapAttachment : public FramebufferAttachment class TextureCubeMapAttachment : public TextureAttachment
{ {
public: public:
TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level); TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level);
...@@ -117,21 +132,18 @@ class TextureCubeMapAttachment : public FramebufferAttachment ...@@ -117,21 +132,18 @@ class TextureCubeMapAttachment : public FramebufferAttachment
virtual ~TextureCubeMapAttachment(); virtual ~TextureCubeMapAttachment();
rx::RenderTarget *getRenderTarget(); rx::RenderTarget *getRenderTarget();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const; virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const; virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const; virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const; virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const; virtual unsigned int getSerial() const;
virtual GLuint id() const;
virtual GLenum type() const; virtual GLenum type() const;
virtual GLint mipLevel() const; virtual GLint mipLevel() const;
virtual GLint layer() const; virtual GLint layer() const;
virtual unsigned int getTextureSerial() const; virtual Texture *getTexture() const;
private: private:
DISALLOW_COPY_AND_ASSIGN(TextureCubeMapAttachment); DISALLOW_COPY_AND_ASSIGN(TextureCubeMapAttachment);
...@@ -141,7 +153,7 @@ class TextureCubeMapAttachment : public FramebufferAttachment ...@@ -141,7 +153,7 @@ class TextureCubeMapAttachment : public FramebufferAttachment
const GLenum mFaceTarget; const GLenum mFaceTarget;
}; };
class Texture3DAttachment : public FramebufferAttachment class Texture3DAttachment : public TextureAttachment
{ {
public: public:
Texture3DAttachment(Texture3D *texture, GLint level, GLint layer); Texture3DAttachment(Texture3D *texture, GLint level, GLint layer);
...@@ -149,21 +161,18 @@ class Texture3DAttachment : public FramebufferAttachment ...@@ -149,21 +161,18 @@ class Texture3DAttachment : public FramebufferAttachment
virtual ~Texture3DAttachment(); virtual ~Texture3DAttachment();
rx::RenderTarget *getRenderTarget(); rx::RenderTarget *getRenderTarget();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const; virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const; virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const; virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const; virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const; virtual unsigned int getSerial() const;
virtual GLuint id() const;
virtual GLenum type() const; virtual GLenum type() const;
virtual GLint mipLevel() const; virtual GLint mipLevel() const;
virtual GLint layer() const; virtual GLint layer() const;
virtual unsigned int getTextureSerial() const; virtual Texture *getTexture() const;
private: private:
DISALLOW_COPY_AND_ASSIGN(Texture3DAttachment); DISALLOW_COPY_AND_ASSIGN(Texture3DAttachment);
...@@ -173,7 +182,7 @@ class Texture3DAttachment : public FramebufferAttachment ...@@ -173,7 +182,7 @@ class Texture3DAttachment : public FramebufferAttachment
const GLint mLayer; const GLint mLayer;
}; };
class Texture2DArrayAttachment : public FramebufferAttachment class Texture2DArrayAttachment : public TextureAttachment
{ {
public: public:
Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer); Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer);
...@@ -181,21 +190,18 @@ class Texture2DArrayAttachment : public FramebufferAttachment ...@@ -181,21 +190,18 @@ class Texture2DArrayAttachment : public FramebufferAttachment
virtual ~Texture2DArrayAttachment(); virtual ~Texture2DArrayAttachment();
rx::RenderTarget *getRenderTarget(); rx::RenderTarget *getRenderTarget();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const; virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const; virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const; virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const; virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const; virtual unsigned int getSerial() const;
virtual GLuint id() const;
virtual GLenum type() const; virtual GLenum type() const;
virtual GLint mipLevel() const; virtual GLint mipLevel() const;
virtual GLint layer() const; virtual GLint layer() const;
virtual unsigned int getTextureSerial() const; virtual Texture *getTexture() const;
private: private:
DISALLOW_COPY_AND_ASSIGN(Texture2DArrayAttachment); DISALLOW_COPY_AND_ASSIGN(Texture2DArrayAttachment);
......
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