Store value types for FBO attachments.

*re-land with fix for Mac*

This prevents us from re-allocating FBO attachments every set.
This change requires quite a bit of refactoring.

BUG=angleproject:963

Change-Id: Ia1f83e3c427d446ddbe16c6703db136942149e91
Reviewed-on: https://chromium-review.googlesource.com/266691
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Framebuffer.h b/src/libANGLE/Framebuffer.h
index dffb1e7..486d8c8 100644
--- a/src/libANGLE/Framebuffer.h
+++ b/src/libANGLE/Framebuffer.h
@@ -15,6 +15,7 @@
 #include "common/angleutils.h"
 #include "libANGLE/Constants.h"
 #include "libANGLE/Error.h"
+#include "libANGLE/FramebufferAttachment.h"
 #include "libANGLE/RefCountObject.h"
 
 namespace rx
@@ -32,7 +33,6 @@
 
 namespace gl
 {
-class FramebufferAttachment;
 class Renderbuffer;
 class State;
 class Texture;
@@ -43,8 +43,6 @@
 struct ImageIndex;
 struct Rectangle;
 
-typedef std::vector<const FramebufferAttachment *> AttachmentList;
-
 class Framebuffer
 {
   public:
@@ -64,7 +62,7 @@
         const FramebufferAttachment *getDepthStencilAttachment() const;
 
         const std::vector<GLenum> &getDrawBufferStates() const { return mDrawBufferStates; }
-        const std::vector<FramebufferAttachment *> &getColorAttachments() const { return mColorAttachments; }
+        const std::vector<FramebufferAttachment> &getColorAttachments() const { return mColorAttachments; }
 
       private:
         friend class Framebuffer;
@@ -73,9 +71,9 @@
         FramebufferAttachment *getStencilAttachment();
         FramebufferAttachment *getDepthStencilAttachment();
 
-        std::vector<FramebufferAttachment *> mColorAttachments;
-        FramebufferAttachment *mDepthAttachment;
-        FramebufferAttachment *mStencilAttachment;
+        std::vector<FramebufferAttachment> mColorAttachments;
+        FramebufferAttachment mDepthAttachment;
+        FramebufferAttachment mStencilAttachment;
 
         std::vector<GLenum> mDrawBufferStates;
         GLenum mReadBufferState;
@@ -89,9 +87,11 @@
 
     GLuint id() const { return mId; }
 
-    void setTextureAttachment(GLenum attachment, Texture *texture, const ImageIndex &imageIndex);
-    void setRenderbufferAttachment(GLenum attachment, Renderbuffer *renderbuffer);
-    void setNULLAttachment(GLenum attachment);
+    void setAttachment(GLenum type,
+                       GLenum binding,
+                       const ImageIndex &textureIndex,
+                       FramebufferAttachmentObject *resource);
+    void resetAttachment(GLenum binding);
 
     void detachTexture(GLuint texture);
     void detachRenderbuffer(GLuint renderbuffer);
@@ -109,7 +109,6 @@
     GLenum getReadColorbufferType() const;
     const FramebufferAttachment *getFirstColorbuffer() const;
 
-    FramebufferAttachment *getAttachment(GLenum attachment);
     const FramebufferAttachment *getAttachment(GLenum attachment) const;
 
     GLenum getDrawBufferState(unsigned int colorAttachment) const;
@@ -144,7 +143,6 @@
                GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer);
 
   protected:
-    void setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj);
     void detachResourceById(GLenum resourceType, GLuint resourceId);
 
     Data mData;