Eliminate typed render target Texture attachment method.

More convergance to the base TextureAttachment class.

BUG=angle:732

Change-Id: I9aae1a49ab3908a4eb4cec4bce201b88a7d93926
Reviewed-on: https://chromium-review.googlesource.com/213859
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
diff --git a/src/libGLESv2/FramebufferAttachment.cpp b/src/libGLESv2/FramebufferAttachment.cpp
index b611a44..a354a89 100644
--- a/src/libGLESv2/FramebufferAttachment.cpp
+++ b/src/libGLESv2/FramebufferAttachment.cpp
@@ -138,6 +138,16 @@
     return mIndex.layerIndex;
 }
 
+rx::RenderTarget *TextureAttachment::getRenderTarget()
+{
+    return getTexture()->getRenderTarget(mIndex);
+}
+
+unsigned int TextureAttachment::getSerial() const
+{
+    return getTexture()->getRenderTargetSerial(mIndex);
+}
+
 ///// Texture2DAttachment Implementation ////////
 
 Texture2DAttachment::Texture2DAttachment(GLenum binding, Texture2D *texture, GLint level)
@@ -152,16 +162,6 @@
     mTexture2D.set(NULL);
 }
 
-rx::RenderTarget *Texture2DAttachment::getRenderTarget()
-{
-    return mTexture2D->getRenderTarget(mLevel);
-}
-
-unsigned int Texture2DAttachment::getSerial() const
-{
-    return mTexture2D->getRenderTargetSerial(mLevel);
-}
-
 Texture *Texture2DAttachment::getTexture() const
 {
     return mTexture2D.get();
@@ -182,16 +182,6 @@
     mTextureCubeMap.set(NULL);
 }
 
-rx::RenderTarget *TextureCubeMapAttachment::getRenderTarget()
-{
-    return mTextureCubeMap->getRenderTarget(mFaceTarget, mLevel);
-}
-
-unsigned int TextureCubeMapAttachment::getSerial() const
-{
-    return mTextureCubeMap->getRenderTargetSerial(mFaceTarget, mLevel);
-}
-
 Texture *TextureCubeMapAttachment::getTexture() const
 {
     return mTextureCubeMap.get();
@@ -212,16 +202,6 @@
     mTexture3D.set(NULL);
 }
 
-rx::RenderTarget *Texture3DAttachment::getRenderTarget()
-{
-    return mTexture3D->getRenderTarget(mLevel, mLayer);
-}
-
-unsigned int Texture3DAttachment::getSerial() const
-{
-    return mTexture3D->getRenderTargetSerial(mLevel, mLayer);
-}
-
 Texture *Texture3DAttachment::getTexture() const
 {
     return mTexture3D.get();
@@ -242,16 +222,6 @@
     mTexture2DArray.set(NULL);
 }
 
-rx::RenderTarget *Texture2DArrayAttachment::getRenderTarget()
-{
-    return mTexture2DArray->getRenderTarget(mLevel, mLayer);
-}
-
-unsigned int Texture2DArrayAttachment::getSerial() const
-{
-    return mTexture2DArray->getRenderTargetSerial(mLevel, mLayer);
-}
-
 Texture *Texture2DArrayAttachment::getTexture() const
 {
     return mTexture2DArray.get();
diff --git a/src/libGLESv2/FramebufferAttachment.h b/src/libGLESv2/FramebufferAttachment.h
index db72bb2..07a19ba 100644
--- a/src/libGLESv2/FramebufferAttachment.h
+++ b/src/libGLESv2/FramebufferAttachment.h
@@ -98,6 +98,9 @@
     virtual GLint mipLevel() const;
     virtual GLint layer() const;
 
+    virtual rx::RenderTarget *getRenderTarget();
+    virtual unsigned int getSerial() const;
+
   protected:
     virtual Texture *getTexture() const = 0;
     ImageIndex mIndex;
@@ -112,10 +115,6 @@
     Texture2DAttachment(GLenum binding, Texture2D *texture, GLint level);
 
     virtual ~Texture2DAttachment();
-
-    rx::RenderTarget *getRenderTarget();
-    virtual unsigned int getSerial() const;
-
     virtual Texture *getTexture() const;
 
   private:
@@ -131,10 +130,6 @@
     TextureCubeMapAttachment(GLenum binding, TextureCubeMap *texture, GLenum faceTarget, GLint level);
 
     virtual ~TextureCubeMapAttachment();
-
-    rx::RenderTarget *getRenderTarget();
-    virtual unsigned int getSerial() const;
-
     virtual Texture *getTexture() const;
 
   private:
@@ -151,10 +146,6 @@
     Texture3DAttachment(GLenum binding, Texture3D *texture, GLint level, GLint layer);
 
     virtual ~Texture3DAttachment();
-
-    rx::RenderTarget *getRenderTarget();
-    virtual unsigned int getSerial() const;
-
     virtual Texture *getTexture() const;
 
   private:
@@ -171,10 +162,6 @@
     Texture2DArrayAttachment(GLenum binding, Texture2DArray *texture, GLint level, GLint layer);
 
     virtual ~Texture2DArrayAttachment();
-
-    rx::RenderTarget *getRenderTarget();
-    virtual unsigned int getSerial() const;
-
     virtual Texture *getTexture() const;
 
   private:
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index f5010b3..528eb10 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -179,6 +179,16 @@
     return (getImplementation()->getLayerCount(0) > 0 ? getImplementation()->getImage(0, 0) : NULL);
 }
 
