diff options
-rw-r--r-- | src/libGLESv2/Framebuffer.cpp | 12 | ||||
-rw-r--r-- | src/libGLESv2/FramebufferAttachment.cpp | 108 | ||||
-rw-r--r-- | src/libGLESv2/FramebufferAttachment.h | 71 |
3 files changed, 26 insertions, 165 deletions
diff --git a/src/libGLESv2/Framebuffer.cpp b/src/libGLESv2/Framebuffer.cpp index 6247b5a0..8db41908 100644 --- a/src/libGLESv2/Framebuffer.cpp +++ b/src/libGLESv2/Framebuffer.cpp @@ -69,8 +69,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum binding, GLenum type Texture *texture = context->getTexture(handle); if (texture && texture->getTarget() == GL_TEXTURE_2D) { - Texture2D *tex2D = static_cast<Texture2D*>(texture); - return new Texture2DAttachment(binding, tex2D, level); + return new TextureAttachment(binding, texture, ImageIndex::Make2D(level)); } else { @@ -88,8 +87,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum binding, GLenum type Texture *texture = context->getTexture(handle); if (texture && texture->getTarget() == GL_TEXTURE_CUBE_MAP) { - TextureCubeMap *texCube = static_cast<TextureCubeMap*>(texture); - return new TextureCubeMapAttachment(binding, texCube, type, level); + return new TextureAttachment(binding, texture, ImageIndex::MakeCube(type, level)); } else { @@ -102,8 +100,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum binding, GLenum type Texture *texture = context->getTexture(handle); if (texture && texture->getTarget() == GL_TEXTURE_3D) { - Texture3D *tex3D = static_cast<Texture3D*>(texture); - return new Texture3DAttachment(binding, tex3D, level, layer); + return new TextureAttachment(binding, texture, ImageIndex::Make3D(level, layer)); } else { @@ -116,8 +113,7 @@ FramebufferAttachment *Framebuffer::createAttachment(GLenum binding, GLenum type Texture *texture = context->getTexture(handle); if (texture && texture->getTarget() == GL_TEXTURE_2D_ARRAY) { - Texture2DArray *tex2DArray = static_cast<Texture2DArray*>(texture); - return new Texture2DArrayAttachment(binding, tex2DArray, level, layer); + return new TextureAttachment(binding, texture, ImageIndex::Make2DArray(level, layer)); } else { diff --git a/src/libGLESv2/FramebufferAttachment.cpp b/src/libGLESv2/FramebufferAttachment.cpp index a354a89d..971f188c 100644 --- a/src/libGLESv2/FramebufferAttachment.cpp +++ b/src/libGLESv2/FramebufferAttachment.cpp @@ -78,14 +78,21 @@ bool FramebufferAttachment::isTexture() const ///// TextureAttachment Implementation //////// -TextureAttachment::TextureAttachment(GLenum binding, const ImageIndex &index) +TextureAttachment::TextureAttachment(GLenum binding, Texture *texture, const ImageIndex &index) : FramebufferAttachment(binding), mIndex(index) -{} +{ + mTexture.set(texture); +} + +TextureAttachment::~TextureAttachment() +{ + mTexture.set(NULL); +} rx::TextureStorage *TextureAttachment::getTextureStorage() { - return getTexture()->getNativeTexture()->getStorageInstance(); + return mTexture->getNativeTexture()->getStorageInstance(); } GLsizei TextureAttachment::getSamples() const @@ -95,32 +102,32 @@ GLsizei TextureAttachment::getSamples() const GLuint TextureAttachment::id() const { - return getTexture()->id(); + return mTexture->id(); } unsigned int TextureAttachment::getTextureSerial() const { - return getTexture()->getTextureSerial(); + return mTexture->getTextureSerial(); } GLsizei TextureAttachment::getWidth() const { - return getTexture()->getWidth(mIndex); + return mTexture->getWidth(mIndex); } GLsizei TextureAttachment::getHeight() const { - return getTexture()->getHeight(mIndex); + return mTexture->getHeight(mIndex); } GLenum TextureAttachment::getInternalFormat() const { - return getTexture()->getInternalFormat(mIndex); + return mTexture->getInternalFormat(mIndex); } GLenum TextureAttachment::getActualFormat() const { - return getTexture()->getActualFormat(mIndex); + return mTexture->getActualFormat(mIndex); } GLenum TextureAttachment::type() const @@ -140,91 +147,12 @@ GLint TextureAttachment::layer() const rx::RenderTarget *TextureAttachment::getRenderTarget() { - return getTexture()->getRenderTarget(mIndex); + return mTexture->getRenderTarget(mIndex); } unsigned int TextureAttachment::getSerial() const { - return getTexture()->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(); + return mTexture->getRenderTargetSerial(mIndex); } ////// RenderbufferAttachment Implementation ////// diff --git a/src/libGLESv2/FramebufferAttachment.h b/src/libGLESv2/FramebufferAttachment.h index 07a19ba6..4b827641 100644 --- a/src/libGLESv2/FramebufferAttachment.h +++ b/src/libGLESv2/FramebufferAttachment.h @@ -82,7 +82,8 @@ class FramebufferAttachment class TextureAttachment : public FramebufferAttachment { public: - TextureAttachment(GLenum binding, const ImageIndex &index); + TextureAttachment(GLenum binding, Texture *texture, const ImageIndex &index); + virtual ~TextureAttachment(); rx::TextureStorage *getTextureStorage(); virtual GLsizei getSamples() const; @@ -101,75 +102,11 @@ class TextureAttachment : public FramebufferAttachment virtual rx::RenderTarget *getRenderTarget(); virtual unsigned int getSerial() const; - protected: - virtual Texture *getTexture() const = 0; - ImageIndex mIndex; - private: 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; - const GLint mLevel; - 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; + BindingPointer<Texture> mTexture; + ImageIndex mIndex; }; class RenderbufferAttachment : public FramebufferAttachment |