+rx::RenderTarget *Texture::getRenderTarget(const ImageIndex &index)
+{
+    return mTexture->getRenderTarget(index.mipIndex, index.layerIndex);
+}
+
+unsigned int Texture::getRenderTargetSerial(const ImageIndex &index)
+{
+    return mTexture->getRenderTargetSerial(index.mipIndex, index.layerIndex);
+}
+
 Texture2D::Texture2D(rx::TextureImpl *impl, GLuint id)
     : Texture(impl, id, GL_TEXTURE_2D)
 {
@@ -366,16 +376,6 @@
     mTexture->generateMipmaps();
 }
 
-unsigned int Texture2D::getRenderTargetSerial(GLint level)
-{
-    return mTexture->getRenderTargetSerial(level, 0);
-}
-
-rx::RenderTarget *Texture2D::getRenderTarget(GLint level)
-{
-    return mTexture->getRenderTarget(level, 0);
-}
-
 // Tests for 2D texture (mipmap) completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
 bool Texture2D::isMipmapComplete() const
 {
@@ -609,11 +609,6 @@
     return true;
 }
 
-unsigned int TextureCubeMap::getRenderTargetSerial(GLenum target, GLint level)
-{
-    return mTexture->getRenderTargetSerial(level, targetToLayerIndex(target));
-}
-
 int TextureCubeMap::targetToLayerIndex(GLenum target)
 {
     META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_X - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 1);
@@ -636,11 +631,6 @@
     return GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
 }
 
-rx::RenderTarget *TextureCubeMap::getRenderTarget(GLenum target, GLint level)
-{
-    return mTexture->getRenderTarget(level, targetToLayerIndex(target));
-}
-
 bool TextureCubeMap::isMipmapComplete() const
 {
     if (isImmutable())
@@ -805,17 +795,6 @@
     return true;
 }
 
-unsigned int Texture3D::getRenderTargetSerial(GLint level, GLint layer)
-{
-    return mTexture->getRenderTargetSerial(level, layer);
-}
-
-
-rx::RenderTarget *Texture3D::getRenderTarget(GLint level, GLint layer)
-{
-    return mTexture->getRenderTarget(level, layer);
-}
-
 bool Texture3D::isMipmapComplete() const
 {
     int levelCount = mipLevels();
@@ -974,16 +953,6 @@
     return true;
 }
 
-unsigned int Texture2DArray::getRenderTargetSerial(GLint level, GLint layer)
-{
-    return mTexture->getRenderTargetSerial(level, layer);
-}
-
-rx::RenderTarget *Texture2DArray::getRenderTarget(GLint level, GLint layer)
-{
-    return mTexture->getRenderTarget(level, layer);
-}
-
 bool Texture2DArray::isMipmapComplete() const
 {
     int levelCount = mipLevels();
diff --git a/src/libGLESv2/Texture.h b/src/libGLESv2/Texture.h
index d7053d3..13e4496 100644
--- a/src/libGLESv2/Texture.h
+++ b/src/libGLESv2/Texture.h
@@ -99,6 +99,11 @@
 
     const rx::Image *getBaseLevelImage() const;
 
+    // TODO: move these to TextureD3D
+    friend class TextureAttachment;
+    rx::RenderTarget *getRenderTarget(const ImageIndex &index);
+    unsigned int getRenderTargetSerial(const ImageIndex &index);
+
   private:
     DISALLOW_COPY_AND_ASSIGN(Texture);
 };
@@ -130,12 +135,6 @@
 
     virtual void generateMipmaps();
 
-    unsigned int getRenderTargetSerial(GLint level);
-
-  protected:
-    friend class Texture2DAttachment;
-    rx::RenderTarget *getRenderTarget(GLint level);
-
   private:
     DISALLOW_COPY_AND_ASSIGN(Texture2D);
 
@@ -177,15 +176,9 @@
 
     bool isCubeComplete() const;
 
-    unsigned int getRenderTargetSerial(GLenum target, GLint level);
-
     static int targetToLayerIndex(GLenum target);
     static GLenum layerIndexToTarget(GLint layer);
 
-  protected:
-    friend class TextureCubeMapAttachment;
-    rx::RenderTarget *getRenderTarget(GLenum target, GLint level);
-
   private:
     DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
 
@@ -216,12 +209,6 @@
 
     virtual bool isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const;
 
-    unsigned int getRenderTargetSerial(GLint level, GLint layer);
-
-  protected:
-    friend class Texture3DAttachment;
-    rx::RenderTarget *getRenderTarget(GLint level, GLint layer);
-
   private:
     DISALLOW_COPY_AND_ASSIGN(Texture3D);
 
@@ -252,12 +239,6 @@
 
     virtual bool isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const;
 
-    unsigned int getRenderTargetSerial(GLint level, GLint layer);
-
-  protected:
-    friend class Texture2DArrayAttachment;
-    rx::RenderTarget *getRenderTarget(GLint level, GLint layer);
-
   private:
     DISALLOW_COPY_AND_ASSIGN(Texture2DArray);